-
Notifications
You must be signed in to change notification settings - Fork 14
Add QAN URL state persistence tests #1139
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import pmmTest from '@fixtures/pmmTest'; | ||
| import { Timeouts } from '@helpers/timeouts'; | ||
| import StoredMetricsPage from '@pages/qan/storedMetrics/storedMetrics.page'; | ||
| import { expect, type ConsoleMessage } from '@playwright/test'; | ||
|
|
||
| pmmTest.beforeEach(async ({ grafanaHelper, page, queryAnalytics }) => { | ||
| await grafanaHelper.authorize(); | ||
| await page.goto(queryAnalytics.url); | ||
| await queryAnalytics.storedMetrics.elements.iframe.waitFor({ | ||
| state: 'visible', | ||
| timeout: Timeouts.THIRTY_SECONDS, | ||
| }); | ||
| }); | ||
|
|
||
| pmmTest( | ||
| 'PMM-T2268 Verify QAN shared URL restores filters and pagination @rta', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Add the This QAN test declares only As per coding guidelines, “Tag tests for CI filtering, using applicable tags such as 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| async ({ context, page, queryAnalytics }) => { | ||
| const { storedMetrics } = queryAnalytics; | ||
| const mongoDbLabel = storedMetrics.builders.serviceTypeLabel('mongodb'); | ||
| const errors: string[] = []; | ||
|
|
||
| const collectErrors = (message: ConsoleMessage) => { | ||
| if (message.type() === 'error') errors.push(message.text()); | ||
| }; | ||
|
|
||
| page.on('console', collectErrors); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, As per coding guidelines, “Make tests idempotent and clean up resources created during tests.” Also applies to: 55-68 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| await mongoDbLabel.scrollIntoViewIfNeeded(); | ||
| await mongoDbLabel.click(); | ||
|
|
||
| const secondPaginationItem = storedMetrics.builders.paginationItem('2'); | ||
|
|
||
| await expect(secondPaginationItem).toBeVisible({ timeout: Timeouts.THIRTY_SECONDS }); | ||
| await secondPaginationItem.click(); | ||
|
|
||
| for (let index = 0; index < 4; index++) { | ||
| await mongoDbLabel.click(); | ||
| } | ||
|
|
||
| for (const pageNumber of ['1', '2', '1', '2']) { | ||
| await storedMetrics.builders.paginationItem(pageNumber).click(); | ||
| } | ||
|
|
||
| for (const value of ['a', 'ab', 'abc', '']) { | ||
| await storedMetrics.inputs.search.fill(value); | ||
| } | ||
|
|
||
| // eslint-disable-next-line playwright/no-wait-for-timeout -- allow debounce and console errors to settle | ||
| await page.waitForTimeout(Timeouts.HALF_SECOND); | ||
|
|
||
| await expect.poll(() => new URL(page.url()).searchParams.has('dimensionSearchText')).toBeFalsy(); | ||
| await expect.poll(() => new URL(page.url()).searchParams.get('page_number')).toBe('2'); | ||
| await expect.poll(() => new URL(page.url()).searchParams.getAll('var-service_type')).toContain('mongodb'); | ||
|
|
||
| const sharedUrl = page.url(); | ||
| const sharedPage = await context.newPage(); | ||
|
|
||
| await sharedPage.goto(sharedUrl); | ||
|
|
||
| const sharedStoredMetrics = new StoredMetricsPage(sharedPage); | ||
|
|
||
| await expect(sharedStoredMetrics.builders.serviceTypeFilter('mongodb')).toBeChecked({ | ||
| timeout: Timeouts.THIRTY_SECONDS, | ||
| }); | ||
| await expect(sharedStoredMetrics.builders.paginationItem('2')).toHaveClass(/ant-pagination-item-active/); | ||
|
|
||
| page.off('console', collectErrors); | ||
| expect(errors).toEqual([]); | ||
| await sharedPage.close(); | ||
| }, | ||
| ); | ||
There was a problem hiding this comment.
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-L331e2e_tests/tests/qan/rta/session.test.ts#L55-L72🤖 Prompt for AI Agents
Source: Coding guidelines