Skip to content

Commit

Permalink
Basic home page migrated
Browse files Browse the repository at this point in the history
  • Loading branch information
flurdy committed Dec 5, 2024
1 parent c50bac7 commit 49fdd03
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 2 deletions.
124 changes: 124 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions test/page-objects/home.page.js
Original file line number Diff line number Diff line change
@@ -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<boolean>}
*/
navIsActive() {
return super.navIsActive('home')
}

open() {
return super.open('/')
}
Expand Down
40 changes: 39 additions & 1 deletion test/page-objects/page.js
Original file line number Diff line number Diff line change
@@ -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<boolean>}
*/
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 }
10 changes: 9 additions & 1 deletion test/specs/home.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
})
})

0 comments on commit 49fdd03

Please sign in to comment.