* Scopes API client * Initial RTK query commit * Copy API client from generated enterprise folder * Mock ScopesApiClient for integration tests * Update e2e tests * Handle group expansion for dashboard navigation * Extract integration test mocks * Move mock to only be for integration tests * Update path for enterprise sync script * Re-export mockData * Disregard caching for search * Leave name parameters empty * Disable subscriptions for client requests * Add functionality to reset cache between mocked requests * Use grafana-test-utils for scopes integration tests * Rollback mock setup * Remove store form window object * Remove cache helper * Restore scopenode search functionality * Improve request erro handling * Clean up subscription in case subscription: false lies * Fix logging security risk * Rewrite tests to cover RTK query usage and improve error catching * Update USE_LIVE_DATA to be consistent * Remove unused timout parameter * Fix error handling * Make dashboard-navigation test pass
94 lines
3.0 KiB
TypeScript
94 lines
3.0 KiB
TypeScript
import { Page } from '@playwright/test';
|
|
|
|
import { expect, DashboardPage, E2ESelectorGroups } from '@grafana/plugin-e2e';
|
|
|
|
export function getAdHocFilterPills(page: Page) {
|
|
return page.getByLabel(/^Edit filter with key/);
|
|
}
|
|
|
|
export async function waitForAdHocOption(page: Page) {
|
|
await page.waitForSelector('[role="option"]', { state: 'visible' });
|
|
}
|
|
|
|
export async function getMarkdownHTMLContent(page: DashboardPage, selectors: E2ESelectorGroups) {
|
|
const panelContent = page.getByGrafanaSelector(selectors.components.Panels.Panel.content).first();
|
|
await expect(panelContent).toBeVisible();
|
|
return panelContent.locator('.markdown-html');
|
|
}
|
|
|
|
export function getAdhocFiltersInput(page: DashboardPage, selectors: E2ESelectorGroups) {
|
|
return page
|
|
.getByGrafanaSelector(selectors.pages.Dashboard.SubMenu.submenuItemLabels('adHoc'))
|
|
.locator('..')
|
|
.locator('input');
|
|
}
|
|
|
|
export function getGroupByInput(page: DashboardPage, selectors: E2ESelectorGroups) {
|
|
return page
|
|
.getByGrafanaSelector(selectors.pages.Dashboard.SubMenu.submenuItemLabels('groupBy'))
|
|
.locator('..')
|
|
.locator('input');
|
|
}
|
|
|
|
export function getAdHocFilterOptionValues(page: Page) {
|
|
return page.getByTestId(/^data-testid ad hoc filter option value/);
|
|
}
|
|
|
|
export function getAdHocFilterRestoreButton(page: Page, type: string) {
|
|
if (type === 'dashboard') {
|
|
return page.getByLabel('Restore the value set by this dashboard.');
|
|
}
|
|
|
|
if (type === 'scope') {
|
|
return page.getByLabel('Restore the value set by your selected scope.');
|
|
}
|
|
|
|
return page.getByLabel('Restore filter to its original value.');
|
|
}
|
|
|
|
export function getGroupByRestoreButton(page: Page) {
|
|
return page.getByLabel('Restore groupby set by this dashboard.');
|
|
}
|
|
|
|
export function getScopesSelectorInput(page: Page) {
|
|
return page.getByTestId('scopes-selector-input');
|
|
}
|
|
|
|
export function getRecentScopesSelector(page: Page) {
|
|
return page.getByTestId('scopes-selector-recent-scopes-section');
|
|
}
|
|
|
|
export function getScopeTreeCheckboxes(page: Page) {
|
|
return page.locator('input[type="checkbox"][data-testid^="scopes-tree"]');
|
|
}
|
|
|
|
export function getScopesDashboards(page: Page) {
|
|
return page.locator('[data-testid^="scopes-dashboards-"][role="treeitem"]');
|
|
}
|
|
|
|
/**
|
|
* Clicks the first available dashboard in the scopes dashboard list.
|
|
*/
|
|
export async function clickFirstScopesDashboard(page: Page) {
|
|
const dashboards = getScopesDashboards(page);
|
|
// Wait for at least one dashboard to be visible
|
|
await expect(dashboards.first()).toBeVisible({ timeout: 10000 });
|
|
// Click - Playwright will automatically wait for the element to be actionable
|
|
await dashboards.first().click();
|
|
}
|
|
|
|
export function getScopesDashboardsSearchInput(page: Page) {
|
|
return page.getByTestId('scopes-dashboards-search');
|
|
}
|
|
|
|
export function getGroupByValues(page: Page) {
|
|
return page
|
|
.getByTestId(/^GroupBySelect-/)
|
|
.first()
|
|
.locator('div:has(+ button)');
|
|
}
|
|
|
|
export function getGroupByOptions(page: Page) {
|
|
return page.getByTestId('data-testid Select option');
|
|
}
|