SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
test(dashboards): e2e for the dashboards list page (#13263)
Abhi kumar8ab8c63beac3
diff --git a/tests/e2e/drivers/dashboard-list.ts b/tests/e2e/drivers/dashboard-list.tsindex 3ab8640ede..83355c2161 100644--- a/tests/e2e/drivers/dashboard-list.ts+++ b/tests/e2e/drivers/dashboard-list.ts@@ -93,6 +93,11 @@ export interface DashboardList {* lands on. The dashboard is deleted when the test ends.*/create(fields: NewDashboardFields): Promise<string>;+ /**+ * Uploads `dashboard` as a .json file on the Import JSON tab and submits it,+ * returning the id from the route it lands on. Deleted when the test ends.+ */+ importJson(dashboard: PostableDashboard): Promise<string>;/** Rows render titles in `dashboard-title-<index>`, not by id. */rowTitle(name: string): Locator;/** Opens the row's actions menu and confirms Delete. */@@ -174,6 +179,28 @@ function dashboardListDriver(page: Page): DashboardList {await option.click();};+ // Tracked from the response, before the route settles, so a failed+ // navigation still cleans up.+ const submitAndTrack = async (submit: Locator): Promise<string> => {+ const [response] = await Promise.all([+ page.waitForResponse(+ (r) =>+ r.request().method() === 'POST' &&+ // The app is served under the base path, and so is its API.+ new URL(r.url()).pathname === `${BASE_PATH}${DASHBOARDS_API}`,+ ),+ submit.click(),+ ]);+ expect(response.ok(), `POST ${DASHBOARDS_API} failed`).toBe(true);+ const created = ((await response.json()) as { data: { id: string } }).data.id;+ trackDashboard(page, created);++ await page.waitForURL(DASHBOARD_ROUTE);+ const id = DASHBOARD_ROUTE.exec(new URL(page.url()).pathname)?.[1];+ expect(id).toBe(created);+ return created;+ };+const list: DashboardList = {async open(name, sort = {}) {const params = new URLSearchParams(@@ -203,27 +230,21 @@ function dashboardListDriver(page: Page): DashboardList {await list.tagsInput().press('Enter');}await expect(list.tagChips()).toHaveCount(tags.length);-- const [response] = await Promise.all([- page.waitForResponse(- (r) =>- r.request().method() === 'POST' &&- // The app is served under the base path, and so is its API.- new URL(r.url()).pathname === `${BASE_PATH}${DASHBOARDS_API}`,- ),- list.submit().click(),+ return submitAndTrack(list.submit());+ },+ async importJson(dashboard) {+ await list.openNewDashboard('Import JSON');+ const [chooser] = await Promise.all([+ page.waitForEvent('filechooser'),+ list.uploadJsonButton().click(),]);- // Tracked from the response, before the route settles, so a failed- // navigation still cleans up.- expect(response.ok(), `POST ${DASHBOARDS_API} failed`).toBe(true);- const created = ((await response.json()) as { data: { id: string } }).data- .id;- trackDashboard(page, created);-- await page.waitForURL(DASHBOARD_ROUTE);- const id = DASHBOARD_ROUTE.exec(new URL(page.url()).pathname)?.[1];- expect(id).toBe(created);- return created;+ await chooser.setFiles({+ name: 'dashboard.json',+ mimeType: 'application/json',+ buffer: Buffer.from(JSON.stringify(dashboard)),+ });+ await expect(list.jsonEditor()).toContainText(dashboard.spec.display.name);+ return submitAndTrack(list.importJsonSubmit());},rowTitle,async delete(name) {diff --git a/tests/e2e/tests/dashboards/list/create-import.spec.ts b/tests/e2e/tests/dashboards/list/create-import.spec.tsnew file mode 100644index 0000000000..cf71045b41--- /dev/null+++ b/tests/e2e/tests/dashboards/list/create-import.spec.ts@@ -0,0 +1,67 @@+import {+ expect,+ LIST_URL,+ listDashboard,+ test,+ uniqueName,+} from '../../../drivers/dashboard-list';++test.describe('Dashboards — list create and import', () => {+ test('TC-01 New dashboard offers Blank, template and Import JSON tabs', async ({+ dashboardList,+ }) => {+ await dashboardList.open();++ await dashboardList.openNewDashboard();++ await expect(dashboardList.newDashboardTabs()).toHaveText([+ 'Blank',+ 'From a template',+ 'Import JSON',+ ]);+ await expect(dashboardList.nameInput()).toHaveValue('Sample Dashboard');+ });++ test('TC-02 an uploaded JSON file imports and opens the dashboard', async ({+ dashboardList,+ dashboards,+ }) => {+ const name = uniqueName('import');+ await dashboardList.open();++ const id = await dashboardList.importJson(+ listDashboard(name, [{ key: 'team', value: 'e2e' }]),+ );++ await expect(dashboards.title()).toHaveText(name);+ const saved = await dashboards.get(id);+ expect(saved.spec.display.name).toBe(name);+ expect(saved.tags).toEqual([{ key: 'team', value: 'e2e' }]);+ });++ test('TC-03 Escape dismisses the dialog and stays on the list', async ({+ authedPage: page,+ dashboardList,+ }) => {+ await dashboardList.open();+ await dashboardList.openNewDashboard('Import JSON');++ await dashboardList.dismissWithEscape();++ await expect(dashboardList.newDashboardDialog()).toBeHidden();+ await expect(page).toHaveURL(LIST_URL);+ });++ test('TC-04 the close button dismisses the dialog and stays on the list', async ({+ authedPage: page,+ dashboardList,+ }) => {+ await dashboardList.open();+ await dashboardList.openNewDashboard('Import JSON');++ await dashboardList.closeDialog();++ await expect(dashboardList.newDashboardDialog()).toBeHidden();+ await expect(page).toHaveURL(LIST_URL);+ });+});diff --git a/tests/e2e/tests/dashboards/list/navigation.spec.ts b/tests/e2e/tests/dashboards/list/navigation.spec.tsnew file mode 100644index 0000000000..4299405709--- /dev/null+++ b/tests/e2e/tests/dashboards/list/navigation.spec.ts@@ -0,0 +1,114 @@+import {+ expect,+ listDashboard,+ nameContains,+ LIST_URL,+ PATH,+ test,+ uniqueName,+} from '../../../drivers/dashboard-list';++test.describe('Dashboards — list navigation', () => {+ test('TC-01 the page renders its chrome and core controls', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('chrome');+ await dashboards.seed(listDashboard(name));++ await dashboardList.open(name);++ await expect(page).toHaveTitle('SigNoz | All Dashboards');+ await expect(dashboardList.heading()).toHaveText('All dashboards');+ await expect(dashboardList.search()).toBeVisible();+ await expect(dashboardList.newDashboardButton()).toBeVisible();+ await expect(dashboardList.sortButton()).toBeVisible();+ await expect(dashboardList.rowTitle(name)).toBeVisible();+ await expect(dashboardList.feedbackButton()).toBeVisible();+ await expect(dashboardList.shareButton()).toBeVisible();+ });++ test('TC-02 clicking a row opens its dashboard', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('row');+ const id = await dashboards.seed(listDashboard(name));+ await dashboardList.open(name);++ await dashboardList.openRow(name);++ await expect(page).toHaveURL(PATH.onDashboard(id));+ });++ test('TC-03 View opens the dashboard detail page', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('view');+ const id = await dashboards.seed(listDashboard(name));+ await dashboardList.open(name);+ await dashboardList.openRowMenu(name);++ await dashboardList.rowAction('view').click();++ await expect(page).toHaveURL(PATH.onDashboard(id));+ await expect(dashboards.title()).toHaveText(name);+ });++ test('TC-04 the sidebar Dashboards entry opens the list', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ await dashboards.visit('/home');++ await dashboardList.sidebarDashboards().click();++ await expect(page).toHaveURL(LIST_URL);+ await expect(page).toHaveTitle('SigNoz | All Dashboards');+ });++ test('TC-05 the sidebar Dashboards entry leaves a dashboard for the list', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('sidebar');+ const id = await dashboards.seed(listDashboard(name));+ await dashboards.openEmpty(id);+ await expect(dashboards.title()).toHaveText(name);++ await dashboardList.sidebarDashboards().click();++ await expect(page).toHaveURL(LIST_URL);+ await expect(dashboardList.heading()).toHaveText('All dashboards');+ });++ test('TC-06 Back from a dashboard restores the search', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('back');+ const id = await dashboards.seed(listDashboard(name));+ // Typed, not opened with the param, so Back replays the app's own write.+ await dashboardList.open();+ await dashboardList.runSearch(nameContains(name));+ await expect(dashboardList.rows()).toHaveText([name]);+ await dashboardList.openRow(name);+ await expect(page).toHaveURL(PATH.onDashboard(id));++ await dashboardList.back();++ await expect(page).toHaveURL(LIST_URL);+ expect(new URL(page.url()).searchParams.get('query')).toBe(+ nameContains(name),+ );+ await expect(dashboardList.search()).toHaveText(nameContains(name));+ await expect(dashboardList.rows()).toHaveText([name]);+ });+});diff --git a/tests/e2e/tests/dashboards/list/row-actions.spec.ts b/tests/e2e/tests/dashboards/list/row-actions.spec.tsnew file mode 100644index 0000000000..df653efc76--- /dev/null+++ b/tests/e2e/tests/dashboards/list/row-actions.spec.ts@@ -0,0 +1,113 @@+import {+ expect,+ listDashboard,+ LIST_URL,+ PATH,+ test,+ uniqueName,+} from '../../../drivers/dashboard-list';++test.describe('Dashboards — list row actions', () => {+ test('TC-01 an admin sees every row action', async ({+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('menu');+ await dashboards.seed(listDashboard(name));+ await dashboardList.open(name);++ await dashboardList.openRowMenu(name);++ await expect(dashboardList.rowMenuItems()).toHaveText([+ 'View',+ 'Open in New Tab',+ 'Copy Link',+ 'Rename',+ 'Add Tags',+ 'Duplicate',+ 'Lock Dashboard',+ 'Delete Dashboard',+ ]);+ // A denied action stays listed but disabled.+ await expect(+ dashboardList.rowMenu().getByRole('menuitem', { disabled: true }),+ ).toHaveCount(0);+ });++ test('TC-02 Open in New Tab opens the dashboard in a new tab', async ({+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('new-tab');+ const id = await dashboards.seed(listDashboard(name));+ await dashboardList.open(name);++ const tab = await dashboardList.openInNewTab(name);++ await expect(tab).toHaveURL(PATH.onDashboard(id));+ await tab.close();+ });++ test('TC-03 Copy Link copies the dashboard URL', async ({+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('copy');+ const id = await dashboards.seed(listDashboard(name));+ await dashboardList.open(name);++ const copied = await dashboardList.copyLink(name);++ expect(new URL(copied).pathname).toMatch(PATH.onDashboard(id));+ });++ test('TC-04 the menu closes on a click outside it', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('dismiss');+ await dashboards.seed(listDashboard(name));+ await dashboardList.open(name);+ await dashboardList.openRowMenu(name);++ await dashboardList.clickOutside();++ await expect(dashboardList.rowMenu()).toBeHidden();+ await expect(page).toHaveURL(LIST_URL);+ });++ test('TC-05 Delete asks for confirmation naming the dashboard', async ({+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('delete-confirm');+ await dashboards.seed(listDashboard(name));+ await dashboardList.open(name);++ const confirm = await dashboardList.requestDelete(name);++ await expect(confirm).toContainText(+ `Are you sure you want to delete the ${name} dashboard?`,+ );+ await expect(confirm.getByRole('button', { name: 'Cancel' })).toBeVisible();+ await expect(confirm.getByRole('button', { name: 'Delete' })).toBeVisible();+ });++ test('TC-06 cancelling Delete keeps the dashboard and stays on the list', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('delete-cancel');+ const id = await dashboards.seed(listDashboard(name));+ await dashboardList.open(name);+ await dashboardList.requestDelete(name);++ await dashboardList.cancelDelete();++ await expect(page).toHaveURL(LIST_URL);+ await expect(dashboardList.rowTitle(name)).toBeVisible();+ expect((await dashboards.get(id)).id).toBe(id);+ });+});diff --git a/tests/e2e/tests/dashboards/list/search.spec.ts b/tests/e2e/tests/dashboards/list/search.spec.tsnew file mode 100644index 0000000000..8ca0b4b89c--- /dev/null+++ b/tests/e2e/tests/dashboards/list/search.spec.ts@@ -0,0 +1,104 @@+import {+ expect,+ listDashboard,+ nameContains,+ test,+ uniqueName,+} from '../../../drivers/dashboard-list';++test.describe('Dashboards — list search', () => {+ test('TC-01 searching by name writes the query to the URL and lists the match', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('search');+ await dashboards.seed(listDashboard(name));+ await dashboardList.open();++ await dashboardList.runSearch(nameContains(name));++ expect(new URL(page.url()).searchParams.get('query')).toBe(+ nameContains(name),+ );+ await expect(dashboardList.search()).toHaveText(nameContains(name));+ await expect(dashboardList.rows()).toHaveText([name]);+ });++ test('TC-02 searching by a tag lists the tagged dashboard', async ({+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('tagged');+ const value = name.split(' ').pop() as string;+ await dashboards.seed(listDashboard(name, [{ key: 'team', value }]));+ await dashboardList.open();++ await dashboardList.runSearch(`team = '${value}'`);++ await expect(dashboardList.rows()).toHaveText([name]);+ });++ test('TC-03 a query param on load pre-fills the search and filters the list', async ({+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('deeplink');+ await dashboards.seed(listDashboard(name));++ await dashboardList.open(name);++ await expect(dashboardList.search()).toHaveText(nameContains(name));+ await expect(dashboardList.rows()).toHaveText([name]);+ });++ test('TC-04 clearing the search drops the query and lists every dashboard', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('clear');+ const other = uniqueName('clear-other');+ await dashboards.seed(listDashboard(other));+ await dashboards.seed(listDashboard(name));+ await dashboardList.open(name);+ await expect(dashboardList.rows()).toHaveText([name]);++ await dashboardList.clearFilters().click();++ await expect(page).not.toHaveURL(/[?&]query=/);+ await expect(dashboardList.searchPlaceholder()).toBeVisible();+ // Not the seeded rows by name: pinned and other workers' dashboards come+ // first, so either can fall off the first page.+ await expect.poll(() => dashboardList.rows().count()).toBeGreaterThan(1);+ });++ test('TC-05 a search with no match shows the no-results state', async ({+ dashboards,+ dashboardList,+ }) => {+ // The search box only renders once any dashboard exists.+ await dashboards.seed(listDashboard(uniqueName('unrelated')));+ const missing = uniqueName('missing');+ await dashboardList.open();++ await dashboardList.runSearch(nameContains(missing));++ await expect(dashboardList.noResults()).toContainText(missing);+ await expect(dashboardList.rows()).toHaveCount(0);+ await expect(dashboardList.search()).toHaveText(nameContains(missing));+ });++ test('TC-06 ILIKE matches a name regardless of case', async ({+ dashboards,+ dashboardList,+ }) => {+ const name = uniqueName('Mixed CASE');+ await dashboards.seed(listDashboard(name));+ await dashboardList.open();++ await dashboardList.runSearch(`name ILIKE '%${name.toLowerCase()}%'`);++ await expect(dashboardList.rows()).toHaveText([name]);+ });+});diff --git a/tests/e2e/tests/dashboards/list/sort.spec.ts b/tests/e2e/tests/dashboards/list/sort.spec.tsnew file mode 100644index 0000000000..70430aa867--- /dev/null+++ b/tests/e2e/tests/dashboards/list/sort.spec.ts@@ -0,0 +1,67 @@+import {+ expect,+ listDashboard,+ test,+ uniqueName,+} from '../../../drivers/dashboard-list';++test.describe('Dashboards — list sort', () => {+ test('TC-01 sort options write sort and order to the URL and reorder rows', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ const prefix = uniqueName('sort');+ const [a, b, c] = ['a', 'b', 'c'].map((suffix) => `${prefix} ${suffix}`);+ // Created c, a, b, then updated a, c: every sort gives a different order.+ const ids: Record<string, string> = {};+ for (const name of [c, a, b]) {+ ids[name] = await dashboards.seed(listDashboard(name));+ }+ for (const name of [a, c]) {+ await dashboards.setLocked(ids[name], true);+ await dashboards.setLocked(ids[name], false);+ }+ await dashboardList.open(prefix);++ await dashboardList.sortBy('name');+ await expect(page).toHaveURL(/[?&]sort=name(&|$)/);+ await dashboardList.sortOrder('asc');+ await expect(page).toHaveURL(/[?&]order=asc(&|$)/);+ await expect(dashboardList.rows()).toHaveText([a, b, c]);++ await dashboardList.sortOrder('desc');+ await expect(page).not.toHaveURL(/[?&]order=asc/);+ await expect(dashboardList.rows()).toHaveText([c, b, a]);++ await dashboardList.sortBy('created');+ await expect(page).toHaveURL(/[?&]sort=created_at(&|$)/);+ await expect(dashboardList.rows()).toHaveText([b, a, c]);+ await expect(dashboardList.sortButton()).toContainText('Last created');++ // Last updated is the default, so picking it clears the param.+ await dashboardList.sortBy('updated');+ await expect(page).not.toHaveURL(/[?&]sort=/);+ await expect(dashboardList.rows()).toHaveText([c, a, b]);+ });++ test('TC-02 sort params on load are honoured', async ({+ authedPage: page,+ dashboards,+ dashboardList,+ }) => {+ const prefix = uniqueName('sort-load');+ const first = `${prefix} a`;+ const second = `${prefix} b`;+ // Last updated first by default, so name ascending reverses it.+ await dashboards.seed(listDashboard(first));+ await dashboards.seed(listDashboard(second));++ await dashboardList.open(prefix, { sort: 'name', order: 'asc' });++ await expect(page).toHaveURL(/[?&]sort=name(&|$)/);+ await expect(page).toHaveURL(/[?&]order=asc(&|$)/);+ await expect(dashboardList.sortButton()).toContainText('Name');+ await expect(dashboardList.rows()).toHaveText([first, second]);+ });+});