|
|
@ -79,62 +79,60 @@ export class FormPage extends BasePage { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async verifyFormFieldLabel({ index, label }: { index: number; label: string }) { |
|
|
|
async verifyFormFieldLabel({ index, label }: { index: number; label: string }) { |
|
|
|
await expect(await this.getFormFields().nth(index).locator('[data-testid="nc-form-input-label"]')).toContainText( |
|
|
|
await expect(this.getFormFields().nth(index).locator('[data-testid="nc-form-input-label"]')).toContainText(label); |
|
|
|
label |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async verifyFormFieldHelpText({ index, helpText }: { index: number; helpText: string }) { |
|
|
|
async verifyFormFieldHelpText({ index, helpText }: { index: number; helpText: string }) { |
|
|
|
await expect( |
|
|
|
await expect( |
|
|
|
await this.getFormFields().nth(index).locator('[data-testid="nc-form-input-help-text-label"]') |
|
|
|
this.getFormFields().nth(index).locator('[data-testid="nc-form-input-help-text-label"]') |
|
|
|
).toContainText(helpText); |
|
|
|
).toContainText(helpText); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async verifyFieldsIsEditable({ index }: { index: number }) { |
|
|
|
async verifyFieldsIsEditable({ index }: { index: number }) { |
|
|
|
await expect(await this.getFormFields().nth(index)).toHaveClass(/nc-editable/); |
|
|
|
await expect(this.getFormFields().nth(index)).toHaveClass(/nc-editable/); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async verifyAfterSubmitMsg({ msg }: { msg: string }) { |
|
|
|
async verifyAfterSubmitMsg({ msg }: { msg: string }) { |
|
|
|
await expect((await this.afterSubmitMsg.inputValue()).includes(msg)).toBeTruthy(); |
|
|
|
expect((await this.afterSubmitMsg.inputValue()).includes(msg)).toBeTruthy(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async verifyFormViewFieldsOrder({ fields }: { fields: string[] }) { |
|
|
|
async verifyFormViewFieldsOrder({ fields }: { fields: string[] }) { |
|
|
|
const fieldLabels = await this.get().locator('[data-testid="nc-form-input-label"]'); |
|
|
|
const fieldLabels = this.get().locator('[data-testid="nc-form-input-label"]'); |
|
|
|
await expect(await fieldLabels).toHaveCount(fields.length); |
|
|
|
await expect(fieldLabels).toHaveCount(fields.length); |
|
|
|
for (let i = 0; i < fields.length; i++) { |
|
|
|
for (let i = 0; i < fields.length; i++) { |
|
|
|
await expect(await fieldLabels.nth(i)).toContainText(fields[i]); |
|
|
|
await expect(fieldLabels.nth(i)).toContainText(fields[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async reorderFields({ sourceField, destinationField }: { sourceField: string; destinationField: string }) { |
|
|
|
async reorderFields({ sourceField, destinationField }: { sourceField: string; destinationField: string }) { |
|
|
|
await expect(await this.get().locator(`.nc-form-drag-${sourceField}`)).toBeVisible(); |
|
|
|
await expect(this.get().locator(`.nc-form-drag-${sourceField}`)).toBeVisible(); |
|
|
|
await expect(await this.get().locator(`.nc-form-drag-${destinationField}`)).toBeVisible(); |
|
|
|
await expect(this.get().locator(`.nc-form-drag-${destinationField}`)).toBeVisible(); |
|
|
|
const src = await this.get().locator(`.nc-form-drag-${sourceField.replace(' ', '')}`); |
|
|
|
const src = this.get().locator(`.nc-form-drag-${sourceField.replace(' ', '')}`); |
|
|
|
const dst = await this.get().locator(`.nc-form-drag-${destinationField.replace(' ', '')}`); |
|
|
|
const dst = this.get().locator(`.nc-form-drag-${destinationField.replace(' ', '')}`); |
|
|
|
await src.dragTo(dst); |
|
|
|
await src.dragTo(dst); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async removeField({ field, mode }: { mode: string; field: string }) { |
|
|
|
async removeField({ field, mode }: { mode: string; field: string }) { |
|
|
|
if (mode === 'dragDrop') { |
|
|
|
if (mode === 'dragDrop') { |
|
|
|
const src = await this.get().locator(`.nc-form-drag-${field.replace(' ', '')}`); |
|
|
|
const src = this.get().locator(`.nc-form-drag-${field.replace(' ', '')}`); |
|
|
|
const dst = await this.get().locator(`[data-testid="nc-drag-n-drop-to-hide"]`); |
|
|
|
const dst = this.get().locator(`[data-testid="nc-drag-n-drop-to-hide"]`); |
|
|
|
await src.dragTo(dst); |
|
|
|
await src.dragTo(dst); |
|
|
|
} else if (mode === 'hideField') { |
|
|
|
} else if (mode === 'hideField') { |
|
|
|
const src = await this.get().locator(`.nc-form-drag-${field.replace(' ', '')}`); |
|
|
|
const src = this.get().locator(`.nc-form-drag-${field.replace(' ', '')}`); |
|
|
|
await src.locator(`[data-testid="nc-field-remove-icon"]`).click(); |
|
|
|
await src.locator(`[data-testid="nc-field-remove-icon"]`).click(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async addField({ field, mode }: { mode: string; field: string }) { |
|
|
|
async addField({ field, mode }: { mode: string; field: string }) { |
|
|
|
if (mode === 'dragDrop') { |
|
|
|
if (mode === 'dragDrop') { |
|
|
|
const src = await this.get().locator(`[data-testid="nc-form-hidden-column-${field}"] > div.ant-card-body`); |
|
|
|
const src = this.get().locator(`[data-testid="nc-form-hidden-column-${field}"] > div.ant-card-body`); |
|
|
|
const dst = await this.get().locator(`[data-testid="nc-form-input-Country"]`); |
|
|
|
const dst = this.get().locator(`[data-testid="nc-form-input-Country"]`); |
|
|
|
await src.waitFor({ state: 'visible' }); |
|
|
|
await src.waitFor({ state: 'visible' }); |
|
|
|
await dst.waitFor({ state: 'visible' }); |
|
|
|
await dst.waitFor({ state: 'visible' }); |
|
|
|
await src.dragTo(dst, { trial: true }); |
|
|
|
await src.dragTo(dst, { trial: true }); |
|
|
|
await src.dragTo(dst); |
|
|
|
await src.dragTo(dst); |
|
|
|
} else if (mode === 'clickField') { |
|
|
|
} else if (mode === 'clickField') { |
|
|
|
const src = await this.get().locator(`[data-testid="nc-form-hidden-column-${field}"]`); |
|
|
|
const src = this.get().locator(`[data-testid="nc-form-hidden-column-${field}"]`); |
|
|
|
await src.click(); |
|
|
|
await src.click(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -206,12 +204,12 @@ export class FormPage extends BasePage { |
|
|
|
if (required) expectText = label + ' *'; |
|
|
|
if (required) expectText = label + ' *'; |
|
|
|
else expectText = label; |
|
|
|
else expectText = label; |
|
|
|
|
|
|
|
|
|
|
|
const fieldLabel = await this.get() |
|
|
|
const fieldLabel = this.get() |
|
|
|
.locator(`.nc-form-drag-${field.replace(' ', '')}`) |
|
|
|
.locator(`.nc-form-drag-${field.replace(' ', '')}`) |
|
|
|
.locator('div[data-testid="nc-form-input-label"]'); |
|
|
|
.locator('div[data-testid="nc-form-input-label"]'); |
|
|
|
await expect(fieldLabel).toHaveText(expectText); |
|
|
|
await expect(fieldLabel).toHaveText(expectText); |
|
|
|
|
|
|
|
|
|
|
|
const fieldHelpText = await 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"]'); |
|
|
|
await expect(fieldHelpText).toHaveText(helpText); |
|
|
|
await expect(fieldHelpText).toHaveText(helpText); |
|
|
@ -232,10 +230,10 @@ export class FormPage extends BasePage { |
|
|
|
await this.rootPage.waitForTimeout(100 * retryCounter); |
|
|
|
await this.rootPage.waitForTimeout(100 * retryCounter); |
|
|
|
retryCounter++; |
|
|
|
retryCounter++; |
|
|
|
} |
|
|
|
} |
|
|
|
await expect(await this.getFormAfterSubmit()).toContainText(param.message); |
|
|
|
await expect(this.getFormAfterSubmit()).toContainText(param.message); |
|
|
|
} |
|
|
|
} |
|
|
|
if (true === param.submitAnotherForm) { |
|
|
|
if (true === param.submitAnotherForm) { |
|
|
|
await expect(await this.getFormAfterSubmit().locator('button:has-text("Submit Another Form")')).toBeVisible(); |
|
|
|
await expect(this.getFormAfterSubmit().locator('button:has-text("Submit Another Form")')).toBeVisible(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (true === param.showBlankForm) { |
|
|
|
if (true === param.showBlankForm) { |
|
|
|
await this.get().waitFor(); |
|
|
|
await this.get().waitFor(); |
|
|
|