Repository navigation
feat: rating question type #3637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
global-prog
wants to merge
20
commits into
nextcloud:main
Choose a base branch
from
global-prog:contrib/rating-question
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+667
−22
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ee6a7b8
feat: rating question type
global-prog 5074020
refactor: build the rating on the linear scale's settings and validation
global-prog 348add1
implement review comments
Chartman123 b759398
fix(rating): check rating answers against the scale, not ranking answers
AndyScherzinger ac8fdb6
fix(rating): reject booleans and lists as answers on a scale
AndyScherzinger 8daab99
fix(rating): name each option of a rating by its value
AndyScherzinger 1e73e58
fix(rating): keep the rating in view when one of its options gets focus
AndyScherzinger 837f3e1
fix(rating): keep the answer to a rating in drafts and edited responses
AndyScherzinger 5cb0705
fix(rating): focus a new rating question and keep its insert menu
AndyScherzinger 94f1a0e
fix(rating): show why a required rating cannot be submitted
AndyScherzinger 05914b8
fix(rating): move on from a rating on Enter instead of submitting
AndyScherzinger dc5e1a2
fix(rating): name the picker for the highest rating
AndyScherzinger daa4582
refactor(rating): drop the clear-button leftovers and a second icon l…
AndyScherzinger 482e8f6
style: format the list of date and time answer types
AndyScherzinger 3658d8d
fix(rating): reject answers on a scale written with leading zeros
AndyScherzinger a7d3d4f
fix(rating): accept only the icons a rating can draw
AndyScherzinger bf8998d
docs: describe the rating question and its settings
AndyScherzinger 16d6091
refactor(rating): name the rating by the question title
AndyScherzinger 758cc07
test(e2e): cover the rating question
AndyScherzinger 082876e
fix(rating): pass the hint on the name of a rating option to translators
AndyScherzinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,144 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| import { expect, mergeTests } from '@playwright/test' | ||
| 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, | ||
| appNavigationTest, | ||
| formTest, | ||
| topBarTest, | ||
| submitTest, | ||
| resultsTest, | ||
| ) | ||
|
|
||
| test.describe('Rating question', () => { | ||
| test.beforeEach(async ({ page, appNavigation, form }) => { | ||
| await page.goto('apps/forms') | ||
| await page.waitForURL(/apps\/forms\/?$/) | ||
| await appNavigation.clickNewForm() | ||
| await form.fillTitle('Rating test form') | ||
|
|
||
| await form.addQuestion(QuestionType.Rating) | ||
| const questions = await form.getQuestions() | ||
| await questions[0].fillTitle('Rate the service') | ||
| await questions[0].fillDescription('One star is poor') | ||
| }) | ||
|
|
||
| test('Names the rating by its question and each option by its value', async ({ | ||
| topBar, | ||
| submitView, | ||
| }) => { | ||
| await topBar.toggleView(FormsView.View) | ||
|
|
||
| const group = submitView.getQuestion('Rate the service').getByRole('group') | ||
| await expect(group).toHaveAttribute('aria-labelledby', 'q1_title') | ||
| await expect(group).toHaveAttribute('aria-describedby', 'q1_desc') | ||
| const options = group.getByRole('radio') | ||
| await expect(options).toHaveCount(5) | ||
| for (let value = 1; value <= 5; value++) { | ||
| await expect(options.nth(value - 1)).toHaveAccessibleName( | ||
| `${value} of 5`, | ||
| ) | ||
| } | ||
| }) | ||
|
|
||
| test('Restores the rating from local storage on reload', async ({ | ||
| topBar, | ||
| submitView, | ||
| page, | ||
| }) => { | ||
| await topBar.toggleView(FormsView.View) | ||
| await submitView.checkRadio('Rate the service', '4 of 5') | ||
|
|
||
| await page.reload() | ||
|
|
||
| await expect( | ||
| submitView | ||
| .getQuestion('Rate the service') | ||
| .getByRole('radio', { name: '4 of 5' }), | ||
| ).toBeChecked() | ||
| }) | ||
|
|
||
| test('Restores the rating when editing a submission', async ({ | ||
| topBar, | ||
| submitView, | ||
| resultsView, | ||
| page, | ||
| }) => { | ||
| await topBar.toggleView(FormsView.View) | ||
| await submitView.checkRadio('Rate the service', '4 of 5') | ||
| await submitView.submit() | ||
| await expect(submitView.successMessage).toBeVisible() | ||
|
|
||
| await page.goto(page.url().replace(/\/submit.*$/, '/results')) | ||
| await resultsView.switchToResponses() | ||
| await resultsView.editSubmission() | ||
|
|
||
| await expect( | ||
| submitView | ||
| .getQuestion('Rate the service') | ||
| .getByRole('radio', { name: '4 of 5' }), | ||
| ).toBeChecked() | ||
| }) | ||
|
|
||
| test('Moves on from a rating on Enter instead of submitting', async ({ | ||
| topBar, | ||
| submitView, | ||
| }) => { | ||
| await topBar.toggleView(FormsView.View) | ||
| await submitView.checkRadio('Rate the service', '4 of 5') | ||
|
|
||
| const question = submitView.getQuestion('Rate the service') | ||
| await question.getByRole('radio', { name: '4 of 5' }).press('Enter') | ||
|
|
||
| await expect(question.getByRole('radio', { name: '5 of 5' })).toBeFocused() | ||
| await expect(submitView.successMessage).toHaveCount(0) | ||
| }) | ||
|
|
||
| test('Shows an error when a required rating is left empty', async ({ | ||
| form, | ||
| topBar, | ||
| submitView, | ||
| }) => { | ||
| const questions = await form.getQuestions() | ||
| await questions[0].toggleRequired() | ||
| await topBar.toggleView(FormsView.View) | ||
|
|
||
| await submitView.submitButton.click() | ||
|
|
||
| const question = submitView.getQuestion('Rate the service') | ||
| await expect( | ||
| question.getByText('You must answer this question'), | ||
| ).toBeVisible() | ||
| await expect(question.getByRole('radio').first()).toHaveAttribute( | ||
| 'aria-invalid', | ||
| 'true', | ||
| ) | ||
| }) | ||
|
|
||
| test('Focuses a new rating question and offers to insert a question after it', async ({ | ||
| form, | ||
| page, | ||
| }) => { | ||
| await form.addQuestion(QuestionType.Rating) | ||
|
|
||
| const questions = await form.getQuestions() | ||
| await expect(questions[1].titleInput).toBeFocused() | ||
| await expect( | ||
| page.getByRole('button', { | ||
| name: 'Insert question after question 1', | ||
| }), | ||
| ).toHaveCount(1) | ||
| }) | ||
| }) |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.