-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a3b901
commit 4c59fe8
Showing
18 changed files
with
915 additions
and
786 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# These are the environment variables used in the test environment | ||
|
||
DATAJEGER_EMAIL_ADDRESS=datajegeren@test.no | ||
FDK_MAIL_SERVICE_ENDPOINT=/api/sendmail | ||
FDK_MAIL_SERVICE_API_KEY=testapikey | ||
FDK_BASE_URI=https://staging.fellesdatakatalog.digdir.no | ||
FDK_COMMUNITY_BASE_URI=https://community.staging.fellesdatakatalog.digdir.no | ||
FDK_REGISTRATION_BASE_URI=https://registrering.staging.fellesdatakatalog.digdir.no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,9 @@ | |
}, | ||
{ | ||
"files": ["src/**/*.{ts,js,tsx,jsx}"], | ||
"rules": {} | ||
"rules": { | ||
"playwright/expect-expect": "off" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"dataset": "John Wick's dataset", | ||
"location": "Stockholm", | ||
"efforts": "High", | ||
"name": "John Wick", | ||
"email": "johnwick@email.com", | ||
"organizationNumber": "123456789", | ||
"phoneNumber": "12345678" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { test as base } from '@playwright/test'; | ||
import FormPage from '../page-object-model/formPage'; | ||
import { generateAccessibilityBuilder } from '../utils/helpers'; | ||
|
||
export const test = base.extend({ | ||
dataHunterFormPage: async ({ page }, use) => { | ||
const accessibilityBuilder = await generateAccessibilityBuilder(page); | ||
const dataHunterFormPage = new FormPage(page, accessibilityBuilder); | ||
await dataHunterFormPage.goto(); | ||
await use(dataHunterFormPage); | ||
}, | ||
}); | ||
|
||
export { expect } from '@playwright/test'; |
64 changes: 64 additions & 0 deletions
64
apps/forms-e2e/src/data-hunter/page-object-model/formPage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Dictionary, getDictionary } from '@fdk-frontend/dictionaries'; | ||
import { expect, Page } from '@playwright/test'; | ||
import * as mockData from '../data/inputData.json'; | ||
import type AxeBuilder from '@axe-core/playwright'; | ||
|
||
export default class FormPage { | ||
dataHunterPageUrl = '/forms/en/data-hunter'; | ||
page: Page; | ||
dictionary: Dictionary; | ||
accessibilityBuilder; | ||
|
||
constructor(page: Page, accessibilityBuilder?: AxeBuilder) { | ||
this.page = page; | ||
getDictionary('en').then((dict) => (this.dictionary = dict)); | ||
this.accessibilityBuilder = accessibilityBuilder; | ||
} | ||
|
||
public async goto() { | ||
await this.page.goto(this.dataHunterPageUrl); | ||
} | ||
|
||
public async checkAccessibility() { | ||
if (!this.accessibilityBuilder) { | ||
return; | ||
} | ||
const result = await this.accessibilityBuilder.analyze(); | ||
expect.soft(result.violations).toEqual([]); | ||
} | ||
|
||
// Locators | ||
pageTitle = () => this.page.getByRole('heading', { name: this.dictionary.dataHunterForm.title }); | ||
pageDescription = () => this.page.getByText(this.dictionary.dataHunterForm.description); | ||
datasetInput = () => this.page.getByLabel(this.dictionary.dataHunterForm.dataset.label); | ||
locationInput = () => this.page.getByLabel(this.dictionary.dataHunterForm.location.label); | ||
attemptsInput = () => this.page.getByLabel(this.dictionary.dataHunterForm.efforts.label); | ||
nameInput = () => this.page.getByLabel(this.dictionary.name); | ||
emailInput = () => this.page.getByLabel(this.dictionary.email); | ||
organizationNumberInput = () => this.page.getByLabel(this.dictionary.organizationNumber); | ||
phoneNumberInput = () => this.page.getByLabel(this.dictionary.phoneNumber); | ||
submitButton = () => this.page.getByRole('button', { name: this.dictionary.submitRequest }); | ||
|
||
// Actions | ||
public async checkPageTitleText() { | ||
await expect(this.pageTitle()).toHaveText(this.dictionary.dataHunterForm.title); | ||
} | ||
|
||
public async checkPageDescriptionText() { | ||
await expect(this.pageDescription()).toHaveText(this.dictionary.dataHunterForm.description); | ||
} | ||
|
||
public async fillForm() { | ||
await this.datasetInput().fill(mockData.dataset); | ||
await this.locationInput().fill(mockData.location); | ||
await this.attemptsInput().fill(mockData.efforts); | ||
await this.nameInput().fill(mockData.name); | ||
await this.emailInput().fill(mockData.email); | ||
await this.organizationNumberInput().fill(mockData.organizationNumber); | ||
await this.phoneNumberInput().fill(mockData.phoneNumber); | ||
} | ||
|
||
public async submitForm() { | ||
await this.submitButton().click(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { test } from '../fixtures/basePage'; | ||
|
||
|
||
|
||
test('should not have any automatically detectable accessibility issues', async ({ dataHunterFormPage }) => { | ||
await dataHunterFormPage.checkAccessibility(); | ||
}); | ||
|
||
test('check page text', async ({ dataHunterFormPage }) => { | ||
await dataHunterFormPage.checkPageTitleText(); | ||
await dataHunterFormPage.checkPageDescriptionText(); | ||
}); | ||
|
||
test('fill form', async ({ dataHunterFormPage }) => { | ||
await dataHunterFormPage.fillForm(); | ||
await dataHunterFormPage.submitForm(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import AxeBuilder from "@axe-core/playwright"; | ||
import { Page } from "@playwright/test"; | ||
|
||
export const generateAccessibilityBuilder = async (page: Page) => | ||
new AxeBuilder({ page }).withTags([ | ||
'wcag2a', | ||
'wcag2aa', | ||
'wcag2aaa', | ||
'wcag21a', | ||
'wcag21aa', | ||
'wcag22aa', | ||
'best-practice', | ||
]); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
.button { | ||
margin-top: 3rem; | ||
align-self: flex-start; | ||
background-color: #0057A3; | ||
} | ||
|
||
.orgNumberField { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.