Browse Source

test(mulfi-field): keyboard shortcuts test cases

pull/7408/head
Ramesh Mane 12 months ago
parent
commit
29f781710d
  1. 63
      tests/playwright/tests/db/features/multiFieldEditor.spec.ts

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

@ -117,7 +117,7 @@ const allFieldList = [
},
];
test.describe('Multi Field Editor', () => {
test.describe.only('Multi Field Editor', () => {
let dashboard: DashboardPage, fields: FieldsPage;
let context: any;
const defaultFieldName = 'Multi Field Editor';
@ -140,6 +140,12 @@ test.describe('Multi Field Editor', () => {
await dashboard.details.clickFieldsTab();
}
async function toggleShowSystemFieldsFromDataTab() {
await dashboard.grid.topbar.openDataTab();
await dashboard.grid.toolbar.fields.toggleShowSystemFields();
await openMultiFieldOfATable();
}
const verifyGridColumnHeaders = async ({ fields = [] }: { fields: string[] }) => {
await dashboard.grid.topbar.openDataTab();
@ -167,7 +173,13 @@ test.describe('Multi Field Editor', () => {
);
};
test('Add New field, update & Restore, reset ', async () => {
test('Verify system fields are not listed, Add New field, update & Restore, reset', async () => {
//Verify system fields are not listed
await toggleShowSystemFieldsFromDataTab();
let fieldsText = await fields.getAllFieldText();
expect(fieldsText.length).toBe(1);
await toggleShowSystemFieldsFromDataTab();
// Add New Field
await fields.createOrUpdate({ title: 'Name', saveChanges: false });
await expect(fields.getField({ title: 'Name' })).toContainText('New field');
@ -185,7 +197,7 @@ test.describe('Multi Field Editor', () => {
await fields.clickRestoreField({ title: 'Updated Name to restore' });
// verify grid column header
const fieldsText = await fields.getAllFieldText();
fieldsText = await fields.getAllFieldText();
expect(fieldsText).toEqual(['Title', 'Updated Name']);
await verifyGridColumnHeaders({ fields: fieldsText });
@ -198,7 +210,8 @@ test.describe('Multi Field Editor', () => {
await verifyGridColumnHeaders({ fields: fieldsText });
});
test('Add all fields and check status on clicking each field', async () => {
// Todo: remove `skip`, if `optimized dependencies changed. reloading` issue is fixed
test.skip('Add all fields and check status on clicking each field', async () => {
// Add all fields, verify status and save
for (const field of allFieldList) {
await fields.createOrUpdate({ ...field, saveChanges: false });
@ -239,21 +252,13 @@ test.describe('Multi Field Editor', () => {
await fields.createOrUpdate({ title: 'Below Inserted Field', insertBelowColumnTitle: defaultFieldName });
// delete and verify
// By field action menu
await fields.selectFieldAction({ title: `${defaultFieldName}_copy`, action: 'delete' });
await expect(fields.getField({ title: `${defaultFieldName}_copy` })).toContainText('Deleted field');
// By keyboard delete button
await fields.getField({ title: 'Above Inserted Field' }).click();
await dashboard.rootPage.keyboard.press((await dashboard.isMacOs()) ? 'Meta+Delete' : 'Delete');
await expect(fields.getField({ title: 'Above Inserted Field' })).toContainText('Deleted field');
await fields.saveChanges();
fieldsText = await fields.getAllFieldText();
expect(
fieldsText.every(field => !['Above Inserted Field', `${defaultFieldName}_copy`].includes(field))
).toBeTruthy();
expect(!fieldsText.includes(`${defaultFieldName}_copy`)).toBeTruthy();
// verify grid column header
await verifyGridColumnHeaders({ fields: fieldsText });
@ -340,4 +345,36 @@ test.describe('Multi Field Editor', () => {
await verifyGridColumnHeaders({ fields: expectedFieldText });
});
test('Keyboard shortcuts: add new field, save and delete', async () => {
// add new field
await dashboard.rootPage.keyboard.press('Alt+C');
// verify field is added and has `New field` status
let fieldsText = await fields.getAllFieldText();
await expect(fields.getField({ title: fieldsText[fieldsText.length - 1] })).toContainText('New field');
// update title
await fields.createOrUpdate({ title: defaultFieldName, isUpdateMode: true });
// save the changes
await dashboard.rootPage.keyboard.press((await dashboard.isMacOs()) ? 'Meta+S' : 'Control+S');
await dashboard.rootPage.waitForTimeout(500);
// verify result
fieldsText = await fields.getAllFieldText();
expect(fieldsText).toEqual(['Title', defaultFieldName]);
// delete field
await fields.getField({ title: defaultFieldName }).click();
await dashboard.rootPage.keyboard.press((await dashboard.isMacOs()) ? 'Meta+Delete' : 'Delete');
await expect(fields.getField({ title: defaultFieldName })).toContainText('Deleted field');
// save the changes
await dashboard.rootPage.keyboard.press((await dashboard.isMacOs()) ? 'Meta+S' : 'Control+S');
await dashboard.rootPage.waitForTimeout(500);
fieldsText = await fields.getAllFieldText();
expect(fieldsText).toEqual(['Title']);
});
});

Loading…
Cancel
Save