Browse Source

test(multi-field): field restore test cases

pull/7408/head
Ramesh Mane 9 months ago
parent
commit
536f2c4aa2
  1. 4
      tests/playwright/pages/Dashboard/Details/FieldsPage.ts
  2. 20
      tests/playwright/tests/db/features/multiFieldEditor.spec.ts

4
tests/playwright/pages/Dashboard/Details/FieldsPage.ts

@ -45,6 +45,10 @@ export class FieldsPage extends BasePage {
await this.addNewFieldButton.click(); await this.addNewFieldButton.click();
} }
async clickRestoreField({ title }: { title: string }) {
await this.getField({ title }).getByTestId('nc-field-restore-changes').click();
}
async createOrUpdate({ async createOrUpdate({
title, title,
type = UITypes.SingleLineText, type = UITypes.SingleLineText,

20
tests/playwright/tests/db/features/multiFieldEditor.spec.ts

@ -50,10 +50,12 @@ test.describe('Multi Field Editor', () => {
await fields.searchFieldInput.fill(searchQuery); await fields.searchFieldInput.fill(searchQuery);
const allFields = await fields.getAllFieldText(); const allFields = await fields.getAllFieldText();
expect(allFields).toEqual(fieldList.filter(field => field.toLowerCase().includes(searchQuery.toLowerCase()))); expect(allFields).toEqual(
searchQuery ? fieldList.filter(field => field.toLowerCase().includes(searchQuery.toLowerCase())) : fieldList
);
}; };
test('Add New field, update and reset ', async () => { test('Add New field, update & Restore, reset ', async () => {
// Add New Field // Add New Field
await fields.createOrUpdate({ title: 'Name', saveChanges: false }); await fields.createOrUpdate({ title: 'Name', saveChanges: false });
await expect(fields.getField({ title: 'Name' })).toContainText('New field'); await expect(fields.getField({ title: 'Name' })).toContainText('New field');
@ -65,6 +67,11 @@ test.describe('Multi Field Editor', () => {
await expect(fields.getField({ title: 'Updated Name' })).toContainText('Updated field'); await expect(fields.getField({ title: 'Updated Name' })).toContainText('Updated field');
await fields.saveChanges(); await fields.saveChanges();
// Update and restore field changes
await fields.getField({ title: 'Updated Name' }).click();
await fields.createOrUpdate({ title: 'Updated Name to restore', saveChanges: false, isUpdateMode: true });
await fields.clickRestoreField({ title: 'Updated Name to restore' });
// verify grid column header // verify grid column header
const fieldsText = await fields.getAllFieldText(); const fieldsText = await fields.getAllFieldText();
expect(fieldsText).toEqual(['Title', 'Updated Name']); expect(fieldsText).toEqual(['Title', 'Updated Name']);
@ -143,7 +150,14 @@ test.describe('Multi Field Editor', () => {
searchQuery = 'Rich text'; searchQuery = 'Rich text';
await searchAndVerifyFields({ await searchAndVerifyFields({
searchQuery, searchQuery,
fieldList, fieldList: ['Title', ...fieldList],
});
// clear search and verify
await fields.clearSearch();
await searchAndVerifyFields({
searchQuery: '',
fieldList: ['Title', ...fieldList],
}); });
}); });

Loading…
Cancel
Save