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.
83 lines
2.9 KiB
83 lines
2.9 KiB
2 years ago
|
import { expect } from '@playwright/test';
|
||
|
import BasePage from '../../../Base';
|
||
|
import { ToolbarPage } from './index';
|
||
2 years ago
|
|
||
|
export class ToolbarFieldsPage extends BasePage {
|
||
|
readonly toolbar: ToolbarPage;
|
||
|
|
||
|
constructor(toolbar: ToolbarPage) {
|
||
|
super(toolbar.rootPage);
|
||
|
this.toolbar = toolbar;
|
||
|
}
|
||
|
|
||
|
get() {
|
||
2 years ago
|
return this.rootPage.locator(`[data-nc="nc-fields-menu"]`);
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
// todo: Click and toggle are similar method. Remove one of them
|
||
|
async toggle({ title, isLocallySaved }: { title: string; isLocallySaved?: boolean }) {
|
||
2 years ago
|
await this.toolbar.clickFields();
|
||
2 years ago
|
const toggleColumn = this.get()
|
||
2 years ago
|
.locator(`[data-nc="nc-fields-menu-${title}"]`)
|
||
2 years ago
|
.locator('input[type="checkbox"]')
|
||
|
.click();
|
||
2 years ago
|
|
||
|
await this.waitForResponse({
|
||
|
uiAction: toggleColumn,
|
||
2 years ago
|
requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
|
||
|
httpMethodsToMatch: ['GET'],
|
||
|
});
|
||
2 years ago
|
await this.toolbar.parent.dashboard.waitForLoaderToDisappear();
|
||
2 years ago
|
await this.toolbar.clickFields();
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
async verify({ title, checked }: { title: string; checked: boolean }) {
|
||
2 years ago
|
const checkbox = this.get().locator(`[data-nc="nc-fields-menu-${title}"]`).locator('input[type="checkbox"]');
|
||
2 years ago
|
|
||
|
if (checked) {
|
||
|
await expect(checkbox).toBeChecked();
|
||
|
} else {
|
||
|
await expect(checkbox).not.toBeChecked();
|
||
|
}
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async click({ title, isLocallySaved }: { title: string; isLocallySaved?: boolean }) {
|
||
|
await this.waitForResponse({
|
||
2 years ago
|
uiAction: this.get().locator(`[data-nc="nc-fields-menu-${title}"]`).locator('input[type="checkbox"]').click(),
|
||
2 years ago
|
requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
|
||
|
httpMethodsToMatch: ['GET'],
|
||
|
});
|
||
2 years ago
|
await this.toolbar.parent.waitLoading();
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
async hideAll({ isLocallySaved }: { isLocallySaved?: boolean } = {}) {
|
||
2 years ago
|
await this.toolbar.clickFields();
|
||
2 years ago
|
await this.waitForResponse({
|
||
|
uiAction: this.get().locator(`button:has-text("Hide all")`).click(),
|
||
2 years ago
|
requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
|
||
2 years ago
|
httpMethodsToMatch: ['GET'],
|
||
|
});
|
||
2 years ago
|
await this.toolbar.clickFields();
|
||
|
}
|
||
|
|
||
2 years ago
|
async showAll({ isLocallySaved }: { isLocallySaved?: boolean } = {}) {
|
||
2 years ago
|
await this.toolbar.clickFields();
|
||
2 years ago
|
await this.waitForResponse({
|
||
|
uiAction: this.get().locator(`button:has-text("Show all")`).click(),
|
||
2 years ago
|
requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
|
||
2 years ago
|
httpMethodsToMatch: ['GET'],
|
||
|
});
|
||
2 years ago
|
await this.toolbar.clickFields();
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
async toggleShowSystemFields({ isLocallySaved }: { isLocallySaved?: boolean } = {}) {
|
||
2 years ago
|
await this.toolbar.clickFields();
|
||
2 years ago
|
await this.waitForResponse({
|
||
|
uiAction: this.get().locator(`.nc-fields-show-system-fields`).click(),
|
||
2 years ago
|
requestUrlPathToMatch: isLocallySaved ? '/api/v1/db/public/' : '/api/v1/db/data/noco/',
|
||
2 years ago
|
httpMethodsToMatch: ['GET'],
|
||
|
});
|
||
2 years ago
|
await this.toolbar.clickFields();
|
||
|
}
|
||
2 years ago
|
}
|