From 6e028614657a10b2ba6a157afe846d9cfd0a4e20 Mon Sep 17 00:00:00 2001 From: ada mandala Date: Thu, 11 Jan 2024 11:08:15 -0600 Subject: [PATCH] fix broken and flaky tests --- .../js/column_settings/attributes_tab.spec.ts | 1 - .../js/column_settings/interactions.spec.ts | 47 ++++++++++++------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/rust/perspective-viewer/test/js/column_settings/attributes_tab.spec.ts b/rust/perspective-viewer/test/js/column_settings/attributes_tab.spec.ts index d49c34bb87..30fba88cfe 100644 --- a/rust/perspective-viewer/test/js/column_settings/attributes_tab.spec.ts +++ b/rust/perspective-viewer/test/js/column_settings/attributes_tab.spec.ts @@ -139,7 +139,6 @@ test.describe("Attributes Tab", () => { await expr.activeBtn.click(); expr = await view.settingsPanel.inactiveColumns.getColumnByName("expr"); - await expr.editBtn.click(); await expect(attributesTab.deleteBtn).toBeEnabled(); await attributesTab.deleteBtn.click(); await expect(attributesTab.container).toBeHidden(); diff --git a/rust/perspective-viewer/test/js/column_settings/interactions.spec.ts b/rust/perspective-viewer/test/js/column_settings/interactions.spec.ts index cf81a18e67..9a839324f1 100644 --- a/rust/perspective-viewer/test/js/column_settings/interactions.spec.ts +++ b/rust/perspective-viewer/test/js/column_settings/interactions.spec.ts @@ -261,39 +261,52 @@ async function checkOutput( expected: ExpectedState, initial_state: SidebarState ) { + const POSSIBLE_TABS = ["Style", "Attributes"]; + + const check_tabs = async (selectedTab, tabs, unexpected_tabs) => { + await view.columnSettingsSidebar.container + .locator(".tab.selected") + .getByText(selectedTab) + .waitFor(); + for (let tab of tabs) { + await view.columnSettingsSidebar.tabTitle.getByText(tab).waitFor(); + } + for (let tab of unexpected_tabs) { + await view.columnSettingsSidebar.tabTitle + .getByText(tab) + .waitFor({ state: "hidden" }); + } + }; + if ("type" in expected) { - view.columnSettingsSidebar.container + await view.columnSettingsSidebar.container .locator(`.type-icon.${expected.type}`) - .waitFor({ timeout: 3000 }); + .waitFor(); } if ("unchanged" in expected) { if (!initial_state.open) { await expect(view.columnSettingsSidebar.container).toBeHidden({ timeout: 1000, }); - } else if ("type" in expected) { - expect(await view.columnSettingsSidebar.getSelectedTab()).toBe( - initial_state.selectedTab + } else { + const unexpected_tabs = POSSIBLE_TABS.filter( + (t) => !initial_state.tabs.includes(t) ); - expect(await view.columnSettingsSidebar.getTabs()).toStrictEqual( - initial_state.tabs + await check_tabs( + initial_state.selectedTab, + initial_state.tabs, + unexpected_tabs ); - } else { - expect( - await view.columnSettingsSidebar.container.innerHTML() - ).toEqual(initial_state.snapshot); } } else if ("closed" in expected) { await expect(view.columnSettingsSidebar.container).toBeHidden({ timeout: 1000, }); } else { - expect(await view.columnSettingsSidebar.getSelectedTab()).toBe( - expected.selectedTab - ); - expect(await view.columnSettingsSidebar.getTabs()).toStrictEqual( - expected.tabs + const unexpected_tabs = POSSIBLE_TABS.filter( + (t) => !expected.tabs.includes(t) ); + await check_tabs(expected.selectedTab, expected.tabs, unexpected_tabs); } } @@ -321,7 +334,7 @@ test.describe("Column Settings State on Interaction", () => { "where", ], text: ["reorder", "open", "deactivate"], - dnd: ["open", "deactivate", "groupby"], + dnd: ["open", "deactivate", "groupby", "splitby"], }; for (const [name, spec] of Object.entries(TEST_SPEC)) {