test(nc-gui): form view field validation test fail issue

This commit is contained in:
Ramesh Mane
2025-07-21 11:39:59 +00:00
parent 22883b0a0f
commit 1548ac7fc7
3 changed files with 9 additions and 7 deletions

View File

@@ -666,7 +666,7 @@ export class FormPage extends BasePage {
// ant-form-item-explain // ant-form-item-explain
const field = this.get().locator(`[data-testid="nc-form-fields"][data-title="${title}"]`); const field = this.get().locator(`[data-testid="nc-form-fields"][data-title="${title}"]`);
await field.scrollIntoViewIfNeeded(); await field.scrollIntoViewIfNeeded();
const fieldErrorEl = field.locator('.ant-form-item-explain-error'); const fieldErrorEl = field.locator('.ant-form-item-explain');
return { return {
locator: fieldErrorEl, locator: fieldErrorEl,

View File

@@ -150,22 +150,24 @@ export class SurveyFormPage extends BasePage {
} }
async getFormFieldErrors() { async getFormFieldErrors() {
const fieldErrorEl = this.get().locator('.ant-form-item-explain-error'); const fieldErrorEl = this.get().locator('.ant-form-item-explain');
return { return {
locator: fieldErrorEl, locator: fieldErrorEl,
verify: async ({ hasError, hasErrorMsg }: { hasError?: boolean; hasErrorMsg?: string | RegExp }) => { verify: async ({ hasError, hasErrorMsg }: { hasError?: boolean; hasErrorMsg?: string | RegExp }) => {
if (hasError !== undefined) { if (hasError !== undefined) {
if (hasError) { if (hasError) {
await expect(fieldErrorEl).toBeVisible(); await expect(fieldErrorEl.locator('.ant-form-item-explain-error').first()).toBeVisible();
} else { } else {
await expect(fieldErrorEl).not.toBeVisible(); await expect(fieldErrorEl.locator('.ant-form-item-explain-error').first()).not.toBeVisible();
} }
} }
if (hasErrorMsg !== undefined) { if (hasErrorMsg !== undefined) {
await expect(fieldErrorEl).toBeVisible(); await expect(fieldErrorEl.locator('.ant-form-item-explain-error').first()).toBeVisible();
await expect(fieldErrorEl.locator('> div').filter({ hasText: hasErrorMsg }).first()).toHaveText(hasErrorMsg); await expect(
fieldErrorEl.locator('.ant-form-item-explain-error').filter({ hasText: hasErrorMsg }).first()
).toHaveText(hasErrorMsg);
} }
}, },
}; };

View File

@@ -85,7 +85,7 @@ export class SharedFormPage extends BasePage {
async getFormFieldErrors({ title }: { title: string }) { async getFormFieldErrors({ title }: { title: string }) {
const field = this.get().getByTestId(`nc-shared-form-item-${title.replace(' ', '')}`); const field = this.get().getByTestId(`nc-shared-form-item-${title.replace(' ', '')}`);
await field.scrollIntoViewIfNeeded(); await field.scrollIntoViewIfNeeded();
const fieldErrorEl = field.locator('.ant-form-item-explain-error'); const fieldErrorEl = field.locator('.ant-form-item-explain');
return { return {
locator: fieldErrorEl, locator: fieldErrorEl,
verify: async ({ hasError, hasErrorMsg }: { hasError?: boolean; hasErrorMsg?: string | RegExp }) => { verify: async ({ hasError, hasErrorMsg }: { hasError?: boolean; hasErrorMsg?: string | RegExp }) => {