Browse Source

test(nc-gui): form view pw test fail issue

pull/7741/head
Ramesh Mane 10 months ago
parent
commit
73d23036b7
  1. 8
      packages/nc-gui/components/smartsheet/Form.vue
  2. 32
      tests/playwright/pages/Dashboard/Form/index.ts
  3. 1
      tests/playwright/tests/db/views/viewForm.spec.ts

8
packages/nc-gui/components/smartsheet/Form.vue

@ -968,7 +968,7 @@ useEventListener(
v-if="isEditable && !isLocked" v-if="isEditable && !isLocked"
v-model:value="formViewData.subheading" v-model:value="formViewData.subheading"
:placeholder="$t('msg.info.formDesc')" :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 is-form-field
:autofocus="activeRow === NcForm.subheading" :autofocus="activeRow === NcForm.subheading"
:data-testid="NcForm.subheading" :data-testid="NcForm.subheading"
@ -978,7 +978,7 @@ useEventListener(
<LazyCellRichText <LazyCellRichText
v-else-if="formViewData.subheading" v-else-if="formViewData.subheading"
:value="formViewData.subheading" :value="formViewData.subheading"
class="font-medium text-base !text-gray-500" class="font-medium text-base !text-gray-500 -ml-1"
is-form-field is-form-field
read-only read-only
sync-value-change sync-value-change
@ -1042,7 +1042,7 @@ useEventListener(
is-form-field is-form-field
read-only read-only
sync-value-change sync-value-change
class="nc-form-help-text text-gray-500 text-sm mt-2" class="nc-form-help-text text-gray-500 text-sm mt-2 -ml-1"
data-testid="nc-form-help-text" data-testid="nc-form-help-text"
@update:value="updateColMeta(element)" @update:value="updateColMeta(element)"
/> />
@ -1386,6 +1386,7 @@ useEventListener(
<a-switch <a-switch
:checked="visibleColumns.length === localColumns.length" :checked="visibleColumns.length === localColumns.length"
size="small" size="small"
class="nc-switch"
@change="handleAddOrRemoveAllColumns" @change="handleAddOrRemoveAllColumns"
/> />
</div> </div>
@ -1447,6 +1448,7 @@ useEventListener(
<a-switch <a-switch
:checked="!!field.show" :checked="!!field.show"
:disabled="field.required || isLocked || !isEditable" :disabled="field.required || isLocked || !isEditable"
class="nc-switch"
size="small" size="small"
/> />
</div> </div>

32
tests/playwright/pages/Dashboard/Form/index.ts

@ -10,8 +10,7 @@ export class FormPage extends BasePage {
readonly topbar: TopbarPage; readonly topbar: TopbarPage;
// todo: All the locator should be private // todo: All the locator should be private
readonly addAllButton: Locator; readonly addOrRemoveAllButton: Locator;
readonly removeAllButton: Locator;
readonly submitButton: Locator; readonly submitButton: Locator;
readonly showAnotherFormRadioButton: Locator; readonly showAnotherFormRadioButton: Locator;
@ -30,8 +29,10 @@ export class FormPage extends BasePage {
this.toolbar = new ToolbarPage(this); this.toolbar = new ToolbarPage(this);
this.topbar = new TopbarPage(this); this.topbar = new TopbarPage(this);
this.addAllButton = dashboard.get().locator('[data-testid="nc-form-show-all-fields"]').locator('.nc-switch'); this.addOrRemoveAllButton = dashboard
this.removeAllButton = dashboard.get().locator('[data-testid="nc-form-show-all-fields"]').locator('.nc-switch'); .get()
.locator('[data-testid="nc-form-show-all-fields"]')
.locator('.nc-switch');
this.submitButton = dashboard.get().locator('[data-testid="nc-form-submit"]'); this.submitButton = dashboard.get().locator('[data-testid="nc-form-submit"]');
this.showAnotherFormRadioButton = dashboard.get().locator('[data-testid="nc-form-checkbox-submit-another-form"]'); 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"]'); .locator('[data-testid="nc-form-checkbox-show-blank-form"]');
this.emailMeRadioButton = dashboard.get().locator('[data-testid="nc-form-checkbox-send-email"]'); this.emailMeRadioButton = dashboard.get().locator('[data-testid="nc-form-checkbox-send-email"]');
this.formHeading = dashboard.get().locator('[data-testid="nc-form-heading"]'); this.formHeading = dashboard.get().locator('[data-testid="nc-form-heading"]');
this.formSubHeading = dashboard.get().locator('[data-testid="nc-form-sub-heading"]'); 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"]'); this.afterSubmitMsg = dashboard.get().locator('[data-testid="nc-form-after-submit-msg"] .tiptap.ProseMirror');
this.formFields = dashboard.get().locator('.nc-form-fields-list'); this.formFields = dashboard.get().locator('.nc-form-fields-list');
} }
@ -67,7 +68,7 @@ export class FormPage extends BasePage {
} }
getFormFieldsInputHelpText() { 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 }) { async verifyFormFieldLabel({ index, label }: { index: number; label: string }) {
@ -83,7 +84,7 @@ export class FormPage extends BasePage {
} }
async verifyAfterSubmitMsg({ msg }: { msg: string }) { 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[] }) { async verifyFormViewFieldsOrder({ fields }: { fields: string[] }) {
@ -136,11 +137,18 @@ export class FormPage extends BasePage {
} }
async removeAllFields() { 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() { async addAllFields() {
await this.addAllButton.click(); if (!(await this.addOrRemoveAllButton.isChecked())) {
await this.addOrRemoveAllButton.click();
}
} }
async configureHeader(param: { subtitle: string; title: string }) { async configureHeader(param: { subtitle: string; title: string }) {
@ -166,7 +174,7 @@ export class FormPage extends BasePage {
async verifyHeader(param: { subtitle: string; title: string }) { async verifyHeader(param: { subtitle: string; title: string }) {
await expect.poll(async () => await this.formHeading.inputValue()).toBe(param.title); 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 }[]) { async fillForm(param: { field: string; value: string }[]) {
@ -233,7 +241,7 @@ export class FormPage extends BasePage {
const fieldHelpText = this.get() const fieldHelpText = this.get()
.locator(`.nc-form-drag-${field.replace(' ', '')}`) .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); await expect(fieldHelpText).toHaveText(helpText);
} }

1
tests/playwright/tests/db/views/viewForm.spec.ts

@ -6,7 +6,6 @@ import { SharedFormPage } from '../../../pages/SharedForm';
import { Api, UITypes } from 'nocodb-sdk'; import { Api, UITypes } from 'nocodb-sdk';
import { LoginPage } from '../../../pages/LoginPage'; import { LoginPage } from '../../../pages/LoginPage';
import { getDefaultPwd } from '../../../tests/utils/general'; import { getDefaultPwd } from '../../../tests/utils/general';
import { WorkspacePage } from '../../../pages/WorkspacePage';
import { enableQuickRun, isEE } from '../../../setup/db'; import { enableQuickRun, isEE } from '../../../setup/db';
// todo: Move most of the ui actions to page object and await on the api response // todo: Move most of the ui actions to page object and await on the api response

Loading…
Cancel
Save