Skip to content

Commit

Permalink
Improve tests (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
raplemie authored Dec 20, 2023
1 parent fc5b6af commit 857067c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
14 changes: 12 additions & 2 deletions full-stack-tests/ui/tests/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ export interface SavedFrontstageState {
};
savedTabs: {
allIds: string[];
byId: {
[id in string]: {
popoutBounds: {
bottom: number;
left: number;
right: number;
top: number;
};
};
};
};
};
}
Expand Down Expand Up @@ -205,8 +215,8 @@ export async function dragTab(tab: Locator, target: Locator) {
await tab.dispatchEvent("mousemove", { clientX: 20, clientY: 20 });
const bounds = (await target.boundingBox())!;
await body.dispatchEvent("mousemove", {
clientX: bounds.x,
clientY: bounds.y,
clientX: bounds.x + bounds.width / 2,
clientY: bounds.y + bounds.height / 2,
});
await body.dispatchEvent("mouseup");
}
Expand Down
11 changes: 7 additions & 4 deletions full-stack-tests/ui/tests/popout-widget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ test.describe("popout widget", () => {
await expectSavedFrontstageState(context, (state) => {
return (
state.nineZone.widgets["appui-test-providers:ViewAttributesWidget"]
?.activeTabId === "appui-test-providers:ViewAttributesWidget"
?.activeTabId === "appui-test-providers:ViewAttributesWidget" &&
!!state.nineZone.savedTabs.byId[
"appui-test-providers:ViewAttributesWidget"
]
);
});

Expand Down Expand Up @@ -180,18 +183,18 @@ test.describe("popout widget", () => {
page,
}) => {
const id = "appui-test-providers:PopoutMountUnmountWidget";
const widgetLifecycle = trackWidgetLifecycle(page, id);
const widget = floatingWidgetLocator({
page,
id,
});

await expect(widget).toBeVisible();
const widgetLifecycle = trackWidgetLifecycle(page, id);
const popoutPage = await popoutWidget(context, widget);
expect(popoutPage.isClosed()).toBe(false);

await popoutPage.close();

expect(widgetLifecycle.mountCount).toBe(1);
expect(widgetLifecycle.mountCount).toBe(0);
expect(widgetLifecycle.unMountCount).toBe(0);
});
});
Expand Down
8 changes: 4 additions & 4 deletions full-stack-tests/ui/tests/widget-state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,15 @@ test.describe("widget state", () => {
});

test("should unmount and hide widget when unloading", async ({ page }) => {
const widgetLifecycle = trackWidgetLifecycle(page, "WL-A");
const tab = tabLocator(page, "WL-A");
await expect(tab).toBeVisible();
expect(widgetLifecycle.mountCount).toBe(1);
await expect(tab).toBeVisible({ timeout: 10000 });
const widgetLifecycle = trackWidgetLifecycle(page, "WL-A");
expect(widgetLifecycle.mountCount).toBe(0);
expect(widgetLifecycle.unMountCount).toBe(0);

await setWidgetState(page, "WL-A", WidgetState.Unloaded);
await expect(tab).not.toBeVisible();
expect(widgetLifecycle.mountCount).toBe(1);
expect(widgetLifecycle.mountCount).toBe(0);
expect(widgetLifecycle.unMountCount).toBe(1);
});

Expand Down

0 comments on commit 857067c

Please sign in to comment.