Browse Source

update tests for invalid function error

pull/7305/head
starbirdtech383 1 year ago committed by starbirdtech383
parent
commit
478c347e92
  1. 6
      tests/playwright/pages/Base.ts
  2. 13
      tests/playwright/pages/Dashboard/Grid/Column/index.ts
  3. 7
      tests/playwright/tests/db/columns/columnFormula.spec.ts

6
tests/playwright/pages/Base.ts

@ -16,10 +16,8 @@ export default abstract class BasePage {
await this.rootPage.locator('.ant-message .ant-message-notice-content', { hasText: message }).last().isVisible();
}
async verifyLastToast({ message }: { message: string }) {
await expect(
this.rootPage.locator('.ant-message .ant-message-notice-content', { hasText: message }).last()
).toHaveText(message);
async verifyErrorMessage({ message }: { message: RegExp }) {
await expect(this.get().locator('.ant-form-item-explain-error', { hasText: message })).toBeVisible();
}
async waitForResponse({

13
tests/playwright/pages/Dashboard/Grid/Column/index.ts

@ -375,17 +375,12 @@ export class ColumnPageObject extends BasePage {
await this.rootPage.waitForTimeout(200);
}
async saveFail({ errorMessage }: { errorMessage?: string } = {}) {
await this.waitForResponse({
uiAction: async () => await this.get().locator('button:has-text("Save")').click(),
requestUrlPathToMatch: 'api/v1/db/meta',
httpMethodsToMatch: ['GET', 'PATCH'],
responseStatusCodeToMatch: 400,
});
await this.verifyLastToast({
async checkMessageAndClose({ errorMessage }: { errorMessage?: RegExp } = {}) {
await this.verifyErrorMessage({
message: errorMessage,
});
await this.get().waitFor({ state: 'visible' });
await this.get().locator('button:has-text("Cancel")').click();
await this.get().waitFor({ state: 'hidden' });
await this.rootPage.waitForTimeout(200);
}

7
tests/playwright/tests/db/columns/columnFormula.spec.ts

@ -117,10 +117,12 @@ const formulaDataByDbType = (context: NcContext, index: number) => {
{
formula: 'ROUNDDOWN({CityId} + 2.49, 1)',
result: ['3.4', '4.4', '5.4', '6.4', '7.4'],
unSupDbType: ['sqlite3'],
},
{
formula: 'ROUNDUP({CityId} + 2.49, 1)',
result: ['3.5', '4.5', '5.5', '6.5', '7.5'],
unSupDbType: ['sqlite3'],
},
{
formula: 'RECORD_ID()',
@ -132,13 +134,11 @@ const formulaDataByDbType = (context: NcContext, index: number) => {
unSupDbType: ['sqlite3'],
},
{
// TODO: this is bug in mysql, its being case in-sensitive.
formula: 'REGEX_EXTRACT({City}, "a[a-z]a")',
result: ['', '', '', '', 'ana'],
unSupDbType: ['sqlite3'],
},
{
// TODO: this is bug in mysql, its being case in-sensitive.
formula: 'REGEX_REPLACE({City}, "a[a-z]a","...")',
result: ['A Corua (La Corua)', 'Abha', 'Abu Dhabi', 'Acua', 'Ad...'],
unSupDbType: ['sqlite3'],
@ -277,9 +277,10 @@ test.describe('Virtual Columns', () => {
type: 'Formula',
formula: formulaData[i].formula,
});
console.log(`running test function: ${formulaData[i].formula}`);
if (formulaData[i].unSupDbType?.includes(dbType)) {
// assert for message not supported or greyed out save button.
await dashboard.grid.column.saveFail({ errorMessage: 'Invalid Formula' });
await dashboard.grid.column.checkMessageAndClose({ errorMessage: new RegExp('Function .* is not available') });
continue;
}
await dashboard.grid.column.save({ isUpdated: true });

Loading…
Cancel
Save