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
Command palette e2e spec simplification (#82905)
Nemanja Glumac0bdad48e91b1
diff --git a/e2e/support/helpers/e2e-command-palette-helpers.js b/e2e/support/helpers/e2e-command-palette-helpers.jsindex f54a859b518..aae08a4e696 100644--- a/e2e/support/helpers/e2e-command-palette-helpers.js+++ b/e2e/support/helpers/e2e-command-palette-helpers.js@@ -3,8 +3,6 @@ export const shortcutModal = () =>cy.findByRole("dialog", { name: "Shortcuts" });export const openCommandPalette = () => cy.get("body").type("{ctrl+k}{cmd+k}");-export const openShortcutModal = () => cy.get("body").type("{shift+?}");-export const commandPaletteButton = () =>cy.findByTestId("app-bar")diff --git a/e2e/test/scenarios/onboarding/command-palette.cy.spec.js b/e2e/test/scenarios/onboarding/command-palette.cy.spec.jsindex 6812da2d663..8d03460e7d6 100644--- a/e2e/test/scenarios/onboarding/command-palette.cy.spec.js+++ b/e2e/test/scenarios/onboarding/command-palette.cy.spec.js@@ -1,5 +1,5 @@const { H } = cy;-import { SAMPLE_DB_ID, USERS } from "e2e/support/cypress_data";+import { SAMPLE_DB_ID, USERS, USER_GROUPS } from "e2e/support/cypress_data";import {ADMIN_PERSONAL_COLLECTION_ID,ORDERS_BY_YEAR_QUESTION_ID,@@ -13,6 +13,7 @@ import {} from "metabase-types/api/mocks";const { admin } = USERS;+const { ALL_USERS_GROUP } = USER_GROUPS;const TAB_1 = {id: 1,@@ -67,6 +68,14 @@ describe("command palette", () => {description: "The best question",});+ // Create a document so that it appears in the recents list. It goes first so+ // the dashboard below stays the most recent, and therefore selected, entry.+ cy.request(+ "POST",+ "/api/document",+ createMockDocument({ collection_id: ADMIN_PERSONAL_COLLECTION_ID }),+ );+//Request to have an item in the recents listcy.request(`/api/dashboard/${ORDERS_DASHBOARD_ID}`);@@ -79,21 +88,20 @@ describe("command palette", () => {"aria-selected","true",);++ // UXW-1786+ cy.findByRole("option", { name: "Test Document" }).should(+ "contain.text",+ "Bobby Tables's Personal Collection",+ );+H.closeCommandPalette();H.commandPalette().should("not.exist");cy.log("open the command palette with keybinding");H.openCommandPalette();H.commandPalette().within(() => {- H.commandPaletteInput().should("exist");-- cy.log("does not show actions if there is no search query");- cy.findByText("New question").should("not.exist");- cy.findByText("New SQL query").should("not.exist");- cy.findByText("New dashboard").should("not.exist");- cy.findByText("New collection").should("not.exist");- cy.findByText("New model").should("not.exist");- cy.findByText("New metric").should("not.exist");+ H.commandPaletteInput().should("be.visible");cy.log("Should show recent items");cy.findByRole("option", { name: "Orders in a dashboard" }).should(@@ -115,35 +123,43 @@ describe("command palette", () => {// Since the command palette list is virtualized, we will search for a few// to ensure they're reachableH.commandPaletteInput().clear().type("People");- cy.findByRole("option", { name: "People" }).should("exist");+ cy.findByRole("option", { name: "People" }).should("be.visible");H.commandPaletteInput().clear().type("Uploads");- cy.findByRole("option", { name: "Settings - Uploads" }).should("exist");-- // When entering a query, if there are results that come before search results, highlight- // the first action, otherwise, highlight the first search result- H.commandPaletteInput().clear().type("Form");- cy.findByRole("option", { name: "Performance" }).should(- "have.attr",- "aria-selected",- "true",+ cy.findByRole("option", { name: "Settings - Uploads" }).should(+ "be.visible",);- cy.findByRole("option", { name: /View and filter/ }).should("exist");// Check that we are not filtering search results by action nameH.commandPaletteInput().clear().type("Company");- cy.findByRole("option", { name: /View and filter/ }).should("exist");+ cy.findByRole("option", { name: /View and filter/ }).should("be.visible");cy.findByRole("option", { name: "Products" }).should("have.attr","aria-selected","true",);- cy.findByRole("option", { name: "People" }).should("exist");- cy.findByRole("option", { name: "Reviews" }).should("exist");- H.commandPaletteInput().clear();+ cy.findByRole("option", { name: "People" }).should("be.visible");+ cy.findByRole("option", { name: "Reviews" }).should("be.visible");++ cy.log("search results render in the order the API returned them");+ // Registered here, not at the top of the test: the alias yields the last+ // matching request, and the searches above would shadow this one.+ cy.intercept("/api/search?*").as("searchData");+ H.commandPaletteInput().clear().type("Cou");+ cy.wait("@searchData");+ cy.findByText("Loading...").should("not.exist");- H.commandPaletteInput().clear().type("New met");- cy.findByText("New metric").should("exist");+ cy.get("@searchData").then(({ response }) => {+ const results = response.body.data;++ cy.findAllByRole("option")+ // filter out unrelated items, keep only options with data+ .invoke("slice", 3, -2)+ .should("have.length", results.length)+ .each(($option, index) => {+ cy.wrap($option).should("contain", results[index].name);+ });+ });});cy.log("We can close the command palette using escape");@@ -162,8 +178,7 @@ describe("command palette", () => {.should("not.exist");H.commandPalette().findByText("No results for “New”").should("be.visible");- // Every "New …" action matches "New" equally, so the default order applies- // and "New question" is first and selected by default.+ cy.log("the virtualized list is navigable by keyboard");H.commandPalette().findByRole("option", { name: "New question" }).should("have.attr", "aria-selected", "true");@@ -200,172 +215,69 @@ describe("command palette", () => {.should("have.attr", "aria-selected", "true");});- it("should display search results in the order returned by the API", () => {- cy.visit("/");+ it("should render admin links for non-admins that have specific privileges", () => {+ cy.log("setup permissions");- cy.findByRole("button", { name: /search/i }).click();- cy.intercept("/api/search?*").as("searchData");-- H.commandPalette().within(() => {- H.commandPaletteInput().type("Cou");- cy.wait("@searchData");- cy.findByText("Loading...").should("not.exist");-- cy.get("@searchData").then(({ response }) => {- const results = response.body.data;+ H.activateToken("pro-self-hosted");- cy.findAllByRole("option")- // filter out unrelated items, keep only options with data- .invoke("slice", 3, -2)- .should("have.length", results.length)- .each(($option, index) => {- cy.wrap($option).should("contain", results[index].name);- });- });+ H.updateAdvancedPermissionsGraph({+ [ALL_USERS_GROUP]: { setting: "yes", monitoring: "yes" },});- });- // Making this a separate test for now because it requires the bleeding edge token, which- // Enables a bunch of other stuff and messes up the "Renders a searchable command palette"- // test. In the future, this can be integrated into the test above, or moved to a BE test- it("should display collection names for documents in recents", () => {- //Create a document so that it appears in the recents list- cy.request(- "POST",- "/api/document",- createMockDocument({ collection_id: ADMIN_PERSONAL_COLLECTION_ID }),- );-- cy.visit("/");-- cy.findByRole("button", { name: /search/i }).click();- H.commandPalette().should("be.visible");-- // UXW-1786- cy.findByRole("option", { name: "Test Document" }).should(- "contain.text",- "Bobby Tables's Personal Collection",+ cy.request("GET", "/api/permissions/graph").then(+ ({ body: { groups, revision } }) => {+ cy.request("PUT", "/api/permissions/graph", {+ revision,+ groups: {+ ...groups,+ [ALL_USERS_GROUP]: {+ ...groups[ALL_USERS_GROUP],+ [SAMPLE_DB_ID]: {+ ...groups[ALL_USERS_GROUP]?.[SAMPLE_DB_ID],+ // "Manage table metadata" and "Manage database"+ "data-model": { schemas: "all" },+ details: "yes",+ },+ },+ },+ });+ },);- });-- describe("admin settings links", () => {- it("should render links to all admin settings pages for admins", () => {- cy.visit("/");- cy.findByTestId("home-page")- .findByText(/see what metabase can do/i)- .should("exist");-- H.openCommandPalette();- H.commandPalette().within(() => {- H.commandPaletteInput().type("Settings -");- cy.log("check admin sees all settings links");- H.commandPaletteAction("Settings - General").should("be.visible");- H.commandPaletteAction("Settings - Email").should("be.visible");- H.commandPaletteInput().clear();-- cy.log("should see admin links");- H.commandPaletteInput().type("Performance");- H.commandPaletteAction("Performance").should("be.visible");- });- });-- it("should not render any links to settings or admin pages for non-admins without privledged access", () => {- cy.signInAsNormalUser();- cy.visit("/");- cy.findByTestId("home-page")- .findByText(/see what metabase can do/i)- .should("exist");-- H.openCommandPalette();- H.commandPalette().within(() => {- cy.log("check normal user does not see any setting links");- H.commandPaletteInput().type("Settings -");- H.commandPaletteAction("Settings - Setup").should("not.exist");- H.commandPaletteAction("Settings - General").should("not.exist");- H.commandPaletteInput().clear();-- cy.log("should not see admin links");- H.commandPaletteInput().type("Performance");- H.commandPaletteAction("Performance").should("not.exist");- H.commandPaletteInput().clear();-- // Monitor tools live outside the Admin command-palette links- H.commandPaletteInput().clear().type("tool");- H.commandPaletteAction("Tools").should("not.exist");- H.commandPaletteInput().clear();-- //Database and table metadata-- H.commandPaletteInput().type("data");- H.commandPaletteAction("Databases").should("not.exist");- H.commandPaletteInput().clear().type("tabl");- H.commandPaletteAction("Table Metadata").should("not.exist");- });- });-- describe("with advanced permissions", () => {- it("should render links for non-admins that have specific privileges", () => {- // setup- cy.log("setup permissions");- H.activateToken("pro-self-hosted");- cy.visit("/admin/permissions/application");-- const SETTINGS_INDEX = 0;- const MONITORING_INDEX = 1;- H.modifyPermission("All Users", SETTINGS_INDEX, "Yes");- H.modifyPermission("All Users", MONITORING_INDEX, "Yes");-- H.saveChangesToPermissions();-- cy.findByRole("tab", { name: "Data" }).click();- cy.findByRole("menuitem", { name: "All Users" }).click();-- const TABLE_METADATA_INDEX = 3;- const DATABASE_INDEX = 4;-- H.modifyPermission("Sample Database", TABLE_METADATA_INDEX, "Yes");- H.modifyPermission("Sample Database", DATABASE_INDEX, "Yes");-- H.saveChangesToPermissions();-- cy.signInAsNormalUser();+ cy.signInAsNormalUser();- // test- cy.visit("/");- cy.findByTestId("home-page")- .findByText(/see what metabase can do/i)- .should("exist");+ cy.visit("/");+ cy.findByTestId("home-page")+ .findByText(/see what metabase can do/i)+ .should("exist");- H.openCommandPalette();- H.commandPalette().within(() => {- // Settings Pages- H.commandPaletteInput().type("Settings -");- cy.log(- "check user with settings permissions see non-admin restricted settings links",- );- H.commandPaletteAction("Settings - Setup").should("not.exist");- H.commandPaletteAction("Settings - General").should("exist");- H.commandPaletteInput().clear();+ H.openCommandPalette();+ H.commandPalette().within(() => {+ // Settings Pages+ H.commandPaletteInput().type("Settings -");+ cy.log(+ "check user with settings permissions see non-admin restricted settings links",+ );+ H.commandPaletteAction("Settings - General").should("be.visible");+ H.commandPaletteAction("Settings - Setup").should("not.exist");+ H.commandPaletteInput().clear();- // Monitor tools live outside the Admin command-palette links- H.commandPaletteInput().clear().type("tool");- H.commandPaletteAction("Tools").should("not.exist");- H.commandPaletteInput().clear();+ // Monitor tools live outside the Admin command-palette links+ H.commandPaletteInput().clear().type("tool");+ H.commandPaletteAction("Tools").should("not.exist");+ H.commandPaletteInput().clear();- //Database and table metadata+ //Database and table metadata- H.commandPaletteInput().type("data");- H.commandPaletteAction("Databases").should("exist");- H.commandPaletteInput().clear().type("tabl");- H.commandPaletteAction("Table Metadata").should("exist");- H.commandPaletteInput().clear();+ H.commandPaletteInput().type("data");+ H.commandPaletteAction("Databases").should("be.visible");+ H.commandPaletteInput().clear().type("tabl");+ H.commandPaletteAction("Table Metadata").should("be.visible");+ H.commandPaletteInput().clear();- cy.log("should not see other admin links");- H.commandPaletteInput().type("Performance");- H.commandPaletteAction("Performance").should("not.exist");- });- });+ cy.log("should not see other admin links");+ H.commandPaletteInput().type("Performance");+ H.commandPaletteAction("Performance").should("not.exist");});});@@ -378,7 +290,7 @@ describe("command palette", () => {},});- cy.findByPlaceholderText("Search…").click();+ cy.findByPlaceholderText("Search…").should("be.visible").click();cy.findByRole("button", { name: / \+ K/ }).should("not.exist");cy.get("body").type("{esc}");@@ -405,245 +317,125 @@ describe("command palette", () => {cy.findByLabelText(/Email address/).type(admin.email);cy.findByLabelText("Password").type(admin.password);cy.button("Sign in").click();- cy.findByTestId("greeting-message");+ cy.findByTestId("greeting-message").should("be.visible");+ // The palette stays disabled until its own effect sees the logged-in user,+ // and the greeting renders independently of the app bar, so wait for the+ // shell that hosts the palette before reaching for the keybinding.+ H.commandPaletteButton().should("be.visible");H.openCommandPalette();- H.commandPalette().should("exist");- });-- it("The Search button should resize when on mobile", () => {- cy.viewport("iphone-x");- cy.visit("/");- H.commandPaletteButton().should("not.contain.text", "search");- });-- it("Should have a new metric item", () => {- cy.visit("/");- cy.findByRole("button", { name: /search/i }).click();-- H.commandPalette().within(() => {- H.commandPaletteInput().should("exist").type("Me");- cy.findByText("New metric").should("be.visible").click();-- cy.location("pathname").should("eq", "/metric/new");- });- });-- it("should show the 'Download diagnostics' command palette item", () => {- cy.visit("/");- cy.findByRole("button", { name: /search/i }).click();-- H.commandPalette().within(() => {- H.commandPaletteInput().should("exist").type("Issue");- cy.findByText("Download diagnostics").should("be.visible");- });- });-- it("should allow searching personal collections if no results and user is admin", () => {- cy.visit("/");- cy.findByRole("button", { name: /search/i }).click();- cy.realType("asdf");- H.commandPalette()- .get("#search-results-metadata")- .should("contain", "Search everything");- });-- it("should show the 'New embed' command palette item", () => {- cy.visit("/");- cy.findByRole("button", { name: /search/i }).click();-- H.commandPalette().within(() => {- H.commandPaletteInput().should("exist").type("new embed");- cy.findByText("New embed").should("be.visible");- });- });-- describe("ee", () => {- beforeEach(() => {- H.activateToken("pro-self-hosted");- });-- it("should have a 'New document' item", () => {- cy.visit("/");- cy.findByRole("button", { name: /search/i }).click();- H.commandPalette().within(() => {- H.commandPaletteInput().should("be.visible").type("new document");- cy.findByText("New document").should("be.visible").click();- cy.location("pathname").should("eq", "/document/new");- });- });+ H.commandPalette().should("be.visible");});});-describe("shortcuts", { tags: ["@actions"] }, () => {+describe("shortcuts", () => {beforeEach(() => {- H.resetSnowplow();H.restore();cy.signInAsAdmin();- H.enableTracking();});- it("should render a shortcuts modal, and global shortcuts should be available", () => {- H.setActionsEnabledForDB(SAMPLE_DB_ID);+ it("should navigate to seeded destinations and report to snowplow", () => {+ H.resetSnowplow();+ H.enableTracking();+cy.visit("/");cy.findByTestId("home-page").findByTestId("loading-indicator").should("not.exist");- H.openShortcutModal();-- H.shortcutModal().within(() => {- cy.findByRole("tab", { name: "General" }).should("exist");- cy.findByRole("tab", { name: "Dashboards" }).should("exist");- });- cy.realPress("Escape");- H.shortcutModal().should("not.exist");- H.openShortcutModal();- cy.realPress("?");- H.shortcutModal().should("not.exist");+ cy.log("the shortcuts modal is reachable from the help menu");H.getProfileLink().click();H.popover().findByText("Help").click();H.getHelpSubmenu().findByText("Keyboard shortcuts").click();- H.shortcutModal().should("exist");+ H.shortcutModal().should("be.visible");cy.realPress("Escape");H.shortcutModal().should("not.exist");-- // Test a few global shortcuts- cy.realPress("c").realPress("f");- cy.findByRole("dialog", { name: /collection/i }).should("exist");- cy.realPress("Escape");- H.expectUnstructuredSnowplowEvent({- event: "keyboard_shortcut_performed",- event_detail: "create-new-collection",- });- H.openCommandPalette();- H.commandPaletteInput().should("be.visible").type("new dashboard");- H.commandPalette().findByRole("option", { name: "New dashboard" }).click();- cy.findByRole("dialog", { name: /dashboard/i }).should("exist");- cy.realPress("Escape");-- // Using a command palette action registered as a shortcut should only- // emit snowplow events when using keyboard shortcuts, not command palette- H.expectUnstructuredSnowplowEvent(- {- event: "keyboard_shortcut_performed",- event_detail: "create-new-dashboard",- },- 0,- );-- cy.realPress("c").realPress("d");- cy.findByRole("dialog", { name: /dashboard/i }).should("exist");- cy.realPress("Escape");- H.expectUnstructuredSnowplowEvent(- {- event: "keyboard_shortcut_performed",- event_detail: "create-new-dashboard",- },- 1,- );-- cy.realPress("g").realPress("d");- cy.location("pathname").should("contain", "browse/databases");-- cy.realPress(["Meta", "["]);H.navigationSidebar().should("be.visible");- cy.realPress("[");- H.navigationSidebar().should("not.be.visible");- cy.realPress("[");- H.navigationSidebar().should("be.visible");- H.expectUnstructuredSnowplowEvent(- {- event: "keyboard_shortcut_performed",- event_detail: "toggle-navbar",- },- 2,- );-+ // Each destination is anchored on rendered content, not just the URL: the+ // pathname changes when the route transition starts, and a chord pressed+ // while the next page is still mounting is dropped.cy.realPress("g").realPress("p");cy.location("pathname").should("equal",`/collection/${ADMIN_PERSONAL_COLLECTION_ID}`,);- H.expectUnstructuredSnowplowEvent({- event: "keyboard_shortcut_performed",- event_detail: "navigate-personal-collection",- });+ cy.findByTestId("collection-name-heading").should(+ "contain.text",+ "Bobby Tables's Personal Collection",+ );cy.realPress("g").realPress("t");cy.location("pathname").should("equal", "/trash");-- H.expectUnstructuredSnowplowEvent({- event: "keyboard_shortcut_performed",- event_detail: "navigate-trash",- });+ cy.findByTestId("collection-name-heading").should("contain.text", "Trash");cy.realPress("g").realPress("s");cy.location("pathname").should("match", /^\/data-studio/);+ H.DataStudio.nav().should("be.visible");H.expectUnstructuredSnowplowEvent({event: "keyboard_shortcut_performed",- event_detail: "navigate-data-studio",+ event_detail: "navigate-trash",});-- cy.realPress("g").realPress("m");-- cy.log("shortcuts should not be enabled when working in a modal (ADM 658)");-- H.navigationSidebar().should("be.visible");- // Mantine Modals- H.startNewCollectionFromSidebar();-- cy.findByTestId("new-collection-modal")- .findByLabelText(/collection it's saved in/i)- .click();-- // Remove focus- H.entityPickerModal().findByRole("heading").click();-- cy.realPress("[");- H.navigationSidebar().should("be.visible");- cy.realPress("Escape");- cy.realPress("[");- H.navigationSidebar().should("be.visible");- cy.realPress("Escape");- // Legacy Modals-- H.startNewAction();-- // Remove focus- H.modal()- .findByText(/Build custom forms/)- .click();- cy.realPress("[");- H.navigationSidebar().should("be.visible");- cy.realPress("Escape");- cy.realPress("[");- H.navigationSidebar().should("not.visible");-- H.goToAdmin();-- cy.findByTestId("site-name-setting").should("exist");- cy.location("pathname").should("contain", "/admin/settings");- cy.realPress("5");- cy.location("pathname").should("contain", "/admin/datamodel");- cy.realPress("9");- cy.location("pathname").should("contain", "/admin/help");});- it("should not navigate to data studio via shortcut for non-admin users", () => {- cy.signInAsNormalUser();- cy.visit("/");- cy.findByTestId("home-page")- .findByText(/see what metabase can do/i)- .should("exist");+ it(+ "should not fire shortcuts while a modal holds focus (ADM 658)",+ { tags: ["@actions"] },+ () => {+ H.setActionsEnabledForDB(SAMPLE_DB_ID);- cy.realPress("g").realPress("s");- cy.location("pathname").should("equal", "/");- });+ cy.visit("/");+ cy.findByTestId("home-page")+ .findByTestId("loading-indicator")+ .should("not.exist");+ H.navigationSidebar().should("be.visible");++ cy.log("Mantine modals");+ H.startNewCollectionFromSidebar();+ cy.findByTestId("new-collection-modal")+ .should("be.visible")+ .findByLabelText(/collection it's saved in/i)+ .click();++ // Remove focus+ H.entityPickerModal().findByRole("heading").click();++ cy.realPress("[");+ H.navigationSidebar().should("be.visible");+ cy.realPress("Escape");+ H.entityPickerModal().should("not.exist");++ cy.realPress("[");+ H.navigationSidebar().should("be.visible");+ cy.realPress("Escape");+ cy.findByTestId("new-collection-modal").should("not.exist");++ cy.log("Legacy modals");+ H.startNewAction();++ // Remove focus+ H.modal()+ .findByText(/Build custom forms/)+ .click();++ cy.realPress("[");+ H.navigationSidebar().should("be.visible");+ cy.realPress("Escape");+ cy.findByTestId("action-creator").should("not.exist");++ cy.log("the shortcut works again once no modal holds focus");+ cy.realPress("[");+ H.navigationSidebar().should("not.be.visible");+ },+ );it("should support dashboard shortcuts", () => {+ cy.intercept("POST", "/api/bookmark/dashboard/*").as("bookmarkDashboard");+ cy.intercept("DELETE", "/api/bookmark/dashboard/*").as(+ "unbookmarkDashboard",+ );+H.createDashboardWithTabs({tabs: [TAB_1, TAB_2, TAB_3, TAB_4],dashcards: [@@ -670,16 +462,25 @@ describe("shortcuts", { tags: ["@actions"] }, () => {],}).then((dashboard) => H.visitDashboard(dashboard.id));- H.openShortcutModal();- H.shortcutModal().should("exist");- cy.realPress("Escape");+ // The o shortcut is registered by the header's bookmark toggle, and+ // visitDashboard only waits for the dashcard queries, so the keystroke can+ // land before that component has mounted and be dropped.+ H.dashboardHeader()+ .findByRole("button", { name: "Bookmark" })+ .should("be.visible");+ // The second press reads whether the dashboard is bookmarked from the+ // refetched bookmark list, so each toggle waits for its write to land and+ // for the sidebar to catch up before the next press.cy.realPress("o");+ cy.wait("@bookmarkDashboard");H.openNavigationSidebar();H.navigationSidebar().findByRole("section", { name: "Bookmarks" }).should("contain.text", "Test Dashboard");+cy.realPress("o");+ cy.wait("@unbookmarkDashboard");H.navigationSidebar().findByRole("section", { name: "Bookmarks" }).should("not.exist");diff --git a/frontend/src/metabase/admin/app/reducers.unit.spec.ts b/frontend/src/metabase/admin/app/reducers.unit.spec.tsnew file mode 100644index 00000000000..63f5fd31e33--- /dev/null+++ b/frontend/src/metabase/admin/app/reducers.unit.spec.ts@@ -0,0 +1,65 @@+import fetchMock from "fetch-mock";++import { getStore } from "__support__/entities-store";+import { Api } from "metabase/api/api";+import { currentUserApi } from "metabase/current-user";+import { combineReducers } from "metabase/redux";+import { createMockUser } from "metabase-types/api/mocks";++import { appReducer, getAdminPaths } from "./reducers";++describe("getAdminPaths", () => {+ // The order is load-bearing: AdminNavbar binds the digits 1-9 to+ // `adminPaths[key - 1]`, so inserting or reordering an entry silently+ // re-points a keyboard shortcut at a different page.+ it("keeps the tab order the digit shortcuts are bound to", () => {+ expect(getAdminPaths().map(({ key }) => key)).toEqual([+ "settings",+ "databases",+ "embedding",+ "metabot",+ "data-model",+ "people",+ "permissions",+ "performance",+ "help",+ ]);+ });+});++describe("admin paths reducer", () => {+ const setup = async ({ isAdmin }: { isAdmin: boolean }) => {+ fetchMock.get(+ "path:/api/user/current",+ createMockUser({ is_superuser: isAdmin }),+ );+ const store = getStore(+ {+ [Api.reducerPath]: Api.reducer,+ admin: combineReducers({ app: appReducer }),+ },+ {},+ [Api.middleware],+ );++ const initialKeys = store.getState().admin.app.paths.map(({ key }) => key);+ await store.dispatch(currentUserApi.endpoints.getCurrentUser.initiate());+ const keys = store.getState().admin.app.paths.map(({ key }) => key);++ store.dispatch(Api.util.resetApiState());+ return { initialKeys, keys };+ };++ it("keeps every admin path for an admin", async () => {+ const { initialKeys, keys } = await setup({ isAdmin: true });++ expect(keys).toEqual(initialKeys);+ });++ it("drops every admin path for a non-admin without extra permissions", async () => {+ const { initialKeys, keys } = await setup({ isAdmin: false });++ expect(initialKeys).toContain("settings");+ expect(keys).toEqual([]);+ });+});diff --git a/frontend/src/metabase/nav/components/AdminNavbar/AdminNavbar.unit.spec.tsx b/frontend/src/metabase/nav/components/AdminNavbar/AdminNavbar.unit.spec.tsxindex c3327ed9f45..018993c3194 100644--- a/frontend/src/metabase/nav/components/AdminNavbar/AdminNavbar.unit.spec.tsx+++ b/frontend/src/metabase/nav/components/AdminNavbar/AdminNavbar.unit.spec.tsx@@ -1,7 +1,10 @@+import userEvent from "@testing-library/user-event";+import { setupBugReportingDetailsEndpoint } from "__support__/server-mocks";import { mockSettings } from "__support__/settings";import { createMockState } from "__support__/state";-import { renderWithProviders, screen } from "__support__/ui";+import { renderWithProviders, screen, waitFor } from "__support__/ui";+import type { AdminPath } from "metabase/redux/store";import { Route } from "metabase/router";import {createMockSettings,@@ -11,7 +14,26 @@ import {import { AdminNavbar } from "./AdminNavbar";-const setup = ({ isAdmin = false, isPaidPlan = false }) => {+// The real tab list and its order live with `getAdminPaths`, which pins them in+// its own spec. Here the list is a fixture: what matters is that digit N routes+// to the Nth tab, whatever the tabs happen to be.+const ADMIN_PATHS: AdminPath[] = [+ { key: "settings", path: "/admin/settings", getName: () => "Settings" },+ { key: "databases", path: "/admin/databases", getName: () => "Databases" },+ { key: "people", path: "/admin/people", getName: () => "People" },+];++type SetupOpts = {+ isAdmin?: boolean;+ isPaidPlan?: boolean;+ adminPaths?: AdminPath[];+};++const setup = ({+ isAdmin = false,+ isPaidPlan = false,+ adminPaths = [],+}: SetupOpts) => {setupBugReportingDetailsEndpoint();const state = createMockState({currentUser: createMockUser({ is_superuser: isAdmin }),@@ -23,14 +45,29 @@ const setup = ({ isAdmin = false, isPaidPlan = false }) => {});return renderWithProviders(- <Route path="/" element={<AdminNavbar path="/admin" adminPaths={[]} />} />,+ <Route+ path="*"+ element={<AdminNavbar path="/admin" adminPaths={adminPaths} />}+ />,{storeInitialState: state,withRouter: true,+ initialRoute: "/admin",+ withKBar: true,},);};+const setupTabs = async (adminPaths: AdminPath[] = ADMIN_PATHS) => {+ const { router } = setup({ isAdmin: true, adminPaths });++ // The digit shortcut is registered from an effect; a keystroke dispatched in+ // the same tick as the initial render lands before that and is lost.+ await screen.findByTestId("admin-navbar");++ return { router };+};+describe("AdminNavbar", () => {describe("StoreLink visibility", () => {it("does not show store link when user is not an admin", () => {@@ -48,4 +85,32 @@ describe("AdminNavbar", () => {expect(screen.queryByTestId("store-link")).not.toBeInTheDocument();});});++ describe("tab shortcuts", () => {+ it.each(+ ADMIN_PATHS.map(+ (adminPath, index) =>+ [`${index + 1}`, adminPath.key, adminPath.path] as const,+ ),+ )("pressing %s goes to the %s tab", async (key, _key, pathname) => {+ const { router } = await setupTabs();++ await userEvent.keyboard(key);++ await waitFor(() => expect(router?.location.pathname).toBe(pathname));+ });++ it("ignores digits past the end of the tab list", async () => {+ const { router } = await setupTabs();++ await userEvent.keyboard(`${ADMIN_PATHS.length + 1}`);+ expect(router?.location.pathname).toBe("/admin");++ // The handler is live — the out-of-range digit was ignored, not dropped.+ await userEvent.keyboard("2");+ await waitFor(() =>+ expect(router?.location.pathname).toBe(ADMIN_PATHS[1].path),+ );+ });+ });});diff --git a/frontend/src/metabase/nav/components/AppBar/AppBarToggle.unit.spec.tsx b/frontend/src/metabase/nav/components/AppBar/AppBarToggle.unit.spec.tsxnew file mode 100644index 00000000000..cdba4b5d7f1--- /dev/null+++ b/frontend/src/metabase/nav/components/AppBar/AppBarToggle.unit.spec.tsx@@ -0,0 +1,87 @@+import userEvent from "@testing-library/user-event";++import { renderWithProviders, screen } from "__support__/ui";+import * as Analytics from "metabase/analytics";++import { AppBarToggle } from "./AppBarToggle";++const setup = async () => {+ const onToggleClick = jest.fn();++ renderWithProviders(+ <AppBarToggle isNavBarEnabled isNavBarOpen onToggleClick={onToggleClick} />,+ { withKBar: true },+ );++ // The shortcut is registered from an effect; a keystroke dispatched in the+ // same tick as the initial render lands before that and is lost.+ await screen.findByRole("button", { name: "Toggle sidebar" });++ return { onToggleClick };+};++describe("AppBarToggle", () => {+ beforeEach(() => {+ jest.clearAllMocks();+ });++ afterEach(() => {+ jest.restoreAllMocks();+ });++ it("toggles the sidebar when the button is clicked", async () => {+ const { onToggleClick } = await setup();++ await userEvent.click(+ screen.getByRole("button", { name: "Toggle sidebar" }),+ );++ expect(onToggleClick).toHaveBeenCalledTimes(1);+ });++ it("toggles the sidebar on [ and reports the shortcut", async () => {+ const trackSimpleEvent = jest.spyOn(Analytics, "trackSimpleEvent");+ const { onToggleClick } = await setup();++ await userEvent.keyboard("[[");+ expect(onToggleClick).toHaveBeenCalledTimes(1);++ await userEvent.keyboard("[[");+ expect(onToggleClick).toHaveBeenCalledTimes(2);++ expect(trackSimpleEvent).toHaveBeenCalledWith({+ event: "keyboard_shortcut_performed",+ event_detail: "toggle-navbar",+ });+ });++ it("does not report a shortcut when the button is clicked", async () => {+ const trackSimpleEvent = jest.spyOn(Analytics, "trackSimpleEvent");+ await setup();++ await userEvent.click(+ screen.getByRole("button", { name: "Toggle sidebar" }),+ );++ expect(trackSimpleEvent).not.toHaveBeenCalledWith(+ expect.objectContaining({ event: "keyboard_shortcut_performed" }),+ );+ });++ it("ignores the shortcut while a text input holds focus", async () => {+ const { onToggleClick } = await setup();++ const input = document.createElement("input");+ document.body.appendChild(input);+ input.focus();++ await userEvent.keyboard("[[");+ expect(onToggleClick).not.toHaveBeenCalled();++ input.remove();+ document.body.focus();++ await userEvent.keyboard("[[");+ expect(onToggleClick).toHaveBeenCalledTimes(1);+ });+});diff --git a/frontend/src/metabase/nav/components/search/SearchButton/SearchButton.unit.spec.tsx b/frontend/src/metabase/nav/components/search/SearchButton/SearchButton.unit.spec.tsxindex 95c588c20f0..ee46341bff0 100644--- a/frontend/src/metabase/nav/components/search/SearchButton/SearchButton.unit.spec.tsx+++ b/frontend/src/metabase/nav/components/search/SearchButton/SearchButton.unit.spec.tsx@@ -3,16 +3,54 @@ import { Route } from "metabase/router";import { SearchButton } from "./SearchButton";+const setup = ({+ initialRoute = "/",+ isSmallScreen = false,+}: { initialRoute?: string; isSmallScreen?: boolean } = {}) => {+ jest.spyOn(window, "matchMedia").mockReturnValue({+ media: "",+ matches: isSmallScreen,+ onchange: jest.fn(),+ dispatchEvent: jest.fn(),+ addListener: jest.fn(),+ addEventListener: jest.fn(),+ removeListener: jest.fn(),+ removeEventListener: jest.fn(),+ });++ renderWithProviders(<Route path="*" element={<SearchButton />} />, {+ withKBar: true,+ withRouter: true,+ initialRoute,+ });+};+describe("SearchButton", () => {+ afterEach(() => {+ jest.restoreAllMocks();+ });+it("should show the current search query on the search page (UXW-3370)", () => {- renderWithProviders(<Route path="*" element={<SearchButton />} />, {- withKBar: true,- withRouter: true,- initialRoute: "/search?q=products",- });+ setup({ initialRoute: "/search?q=products" });expect(screen.getByRole("button", { name: /Search/ })).toHaveTextContent("products",);});++ it("should collapse to an icon-only button on small screens", () => {+ setup({ isSmallScreen: true });++ expect(screen.getByRole("button", { name: "Search" })).toHaveTextContent(+ "",+ );+ });++ it("should show the label and keyboard hint on large screens", () => {+ setup();++ const button = screen.getByRole("button", { name: "Search" });+ expect(button).toHaveTextContent("Search...");+ expect(button).toHaveTextContent("K");+ });});diff --git a/frontend/src/metabase/new/components/NewModals/NewModals.unit.spec.tsx b/frontend/src/metabase/new/components/NewModals/NewModals.unit.spec.tsxindex 7805587f48c..1f368cf1837 100644--- a/frontend/src/metabase/new/components/NewModals/NewModals.unit.spec.tsx+++ b/frontend/src/metabase/new/components/NewModals/NewModals.unit.spec.tsx@@ -1,11 +1,18 @@import userEvent from "@testing-library/user-event";+import fetchMock from "fetch-mock";import {setupCardsEndpoints,setupCollectionsEndpoints,setupDatabasesEndpoints,} from "__support__/server-mocks";-import { act, renderWithProviders, screen, waitFor } from "__support__/ui";+import {+ act,+ renderWithProviders,+ screen,+ waitFor,+ within,+} from "__support__/ui";import { loadActionCreator } from "metabase/querying/action-creator";import { setOpenModal } from "metabase/redux/ui";import { Route } from "metabase/router";@@ -34,6 +41,23 @@ async function setup() {await screen.findByTestId("action-creator");}+async function setupShortcut() {+ setupDatabasesEndpoints([createMockDatabase()]);+ setupCardsEndpoints([]);+ setupCollectionsEndpoints({ collections: [] });++ renderWithProviders(<Route path="/" element={<NewModals />} />, {+ withRouter: true,+ withKBar: true,+ });++ // The shortcut is registered from an effect; a keystroke dispatched in the+ // same tick as the initial render lands before that and is lost.+ await waitFor(() =>+ expect(fetchMock.callHistory.called(/\/api\/collection/)).toBe(true),+ );+}+describe("NewModals", () => {it("opens the action creator in new query action mode", async () => {await setup();@@ -43,6 +67,26 @@ describe("NewModals", () => {expect(screen.getByRole("button", { name: "Save" })).toBeInTheDocument();});+ it("toggles the shortcuts modal with ?", async () => {+ await setupShortcut();++ await userEvent.keyboard("{Shift>}?{/Shift}");++ const modal = await screen.findByRole("dialog", { name: "Shortcuts" });+ expect(within(modal).getByRole("tab", { name: "General" })).toBeVisible();+ expect(+ within(modal).getByRole("tab", { name: "Dashboards" }),+ ).toBeVisible();++ await userEvent.keyboard("{Shift>}?{/Shift}");++ await waitFor(() => {+ expect(+ screen.queryByRole("dialog", { name: "Shortcuts" }),+ ).not.toBeInTheDocument();+ });+ });+it("closes the action creator on cancel", async () => {await setup();diff --git a/frontend/src/metabase/palette/components/test/PaletteResults/PaletteResults-oss.unit.spec.tsx b/frontend/src/metabase/palette/components/test/PaletteResults/PaletteResults-oss.unit.spec.tsxindex d82917f34e5..1bb302cfb32 100644--- a/frontend/src/metabase/palette/components/test/PaletteResults/PaletteResults-oss.unit.spec.tsx+++ b/frontend/src/metabase/palette/components/test/PaletteResults/PaletteResults-oss.unit.spec.tsx@@ -1,6 +1,8 @@+import userEvent from "@testing-library/user-event";import fetchMock from "fetch-mock";import { screen, waitFor, within } from "__support__/ui";+import * as Analytics from "metabase/analytics";import {createMockRecentCollectionItem,createMockRecentTableItem,@@ -8,11 +10,18 @@ import {import { type CommonSetupProps, commonSetup } from "./setup";-const setup = (props: CommonSetupProps = {}) => {+const setup = (props: CommonSetupProps = {}) =>commonSetup({ ...props, isEE: false });-};describe("PaletteResults", () => {+ beforeEach(() => {+ jest.clearAllMocks();+ });++ afterEach(() => {+ jest.restoreAllMocks();+ });+it("should not show actions when there is no search query", async () => {setup();expect(await screen.findByText("Recents")).toBeInTheDocument();@@ -209,6 +218,72 @@ describe("PaletteResults", () => {expect(fetchMock.callHistory.calls("path:/api/search").length).toBe(2);});+ it("should offer the Download diagnostics action", async () => {+ setup({ query: "issue" });+ expect(await screen.findByText("Download diagnostics")).toBeInTheDocument();+ });++ it("should offer the New embed action to admins", async () => {+ setup({ query: "new embed", isAdmin: true });+ expect(await screen.findByText("New embed")).toBeInTheDocument();+ });++ it("should not offer the New embed action to non-admins", async () => {+ setup({ query: "new embed", isAdmin: false });+ expect(+ await screen.findByText(`Search Metabase's docs for "new embed"`),+ ).toBeInTheDocument();+ expect(screen.queryByText("New embed")).not.toBeInTheDocument();+ });++ it("should start a new metric", async () => {+ const { router } = setup({ query: "new met" });++ await userEvent.click(await screen.findByText("New metric"));++ await waitFor(() => expect(router?.location.pathname).toBe("/metric/new"));+ });++ it("should start a new document", async () => {+ const { router } = setup({ query: "new document" });++ await userEvent.click(await screen.findByText("New document"));++ await waitFor(() =>+ expect(router?.location.pathname).toBe("/document/new"),+ );+ });++ it("should not report a keyboard shortcut when an action is clicked", async () => {+ const trackSimpleEvent = jest.spyOn(Analytics, "trackSimpleEvent");+ setup({ query: "new met" });++ await userEvent.click(await screen.findByText("New metric"));++ expect(trackSimpleEvent).not.toHaveBeenCalledWith(+ expect.objectContaining({ event: "keyboard_shortcut_performed" }),+ );+ });++ it("should prompt admins to search everything when nothing matched", async () => {+ setup({+ query: "zzzz",+ isAdmin: true,+ settings: { "active-users-count": 2 },+ });++ expect(await screen.findByText("Search everything")).toBeInTheDocument();+ });++ it("should not prompt non-admins to search everything", async () => {+ setup({ query: "zzzz", settings: { "active-users-count": 2 } });++ expect(+ await screen.findByText(`Search Metabase's docs for "zzzz"`),+ ).toBeInTheDocument();+ expect(screen.queryByText("Search everything")).not.toBeInTheDocument();+ });+it("should not allow you to select or click disabled items", async () => {setup({ query: "modelsssss" });expect(await screen.findByLabelText(/No results/)).toHaveAttribute(diff --git a/frontend/src/metabase/palette/components/test/PaletteResults/setup.tsx b/frontend/src/metabase/palette/components/test/PaletteResults/setup.tsxindex df973949f31..20fa5f765ac 100644--- a/frontend/src/metabase/palette/components/test/PaletteResults/setup.tsx+++ b/frontend/src/metabase/palette/components/test/PaletteResults/setup.tsx@@ -20,7 +20,7 @@ import { useCommandPalette } from "metabase/palette/hooks/useCommandPalette";import { useCommandPaletteBasicActions } from "metabase/palette/hooks/useCommandPaletteBasicActions";import { Route, useLocation, useParams } from "metabase/router";import { parseSearchQuery } from "metabase/utils/browser";-import type { RecentItem, Settings } from "metabase-types/api";+import type { CollectionItem, RecentItem, Settings } from "metabase-types/api";import {createMockCollection,createMockCollectionItem,@@ -131,6 +131,7 @@ export interface CommonSetupProps {query?: string;settings?: Partial<Settings>;recents?: RecentItem[];+ searchItems?: CollectionItem[];isEE?: boolean;isAdmin?: boolean;}@@ -139,11 +140,12 @@ export const commonSetup = ({query,settings = {},recents = [recents_1, recents_2],+ searchItems = [model_1, model_2, dashboard],isEE,isAdmin = false,}: CommonSetupProps = {}) => {setupDatabasesEndpoints([DATABASE]);- setupSearchEndpoints([model_1, model_2, dashboard]);+ setupSearchEndpoints(searchItems);setupRecentViewsEndpoints(recents);setupCollectionByIdEndpoint({collections: [createMockCollection({ id: "root", can_write: true })],@@ -183,8 +185,8 @@ export const commonSetup = ({setupEnterprisePlugins();}- renderWithProviders(- <Route path="/" element={<TestComponent q={query} isLoggedIn />} />,+ return renderWithProviders(+ <Route path="*" element={<TestComponent q={query} isLoggedIn />} />,{withKBar: true,withRouter: true,diff --git a/frontend/src/metabase/palette/shortcuts/global-shortcuts.unit.spec.tsx b/frontend/src/metabase/palette/shortcuts/global-shortcuts.unit.spec.tsxnew file mode 100644index 00000000000..c7e2bceb741--- /dev/null+++ b/frontend/src/metabase/palette/shortcuts/global-shortcuts.unit.spec.tsx@@ -0,0 +1,156 @@+import userEvent from "@testing-library/user-event";+import fetchMock from "fetch-mock";++import {+ setupCollectionByIdEndpoint,+ setupDatabasesEndpoints,+ setupRecentViewsEndpoints,+ setupSearchEndpoints,+} from "__support__/server-mocks";+import { createMockState } from "__support__/state";+import { renderWithProviders, waitFor } from "__support__/ui";+import * as Analytics from "metabase/analytics";+import { Palette } from "metabase/palette/components/Palette";+import { Route } from "metabase/router";+import {+ createMockCollection,+ createMockUser,+ createMockUserPermissions,+} from "metabase-types/api/mocks";++const PERSONAL_COLLECTION_ID = 42;++type SetupOpts = {+ isAdmin?: boolean;+};++const setup = async ({ isAdmin = true }: SetupOpts = {}) => {+ setupDatabasesEndpoints([]);+ setupSearchEndpoints([]);+ setupRecentViewsEndpoints([]);+ setupCollectionByIdEndpoint({+ collections: [createMockCollection({ id: "root", can_write: true })],+ });++ const view = renderWithProviders(<Route path="*" element={<Palette />} />, {+ withKBar: true,+ withRouter: true,+ storeInitialState: createMockState({+ currentUser: createMockUser({+ is_superuser: isAdmin,+ personal_collection_id: PERSONAL_COLLECTION_ID,+ permissions: createMockUserPermissions({+ can_create_queries: true,+ can_create_native_queries: true,+ }),+ }),+ }),+ });++ // The palette registers its actions from an effect fed by /api/search. A+ // keystroke dispatched before that registration lands is lost.+ await waitFor(() =>+ expect(fetchMock.callHistory.called("path:/api/search")).toBe(true),+ );++ return view;+};++describe("global keyboard shortcuts", () => {+ beforeEach(() => {+ jest.clearAllMocks();+ });++ afterEach(() => {+ jest.restoreAllMocks();+ });++ describe("navigation", () => {+ it.each([+ ["g d", "gd", "/browse/databases"],+ ["g m", "gm", "/browse/models"],+ ["g k", "gk", "/browse/metrics"],+ ["g t", "gt", "/trash"],+ ["g u", "gu", "/account/profile"],+ ["g a", "ga", "/admin/settings"],+ ["g s", "gs", "/data-studio"],+ ["g p", "gp", `/collection/${PERSONAL_COLLECTION_ID}`],+ ])("%s navigates to %s", async (_name, keys, pathname) => {+ const { router } = await setup();++ await userEvent.keyboard(keys);++ await waitFor(() => expect(router?.location.pathname).toBe(pathname));+ });++ it("does not navigate to Data Studio for users without access", async () => {+ const { router } = await setup({ isAdmin: false });++ await userEvent.keyboard("gs");+ expect(router?.location.pathname).toBe("/");+ // Prove the keyboard pipeline is live for this user before asserting the+ // absence — otherwise the assertion passes for the wrong reason.+ await userEvent.keyboard("gt");++ await waitFor(() => expect(router?.location.pathname).toBe("/trash"));+ });++ it("does not navigate to admin settings for non-admins", async () => {+ const { router } = await setup({ isAdmin: false });++ await userEvent.keyboard("ga");+ expect(router?.location.pathname).toBe("/");+ await userEvent.keyboard("gt");++ await waitFor(() => expect(router?.location.pathname).toBe("/trash"));+ });+ });++ describe("creation", () => {+ it.each([+ ["c f", "cf", "collection"],+ ["c d", "cd", "dashboard"],+ ])("%s opens the %s modal", async (_name, keys, modalId) => {+ const { store } = await setup();++ await userEvent.keyboard(keys);++ await waitFor(() => expect(store.getState().modal.id).toBe(modalId));+ });+ });++ describe("suppression", () => {+ it("ignores shortcuts while a text input holds focus", async () => {+ const { router } = await setup();++ const input = document.createElement("input");+ document.body.appendChild(input);+ input.focus();++ await userEvent.keyboard("gt");+ expect(router?.location.pathname).toBe("/");++ input.remove();+ document.body.focus();++ await userEvent.keyboard("gt");+ await waitFor(() => expect(router?.location.pathname).toBe("/trash"));+ });+ });++ describe("analytics", () => {+ it("reports the shortcut that was performed", async () => {+ const trackSimpleEvent = jest.spyOn(Analytics, "trackSimpleEvent");+ await setup();++ await userEvent.keyboard("gt");++ await waitFor(() => {+ expect(trackSimpleEvent).toHaveBeenCalledWith({+ event: "keyboard_shortcut_performed",+ event_detail: "navigate-trash",+ });+ });+ });+ });+});diff --git a/test/metabase/documents/recent_views_test.clj b/test/metabase/documents/recent_views_test.cljindex 43483ddc774..490e08c7037 100644--- a/test/metabase/documents/recent_views_test.clj+++ b/test/metabase/documents/recent_views_test.clj@@ -3,6 +3,7 @@[clojure.test :refer :all][metabase.activity-feed.core :as activity-feed][metabase.activity-feed.models.recent-views :as recent-views.model]+ [metabase.collections.models.collection :as collection][metabase.events.core :as events][metabase.test :as mt][toucan2.core :as t2]))@@ -83,6 +84,18 @@(is (nil? (:collection_name doc)))(is (nil? (:collection_authority_level doc))))))))+(deftest select-documents-for-recents-personal-collection-test+ (testing "returns the owner-qualified name for a document in a personal collection"+ ;; The command palette shows the collection a recent document lives in, and for a personal+ ;; collection that name is the owner-qualified one written at creation time, not a blank row.+ (let [coll-id (:id (collection/user->personal-collection (mt/user->id :rasta)))]+ (mt/with-temp [:model/Document {doc-id :id} {:name "Personal Document"+ :collection_id coll-id+ :archived false}]+ (let [doc (first (#'recent-views.model/document-recents [doc-id]))]+ (is (= coll-id (:collection_id doc)))+ (is (= "Rasta Toucan's Personal Collection" (:collection_name doc))))))))+(deftest select-documents-for-recents-archived-collections-test(testing "excludes documents from archived collections via left join"(mt/with-temp [:model/Collection {archived-coll-id :id} {:name "Archived Collection"