mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.6 KiB
115 lines
3.6 KiB
2 years ago
|
import { expect } from "@playwright/test";
|
||
2 years ago
|
import BasePage from "../../../Base";
|
||
2 years ago
|
import { ToolbarFieldsPage } from "./Fields";
|
||
|
import { ToolbarSortPage } from "./Sort";
|
||
|
import { ToolbarFilterPage } from "./Filter";
|
||
2 years ago
|
import { ToolbarShareViewPage } from "./ShareView";
|
||
2 years ago
|
import { ToolbarViewMenuPage } from "./ViewMenu";
|
||
2 years ago
|
import * as fs from "fs";
|
||
2 years ago
|
import { GridPage } from "../../Grid";
|
||
2 years ago
|
import { ToolbarActionsPage } from "./Actions";
|
||
2 years ago
|
import { GalleryPage } from "../../Gallery";
|
||
|
import { FormPage } from "../../Form";
|
||
2 years ago
|
|
||
|
export class ToolbarPage extends BasePage {
|
||
2 years ago
|
readonly parent: GridPage | GalleryPage | FormPage;
|
||
2 years ago
|
readonly fields: ToolbarFieldsPage;
|
||
|
readonly sort: ToolbarSortPage;
|
||
|
readonly filter: ToolbarFilterPage;
|
||
2 years ago
|
readonly shareView: ToolbarShareViewPage;
|
||
2 years ago
|
readonly viewsMenu: ToolbarViewMenuPage;
|
||
2 years ago
|
readonly actions: ToolbarActionsPage;
|
||
2 years ago
|
|
||
2 years ago
|
constructor(parent: GridPage | GalleryPage | FormPage) {
|
||
|
super(parent.rootPage);
|
||
|
this.parent = parent;
|
||
2 years ago
|
this.fields = new ToolbarFieldsPage(this);
|
||
|
this.sort = new ToolbarSortPage(this);
|
||
|
this.filter = new ToolbarFilterPage(this);
|
||
2 years ago
|
this.shareView = new ToolbarShareViewPage(this);
|
||
2 years ago
|
this.viewsMenu = new ToolbarViewMenuPage(this);
|
||
2 years ago
|
this.actions = new ToolbarActionsPage(this);
|
||
2 years ago
|
}
|
||
|
|
||
|
get() {
|
||
|
return this.rootPage.locator(`.nc-table-toolbar`);
|
||
|
}
|
||
|
|
||
2 years ago
|
async clickActions() {
|
||
|
const menuOpen = await this.actions.get().isVisible();
|
||
|
|
||
|
await this.get().locator(`button.nc-actions-menu-btn`).click();
|
||
|
|
||
|
// Wait for the menu to close
|
||
|
if (menuOpen) await this.fields.get().waitFor({ state: "hidden" });
|
||
|
}
|
||
|
|
||
|
|
||
2 years ago
|
async clickFields() {
|
||
2 years ago
|
const menuOpen = await this.fields.get().isVisible();
|
||
|
|
||
2 years ago
|
await this.get().locator(`button:has-text("Fields")`).click();
|
||
2 years ago
|
|
||
|
// Wait for the menu to close
|
||
2 years ago
|
if (menuOpen) await this.fields.get().waitFor({ state: "hidden" });
|
||
2 years ago
|
}
|
||
|
|
||
|
async clickSort() {
|
||
2 years ago
|
const menuOpen = await this.sort.get().isVisible();
|
||
|
|
||
2 years ago
|
await this.get().locator(`button:has-text("Sort")`).click();
|
||
2 years ago
|
|
||
|
// Wait for the menu to close
|
||
2 years ago
|
if (menuOpen) await this.sort.get().waitFor({ state: "hidden" });
|
||
2 years ago
|
}
|
||
|
|
||
|
async clickFilter() {
|
||
2 years ago
|
const menuOpen = await this.filter.get().isVisible();
|
||
|
|
||
2 years ago
|
await this.get().locator(`button:has-text("Filter")`).click();
|
||
2 years ago
|
|
||
|
// Wait for the menu to close
|
||
2 years ago
|
if (menuOpen) await this.filter.get().waitFor({ state: "hidden" });
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async clickShareView() {
|
||
2 years ago
|
const menuOpen = await this.shareView.get().isVisible();
|
||
2 years ago
|
await this.get().locator(`button:has-text("Share View")`).click();
|
||
2 years ago
|
|
||
|
// Wait for the menu to close
|
||
2 years ago
|
if (menuOpen) await this.shareView.get().waitFor({ state: "hidden" });
|
||
2 years ago
|
}
|
||
|
|
||
|
async clickAddNewRow() {
|
||
2 years ago
|
await this.get().locator(`.nc-toolbar-btn.nc-add-new-row-btn`).click();
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
|
async clickDownload(type: string, verificationFile: string) {
|
||
|
await this.get().locator(`.nc-toolbar-btn.nc-actions-menu-btn`).click();
|
||
|
|
||
|
const [download] = await Promise.all([
|
||
|
// Start waiting for the download
|
||
|
this.rootPage.waitForEvent("download"),
|
||
|
// Perform the action that initiates download
|
||
|
this.rootPage
|
||
|
.locator(`.nc-dropdown-actions-menu`)
|
||
|
.locator(`li.ant-dropdown-menu-item:has-text("${type}")`)
|
||
|
.click(),
|
||
|
]);
|
||
|
|
||
|
// Save downloaded file somewhere
|
||
|
await download.saveAs("./at.txt");
|
||
|
|
||
|
// verify downloaded content against expected content
|
||
|
const expectedData = fs.readFileSync("./fixtures/expectedData.txt", "utf8");
|
||
|
const file = fs.readFileSync("./at.txt", "utf8");
|
||
|
await expect(file).toEqual(expectedData);
|
||
|
}
|
||
2 years ago
|
|
||
|
async verifyDownloadDisabled() {
|
||
|
await this.get()
|
||
|
.locator(`.nc-toolbar-btn.nc-actions-menu-btn`)
|
||
|
.waitFor({ state: "hidden" });
|
||
|
}
|
||
2 years ago
|
}
|