Skip to content

Add QAN URL state persistence tests - #1139

Open
kiranvuyurru wants to merge 2 commits into
mainfrom
PMM-14848-url-parameters
Open

Add QAN URL state persistence tests#1139
kiranvuyurru wants to merge 2 commits into
mainfrom
PMM-14848-url-parameters

Conversation

@kiranvuyurru

@kiranvuyurru kiranvuyurru commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Add comprehensive tests for URL state persistence across RTA overview, sessions, and stored metrics pages. Includes new page object methods and locators for filters, pagination, and rows-per-page controls. Adds mock helper for RTA sessions and new storedMetrics URL state test suite (PMM-T2265, PMM-T2266, PMM-T2267, PMM-T2268).
https://github.com/percona/pmm-qa/actions/runs/31022412293/job/92362695351

Add comprehensive tests for URL state persistence across RTA overview, sessions, and stored metrics pages. Includes new page object methods and locators for filters, pagination, and rows-per-page controls. Adds mock helper for RTA sessions and new storedMetrics URL state test suite (PMM-T2265, PMM-T2266, PMM-T2267, PMM-T2268).
@kiranvuyurru
kiranvuyurru marked this pull request as ready for review August 5, 2026 17:06
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9ed5597e-37f7-4a27-b372-8def5b58a7f4

📥 Commits

Reviewing files that changed from the base of the PR and between b5934e1 and bd5a98b.

📒 Files selected for processing (1)
  • e2e_tests/tests/qan/rta/overview.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • percona/pmm-qa (manual)
  • percona/pmm (manual)
🚧 Files skipped from review as they are similar to previous changes (1)
  • e2e_tests/tests/qan/rta/overview.test.ts

Walkthrough

Changes

URL State Coverage

Layer / File(s) Summary
RTA overview state
e2e_tests/pages/qan/rta/realTimeAnalytics.page.ts, e2e_tests/tests/qan/rta/overview.test.ts
RTA coverage verifies URL persistence and reload restoration for query filters, page size, elapsed-time sorting, service IDs, and decimal duration filters.
RTA sessions pagination
e2e_tests/helpers/apiEndpoints.ts, e2e_tests/helpers/mocks.helper.ts, e2e_tests/tests/qan/rta/session.test.ts
The sessions endpoint uses deterministic mock data. The test verifies session page-size persistence and row-count restoration after reload.
Stored Metrics URL state
e2e_tests/pages/qan/storedMetrics/storedMetrics.page.ts, e2e_tests/tests/qan/storedMetrics/urlState.test.ts
Stored Metrics coverage verifies service-type filters, pagination, debounced search, shared URL navigation, restored state, and browser console errors.

Possibly related PRs

  • percona/pmm-qa#1128: Both changes extend RealTimeAnalyticsPage locators and helpers for RTA end-to-end tests.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: adding QAN URL state persistence tests.
Description check ✅ Passed The description directly describes the URL state persistence tests and related page object and mock changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
e2e_tests/tests/qan/storedMetrics/urlState.test.ts (1)

17-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Split the scenario into test.step() phases.

Separate filter changes, pagination changes, URL assertions, and shared-URL restoration into named steps. This makes a failed URL-state assertion identifiable in CI output.

As per coding guidelines, “Use Playwright's test.step() for readable test structure.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e_tests/tests/qan/storedMetrics/urlState.test.ts` around lines 17 - 68,
Split the scenario in the test callback into named Playwright test.step phases
covering filter changes, pagination changes, URL assertions, and shared-URL
restoration. Move the corresponding existing actions and assertions into these
steps without changing their order or behavior, and keep console-error
collection and cleanup correctly scoped across the full scenario.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e_tests/tests/qan/rta/overview.test.ts`:
- Around line 262-274: Select a known service in the test before capturing
serviceIds, using the existing service-selection control or helper. Assert that
the pre-reload URL contains the selected service ID, then preserve the existing
reload flow and verify the post-reload serviceIds matches the captured value.
- Around line 245-275: Add readable pmmTest.step() blocks to structure the
URL-state tests: in e2e_tests/tests/qan/rta/overview.test.ts lines 245-275,
separate state setup, URL verification, reload, and restored-state checks; in
lines 278-331, separate duration setup, filtered-results verification, URL
verification, and restoration checks; in e2e_tests/tests/qan/rta/session.test.ts
lines 55-72, separate mock setup, page-size selection, URL verification, and
reload checks.

In `@e2e_tests/tests/qan/storedMetrics/urlState.test.ts`:
- Line 16: Add the `@qan` tag to the test title for “PMM-T2268 Verify QAN shared
URL restores filters and pagination,” while retaining the existing `@rta` tag.
- Line 26: Wrap the test body after the page setup and console listener
registration in a try/finally block. Keep the existing assertions and test flow
in try, and move page.off('console', collectErrors) plus sharedPage.close() into
finally so both cleanup operations run on success and failure.

---

Nitpick comments:
In `@e2e_tests/tests/qan/storedMetrics/urlState.test.ts`:
- Around line 17-68: Split the scenario in the test callback into named
Playwright test.step phases covering filter changes, pagination changes, URL
assertions, and shared-URL restoration. Move the corresponding existing actions
and assertions into these steps without changing their order or behavior, and
keep console-error collection and cleanup correctly scoped across the full
scenario.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 31dd7321-b48b-4220-a07f-0ac1c7967a38

📥 Commits

Reviewing files that changed from the base of the PR and between 9cc19fb and b5934e1.

📒 Files selected for processing (7)
  • e2e_tests/helpers/apiEndpoints.ts
  • e2e_tests/helpers/mocks.helper.ts
  • e2e_tests/pages/qan/rta/realTimeAnalytics.page.ts
  • e2e_tests/pages/qan/storedMetrics/storedMetrics.page.ts
  • e2e_tests/tests/qan/rta/overview.test.ts
  • e2e_tests/tests/qan/rta/session.test.ts
  • e2e_tests/tests/qan/storedMetrics/urlState.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • percona/pmm-qa (manual)
  • percona/pmm (manual)

Comment on lines +245 to +275
pmmTest(
'PMM-T2265 Verify RTA overview table state is stored in the URL and restored after refresh @rta',
async ({ page, queryAnalytics }) => {
const { rta } = queryAnalytics;

await rta.buttons.pauseRealTimeAnalytics.click();
await rta.filterQueriesByText('db.runCommand');
await rta.inputs.rowsLimit.click();
await rta.builders.rowsPerPageOption('10').click();
await rta.clickElapsedTimeHeader();

await expect
.poll(() => new URL(page.url()).searchParams.get('overview.f.queryText'))
.toBe('db.runCommand');
await expect.poll(() => new URL(page.url()).searchParams.get('overview.pageSize')).toBe('10');
await expect.poll(() => new URL(page.url()).searchParams.get('overview.sort')).not.toBeNull();

const urlBeforeReload = new URL(page.url());
const serviceIds = urlBeforeReload.searchParams.getAll('serviceIds');

await page.reload();
await rta.elements.realTimeTable.waitFor({ state: 'visible' });
await rta.openFiltersIfHidden();

await expect(rta.inputs.filterByQueryText).toHaveValue('db.runCommand');
await expect(rta.inputs.rowsLimit).toHaveText('10');
await expect(rta.elements.elapsedTimeColumnHeader).toHaveAccessibleName(
/Elapsed time Sorted by Elapsed time descending/,
);
expect(new URL(page.url()).searchParams.getAll('serviceIds')).toEqual(serviceIds);
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add readable pmmTest.step() blocks to the new URL-state tests.

  • e2e_tests/tests/qan/rta/overview.test.ts#L245-L275: Separate state setup, URL verification, reload, and restored-state checks.
  • e2e_tests/tests/qan/rta/overview.test.ts#L278-L331: Separate duration setup, filtered-results verification, URL verification, and restoration checks.
  • e2e_tests/tests/qan/rta/session.test.ts#L55-L72: Separate mock setup, page-size selection, URL verification, and reload checks.

As per coding guidelines, “Use Playwright's test.step() for readable test structure.”

📍 Affects 2 files
  • e2e_tests/tests/qan/rta/overview.test.ts#L245-L275 (this comment)
  • e2e_tests/tests/qan/rta/overview.test.ts#L278-L331
  • e2e_tests/tests/qan/rta/session.test.ts#L55-L72
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e_tests/tests/qan/rta/overview.test.ts` around lines 245 - 275, Add
readable pmmTest.step() blocks to structure the URL-state tests: in
e2e_tests/tests/qan/rta/overview.test.ts lines 245-275, separate state setup,
URL verification, reload, and restored-state checks; in lines 278-331, separate
duration setup, filtered-results verification, URL verification, and restoration
checks; in e2e_tests/tests/qan/rta/session.test.ts lines 55-72, separate mock
setup, page-size selection, URL verification, and reload checks.

Source: Coding guidelines

Comment on lines +262 to +274
const urlBeforeReload = new URL(page.url());
const serviceIds = urlBeforeReload.searchParams.getAll('serviceIds');

await page.reload();
await rta.elements.realTimeTable.waitFor({ state: 'visible' });
await rta.openFiltersIfHidden();

await expect(rta.inputs.filterByQueryText).toHaveValue('db.runCommand');
await expect(rta.inputs.rowsLimit).toHaveText('10');
await expect(rta.elements.elapsedTimeColumnHeader).toHaveAccessibleName(
/Elapsed time Sorted by Elapsed time descending/,
);
expect(new URL(page.url()).searchParams.getAll('serviceIds')).toEqual(serviceIds);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Select a service before verifying serviceIds restoration.

This test does not change the selected service state. It can pass with an empty serviceIds list. Select a known service, then assert its URL value before and after reload.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e_tests/tests/qan/rta/overview.test.ts` around lines 262 - 274, Select a
known service in the test before capturing serviceIds, using the existing
service-selection control or helper. Assert that the pre-reload URL contains the
selected service ID, then preserve the existing reload flow and verify the
post-reload serviceIds matches the captured value.

});

pmmTest(
'PMM-T2268 Verify QAN shared URL restores filters and pagination @rta',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the @qan tag.

This QAN test declares only @rta. A CI selection for @qan cannot include this test. Retain @rta if that selection is also required.

As per coding guidelines, “Tag tests for CI filtering, using applicable tags such as @inventory, @dashboards, and @qan.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e_tests/tests/qan/storedMetrics/urlState.test.ts` at line 16, Add the `@qan`
tag to the test title for “PMM-T2268 Verify QAN shared URL restores filters and
pagination,” while retaining the existing `@rta` tag.

Source: Coding guidelines

if (message.type() === 'error') errors.push(message.text());
};

page.on('console', collectErrors);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Make test cleanup unconditional.

If an assertion fails after Line 26, page.off('console', collectErrors) and sharedPage.close() do not run. Use try/finally so the listener is removed and the created page is closed on every path.

As per coding guidelines, “Make tests idempotent and clean up resources created during tests.”

Also applies to: 55-68

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e_tests/tests/qan/storedMetrics/urlState.test.ts` at line 26, Wrap the test
body after the page setup and console listener registration in a try/finally
block. Keep the existing assertions and test flow in try, and move
page.off('console', collectErrors) plus sharedPage.close() into finally so both
cleanup operations run on success and failure.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant