Files
nocodb/tests/playwright/pages/Dashboard/Import/ImportTemplate.ts
Ramesh Mane 388b9d9590 Nc fix: replace ant design table (#9113)
* fix: replace ant design table

* feat(nc-gui): custom table component

* fix(nc-gui): udpate UIAcl table

* fix(nc-gui): table scrolling issue

* feat(nc-gui): sticky first column of custom table component

* fix(nc-gui): update meta sync ant table with new table

* fix(nc-gui): update import data table

* fix(nc-gui): update import & upload data modal table

* chore(nc-gui): lint

* fix(nc-gui): update all table tab table

* fix(nc-gui): update project members table

* fix(nc-gui): update collaborators list table

* fix(nc-gui): table list search section alignment issue

* fix(nc-gui): collaborators list overflow issue

* fix(nc-gui): small changes

* fix(nc-gui): update project home page tables height

* fix(nc-gui): update oss user table

* fix(nc-gui): small changes

* test(nc-gui): update ant table related test cases

* test(nc-gui): update oss user list test cases

* chore(nc-gui): lint

* chore(nc-gui): cleanup unused css

* fix(nc-gui): add missing invite team image state

* fix(nc-gui): user management test fail issue

* fix(test): oss user management test fails issue

* fix(nc-gui): some pr review changes

* fix(nc-gui): handle empty object entries destructuring case

* fix(nc-gui): pr review changes

* fix(nc-gui): disable ui acl header checkbox is list is empty

* fix(nc-gui): update oss user management pw test

---------

Co-authored-by: Pranav C <pranavxc@gmail.com>
2024-08-01 20:52:29 +05:30

82 lines
2.8 KiB
TypeScript

import { expect, Locator } from '@playwright/test';
import BasePage from '../../Base';
import { DashboardPage } from '..';
import { getTextExcludeIconText } from '../../../tests/utils/general';
export class ImportTemplatePage extends BasePage {
readonly dashboard: DashboardPage;
readonly importButton: Locator;
constructor(dashboard: DashboardPage) {
super(dashboard.rootPage);
this.dashboard = dashboard;
this.importButton = dashboard.get().locator('.nc-btn-import');
}
get() {
return this.dashboard.get().locator(`.nc-modal-quick-import`);
}
async getImportTableList() {
await this.get().locator(`.ant-collapse-header`).nth(0).waitFor();
const tr = this.get().locator(`.ant-collapse-header`);
const rowCount = await tr.count();
const tableList: string[] = [];
for (let i = 0; i < rowCount; i++) {
const tableName = await this.get()
.locator(`.ant-collapse-header`)
.nth(i)
.locator('input[type="text"]')
.inputValue();
tableList.push(tableName);
}
return tableList;
}
async getImportColumnList() {
// return an array
const columnList: { type: string; name: string }[] = [];
const tr = this.get().locator(`tr.nc-table-row:visible`);
const rowCount = await tr.count();
for (let i = 0; i < rowCount; i++) {
// replace \n and \t from innerText
const columnType = (await getTextExcludeIconText(tr.nth(i))).replace(/\n|\t/g, '');
const columnName = await tr.nth(i).locator(`input[type="text"]`).inputValue();
columnList.push({ type: columnType, name: columnName });
}
return columnList;
}
// todo: Add polling logic to assertions
async import({ file, result }: { file: string; result: any }) {
const importFile = this.get().locator(`input[type="file"]`);
await importFile.setInputFiles(file);
await this.importButton.click();
const tblList = await this.getImportTableList();
for (let i = 0; i < result.length; i++) {
expect(tblList[i]).toBe(result[i].name);
const columnList = await this.getImportColumnList();
expect(columnList).toEqual(result[i].columns);
if (i < result.length - 1) {
await this.expandTableList({ index: i + 1 });
}
}
await this.get().locator('button:has-text("Back"):visible').waitFor();
await this.waitForResponse({
requestUrlPathToMatch: '/api/v1/db/data/bulk/',
httpMethodsToMatch: ['POST'],
uiAction: () => this.get().locator('button:has-text("Import"):visible').click(),
});
await this.dashboard.waitForTabRender({
title: tblList[0],
});
}
private async expandTableList(param: { index: number }) {
await this.get().locator(`.ant-collapse-header`).nth(param.index).click();
await this.rootPage.waitForTimeout(1000);
}
}