Browse Source

feat: snapshot crud tests

pull/9879/head
DarkPhoenix2704 1 month ago
parent
commit
049c52386a
  1. 57
      tests/playwright/pages/Dashboard/ProjectView/Settings.ts
  2. 3
      tests/playwright/pages/Dashboard/ProjectView/index.ts

57
tests/playwright/pages/Dashboard/ProjectView/Settings.ts

@ -0,0 +1,57 @@
import BasePage from '../../Base';
import { ProjectViewPage } from './index';
import { expect } from '@playwright/test';
export class BaseSettingsPage extends BasePage {
readonly dashboard: DashboardPage;
readonly baseView: ProjectViewPage;
constructor(baseView: ProjectViewPage) {
super(baseView.rootPage);
this.baseView = baseView;
}
get() {
return this.baseView.get().locator('.nc-base-settings');
}
async changeTab(tabName: 'snapshots' | 'visibility') {
await this.get().getByTestId(`${tabName}-tab`).click();
await this.rootPage.waitForTimeout(1000);
}
async createSnapshot({ snapshotName }: { snapshotName: string }) {
await this.rootPage.getByTestId('add-new-snapshot').click();
await this.rootPage.waitForTimeout(1000);
await this.rootPage.locator('.new-snapshot-title').fill(snapshotName);
await this.rootPage.getByTestId('create-snapshot-btn').click();
await this.rootPage.waitForTimeout(1000);
}
async deleteSnapshot({ snapshotName }: { snapshotName: string }) {
await this.rootPage.getByTestId(`snapshot-${snapshotName}`).getByTestId('delete-snapshot-btn').click();
await this.rootPage.getByTestId('nc-delete-modal-delete-btn').click();
await this.rootPage.waitForTimeout(1000);
}
async restoreSnapshot({ snapshotName }: { snapshotName: string }) {
await this.rootPage.getByTestId(`snapshot-${snapshotName}`).getByTestId('restore-snapshot-btn').click();
await this.rootPage.getByTestId('confirm-restore-snapshot-btn').click();
await this.rootPage.waitForTimeout(3000);
}
async verifySnapshot({ snapshotName, isVisible }: { snapshotName: string; isVisible: boolean }) {
const snapshot = this.rootPage.getByTestId(`snapshot-${snapshotName}`);
if (isVisible) {
await expect(snapshot).toBeVisible({ visible: true });
} else {
await expect(snapshot).toBeVisible({ visible: false });
}
}
}

3
tests/playwright/pages/Dashboard/ProjectView/index.ts

@ -4,6 +4,7 @@ import BasePage from '../../Base';
import { DataSourcePage } from './DataSourcePage';
import { TablesViewPage } from './TablesViewPage';
import { AccessSettingsPage } from './AccessSettingsPage';
import { BaseSettingsPage } from './Settings';
export class ProjectViewPage extends BasePage {
readonly dashboard: DashboardPage;
@ -12,6 +13,7 @@ export class ProjectViewPage extends BasePage {
readonly dataSources: DataSourcePage;
readonly tables: TablesViewPage;
readonly accessSettings: AccessSettingsPage;
readonly settings: BaseSettingsPage;
// assets
readonly tab_allTables: Locator;
@ -30,6 +32,7 @@ export class ProjectViewPage extends BasePage {
this.tables = new TablesViewPage(this);
this.dataSources = new DataSourcePage(this);
this.accessSettings = new AccessSettingsPage(this);
this.settings = new BaseSettingsPage(this);
this.tab_allTables = this.get().locator('[data-testid="proj-view-tab__all-tables"]');
this.tab_dataSources = this.get().locator('[data-testid="proj-view-tab__data-sources"]');

Loading…
Cancel
Save