The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Consolidate monitor e2e tests (#83655)
Chris Vandoodewaardcc2db959544c
diff --git a/e2e/test/scenarios/monitor/ai-auditing/mcp-analytics.cy.spec.ts b/e2e/test/scenarios/monitor/ai-auditing/mcp-analytics.cy.spec.tsindex c88a159be72..701b6296846 100644--- a/e2e/test/scenarios/monitor/ai-auditing/mcp-analytics.cy.spec.ts+++ b/e2e/test/scenarios/monitor/ai-auditing/mcp-analytics.cy.spec.ts@@ -31,41 +31,39 @@ function seedMcpToolCall(function visitMcpAnalyticsPage(): void {cy.intercept("GET", "/api/database/13371337/metadata*").as("auditMetadata");- cy.intercept("POST", "/api/dataset").as("dataset");cy.visit(MCP_ANALYTICS_PATH);cy.wait("@auditMetadata");}+function interceptEventsQuery(alias: string): void {+ cy.intercept("POST", "/api/dataset", (req) => {+ if (req.body?.stages?.[0]?.page) {+ req.alias = alias;+ }+ });+}+describe("scenarios > monitor > ai auditing > mcp analytics", () => {beforeEach(() => {H.restore();cy.signInAsAdmin();});- it("shows the audit-app nav item and a seeded tool call on the page", () => {- H.activateToken("pro-self-hosted");- seedMcpToolCall();-- visitMcpAnalyticsPage();-- cy.log("Nav item lives in the AI Auditing group");- cy.findByRole("link", { name: "MCP analytics" }).should("be.visible");-- cy.log("The page renders with the seeded data (not the empty state)");- H.main().within(() => {- cy.findByRole("heading", { name: "MCP analytics" }).should("be.visible");- cy.findByText("No MCP activity").should("not.exist");- });+ it("is hidden without the audit-app feature and shows seeded tool calls, their errors and the gated error message with it", () => {+ cy.visit(MCP_ANALYTICS_PATH);- cy.log("The seeded tool call shows up in the Events table");- H.main().findByRole("link", { name: "Tool calls" }).click();- cy.wait("@dataset");- H.main().findByText(SEED_TOOL_NAME).should("be.visible");- });+ cy.log("The MCP analytics route is not registered without audit_app");+ cy.findByLabelText("error page").should("be.visible");+ cy.findByTestId("monitor-nav")+ .findByRole("link", { name: /Background tasks/ })+ .should("be.visible");+ cy.findByRole("heading", { name: "MCP analytics" }).should("not.exist");+ cy.findByRole("link", { name: "MCP analytics" }).should("not.exist");- it("surfaces a failed tool call's error type and message", () => {+ cy.log("With audit_app, the page shows the seeded tool calls");H.activateToken("pro-self-hosted");+ seedMcpToolCall();// error_message is gated PII — the backend only records/shows it when retention is on.H.updateSetting("analytics-pii-retention-enabled", true);seedMcpToolCall({@@ -74,9 +72,17 @@ describe("scenarios > monitor > ai auditing > mcp analytics", () => {error_code: SEED_ERROR_CODE,error_message: SEED_ERROR_MESSAGE,});+ H.updateSetting("analytics-pii-retention-enabled", false);visitMcpAnalyticsPage();+ cy.log("Nav item lives in the AI Auditing group");+ cy.findByRole("link", { name: "MCP analytics" }).should("be.visible");++ H.main()+ .findByRole("heading", { name: "MCP analytics" })+ .should("be.visible");+cy.log("The Usage tab surfaces an Errors section once there are failed calls",);@@ -85,24 +91,25 @@ describe("scenarios > monitor > ai auditing > mcp analytics", () => {.scrollIntoView().should("be.visible");- cy.log(- "The Tool calls table shows the derived error type and gated message",- );+ cy.log("The seeded tool calls show up in the Events table");+ interceptEventsQuery("toolCalls");H.main().findByRole("link", { name: "Tool calls" }).click();- cy.wait("@dataset");+ cy.wait("@toolCalls");H.main().within(() => {+ cy.findByText(SEED_TOOL_NAME).scrollIntoView().should("be.visible");cy.findByText(SEED_ERROR_TOOL).scrollIntoView().should("be.visible");cy.findByText(SEED_ERROR_TYPE).scrollIntoView().should("be.visible");- cy.findByText(SEED_ERROR_MESSAGE).scrollIntoView().should("be.visible");+ cy.findByText(SEED_ERROR_MESSAGE).should("not.exist");});- });- it("hides the nav item and the page without the audit-app feature", () => {- cy.visit(MCP_ANALYTICS_PATH);-- cy.log("The MCP analytics route is not registered without audit_app");- cy.findByLabelText("error page").should("be.visible");- cy.findByRole("heading", { name: "MCP analytics" }).should("not.exist");- cy.findByRole("link", { name: "MCP analytics" }).should("not.exist");+ cy.log("The error message shows once PII retention is on");+ H.updateSetting("analytics-pii-retention-enabled", true);+ interceptEventsQuery("toolCallsWithPii");+ cy.reload();+ cy.wait("@toolCallsWithPii");+ H.main().within(() => {+ cy.findByText(SEED_ERROR_TOOL).scrollIntoView().should("be.visible");+ cy.findByText(SEED_ERROR_MESSAGE).scrollIntoView().should("be.visible");+ });});});diff --git a/e2e/test/scenarios/monitor/ai-auditing/usage-auditing.cy.spec.ts b/e2e/test/scenarios/monitor/ai-auditing/usage-auditing.cy.spec.tsindex 43618139fa7..f96e245ef7d 100644--- a/e2e/test/scenarios/monitor/ai-auditing/usage-auditing.cy.spec.ts+++ b/e2e/test/scenarios/monitor/ai-auditing/usage-auditing.cy.spec.ts@@ -81,7 +81,7 @@ describe("scenarios > monitor > ai auditing > usage auditing", () => {seedUsageAuditingData();});- it("renders the usage stats charts from the audit views", () => {+ it("renders the usage stats charts and opens the seeded conversations", () => {visitUsageStatsPage();H.main().within(() => {@@ -94,9 +94,8 @@ describe("scenarios > monitor > ai auditing > usage auditing", () => {});CONVERSATION_CHART_TITLES.forEach(assertChartRendered);- });- it("lists the seeded conversations and opens their details", () => {+ cy.log("conversations list and details");visitConversationsPage();H.main()diff --git a/e2e/test/scenarios/monitor/tools/tools.cy.spec.ts b/e2e/test/scenarios/monitor/tools/tools.cy.spec.tsindex 806d8bdcc25..6d8d70b28cd 100644--- a/e2e/test/scenarios/monitor/tools/tools.cy.spec.ts+++ b/e2e/test/scenarios/monitor/tools/tools.cy.spec.ts@@ -113,7 +113,7 @@ describe("issue 14636", () => {stubPageResponses({ page: 1, alias: "second" });});- it("pagination should work (metabase#14636)", () => {+ it("pagination and filtering should work (metabase#14636)", () => {cy.visit("/monitor/tasks/list");cy.wait("@first");@@ -122,10 +122,9 @@ describe("issue 14636", () => {cy.findByRole("heading", { name: "Background tasks" }).should("be.visible");cy.findByLabelText("pagination").findByText("1 - 50").should("be.visible");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("field values scanning");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("513");+ cy.findByTestId("tasks-table")+ .should("contain.text", "field values scanning")+ .and("contain.text", "513");cy.findByLabelText("Previous page").should("be.disabled");cy.findByLabelText("Next page").should("not.be.disabled").click();@@ -137,15 +136,20 @@ describe("issue 14636", () => {.findByText(`51 - ${total}`).should("be.visible");cy.findByLabelText("pagination").findByText("1 - 50").should("not.exist");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("analyze");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("200");+ cy.findByTestId("tasks-table")+ .should("contain.text", "analyze")+ .and("contain.text", "200")+ .and("not.contain.text", "field values scanning");cy.findByLabelText("Next page").should("be.disabled");cy.findByLabelText("Previous page").should("not.be.disabled").click();cy.location("search").should("eq", "");+ cy.findByLabelText("pagination").findByText("1 - 50").should("be.visible");+ cy.findByTestId("tasks-table").should(+ "contain.text",+ "field values scanning",+ );cy.log("pagination should affect browser history");cy.go("back");@@ -155,20 +159,12 @@ describe("issue 14636", () => {cy.location("pathname").should("eq", "/monitor/tasks/list");cy.location("search").should("eq", "");- cy.log("it should respect page query param on page load");- cy.visit("/monitor/tasks/list?page=1");- cy.wait("@second");-- cy.findByLabelText("pagination")- .findByText(`51 - ${total}`)- .should("be.visible");- });-- it("filtering should work", () => {- const total = 57;+ cy.log("filtering");const task = "field values scanning";const filteredTask = createMockTask({ task });+ stubPageResponses({ page: 0, alias: "unfilteredFirst" });+ stubPageResponses({ page: 1, alias: "unfilteredSecond" });// Keep this test independent of background tasks created asynchronously by H.restore().// The task picker only shows a value that is in the unique task list.cy.intercept("GET", "/api/task/unique-tasks", [task]);@@ -232,10 +228,12 @@ describe("issue 14636", () => {.findByLabelText("Clear").click();cy.location("search").should("eq", "");- cy.wait("@first");+ cy.wait("@unfilteredFirst");cy.findByLabelText("pagination").findByText("1 - 50").should("be.visible");++ cy.log("it should respect page query param on page load");cy.visit("/monitor/tasks/list?page=1");- cy.wait("@second");+ cy.wait("@unfilteredSecond");cy.findByLabelText("pagination").findByText(`51 - ${total}`).should("be.visible");@@ -248,7 +246,7 @@ describe("issue 14636", () => {cy.log("should remove invalid query params");cy.visit("/monitor/tasks/list?status=foobar");- cy.wait("@first");+ cy.wait("@unfilteredFirst");cy.location("search").should("eq", "");getFilterByStatus().should("have.value", "");});@@ -261,6 +259,7 @@ describe("scenarios > monitor > tools > tasks", () => {information: true,},},+ logs: [],});const formattedTaskJson = JSON.stringify(task.task_details, null, 2);@@ -283,7 +282,7 @@ describe("scenarios > monitor > tools > tasks", () => {}).as("getTask");});- it("shows task details page", () => {+ it("shows task details page with and without logs", () => {cy.visit("/monitor/tasks/list");cy.wait("@getTasks");@@ -299,6 +298,12 @@ describe("scenarios > monitor > tools > tasks", () => {cy.get("@lines").eq(3).should("have.text", " }");cy.get("@lines").eq(4).should("have.text", "}");+ cy.log("empty logs");+ cy.findByTestId("monitor-main")+ .findByText("There are no captured logs")+ .should("be.visible");+ cy.findByTestId("task-logs").should("not.exist");+cy.log("copy button");cy.window().then((window) => {cy.stub(window.navigator.clipboard, "writeText").resolves();@@ -316,9 +321,8 @@ describe("scenarios > monitor > tools > tasks", () => {// Ideally, we would compare raw strings here, but Cypress automatically parses JSON filestask.task_details,);- });- it("should render logs when they are present", () => {+ cy.log("logs");const taskWithLogs = {...task,logs: [@@ -345,7 +349,7 @@ describe("scenarios > monitor > tools > tasks", () => {body: taskWithLogs,}).as("getTaskWithLogs");- cy.visit(`/monitor/tasks/list/${task.id}`);+ cy.reload();cy.wait("@getTaskWithLogs");cy.findByTestId("task-logs").scrollIntoView().should("be.visible");@@ -353,25 +357,9 @@ describe("scenarios > monitor > tools > tasks", () => {cy.findByText(new RegExp(taskWithLogs.logs[0].msg)).should("be.visible");cy.findByText(new RegExp(taskWithLogs.logs[1].msg)).should("be.visible");});- });-- it("should show empty state when no logs are present", () => {- const taskWithoutLogs = {- ...task,- logs: [],- };-- cy.intercept("GET", `/api/task/${task.id}`, {- body: taskWithoutLogs,- }).as("getTaskWithoutLogs");-- cy.visit(`/monitor/tasks/list/${task.id}`);- cy.wait("@getTaskWithoutLogs");-- cy.findByTestId("task-logs").should("not.exist");cy.findByTestId("monitor-main").findByText("There are no captured logs")- .should("be.visible");+ .should("not.exist");});});@@ -403,7 +391,7 @@ describe("scenarios > monitor > tools > logs", () => {cy.wait("@getLogs");});- it("should allow to download logs", () => {+ it("should allow to download all logs and filtered logs", () => {cy.button(/Download/).click();cy.readFile("cypress/downloads/logs.txt").should("equal",@@ -412,9 +400,8 @@ describe("scenarios > monitor > tools > logs", () => {`[9da436dc-d79c-42f9-89e3-322c22cd0cd3] ${formatTimestamp(log2.timestamp)} ERROR metabase.server.middleware.log message`,].join("\n"),);- });- it("should allow to download filtered logs", () => {+ cy.deleteDownloadsFolder();cy.findByPlaceholderText("Filter logs").type("error");cy.button(/Download/).click();cy.readFile("cypress/downloads/logs.txt").should(@@ -432,7 +419,7 @@ describe("scenarios > monitor > tools > logs", () => {}});-describe("monitor > tools > erroring questions ", () => {+describe("monitor > tools > erroring questions", () => {const TOOLS_ERRORS_URL = "/monitor/errors";// The filter is required but doesn't have a default value setconst brokenQuestionDetails = {@@ -467,11 +454,13 @@ describe("monitor > tools > erroring questions ", () => {cy.icon("variable").click();cy.findByPlaceholderText("Enter a default value…").type("Foo");+ cy.intercept("PUT", "/api/card/*").as("updateCard");cy.findByText("Save").click();H.modal().within(() => {cy.button("Save").click();});+ cy.wait("@updateCard");}function selectQuestion(name: string) {@@ -482,155 +471,165 @@ describe("monitor > tools > erroring questions ", () => {});}- describe("when feature enabled", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- H.activateToken("pro-self-hosted");+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ H.activateToken("pro-self-hosted");- cy.intercept("POST", "/api/dataset").as("dataset");- });+ cy.intercept("POST", "/api/dataset").as("dataset");- describe("without broken questions", () => {- it("should render the Monitor nav and navigate to Erroring questions by clicking on it", () => {- cy.visit("/monitor");-- cy.findByTestId("monitor-nav")- .findByRole("link", { name: /Erroring questions/ })- .click();- cy.location("pathname").should("eq", TOOLS_ERRORS_URL);-- cy.log("test no results state");-- cy.findByTestId("erroring-questions-table")- .findByText("No results")- .should("be.visible");- // nothing selected -> the bulk action bar (and its button) is hidden- cy.button("Rerun selected").should("not.exist");- cy.findByPlaceholderText(- "Search by question, error, database, or collection",- ).should("be.enabled");- });+ // Unjustified type cast. FIXME+ H.createNativeQuestion(brokenQuestionDetails as NativeQuestionDetails, {+ loadMetadata: true,});- describe("with the existing broken questions", () => {- beforeEach(() => {- // Unjustified type cast. FIXME- H.createNativeQuestion(brokenQuestionDetails as NativeQuestionDetails, {- loadMetadata: true,- });-- cy.visit(TOOLS_ERRORS_URL);- });-- it("should render correctly", () => {- cy.wait("@dataset");-- selectQuestion(brokenQuestionDetails.name);+ cy.visit(TOOLS_ERRORS_URL);+ });- cy.button("Rerun selected").should("not.be.disabled").click();+ it("should rerun, search and clear a broken question", () => {+ cy.wait("@dataset");- cy.wait("@dataset");+ cy.findByRole("heading", { name: "Erroring questions" }).should(+ "be.visible",+ );+ cy.findByTestId("erroring-questions-table")+ .findByText(brokenQuestionDetails.name)+ .should("be.visible");+ // nothing selected -> the bulk action bar (and its button) is hidden+ cy.button("Rerun selected").should("not.exist");+ selectQuestion(brokenQuestionDetails.name);++ cy.intercept("POST", "/api/dataset").as("rerunRefetch");+ cy.button("Rerun selected").should("not.be.disabled").click();++ cy.wait("@rerunRefetch");+ cy.findByTestId("erroring-questions-table").should(+ "have.attr",+ "aria-busy",+ "false",+ );- // The question is still there because we didn't fix it- cy.findByTestId("erroring-questions-table").findByText(- brokenQuestionDetails.name,- );- // rerunning clears the selection, so the bulk action bar closes- cy.button("Rerun selected").should("not.exist");+ // The question is still there because we didn't fix it+ cy.findByTestId("erroring-questions-table")+ .findByText(brokenQuestionDetails.name)+ .should("be.visible");+ // rerunning clears the selection, so the bulk action bar closes+ cy.button("Rerun selected").should("not.exist");- cy.findByPlaceholderText(- "Search by question, error, database, or collection",- )- .should("be.enabled")- .type("foo");+ cy.intercept("POST", "/api/dataset").as("searchRefetch");+ cy.findByPlaceholderText(+ "Search by question, error, database, or collection",+ )+ .should("be.enabled")+ .type("foo");- cy.wait("@dataset");+ cy.wait("@searchRefetch");- cy.findByTestId("erroring-questions-table")- .findByText("No results")- .should("be.visible");+ cy.findByTestId("erroring-questions-table")+ .findByText("No results")+ .should("be.visible");- cy.findByPlaceholderText(- "Search by question, error, database, or collection",- ).clear();+ cy.findByPlaceholderText(+ "Search by question, error, database, or collection",+ ).clear();- fixQuestion(brokenQuestionDetails.name);+ fixQuestion(brokenQuestionDetails.name);- cy.visit(TOOLS_ERRORS_URL);+ cy.visit(TOOLS_ERRORS_URL);- selectQuestion(brokenQuestionDetails.name);+ selectQuestion(brokenQuestionDetails.name);- cy.button("Rerun selected").should("not.be.disabled").click();+ cy.intercept("POST", "/api/dataset").as("fixedRerunRefetch");+ cy.button("Rerun selected").should("not.be.disabled").click();- cy.wait("@dataset");+ cy.wait("@fixedRerunRefetch");- cy.findByTestId("erroring-questions-table")- .findByText("No results")- .should("be.visible");- });- });+ cy.findByTestId("erroring-questions-table")+ .findByText("No results")+ .should("be.visible");});});describe("monitor > tools", () => {+ const TOOLS_ERRORS_URL = "/monitor/errors";+beforeEach(() => {H.restore();cy.signInAsAdmin();H.activateToken("pro-self-hosted");});- it("should show either the erroring questions or the upsell (based on the `audit_app` feature flag)", () => {+ it("should navigate the Monitor tools and show the upsell without the `audit_app` feature flag", () => {cy.log("Enable model persistence in order to have multiple tabs/routes in tools",);cy.request("POST", "/api/persist/enable");- cy.visit("/monitor/errors");+ cy.visit("/monitor");+ cy.location("pathname").should(+ "match",+ /^\/monitor\/dependency-diagnostics/,+ );++ cy.findByTestId("monitor-nav")+ .findByRole("link", { name: /Erroring questions/ })+ .click();+ cy.location("pathname").should("eq", TOOLS_ERRORS_URL);cy.findByRole("heading", {name: "Erroring questions",}).should("be.visible");+ cy.log("test no results state");+ cy.findByTestId("erroring-questions-table")+ .findByText("No results")+ .should("be.visible");+ cy.findByPlaceholderText(+ "Search by question, error, database, or collection",+ ).should("be.enabled");+cy.log("We should be able to switch to the model persistence log page");cy.findByTestId("monitor-nav").findByText("Model persistence log").click();cy.location("pathname").should("eq", "/monitor/model-persistence-log");+ cy.findByTestId("monitor-main")+ .findByRole("heading", { name: "Model persistence log" })+ .should("be.visible");cy.log(- "Once the audit_app feature flag is gone, tools should display an upsell",+ "Back to Tasks should go to the tasks list even with no browser history (metabase#57113)",);- H.deleteToken();- cy.visit("/monitor/errors");+ cy.visit("/monitor/tasks/list");- cy.findByRole("heading", {- name: "Troubleshoot faster",- }).should("be.visible");- cy.findByRole("link", { name: "Upgrade to Pro" });- });+ cy.log("Pick an existing task url");- describe("issue 57113", () => {- it("should navigate to /monitor/tasks/list when clicking Back to Tasks even with no browser history", () => {- cy.visit("/monitor/tasks/list");+ cy.findAllByTestId("task").should("be.visible").first().click();- cy.log("Pick an existing task url");+ cy.location("pathname")+ .should("match", /\/monitor\/tasks\/list\/[0-9]+$/)+ .then((pathname) => {+ // Clear all history and navigate to the task detail page+ cy.window().then((window) => {+ window.history.replaceState(null, "", pathname);+ // Clear the entire history stack by going to about:blank first+ window.location.href = "about:blank";+ });- cy.findAllByTestId("task").should("be.visible").first().click();+ cy.visit(pathname);+ cy.findByText("Back to Tasks").click();+ cy.location("pathname").should("eq", "/monitor/tasks/list");+ });- cy.location("pathname")- .should("match", /\/monitor\/tasks\/list\/[0-9]+$/)- .then((pathname) => {- // Clear all history and navigate to the task detail page- cy.window().then((window) => {- window.history.replaceState(null, "", pathname);- // Clear the entire history stack by going to about:blank first- window.location.href = "about:blank";- });+ cy.log(+ "Once the audit_app feature flag is gone, tools should display an upsell",+ );+ H.deleteToken();+ cy.visit(TOOLS_ERRORS_URL);- cy.visit(pathname);- cy.findByText("Back to Tasks").click();- cy.location("pathname").should("eq", "/monitor/tasks/list");- });- });+ cy.findByRole("heading", {+ name: "Troubleshoot faster",+ }).should("be.visible");+ cy.findByTestId("erroring-questions-table").should("not.exist");+ cy.findByRole("link", { name: "Upgrade to Pro" }).should("be.visible");});});@@ -711,26 +710,20 @@ describe("scenarios > monitor > tools > task runs", () => {}).as("getTaskRun");});- it("should switch between Tasks and Runs tabs", () => {+ it("should switch tabs, open task run details and follow their links", () => {cy.visit("/monitor/tasks/list");- cy.findByTestId("tasks-table").should("be.visible");+ cy.findByTestId("tasks-table")+ .findAllByTestId("task")+ .should("have.length.at.least", 1);cy.findByRole("link", { name: "Runs" }).click();cy.location("pathname").should("eq", "/monitor/tasks/runs");- cy.findByTestId("task-runs-table").should("be.visible");-- cy.findByRole("link", { name: "Tasks" }).click();- cy.location("pathname").should("eq", "/monitor/tasks/list");- cy.findByTestId("tasks-table").should("be.visible");- });-- it("should navigate to task run details and show associated tasks", () => {- cy.visit("/monitor/tasks/runs");cy.wait("@getTaskRuns");cy.findByTestId("task-runs-table").findAllByTestId("task-run")+ .should("have.length.at.least", 1).first().click();cy.wait("@getTaskRun");@@ -739,43 +732,54 @@ describe("scenarios > monitor > tools > task runs", () => {cy.findByTestId("monitor-main").within(() => {cy.findByText("Run type").should("be.visible");+ cy.findByText("Sync").should("be.visible");cy.findByText("Entity").should("be.visible");cy.findByText("Sample Database").should("be.visible");});cy.findByTestId("task-run-tasks-table").should("be.visible");cy.findAllByTestId("task-run-task").should("have.length", 3);- });-- it("should navigate back to runs list from run details", () => {- cy.visit(`/monitor/tasks/runs/${taskRun.id}`);- cy.wait("@getTaskRun");- cy.findByRole("link", { name: /Back to Runs/i }).click();- cy.location("pathname").should("eq", "/monitor/tasks/runs");- });+ cy.log("associated task row opens the task details");+ cy.findByTestId("task-run-tasks-table")+ .findAllByTestId("task-run-task")+ .first()+ .click();+ cy.location("pathname").should(+ "eq",+ `/monitor/tasks/list/${taskRunExtended.tasks[0].id}`,+ );- it("should have clickable entity link in task run details", () => {- cy.visit(`/monitor/tasks/runs/${taskRun.id}`);- cy.wait("@getTaskRun");+ cy.go("back");+ cy.location("pathname").should("eq", `/monitor/tasks/runs/${taskRun.id}`);+ cy.log("entity link opens the database");cy.findByRole("link", { name: /Sample Database/i }).click();cy.location("pathname").should("eq", "/admin/databases/1");- });- it("should navigate to task details from task run details", () => {- cy.visit(`/monitor/tasks/runs/${taskRun.id}`);- cy.wait("@getTaskRun");+ cy.go("back");+ cy.location("pathname").should("eq", `/monitor/tasks/runs/${taskRun.id}`);+ cy.log("cold load of the run details page fetches the run");+ cy.reload();+ cy.wait("@getTaskRun");+ cy.findByTestId("monitor-main")+ .findByText("Sample Database")+ .should("be.visible");cy.findByTestId("task-run-tasks-table").findAllByTestId("task-run-task")- .first()- .click();+ .should("have.length", 3);- cy.location("pathname").should(- "eq",- `/monitor/tasks/list/${taskRunExtended.tasks[0].id}`,- );+ cy.log("Back to Runs opens the runs list");+ cy.findByRole("link", { name: /Back to Runs/i }).click();+ cy.location("pathname").should("eq", "/monitor/tasks/runs");++ cy.log("Tasks tab opens the tasks list");+ cy.findByRole("link", { name: "Tasks" }).click();+ cy.location("pathname").should("eq", "/monitor/tasks/list");+ cy.findByTestId("tasks-table")+ .findAllByTestId("task")+ .should("have.length.at.least", 1);});});@@ -862,6 +866,8 @@ describe("scenarios > monitor > tools > task runs pagination", () => {cy.findByLabelText("Previous page").should("not.be.disabled").click();cy.location("search").should("eq", "");+ cy.findByLabelText("pagination").findByText("1 - 50").should("be.visible");+ cy.findByTestId("task-runs-table").should("contain.text", "Sync");});});@@ -870,7 +876,7 @@ describe("scenarios > monitor > tools > task runs filtering", () => {H.restore();cy.signInAsAdmin();- cy.intercept("GET", "/api/task/runs?*", (request) => {+ cy.intercept({ method: "GET", pathname: "/api/task/runs" }, (request) => {request.reply((response) => {response.body = {data: [],@@ -880,61 +886,9 @@ describe("scenarios > monitor > tools > task runs filtering", () => {};});}).as("getTaskRuns");-- cy.intercept("GET", "/api/task/runs/entities?*", (request) => {- request.reply((response) => {- response.body = [- {- entity_type: "database",- entity_id: 1,- entity_name: "Sample Database",- },- {- entity_type: "database",- entity_id: 2,- entity_name: "Test Database",- },- ];- });- }).as("getEntities");- });-- it("filtering should work for task runs", () => {- cy.visit("/monitor/tasks/runs");- cy.wait("@getTaskRuns");-- cy.log("Filter by run type");- getFilterByRun().click();- H.popover().findByText("Sync").click();- cy.location("search").should("contain", "run-type=sync");- cy.wait("@getTaskRuns");- cy.log("Filter by started at");- selectStartedAt("Previous 30 days");- cy.location("search").should("contain", "started-at=past30days");- cy.wait("@getTaskRuns");-- cy.wait("@getEntities");- cy.log("Filter by entity");- getFilterByEntity().click();- H.popover().findByText("Sample Database").click();- cy.location("search").should("contain", "entity-type=database");- cy.location("search").should("contain", "entity-id=1");- cy.wait("@getTaskRuns");-- cy.log("Filter by status");- getFilterByStatus().click();- H.popover().findByText("Success").click();- cy.location("search").should("contain", "status=success");- cy.wait("@getTaskRuns");-- cy.log("Clear all filters");- getFilterByRun().parent().findByLabelText("Clear").click();- getFilterByStartedAt().parent().findByLabelText("Clear").click();- getFilterByStatus().parent().findByLabelText("Clear").click();- cy.location("search").should("eq", "");});- it("entity picker should be disabled/enabled based on run type, started at and entities availability", () => {+ it("filtering and the entity picker should work for task runs", () => {cy.visit("/monitor/tasks/runs");cy.wait("@getTaskRuns");cy.intercept("GET", "/api/task/runs/entities?*", {@@ -952,8 +906,13 @@ describe("scenarios > monitor > tools > task runs filtering", () => {getFilterByEntity().should("be.disabled");assertFilterByEntityTooltipText("Select a run type first");+ cy.log("Filter by run type");getFilterByRun().click();H.popover().findByText("Sync").click();+ cy.location("search").should("contain", "run-type=sync");+ cy.wait("@getTaskRuns")+ .its("request.url")+ .should("contain", "run-type=sync");cy.log("Should be still disabled until started at is selected");getFilterByEntity().should("be.disabled");@@ -961,6 +920,7 @@ describe("scenarios > monitor > tools > task runs filtering", () => {cy.log("Should show tooltip 'Select a start time' when hovering");assertFilterByEntityTooltipText("Select a start time first");+ cy.log("Filter by started at");selectStartedAt("Previous 30 days");cy.log("Should show loader while loading entities");@@ -970,20 +930,46 @@ describe("scenarios > monitor > tools > task runs filtering", () => {.find(".mb-mantine-Loader-root").should("exist");+ cy.location("search").should("contain", "started-at=past30days");+ cy.wait("@getTaskRuns")+ .its("request.url")+ .should("contain", "started-at=past30days");cy.wait("@getEntitiesDelayed");- cy.log("Should be enabled after entities are loaded");- getFilterByEntity().should("not.be.disabled");+ cy.log("Filter by entity, enabled after entities are loaded");+ getFilterByEntity().should("not.be.disabled").click();+ H.popover().findByText("Sample Database").click();+ getFilterByEntity().should("have.value", "Sample Database");+ cy.location("search").should("contain", "entity-type=database");+ cy.location("search").should("contain", "entity-id=1");+ cy.wait("@getTaskRuns")+ .its("request.url")+ .should("contain", "entity-type=database")+ .and("contain", "entity-id=1");++ cy.log("Filter by status");+ getFilterByStatus().click();+ H.popover().findByText("Success").click();+ cy.location("search").should("contain", "status=success");+ cy.wait("@getTaskRuns")+ .its("request.url")+ .should("contain", "status=success");cy.log("Should clear and disable entity filter when run type is cleared");getFilterByRun().parent().findByLabelText("Clear").click();getFilterByEntity().should("be.disabled");getFilterByEntity().should("have.value", "");+ cy.location("search")+ .should("not.contain", "run-type")+ .and("not.contain", "entity-id");cy.log("Should clear and disable entity filter when started at is cleared");getFilterByRun().click();H.popover().findByText("Sync").click();+ getFilterByEntity().should("not.be.disabled").click();+ H.popover().findByText("Sample Database").click();+ getFilterByEntity().should("have.value", "Sample Database");getFilterByStartedAt().parent().findByLabelText("Clear").click();getFilterByEntity().should("be.disabled");@@ -1001,6 +987,12 @@ describe("scenarios > monitor > tools > task runs filtering", () => {getFilterByEntity().should("be.disabled");assertFilterByEntityTooltipText("No entities available");++ cy.log("Clear all filters");+ getFilterByRun().parent().findByLabelText("Clear").click();+ getFilterByStartedAt().parent().findByLabelText("Clear").click();+ getFilterByStatus().parent().findByLabelText("Clear").click();+ cy.location("search").should("eq", "");});});