Files
buzz/desktop/tests/e2e/search-scope-screenshots.spec.ts
klopez4212 cf03bd7c37 Improve desktop search scoping (#5306)
## What changed

- unify Cmd+K and channel Cmd+F around a removable channel or
conversation scope
- add conservative fuzzy matching for people and channels while
preserving exact-match ordering
- make scoped message search complete for one-character queries and
expose up to 40 scrollable results
- keep the pre-scope channel or DM action in the normal results flow so
it scrolls away with the list

## Validation

- desktop TypeScript typecheck
- desktop text-size and file-size guards
- focused fuzzy-search unit tests (24 passed)
- focused search Playwright coverage (7 passed), including channel and
DM copy, one-character results/no-results, 40-result scrolling, and the
non-sticky scope action
- desktop E2E build
- visual review of channel, scoped, expanded-results, and DM states

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Carl <3c4caeafb646d23867f1c4832e68211d77e2561946171625f75c3ce1a3f2670f@buzz.block.builderlab.xyz>
2026-08-11 11:11:57 -07:00

73 lines
2.7 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { installMockBridge } from "../helpers/bridge";
import { waitForAnimations } from "../helpers/animations";
test("captures global and current-channel search scope states", async ({
page,
}) => {
await installMockBridge(page);
await page.goto("/");
await page.getByTestId("channel-deep-history").click();
await expect(page.getByTestId("chat-title")).toHaveText("deep-history");
await expect(
page.locator('[data-message-id^="mock-deep-history-"]').first(),
).toBeVisible();
await page.getByTestId("channel-general").click();
await expect(page.getByTestId("chat-title")).toHaveText("general");
await expect(page).toHaveURL(
/#\/channels\/9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50$/,
);
await page.keyboard.press("ControlOrMeta+k");
const searchDialog = page.getByTestId("search-results");
const scopeAction = page.getByTestId("search-current-channel-control");
await expect(scopeAction).toContainText("Search in");
await expect(scopeAction).toContainText("#general");
await waitForAnimations(page);
await searchDialog.screenshot({
path: "test-results/search-scope/01-global-channel-scope-action.png",
});
await scopeAction.click();
await page.getByTestId("search-dialog-input").fill("welcome");
await expect(page.getByTestId("search-channel-scope-chip")).toHaveText(
/#general/,
);
await expect(searchDialog).toContainText("Welcome to #general");
await waitForAnimations(page);
await searchDialog.screenshot({
path: "test-results/search-scope/02-current-channel-scoped.png",
});
await page.getByTestId("search-channel-scope-chip").click();
await page.getByTestId("search-dialog-input").fill("deep history message");
await expect(
page.locator('[data-search-section="messages"] .search-result-row'),
).toHaveCount(40);
await page.getByTestId("search-results-list").evaluate((element) => {
element.scrollTop = 180;
});
await expect(scopeAction).not.toBeInViewport();
await waitForAnimations(page);
await searchDialog.screenshot({
path: "test-results/search-scope/03-expanded-scrollable-results.png",
});
await page.keyboard.press("Escape");
await page.getByTestId("channel-alice-tyler").click();
await expect(page.getByTestId("chat-title")).toHaveText("alice-tyler");
await expect(page).toHaveURL(
/#\/channels\/f48efb06-0c93-5025-aac9-2e646bb6bfa8$/,
);
await page.keyboard.press("ControlOrMeta+k");
await expect(scopeAction).toContainText("Search conversation with alice");
await expect(scopeAction).toContainText(
"Search messages in this conversation.",
);
await waitForAnimations(page);
await searchDialog.screenshot({
path: "test-results/search-scope/04-dm-conversation-scope-action.png",
});
});