diff --git a/tests/playwright/pages/Dashboard/Import/ImportTemplate.ts b/tests/playwright/pages/Dashboard/Import/ImportTemplate.ts index 9db97b3318..bc9afbfb4f 100644 --- a/tests/playwright/pages/Dashboard/Import/ImportTemplate.ts +++ b/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 }); } diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts b/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts index ee69da6728..285898a0e5 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts +++ b/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()) diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/Sort.ts b/tests/playwright/pages/Dashboard/common/Toolbar/Sort.ts index 7da27ba7fe..d006d46818 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/Sort.ts +++ b/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); diff --git a/tests/playwright/tests/utils/general.ts b/tests/playwright/tests/utils/general.ts new file mode 100644 index 0000000000..1571666b1a --- /dev/null +++ b/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 };