PMM-15241 Add update-snooze test and HelpPage locator - #1127
Conversation
Add a remind-me-later locator to HelpPage and a new Playwright test (PMM-T2263) that verifies the update notification stays snoozed across page reloads and reappears after the snooze duration. The test mocks users.me and server.updates endpoints, sets pmm-ui.dev.updateSnoozeDurationMs in localStorage, and uses Timeouts helpers. Also import apiEndpoints in the test file.
| await page.context().unroute(apiEndpoints.users.me); | ||
| await page.context().unroute(apiEndpoints.server.updates); | ||
| await page.route(apiEndpoints.users.me, async (route) => { | ||
| if (route.request().method() === 'PUT') { | ||
| const body = route.request().postDataJSON() as { snoozed_pmm_version?: string }; | ||
|
|
||
| snoozedAt = Date.now(); | ||
| snoozedVersion = body.snoozed_pmm_version ?? ''; | ||
| } | ||
|
|
||
| await route.fulfill({ | ||
| body: JSON.stringify({ | ||
| alerting_tour_completed: true, | ||
| product_tour_completed: true, | ||
| snoozed_at: snoozedAt ? new Date(snoozedAt).toISOString() : null, | ||
| snoozed_pmm_version: snoozedVersion, | ||
| user_id: 1, | ||
| }), | ||
| contentType: 'application/json', | ||
| status: 200, | ||
| }); | ||
| }); | ||
| await page.route(apiEndpoints.server.updates, (route) => | ||
| route.fulfill({ | ||
| body: JSON.stringify({ | ||
| installed: {}, | ||
| last_check: new Date().toISOString(), | ||
| latest: { | ||
| timestamp: new Date(0).toISOString(), | ||
| version: updateVersion, | ||
| }, | ||
| update_available: true, | ||
| }), | ||
| contentType: 'application/json', | ||
| status: 200, | ||
| }), | ||
| ); |
There was a problem hiding this comment.
For these API interactions, don't we have fixtures + methods that wrap those?
There was a problem hiding this comment.
we have mocks fixture and mockUpdateAvailable(), but nothing for user-snooze API behavior.
travagliad
left a comment
There was a problem hiding this comment.
Test is failing, please make sure you check the test result before asking for review as you will probably need to change code and we should review it by then
here is the execution of the test where it passed. https://github.com/percona/pmm-qa/actions/runs/30566783377/job/90964485581 |
It failed on this run, so it's flaky test? |
Add a remind-me-later locator to HelpPage and a new Playwright test (PMM-T2263) that verifies the update notification stays snoozed across page reloads and reappears after the snooze duration. The test mocks users.me and server.updates endpoints, sets pmm-ui.dev.updateSnoozeDurationMs in localStorage, and uses Timeouts helpers. Also import apiEndpoints in the test file.