diff --git a/package-lock.json b/package-lock.json index 6ea77a8..efd64a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@wdio/allure-reporter": "8.34.0", "@wdio/cli": "8.35.1", "@wdio/globals": "8.35.1", + "@wdio/junit-reporter": "9.2.14", "@wdio/local-runner": "8.35.1", "@wdio/mocha-framework": "8.35.0", "@wdio/spec-reporter": "8.32.4", @@ -2362,6 +2363,85 @@ "webdriverio": "8.35.1" } }, + "node_modules/@wdio/junit-reporter": { + "version": "9.2.14", + "resolved": "https://registry.npmjs.org/@wdio/junit-reporter/-/junit-reporter-9.2.14.tgz", + "integrity": "sha512-oyIAv+8pzImU4qBWHLdbKiMpHsa3t3LElEemuSQ5/t5dWNpwhQXVRvZzIGbse9GEKY+BBiguHwnwNYDyt+Qz9A==", + "license": "MIT", + "dependencies": { + "@wdio/reporter": "9.2.14", + "@wdio/types": "9.2.2", + "json-stringify-safe": "^5.0.1", + "junit-report-builder": "^5.1.1" + }, + "engines": { + "node": ">=18.20.0" + } + }, + "node_modules/@wdio/junit-reporter/node_modules/@wdio/logger": { + "version": "9.1.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-9.1.3.tgz", + "integrity": "sha512-cumRMK/gE1uedBUw3WmWXOQ7HtB6DR8EyKQioUz2P0IJtRRpglMBdZV7Svr3b++WWawOuzZHMfbTkJQmaVt8Gw==", + "license": "MIT", + "dependencies": { + "chalk": "^5.1.2", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18.20.0" + } + }, + "node_modules/@wdio/junit-reporter/node_modules/@wdio/reporter": { + "version": "9.2.14", + "resolved": "https://registry.npmjs.org/@wdio/reporter/-/reporter-9.2.14.tgz", + "integrity": "sha512-njOqa9+w5zc9AY4fsUmW46EhZ2nzMFRXZPCmwnGZuYk81L3slVfAFhKk1wSTRhSbghjYAZndt9Yo3c4wFLh6Lg==", + "license": "MIT", + "dependencies": { + "@types/node": "^20.1.0", + "@wdio/logger": "9.1.3", + "@wdio/types": "9.2.2", + "diff": "^7.0.0", + "object-inspect": "^1.12.0" + }, + "engines": { + "node": ">=18.20.0" + } + }, + "node_modules/@wdio/junit-reporter/node_modules/@wdio/types": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-9.2.2.tgz", + "integrity": "sha512-nHZ9Ne9iRQFJ1TOYKUn4Fza69IshTTzk6RYmSZ51ImGs9uMZu0+S0Jm9REdly+VLN3FzxG6g2QSe0/F3uNVPdw==", + "license": "MIT", + "dependencies": { + "@types/node": "^20.1.0" + }, + "engines": { + "node": ">=18.20.0" + } + }, + "node_modules/@wdio/junit-reporter/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@wdio/junit-reporter/node_modules/diff": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", + "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/@wdio/local-runner": { "version": "8.35.1", "resolved": "https://registry.npmjs.org/@wdio/local-runner/-/local-runner-8.35.1.tgz", @@ -7151,6 +7231,12 @@ "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", + "license": "ISC" + }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -7173,6 +7259,35 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/junit-report-builder": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/junit-report-builder/-/junit-report-builder-5.1.1.tgz", + "integrity": "sha512-ZNOIIGMzqCGcHQEA2Q4rIQQ3Df6gSIfne+X9Rly9Bc2y55KxAZu8iGv+n2pP0bLf0XAOctJZgeloC54hWzCahQ==", + "license": "MIT", + "dependencies": { + "lodash": "^4.17.21", + "make-dir": "^3.1.0", + "xmlbuilder": "^15.1.1" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/junit-report-builder/node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "license": "MIT", + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -10738,6 +10853,15 @@ } } }, + "node_modules/xmlbuilder": { + "version": "15.1.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz", + "integrity": "sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==", + "license": "MIT", + "engines": { + "node": ">=8.0" + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index b4d386d..0d4f6a0 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "test": "npm run clean && wdio run wdio.conf.js", "test:local": "npm run clean && wdio run wdio.local.conf.js", "test:local:debug": "DEBUG=true npm run test:local", + "test:github": "npm run clean && wdio run wdio.github.conf.js", "format": "prettier --write 'test/**/*.js' '**/*.{js,md,json,config.js}'", "format:check": "prettier --check 'test/**/*.js' '**/*.{js,md,json,config.js}'", "git:pre-commit-hook": "npm run format:check && npm run lint", diff --git a/test/page-objects/home.page.js b/test/page-objects/home.page.js index 37cdd60..6830fde 100644 --- a/test/page-objects/home.page.js +++ b/test/page-objects/home.page.js @@ -1,6 +1,24 @@ +import { $ } from '@wdio/globals' + import { Page } from 'page-objects/page' class HomePage extends Page { + serviceName() { + return $('[data-testid="app-header-service-name"]') + } + + userName() { + return $('[data-testid="app-login-username"]') + } + + /** + * Check if the home nav link is active + * @returns {Promise} + */ + navIsActive() { + return super.navIsActive('home') + } + open() { return super.open('/') } diff --git a/test/page-objects/page.js b/test/page-objects/page.js index aa58a76..f2b855c 100644 --- a/test/page-objects/page.js +++ b/test/page-objects/page.js @@ -1,13 +1,51 @@ import { browser, $ } from '@wdio/globals' class Page { - get pageHeading() { + pageHeading() { return $('h1') } + navItem(navItemName) { + return $(`[data-testid="nav-${navItemName}"]`) + } + + /** + * Check if a navigation item is active + * @param navItemName + * @returns {Promise} + */ + async navIsActive(navItemName) { + const navItem = await this.navItem(navItemName) + const className = await navItem.getAttribute('class') + + return className.includes('app-navigation__link--active') + } + + logInLink(value = 'Sign in') { + return $('[data-testid="app-login-link"]*=' + value) + } + + logOutLink(value = 'Sign out') { + return $('[data-testid="app-login-link"]*=' + value) + } + + async login() { + await this.open('/') + await this.logInLink().click() + } + + async logOut() { + await this.open('/') + await this.logOutLink().click() + } + open(path) { return browser.url(path) } + + link(value) { + return $('a*=' + value) + } } export { Page } diff --git a/test/specs/home.e2e.js b/test/specs/home.e2e.js index d6fa0b9..dce770a 100644 --- a/test/specs/home.e2e.js +++ b/test/specs/home.e2e.js @@ -5,6 +5,14 @@ import HomePage from 'page-objects/home.page' describe('Home page', () => { it('Should be on the "Home" page', async () => { await HomePage.open() - await expect(browser).toHaveTitle('Home') + + await expect(browser).toHaveTitle('Home | Core Delivery Platform - Portal') + await expect(await HomePage.navIsActive()).toBe(true) + await expect(HomePage.serviceName()).toHaveText( + 'Core Delivery Platform - Portal' + ) + await expect(HomePage.pageHeading()).toHaveText( + 'Build your Defra applications on the Core Delivery Platform' + ) }) })