Skip to content

Commit 78a88fd

Browse files
committed
fix(e2e): correct selectors for questions, results tabs, and view routing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
1 parent 58f74ea commit 78a88fd

4 files changed

Lines changed: 20 additions & 17 deletions

File tree

playwright/e2e/question-editing.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import { QuestionType } from '../support/sections/QuestionType'
1111

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

14-
test.beforeEach(async ({ page, appNavigation, form }) => {
15-
await page.goto('apps/forms')
16-
await page.waitForURL(/apps\/forms$/)
17-
await appNavigation.clickNewForm()
18-
await form.fillTitle('Editing test form')
19-
})
20-
2114
test.describe('Question editing lifecycle', () => {
15+
test.beforeEach(async ({ page, appNavigation, form }) => {
16+
await page.goto('apps/forms')
17+
await page.waitForURL(/apps\/forms$/)
18+
await appNavigation.clickNewForm()
19+
await form.fillTitle('Editing test form')
20+
})
21+
2222
const questionTypes = [
2323
QuestionType.ShortAnswer,
2424
QuestionType.LongAnswer,

playwright/support/sections/FormSection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ export class FormSection {
4646

4747
public async getQuestions(): Promise<QuestionSection[]> {
4848
return this.page
49-
.locator('main section')
49+
.getByRole('listitem', { name: /Question number \d+/i })
5050
.all()
51-
.then((sections) =>
52-
sections.map((section) => new QuestionSection(this.page, section)),
51+
.then((items) =>
52+
items.map((item) => new QuestionSection(this.page, item)),
5353
)
5454
}
5555

playwright/support/sections/ResultsSection.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ export class ResultsSection {
1212
public readonly responseCount: Locator
1313

1414
constructor(public readonly page: Page) {
15-
// PillMenu renders NcCheckboxRadioSwitch as radio buttons
16-
this.summaryTab = this.page.getByRole('radio', { name: 'Summary' })
17-
this.responsesTab = this.page.getByRole('radio', { name: 'Responses' })
15+
// Scope to main content to avoid conflict with TopBar radios that have the same names.
16+
// The PillMenu tabs are inside NcAppContent (main), the TopBar is in the navigation header.
17+
const main = this.page.getByRole('main')
18+
this.summaryTab = main.getByRole('radio', { name: 'Summary' })
19+
this.responsesTab = main.getByRole('radio', { name: 'Responses' })
1820
this.noResponsesMessage = this.page.getByText('No responses yet')
1921
// Results.vue renders: "{amount} responses" in a <p> tag
2022
this.responseCount = this.page.getByText(/\d+ responses?/)
@@ -33,8 +35,8 @@ export class ResultsSection {
3335
* ResultsSummary components render the question text as a heading.
3436
*/
3537
public getSummaryForQuestion(name: string | RegExp): Locator {
36-
return this.page
37-
.locator('section')
38-
.filter({ has: this.page.getByRole('heading', { name }) })
38+
// ResultsSummary renders as <div class="section question-summary"> with an <h3> inside.
39+
// We locate the heading and return its parent element.
40+
return this.page.getByRole('main').getByRole('heading', { name }).locator('..')
3941
}
4042
}

playwright/support/sections/TopBarSection.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import type { Locator, Page } from '@playwright/test'
88
export enum FormsView {
99
View = 'View',
1010
Edit = 'Edit',
11-
Results = 'Results',
11+
// TopBar.vue labels this view "Responses" in the UI
12+
Results = 'Responses',
1213
}
1314

1415
export class TopBarSection {

0 commit comments

Comments
 (0)