Browse Source

test: import

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5363/head
Raju Udava 2 years ago
parent
commit
e102460fb4
  1. 8
      tests/playwright/pages/Dashboard/Import/ImportTemplate.ts
  2. 6
      tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts
  3. 6
      tests/playwright/pages/Dashboard/common/Toolbar/Sort.ts
  4. 22
      tests/playwright/tests/utils/general.ts

8
tests/playwright/pages/Dashboard/Import/ImportTemplate.ts

@ -1,6 +1,7 @@
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;
@ -22,7 +23,7 @@ export class ImportTemplatePage extends BasePage {
const rowCount = await tr.count();
const tableList: string[] = [];
for (let i = 0; i < rowCount; i++) {
const tableName = await tr.nth(i).innerText();
const tableName = await getTextExcludeIconText(tr.nth(i));
tableList.push(tableName);
}
return tableList;
@ -35,10 +36,7 @@ export class ImportTemplatePage extends BasePage {
const rowCount = await tr.count();
for (let i = 0; i < rowCount; i++) {
// replace \n and \t from innerText
const columnType = await tr
.nth(i)
.innerText()
.then(text => text.replace(/\n|\t/g, ''));
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 });
}

6
tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts

@ -2,6 +2,7 @@ import { expect } from '@playwright/test';
import BasePage from '../../../Base';
import { ToolbarPage } from './index';
import { UITypes } from 'nocodb-sdk';
import { getTextExcludeIconText } from '../../../../tests/utils/general';
export class ToolbarFilterPage extends BasePage {
readonly toolbar: ToolbarPage;
@ -16,7 +17,10 @@ export class ToolbarFilterPage extends BasePage {
}
async verify({ index, column, operator, value }: { index: number; column: string; operator: string; value: string }) {
await expect(this.get().locator('.nc-filter-field-select').nth(index)).toHaveText(column);
const fieldLocator = await this.get().locator('.nc-filter-field-select').nth(index);
const fieldText = await getTextExcludeIconText(fieldLocator);
await expect(fieldText).toBe(column);
await expect(this.get().locator('.nc-filter-operation-select').nth(index)).toHaveText(operator);
await expect
.poll(async () => await this.get().locator('.nc-filter-value-select > input').nth(index).inputValue())

6
tests/playwright/pages/Dashboard/common/Toolbar/Sort.ts

@ -1,6 +1,7 @@
import { expect } from '@playwright/test';
import BasePage from '../../../Base';
import { ToolbarPage } from './index';
import { getTextExcludeIconText } from '../../../../tests/utils/general';
export class ToolbarSortPage extends BasePage {
readonly toolbar: ToolbarPage;
@ -15,7 +16,10 @@ export class ToolbarSortPage extends BasePage {
}
async verify({ index, column, direction }: { index: number; column: string; direction: string }) {
await expect(this.get().locator('.nc-sort-field-select').nth(index)).toHaveText(column);
const fieldLocator = await this.get().locator('.nc-sort-field-select').nth(index);
const fieldText = await getTextExcludeIconText(fieldLocator);
await expect(fieldText).toBe(column);
await expect(
await this.get().locator('.nc-sort-dir-select >> span.ant-select-selection-item').nth(index)
).toHaveText(direction);

22
tests/playwright/tests/utils/general.ts

@ -0,0 +1,22 @@
// Selector objects include the text of any icons in the textContent property.
// This function removes the text of any icons from the textContent property.
async function getTextExcludeIconText(selector) {
// Get the text of the selector
let text = await selector.textContent();
// List of icons
const icons = await selector.locator('.material-symbols-outlined');
const iconCount = await icons.count();
// Remove the text of each icon from the text
for (let i = 0; i < iconCount; i++) {
await icons.nth(i).waitFor();
const iconText = await icons.nth(i).textContent();
text = text.replace(iconText, '');
}
// trim text for any spaces
return text.trim();
}
export { getTextExcludeIconText };
Loading…
Cancel
Save