Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
assure column settings is open before editing or renaming columns
  • Loading branch information
ada-x64 committed Dec 4, 2023
1 parent fc0606a commit f91d3d1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
4 changes: 2 additions & 2 deletions rust/perspective-viewer/test/js/column_settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ test.describe("Plugin Styles", () => {
await exprCol.editBtn.waitFor();
await rowId.editBtn.waitFor({ state: "detached", timeout: 1000 });

await view.assureColumnSettingsClosed();
await exprCol.editBtn.click();
await checkTab(view.columnSettingsSidebar, false, true);
});
Expand All @@ -110,8 +111,7 @@ test.describe("Plugin Styles", () => {
let col = activeColumns.getColumnByName("expr");
await inactiveColumns.container.waitFor({ state: "hidden" });
await activeColumns.scrollToBottom();
await col.editBtn.click();
await sidebar.container.waitFor({ state: "visible" });
await view.assureColumnSettingsOpen(col);
await checkTab(sidebar, true, true, true);
let tabs = await sidebar.tabTitle.all();
await tabs[1].click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ let runTests = (title: string, beforeEachAndLocalTests: () => void) => {
let table = view.dataGrid.regularTable;

let col = await view.getOrCreateColumnByType("calendar");
await col.editBtn.click();
let name = await col.name.innerText();
expect(name).toBeTruthy();
let td = await table.getFirstCellByColumnName(name);
await td.waitFor();

// text style
view.assureColumnSettingsOpen(col);
await view.columnSettingsSidebar.openTab("style");
let contents = view.columnSettingsSidebar.styleTab.contents;
let checkbox = contents
Expand Down Expand Up @@ -173,13 +173,13 @@ let runTests = (title: string, beforeEachAndLocalTests: () => void) => {
let table = view.dataGrid.regularTable;

let col = await view.getOrCreateColumnByType("string");
await col.editBtn.click();
let name = await col.name.innerText();
expect(name).toBeTruthy();
let td = await table.getFirstCellByColumnName(name);
await td.waitFor();

// bg color
await view.assureColumnSettingsOpen(col);
await view.columnSettingsSidebar.openTab("style");
let contents = view.columnSettingsSidebar.styleTab.contents;
let checkbox = contents.locator("input[type=checkbox]").last();
Expand Down Expand Up @@ -208,7 +208,10 @@ runTests("Datagrid Column Styles", () => {
});
});

test("Edit highlights go away when view re-draws", async ({ page }) => {
// Keeping the column sidebar open makes this unncessary.
test.skip("Edit highlights go away when view re-draws", async ({
page,
}) => {
let viewer = new PspViewer(page);
await viewer.openSettingsPanel();
let btn = await viewer.dataGrid.regularTable.getEditBtnByName("Row ID");
Expand Down
Binary file modified tools/perspective-test/results.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions tools/perspective-test/src/js/models/column_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

import { Locator } from "@playwright/test";
import { Locator, expect } from "@playwright/test";
import { PageView } from "./page";

export class ColumnSettingsSidebar {
Expand All @@ -37,7 +37,7 @@ export class ColumnSettingsSidebar {

async openTab(name: string) {
let locator = this.tabTitle.filter({ hasText: name });
await locator.click();
await locator.click({ timeout: 1000 });
await this.container
.locator(".tab.selected", { hasText: name })
.waitFor({ timeout: 1000 });
Expand Down
20 changes: 19 additions & 1 deletion tools/perspective-test/src/js/models/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import { Locator, Page, expect } from "@playwright/test";
import { ColumnSettingsSidebar } from "./column_settings";
import { ColumnType, SettingsPanel } from "./settings_panel";
import { ColumnSelector, ColumnType, SettingsPanel } from "./settings_panel";
import { DataGridPlugin } from "./plugins";

/**
Expand Down Expand Up @@ -96,4 +96,22 @@ export class PageView {
await viewer!.restore(settings);
}, settings);
}

async assureColumnSettingsOpen(column: ColumnSelector) {
let isEditing = await column.editBtn.evaluate((btn) =>
btn.className.includes("is-editing")
);
if (!isEditing) {
this.container.evaluate((_) =>
console.log("COLUMN SETTINGS CLOSED")
);
await column.editBtn.click({ force: true });
}
expect(this.container).toBeVisible({ timeout: 1000 });
}
async assureColumnSettingsClosed() {
if (await this.columnSettingsSidebar.container.isVisible()) {
await this.columnSettingsSidebar.closeBtn.click();
}
}
}
5 changes: 3 additions & 2 deletions tools/perspective-test/src/js/models/settings_panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class SettingsPanel {
this.orderbyInput = viewer.locator("#sort input");
this.whereInput = viewer.locator("#filter input");
}

/**
* Creates and saves a new expression column.
* @param expr
Expand Down Expand Up @@ -92,7 +93,7 @@ export class SettingsPanel {
* @param expr
*/
async renameExpression(column: ColumnSelector, name: string) {
await column.editBtn.click();
this.pageView.assureColumnSettingsOpen(column);
let sidebar = this.pageView.columnSettingsSidebar;
await sidebar.nameInput.waitFor({
state: "visible",
Expand All @@ -106,7 +107,7 @@ export class SettingsPanel {
}

async editExpression(column: ColumnSelector, newExpression: string) {
await column.editBtn.click();
this.pageView.assureColumnSettingsOpen(column);
let sidebar = this.pageView.columnSettingsSidebar;
await sidebar.openTab("Attributes");
let exprEditor = sidebar.attributesTab.expressionEditor;
Expand Down

0 comments on commit f91d3d1

Please sign in to comment.