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.
122 lines
4.1 KiB
122 lines
4.1 KiB
2 years ago
|
import { expect, Locator } from '@playwright/test';
|
||
|
import BasePage from '../../../Base';
|
||
|
import { GridPage } from '../../Grid';
|
||
|
import { ToolbarPage } from './index';
|
||
2 years ago
|
// @ts-ignore
|
||
2 years ago
|
import fs from 'fs';
|
||
2 years ago
|
|
||
|
export class ToolbarViewMenuPage extends BasePage {
|
||
|
readonly toolbar: ToolbarPage;
|
||
|
readonly viewsMenuBtn: Locator;
|
||
|
|
||
|
constructor(toolbar: ToolbarPage) {
|
||
|
super(toolbar.rootPage);
|
||
|
this.toolbar = toolbar;
|
||
|
this.viewsMenuBtn = this.toolbar.get().locator(`.nc-actions-menu-btn`);
|
||
|
}
|
||
|
|
||
|
get() {
|
||
|
return this.rootPage.locator(`.ant-dropdown.nc-dropdown-actions-menu`);
|
||
|
}
|
||
|
|
||
|
getLockTypeSubMenu() {
|
||
|
return this.rootPage.locator(`[id="sub_menu_1_$$_lock-type-popup"]`);
|
||
|
}
|
||
|
|
||
2 years ago
|
async verifyDownloadAsCSV({
|
||
|
downloadLocator,
|
||
|
expectedDataFile,
|
||
|
}: {
|
||
|
downloadLocator: Locator;
|
||
|
expectedDataFile: string;
|
||
|
}) {
|
||
|
const [download] = await Promise.all([
|
||
|
// Start waiting for the download
|
||
2 years ago
|
this.rootPage.waitForEvent('download'),
|
||
2 years ago
|
// Perform the action that initiates download
|
||
|
downloadLocator.click(),
|
||
|
]);
|
||
|
|
||
|
// Save downloaded file somewhere
|
||
2 years ago
|
await download.saveAs('./output/at.txt');
|
||
2 years ago
|
|
||
|
// verify downloaded content against expected content
|
||
2 years ago
|
const expectedData = fs.readFileSync(expectedDataFile, 'utf8');
|
||
|
const file = fs.readFileSync('./output/at.txt', 'utf8');
|
||
2 years ago
|
await expect(file).toEqual(expectedData);
|
||
|
}
|
||
|
|
||
2 years ago
|
// menu items
|
||
|
// Collaborative View
|
||
|
// Download
|
||
|
// Upload
|
||
|
// Shared View List
|
||
|
// Webhooks
|
||
|
// Get API Snippet
|
||
|
// ERD View
|
||
|
|
||
2 years ago
|
// todo: Move verification out of the click method
|
||
|
async click({ menu, subMenu, verificationInfo }: { menu: string; subMenu?: string; verificationInfo?: any }) {
|
||
2 years ago
|
await this.viewsMenuBtn.click();
|
||
2 years ago
|
await this.get().locator(`.ant-dropdown-menu-title-content:has-text("${menu}")`).first().click();
|
||
2 years ago
|
if (subMenu) {
|
||
2 years ago
|
// for CSV download, pass locator instead of clicking it here
|
||
2 years ago
|
if (subMenu === 'Download as CSV') {
|
||
2 years ago
|
await this.verifyDownloadAsCSV({
|
||
|
downloadLocator: await this.rootPage
|
||
|
.locator(`.ant-dropdown-menu-title-content:has-text("${subMenu}")`)
|
||
|
.last(),
|
||
2 years ago
|
expectedDataFile: verificationInfo?.verificationFile ?? './fixtures/expectedBaseDownloadData.txt',
|
||
2 years ago
|
});
|
||
|
} else {
|
||
2 years ago
|
await this.rootPage.locator(`.ant-dropdown-menu-title-content:has-text("${subMenu}")`).last().click();
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
switch (subMenu) {
|
||
2 years ago
|
case 'Download as CSV':
|
||
2 years ago
|
await this.verifyToast({
|
||
2 years ago
|
message: 'Successfully exported all table data',
|
||
2 years ago
|
});
|
||
|
break;
|
||
2 years ago
|
case 'Locked View':
|
||
2 years ago
|
await this.verifyToast({
|
||
2 years ago
|
message: 'Successfully Switched to locked view',
|
||
2 years ago
|
});
|
||
|
break;
|
||
2 years ago
|
case 'Collaborative View':
|
||
2 years ago
|
await this.verifyToast({
|
||
2 years ago
|
message: 'Successfully Switched to collaborative view',
|
||
2 years ago
|
});
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
2 years ago
|
await this.toolbar.parent.waitLoading();
|
||
2 years ago
|
}
|
||
|
|
||
|
async verifyLockMode() {
|
||
2 years ago
|
await expect(await this.toolbar.get().locator(`.nc-fields-menu-btn.nc-toolbar-btn`)).toBeDisabled();
|
||
|
await expect(await this.toolbar.get().locator(`.nc-filter-menu-btn.nc-toolbar-btn`)).toBeDisabled();
|
||
|
await expect(await this.toolbar.get().locator(`.nc-sort-menu-btn.nc-toolbar-btn`)).toBeDisabled();
|
||
2 years ago
|
await expect(
|
||
2 years ago
|
await this.toolbar.get().locator(`.nc-add-new-row-btn.nc-toolbar-btn > .nc-icon.disabled`)
|
||
2 years ago
|
).toBeVisible();
|
||
|
|
||
2 years ago
|
await (this.toolbar.parent as GridPage).verifyEditDisabled({
|
||
2 years ago
|
columnHeader: 'Country',
|
||
2 years ago
|
});
|
||
2 years ago
|
}
|
||
|
|
||
|
async verifyCollaborativeMode() {
|
||
2 years ago
|
await expect(await this.toolbar.get().locator(`.nc-fields-menu-btn.nc-toolbar-btn`)).toBeEnabled();
|
||
|
await expect(await this.toolbar.get().locator(`.nc-filter-menu-btn.nc-toolbar-btn`)).toBeEnabled();
|
||
|
await expect(await this.toolbar.get().locator(`.nc-sort-menu-btn.nc-toolbar-btn`)).toBeEnabled();
|
||
|
await expect(await this.toolbar.get().locator(`.nc-add-new-row-btn.nc-toolbar-btn > .nc-icon`)).toBeVisible();
|
||
2 years ago
|
|
||
2 years ago
|
await (this.toolbar.parent as GridPage).verifyEditEnabled({
|
||
2 years ago
|
columnHeader: 'Country',
|
||
2 years ago
|
});
|
||
2 years ago
|
}
|
||
|
}
|