Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions playwright/e2e/a11y-question-inputs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

import { expect, mergeTests } from '@playwright/test'
import { test as formTest } from '../support/fixtures/form'
import { test as appNavigationTest } from '../support/fixtures/navigation'
import { test as randomUserTest } from '../support/fixtures/random-user'
import { test as topBarTest } from '../support/fixtures/topBar'
import { QuestionType } from '../support/sections/QuestionType'
import { FormsView } from '../support/sections/TopBarSection'
import { test as formTest } from '../support/fixtures/form.ts'
import { test as appNavigationTest } from '../support/fixtures/navigation.ts'
import { test as randomUserTest } from '../support/fixtures/random-user.ts'
import { test as topBarTest } from '../support/fixtures/topBar.ts'
import { QuestionType } from '../support/sections/QuestionType.ts'
import { FormsView } from '../support/sections/TopBarSection.ts'

const test = mergeTests(randomUserTest, appNavigationTest, formTest, topBarTest)

Expand Down
16 changes: 8 additions & 8 deletions playwright/e2e/form-settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
*/

import { expect, mergeTests } from '@playwright/test'
import { test as formTest } from '../support/fixtures/form'
import { test as appNavigationTest } from '../support/fixtures/navigation'
import { test as randomUserTest } from '../support/fixtures/random-user'
import { test as submitTest } from '../support/fixtures/submit'
import { test as topBarTest } from '../support/fixtures/topBar'
import { waitForApiResponse } from '../support/helpers'
import { QuestionType } from '../support/sections/QuestionType'
import { FormsView } from '../support/sections/TopBarSection'
import { test as formTest } from '../support/fixtures/form.ts'
import { test as appNavigationTest } from '../support/fixtures/navigation.ts'
import { test as randomUserTest } from '../support/fixtures/random-user.ts'
import { test as submitTest } from '../support/fixtures/submit.ts'
import { test as topBarTest } from '../support/fixtures/topBar.ts'
import { waitForApiResponse } from '../support/helpers.ts'
import { QuestionType } from '../support/sections/QuestionType.ts'
import { FormsView } from '../support/sections/TopBarSection.ts'

const test = mergeTests(
randomUserTest,
Expand Down
16 changes: 6 additions & 10 deletions playwright/e2e/form-sharing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
*/

import { expect, mergeTests } from '@playwright/test'
import { test as randomUserTest } from '../support/fixtures/random-user'
import { test as appNavigationTest } from '../support/fixtures/navigation'
import { test as formTest } from '../support/fixtures/form'
import { QuestionType } from '../support/sections/QuestionType'
import { waitForApiResponse } from '../support/helpers'
import { test as formTest } from '../support/fixtures/form.ts'
import { test as appNavigationTest } from '../support/fixtures/navigation.ts'
import { test as randomUserTest } from '../support/fixtures/random-user.ts'
import { waitForApiResponse } from '../support/helpers.ts'
import { QuestionType } from '../support/sections/QuestionType.ts'

const test = mergeTests(
randomUserTest,
appNavigationTest,
formTest,
)
const test = mergeTests(randomUserTest, appNavigationTest, formTest)

test.describe('Form sharing', () => {
test.beforeEach(async ({ page, appNavigation, form }) => {
Expand Down
8 changes: 4 additions & 4 deletions playwright/e2e/question-editing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*/

import { expect, mergeTests } from '@playwright/test'
import { test as randomUserTest } from '../support/fixtures/random-user'
import { test as appNavigationTest } from '../support/fixtures/navigation'
import { test as formTest } from '../support/fixtures/form'
import { QuestionType } from '../support/sections/QuestionType'
import { test as formTest } from '../support/fixtures/form.ts'
import { test as appNavigationTest } from '../support/fixtures/navigation.ts'
import { test as randomUserTest } from '../support/fixtures/random-user.ts'
import { QuestionType } from '../support/sections/QuestionType.ts'

const test = mergeTests(randomUserTest, appNavigationTest, formTest)

Expand Down
14 changes: 7 additions & 7 deletions playwright/e2e/required-fields.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
*/

import { expect, mergeTests } from '@playwright/test'
import { test as formTest } from '../support/fixtures/form'
import { test as appNavigationTest } from '../support/fixtures/navigation'
import { test as randomUserTest } from '../support/fixtures/random-user'
import { test as submitTest } from '../support/fixtures/submit'
import { test as topBarTest } from '../support/fixtures/topBar'
import { QuestionType } from '../support/sections/QuestionType'
import { FormsView } from '../support/sections/TopBarSection'
import { test as formTest } from '../support/fixtures/form.ts'
import { test as appNavigationTest } from '../support/fixtures/navigation.ts'
import { test as randomUserTest } from '../support/fixtures/random-user.ts'
import { test as submitTest } from '../support/fixtures/submit.ts'
import { test as topBarTest } from '../support/fixtures/topBar.ts'
import { QuestionType } from '../support/sections/QuestionType.ts'
import { FormsView } from '../support/sections/TopBarSection.ts'

const test = mergeTests(
randomUserTest,
Expand Down
16 changes: 8 additions & 8 deletions playwright/e2e/results-view.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
*/

import { expect, mergeTests } from '@playwright/test'
import { test as formTest } from '../support/fixtures/form'
import { test as appNavigationTest } from '../support/fixtures/navigation'
import { test as randomUserTest } from '../support/fixtures/random-user'
import { test as resultsTest } from '../support/fixtures/results'
import { test as submitTest } from '../support/fixtures/submit'
import { test as topBarTest } from '../support/fixtures/topBar'
import { QuestionType } from '../support/sections/QuestionType'
import { FormsView } from '../support/sections/TopBarSection'
import { test as formTest } from '../support/fixtures/form.ts'
import { test as appNavigationTest } from '../support/fixtures/navigation.ts'
import { test as randomUserTest } from '../support/fixtures/random-user.ts'
import { test as resultsTest } from '../support/fixtures/results.ts'
import { test as submitTest } from '../support/fixtures/submit.ts'
import { test as topBarTest } from '../support/fixtures/topBar.ts'
import { QuestionType } from '../support/sections/QuestionType.ts'
import { FormsView } from '../support/sections/TopBarSection.ts'

const test = mergeTests(
randomUserTest,
Expand Down
14 changes: 7 additions & 7 deletions playwright/e2e/submit-form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
*/

import { expect, mergeTests } from '@playwright/test'
import { test as randomUserTest } from '../support/fixtures/random-user'
import { test as appNavigationTest } from '../support/fixtures/navigation'
import { test as formTest } from '../support/fixtures/form'
import { test as topBarTest } from '../support/fixtures/topBar'
import { test as submitTest } from '../support/fixtures/submit'
import { QuestionType } from '../support/sections/QuestionType'
import { FormsView } from '../support/sections/TopBarSection'
import { test as formTest } from '../support/fixtures/form.ts'
import { test as appNavigationTest } from '../support/fixtures/navigation.ts'
import { test as randomUserTest } from '../support/fixtures/random-user.ts'
import { test as submitTest } from '../support/fixtures/submit.ts'
import { test as topBarTest } from '../support/fixtures/topBar.ts'
import { QuestionType } from '../support/sections/QuestionType.ts'
import { FormsView } from '../support/sections/TopBarSection.ts'

const test = mergeTests(
randomUserTest,
Expand Down
2 changes: 1 addition & 1 deletion playwright/support/fixtures/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { test as baseTest } from '@playwright/test'
import { ResultsSection } from '../sections/ResultsSection'
import { ResultsSection } from '../sections/ResultsSection.ts'

interface ResultsFixture {
resultsView: ResultsSection
Expand Down
2 changes: 1 addition & 1 deletion playwright/support/fixtures/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { test as baseTest } from '@playwright/test'
import { SubmitSection } from '../sections/SubmitSection'
import { SubmitSection } from '../sections/SubmitSection.ts'

interface SubmitFixture {
submitView: SubmitSection
Expand Down
8 changes: 4 additions & 4 deletions playwright/support/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const FORMS_API_PATH = '/api/v3/forms/'
/**
* Wait for a Forms API response matching the given HTTP method.
* Must be called BEFORE the action that triggers the request.
*
* @param page the current page
* @param method the request method
*/
export function waitForApiResponse(
page: Page,
method: string,
): Promise<Response> {
export function waitForApiResponse(page: Page, method: string): Promise<Response> {
return page.waitForResponse(
(response) =>
response.request().method() === method
Expand Down
3 changes: 2 additions & 1 deletion playwright/support/sections/QuestionSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*/

import type { Locator, Page } from '@playwright/test'
import { waitForApiResponse } from '../helpers'

import { waitForApiResponse } from '../helpers.ts'

export class QuestionSection {
public readonly titleInput: Locator
Expand Down
6 changes: 5 additions & 1 deletion playwright/support/sections/ResultsSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export class ResultsSection {
await this.responsesTab.dispatchEvent('change')
}

/** Get the summary section for a specific question by its title. */
/**
* Get the summary section for a specific question by its title.
*
* @param name the title of the question
*/
public getSummaryForQuestion(name: string | RegExp): Locator {
return this.page
.getByRole('main')
Expand Down
22 changes: 20 additions & 2 deletions playwright/support/sections/SubmitSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export class SubmitSection {
* Get a question's list item by its title text.
* Questions render as <li aria-label="Question number N">,
* and each contains an <h3> with the title text.
*
* @param name the title of the question
*/
public getQuestion(name: string | RegExp): Locator {
return this.page
Expand All @@ -32,8 +34,14 @@ export class SubmitSection {
* QuestionShort renders <input aria-labelledby="qN_title">,
* QuestionLong renders <textarea aria-labelledby="qN_title">.
* Both are matched by getByRole('textbox').
*
* @param questionName the title of the question
* @param value the answer to the question
*/
public async fillText(questionName: string | RegExp, value: string): Promise<void> {
public async fillText(
questionName: string | RegExp,
value: string,
): Promise<void> {
const question = this.getQuestion(questionName)
await question.getByRole('textbox').fill(value)
}
Expand All @@ -42,6 +50,9 @@ export class SubmitSection {
* Check a checkbox option within a question.
* QuestionMultiple renders NcCheckboxRadioSwitch as
* <input type="checkbox"> with the option text as label.
*
* @param questionName the title of the question
* @param optionName the name of the option to check
*/
public async checkOption(
questionName: string | RegExp,
Expand All @@ -57,6 +68,9 @@ export class SubmitSection {
* Check a radio option within a question.
* QuestionMultiple (unique) renders NcCheckboxRadioSwitch as
* <input type="radio"> with the option text as label.
*
* @param questionName the title of the question
* @param optionName the name of the option to check
*/
public async checkRadio(
questionName: string | RegExp,
Expand All @@ -71,6 +85,9 @@ export class SubmitSection {
/**
* Select a dropdown option.
* QuestionDropdown renders NcSelect which uses role="combobox".
*
* @param questionName the title of the question
* @param optionName the name of the option to check
*/
public async selectDropdown(
questionName: string | RegExp,
Expand All @@ -86,7 +103,8 @@ export class SubmitSection {
public async submit(): Promise<Response> {
const response = this.page.waitForResponse(
(resp) =>
(resp.request().method() === 'POST' || resp.request().method() === 'PUT')
(resp.request().method() === 'POST'
|| resp.request().method() === 'PUT')
&& resp.request().url().includes('/api/v3/forms/')
&& resp.request().url().includes('/submissions'),
)
Expand Down
Loading