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
6 changes: 3 additions & 3 deletions playwright/e2e/results-view.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ test.describe('Results view', () => {
await expect(resultsView.page).toHaveURL(/\/results\/summary$/)
})

test('Navigating to /results redirects to /results/summary', async ({ page }) => {
test('Navigating to /results redirects to last viewed subview', async ({ page }) => {
// Start on the responses tab
await page.goto(page.url().replace(/\/summary$/, '/responses'))
await page.waitForURL(/\/results\/responses$/)

// Navigate to the parent results route
await page.goto(page.url().replace(/\/responses$/, ''))
await page.waitForURL(/\/results\/summary$/)
await expect(page).toHaveURL(/\/results\/summary$/)
await page.waitForURL(/\/results\/responses$/)
await expect(page).toHaveURL(/\/results\/responses$/)
})
})

7 changes: 4 additions & 3 deletions playwright/support/sections/SubmitSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export class SubmitSection {
constructor(public readonly page: Page) {
this.clearFormButton = this.page.getByRole('button', { name: 'Clear form' })
this.submitButton = this.page.getByRole('button', { name: 'Submit' })
this.successMessage = this.page.getByText(
'Thank you for completing the form!',
)
this.successMessage = this.page
.getByRole('main')
.locator('.forms-emptycontent')
.getByText('Thank you for completing the form!')
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const routes = [
},
{
path: '/:hash/results',
props: { default: true },
children: [
{
path: '',
name: 'results',
props: { default: true },
redirect: (to) => {
const validViews = ['summary', 'responses']
const storedView = localStorage.getItem(
Expand All @@ -56,11 +56,13 @@ const routes = [
{
path: 'summary',
name: 'results.summary',
props: { default: true },
components: { default: Results },
},
{
path: 'responses',
name: 'results.responses',
props: { default: true },
components: { default: Results },
},
],
Expand Down
5 changes: 5 additions & 0 deletions src/views/Results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ export default {
// Reload results when form changes
async hash() {
await this.fetchFullForm(this.form.id)
await this.loadFormResults()
SetWindowTitle(this.formTitle)
},

Expand Down Expand Up @@ -538,6 +539,10 @@ export default {
},

async beforeMount() {
// Determine the initial viewId based on the route
const viewId = this.isSummaryView ? 'summary' : 'responses'
this.saveActiveResponseViewToLocalStorage(viewId)

await this.fetchFullForm(this.form.id)
this.loadFormResults()
SetWindowTitle(this.formTitle)
Expand Down
Loading