From 73d23036b7f38726ff138af0d903171e20e5a625 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Sat, 2 Mar 2024 07:32:42 +0000 Subject: [PATCH] test(nc-gui): form view pw test fail issue --- .../nc-gui/components/smartsheet/Form.vue | 8 +++-- .../playwright/pages/Dashboard/Form/index.ts | 32 ++++++++++++------- .../tests/db/views/viewForm.spec.ts | 1 - 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Form.vue b/packages/nc-gui/components/smartsheet/Form.vue index 1349ca717d..d40ce79c5f 100644 --- a/packages/nc-gui/components/smartsheet/Form.vue +++ b/packages/nc-gui/components/smartsheet/Form.vue @@ -968,7 +968,7 @@ useEventListener( v-if="isEditable && !isLocked" v-model:value="formViewData.subheading" :placeholder="$t('msg.info.formDesc')" - class="nc-form-focus-element font-medium text-base !text-gray-500" + class="nc-form-focus-element font-medium text-base !text-gray-500 -ml-1" is-form-field :autofocus="activeRow === NcForm.subheading" :data-testid="NcForm.subheading" @@ -978,7 +978,7 @@ useEventListener( @@ -1386,6 +1386,7 @@ useEventListener( @@ -1447,6 +1448,7 @@ useEventListener( diff --git a/tests/playwright/pages/Dashboard/Form/index.ts b/tests/playwright/pages/Dashboard/Form/index.ts index 0b23414f2b..0f18392039 100644 --- a/tests/playwright/pages/Dashboard/Form/index.ts +++ b/tests/playwright/pages/Dashboard/Form/index.ts @@ -10,8 +10,7 @@ export class FormPage extends BasePage { readonly topbar: TopbarPage; // todo: All the locator should be private - readonly addAllButton: Locator; - readonly removeAllButton: Locator; + readonly addOrRemoveAllButton: Locator; readonly submitButton: Locator; readonly showAnotherFormRadioButton: Locator; @@ -30,8 +29,10 @@ export class FormPage extends BasePage { this.toolbar = new ToolbarPage(this); this.topbar = new TopbarPage(this); - this.addAllButton = dashboard.get().locator('[data-testid="nc-form-show-all-fields"]').locator('.nc-switch'); - this.removeAllButton = dashboard.get().locator('[data-testid="nc-form-show-all-fields"]').locator('.nc-switch'); + this.addOrRemoveAllButton = dashboard + .get() + .locator('[data-testid="nc-form-show-all-fields"]') + .locator('.nc-switch'); this.submitButton = dashboard.get().locator('[data-testid="nc-form-submit"]'); this.showAnotherFormRadioButton = dashboard.get().locator('[data-testid="nc-form-checkbox-submit-another-form"]'); @@ -40,8 +41,8 @@ export class FormPage extends BasePage { .locator('[data-testid="nc-form-checkbox-show-blank-form"]'); this.emailMeRadioButton = dashboard.get().locator('[data-testid="nc-form-checkbox-send-email"]'); this.formHeading = dashboard.get().locator('[data-testid="nc-form-heading"]'); - this.formSubHeading = dashboard.get().locator('[data-testid="nc-form-sub-heading"]'); - this.afterSubmitMsg = dashboard.get().locator('[data-testid="nc-form-after-submit-msg"]'); + this.formSubHeading = dashboard.get().locator('[data-testid="nc-form-sub-heading"] .tiptap.ProseMirror'); + this.afterSubmitMsg = dashboard.get().locator('[data-testid="nc-form-after-submit-msg"] .tiptap.ProseMirror'); this.formFields = dashboard.get().locator('.nc-form-fields-list'); } @@ -67,7 +68,7 @@ export class FormPage extends BasePage { } getFormFieldsInputHelpText() { - return this.get().locator('textarea[data-testid="nc-form-input-help-text"]:visible'); + return this.get().locator('[data-testid="nc-form-input-help-text"] .tiptap.ProseMirror:visible'); } async verifyFormFieldLabel({ index, label }: { index: number; label: string }) { @@ -83,7 +84,7 @@ export class FormPage extends BasePage { } async verifyAfterSubmitMsg({ msg }: { msg: string }) { - expect((await this.afterSubmitMsg.inputValue()).includes(msg)).toBeTruthy(); + expect((await this.afterSubmitMsg.textContent()).includes(msg)).toBeTruthy(); } async verifyFormViewFieldsOrder({ fields }: { fields: string[] }) { @@ -136,11 +137,18 @@ export class FormPage extends BasePage { } async removeAllFields() { - await this.removeAllButton.click(); + if (await this.addOrRemoveAllButton.isChecked()) { + await this.addOrRemoveAllButton.click(); + } else { + await this.addOrRemoveAllButton.click(); + await this.addOrRemoveAllButton.click(); + } } async addAllFields() { - await this.addAllButton.click(); + if (!(await this.addOrRemoveAllButton.isChecked())) { + await this.addOrRemoveAllButton.click(); + } } async configureHeader(param: { subtitle: string; title: string }) { @@ -166,7 +174,7 @@ export class FormPage extends BasePage { async verifyHeader(param: { subtitle: string; title: string }) { await expect.poll(async () => await this.formHeading.inputValue()).toBe(param.title); - await expect.poll(async () => await this.formSubHeading.inputValue()).toBe(param.subtitle); + await expect.poll(async () => await this.formSubHeading.textContent()).toBe(param.subtitle); } async fillForm(param: { field: string; value: string }[]) { @@ -233,7 +241,7 @@ export class FormPage extends BasePage { const fieldHelpText = this.get() .locator(`.nc-form-drag-${field.replace(' ', '')}`) - .locator('div[data-testid="nc-form-input-help-text-label"]'); + .locator('div[data-testid="nc-form-input-help-text-label"] .tiptap.ProseMirror'); await expect(fieldHelpText).toHaveText(helpText); } diff --git a/tests/playwright/tests/db/views/viewForm.spec.ts b/tests/playwright/tests/db/views/viewForm.spec.ts index 2c1e0f746b..ea14db981e 100644 --- a/tests/playwright/tests/db/views/viewForm.spec.ts +++ b/tests/playwright/tests/db/views/viewForm.spec.ts @@ -6,7 +6,6 @@ import { SharedFormPage } from '../../../pages/SharedForm'; import { Api, UITypes } from 'nocodb-sdk'; import { LoginPage } from '../../../pages/LoginPage'; import { getDefaultPwd } from '../../../tests/utils/general'; -import { WorkspacePage } from '../../../pages/WorkspacePage'; import { enableQuickRun, isEE } from '../../../setup/db'; // todo: Move most of the ui actions to page object and await on the api response