PRO-365: e2e_tests - Add response analysis page tests#1397
PRO-365: e2e_tests - Add response analysis page tests#1397georgia-i-ai wants to merge 4 commits into
Conversation
|
Claude finished @georgia-i-ai's task in 1m 18s —— View job PR Review
Good coverage of a previously untested page. The One bug: 🔴 DO: The respondent URL regex // line 214 — \d+ won't match a UUID
await page.waitForURL(/\/respondent\/\d+/);
// should be:
await page.waitForURL(/\/respondent\/[0-9a-f-]+/);Compare with ⚪️ NIT: The |
|
Will look at the issue raised by Claude but it seemed to be matching fine (and tests pass). |
Nazehs
left a comment
There was a problem hiding this comment.
LGTM! just some minor comments and suggestions
| }); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ page }) => { |
There was a problem hiding this comment.
Suggestion: Can we extract this to make it reusable similar to the below which I believe response-analysis.e2e.ts, respondent-detail.e2e.ts, and questions.e2e.ts could benefits from
export async function goToFirstQuestion(page: Page, consultationId: string, questionId: string) {
await page.goto(`/consultations/${consultationId}`);
await page.waitForLoadState("networkidle");
await page.getByTestId(`question-link-${questionId}`).click();
await page.waitForURL(/\/questions\//);
await page.waitForLoadState("networkidle");
}
There was a problem hiding this comment.
Sure good idea - I haven't looked to much at the other tests so keep for suggestions of reusable code to move into helpers.ts
- move setup into helper function
c99c465 to
4a082f6
Compare
…ts include checking that filters work as expected, that selecting themes filters responses and flagged filters work as expected, and that clicking on a respondent goes to details page. PRO-365
4a082f6 to
53e525c
Compare
|
Claude finished @georgia-i-ai's task in 2m 3s —— View job PR Review
Good coverage overall, and the review feedback from Nazehs has been addressed. Two issues remain: 🔴 DO: // line 214 — won't match UUID
await page.waitForURL(/\/respondent\/\d+/);
// should match respondent-detail.e2e.ts:56 pattern
await expect(page).toHaveURL(/\/consultations\/.*\/respondent\/.*/);⚪️ NIT: The |
This seems to be needed even despite the wait for network call - without it the response count is incorrect |
|
Claude finished @georgia-i-ai's task in 50s —— View job PR Review
The UUID regex fix is now in place on line 214. Looks good overall. ⚪️ NIT: |
|
All comments addressed from @Nazehs and Claude and rebased on main - ready for re-review. |
| /** | ||
| * Goes to a specific question in a consultation | ||
| */ | ||
| export async function goToQuestion(page: Page, consultationId: string, questionID: string) { |
There was a problem hiding this comment.
NITPICK: Could you consider naming this maybe goToConsultationQuestion or something to increase clarity and context
| }); | ||
|
|
||
| test.afterAll(async () => { | ||
| await deleteFixtureData(testData); |
There was a problem hiding this comment.
Suggestion: There is a CleanupManager class now that is in main could you rebase with main and make use of it for the clean up?
| function sleep() { | ||
| return setTimeout(1000); | ||
| } |
There was a problem hiding this comment.
This is not async and therefore not working as intended?
There was a problem hiding this comment.
Something like this should work:
const sleep = duration => new Promise(resolve => setTimeout(resolve, duration));
| await page.waitForLoadState('networkidle'); | ||
|
|
||
| // Check filter still shows correct count after click (should be same as before) | ||
| await sleep(); // Wait for any debounce to finish and count to update |
There was a problem hiding this comment.
Can we not use something like waitForFunction instead of our own sleep?
| return setTimeout(1000); | ||
| } | ||
|
|
||
| const freeTextResponses = (page: Page) => |
There was a problem hiding this comment.
Can we name this as an action like getFreeTextResponses?
Context
Adds E2E test coverage for the response analysis page (question detail view). The page has several interactive filtering
mechanisms — demographic filters, multichoice answer filters, theme filters, flagged toggle — none of which had automated tests.
Changes proposed in this pull request
New file e2e_tests/tests/response-analysis.e2e.ts with:
Guidance to review
The selector choices are non-obvious in places:
Notes
The testFilter helper function got quite complex in order to handle all of the different ways in which I wanted to use it. Open to ideas on how to simplify. Also happy to move any of the local helpers to
helpers.tsif it is thought they would be useful elsehwere.▎ 🤖 PR description mostly generated with Claude Code (https://claude.ai/claude-code)