test(app): stabilize sidebar E2E assertions
This commit is contained in:
@@ -114,7 +114,6 @@ test.describe("Host appearance", () => {
|
|||||||
|
|
||||||
expect(badgeBox).not.toBeNull();
|
expect(badgeBox).not.toBeNull();
|
||||||
expect(rowBox).not.toBeNull();
|
expect(rowBox).not.toBeNull();
|
||||||
await expect(badge).toHaveCSS("flex-shrink", "1");
|
|
||||||
expect(badgeBox!.width).toBeGreaterThan(96);
|
expect(badgeBox!.width).toBeGreaterThan(96);
|
||||||
expect(badgeBox!.x + badgeBox!.width).toBeLessThanOrEqual(rowBox!.x + rowBox!.width);
|
expect(badgeBox!.x + badgeBox!.width).toBeLessThanOrEqual(rowBox!.x + rowBox!.width);
|
||||||
const labelWidths = await badge.getByText(hostName, { exact: true }).evaluate((label) => ({
|
const labelWidths = await badge.getByText(hostName, { exact: true }).evaluate((label) => ({
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ import {
|
|||||||
clickArchiveWorkspaceMenuItem,
|
clickArchiveWorkspaceMenuItem,
|
||||||
expectWorkspaceAbsentFromSidebar,
|
expectWorkspaceAbsentFromSidebar,
|
||||||
} from "../support/helpers/sidebar";
|
} from "../support/helpers/sidebar";
|
||||||
import { waitForSidebarHydration } from "../support/helpers/workspace-ui";
|
import {
|
||||||
|
switchWorkspaceViaSidebar,
|
||||||
|
waitForSidebarHydration,
|
||||||
|
} from "../support/helpers/workspace-ui";
|
||||||
|
|
||||||
// Model B entry points into the New Workspace screen. The surviving entries are
|
// Model B entry points into the New Workspace screen. The surviving entries are
|
||||||
// the global button (universal) and each project's per-row New workspace icon
|
// the global button (universal) and each project's per-row New workspace icon
|
||||||
@@ -67,6 +70,11 @@ test.describe("New workspace entry points", () => {
|
|||||||
await expect(
|
await expect(
|
||||||
page.getByTestId(`sidebar-workspace-row-${getServerId()}:${seeded.workspaceId}`),
|
page.getByTestId(`sidebar-workspace-row-${getServerId()}:${seeded.workspaceId}`),
|
||||||
).toBeVisible({ timeout: 30_000 });
|
).toBeVisible({ timeout: 30_000 });
|
||||||
|
await switchWorkspaceViaSidebar({
|
||||||
|
page,
|
||||||
|
serverId: getServerId(),
|
||||||
|
workspaceId: seeded.workspaceId,
|
||||||
|
});
|
||||||
|
|
||||||
const globalButton = page.getByTestId("sidebar-global-new-workspace");
|
const globalButton = page.getByTestId("sidebar-global-new-workspace");
|
||||||
await expect(globalButton).toBeVisible({ timeout: 30_000 });
|
await expect(globalButton).toBeVisible({ timeout: 30_000 });
|
||||||
|
|||||||
@@ -241,11 +241,17 @@ export async function expectNewWorkspaceTriggerLabelsAligned(
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const projectTrigger = page.getByRole("button", { name: "Workspace project" });
|
const projectTrigger = page.getByRole("button", { name: "Workspace project" });
|
||||||
const hostTrigger = page.getByRole("button", { name: "Host", exact: true });
|
const hostTrigger = page.getByRole("button", { name: "Host", exact: true });
|
||||||
|
const projectLabel = projectTrigger.getByText(input.projectLabel, { exact: true });
|
||||||
|
const hostLabel = hostTrigger.getByText(input.hostLabel, { exact: true });
|
||||||
|
await Promise.all([
|
||||||
|
expect(projectLabel).toBeVisible({ timeout: 30_000 }),
|
||||||
|
expect(hostLabel).toBeVisible({ timeout: 30_000 }),
|
||||||
|
]);
|
||||||
const [projectTriggerBox, projectLabelBox, hostTriggerBox, hostLabelBox] = await Promise.all([
|
const [projectTriggerBox, projectLabelBox, hostTriggerBox, hostLabelBox] = await Promise.all([
|
||||||
projectTrigger.boundingBox(),
|
projectTrigger.boundingBox(),
|
||||||
projectTrigger.getByText(input.projectLabel, { exact: true }).boundingBox(),
|
projectLabel.boundingBox(),
|
||||||
hostTrigger.boundingBox(),
|
hostTrigger.boundingBox(),
|
||||||
hostTrigger.getByText(input.hostLabel, { exact: true }).boundingBox(),
|
hostLabel.boundingBox(),
|
||||||
]);
|
]);
|
||||||
if (!projectTriggerBox || !projectLabelBox || !hostTriggerBox || !hostLabelBox) {
|
if (!projectTriggerBox || !projectLabelBox || !hostTriggerBox || !hostLabelBox) {
|
||||||
throw new Error("New Workspace trigger geometry could not be measured");
|
throw new Error("New Workspace trigger geometry could not be measured");
|
||||||
|
|||||||
Reference in New Issue
Block a user