Browse Source

feat(playwright): Potential fix for keyboard shortcuts test

pull/4482/head
Muhammed Mustafa 2 years ago
parent
commit
27816b1ea3
  1. 8
      tests/playwright/pages/Base.ts
  2. 10
      tests/playwright/tests/keyboardShortcuts.spec.ts

8
tests/playwright/pages/Base.ts

@ -84,4 +84,12 @@ export default abstract class BasePage {
async getClipboardText() {
return await this.rootPage.evaluate(() => navigator.clipboard.readText());
}
async os() {
return await this.rootPage.evaluate(() => navigator.platform);
}
async isMacOs() {
return (await this.os()).includes('Mac');
}
}

10
tests/playwright/tests/keyboardShortcuts.spec.ts

@ -67,20 +67,20 @@ test.describe('Verify shortcuts', () => {
await page.waitForTimeout(1500);
await grid.cell.click({ index: 0, columnHeader: 'Country' });
await page.waitForTimeout(1500);
await page.keyboard.press('Meta+ArrowRight');
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+ArrowRight' : 'Control+ArrowRight');
await grid.cell.verifyCellActiveSelected({ index: 0, columnHeader: 'City List' });
// Cmd + Right arrow
await page.keyboard.press('Meta+ArrowLeft');
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+ArrowLeft' : 'Control+ArrowLeft');
await grid.cell.verifyCellActiveSelected({ index: 0, columnHeader: 'Country' });
// Cmd + up arrow
await grid.cell.click({ index: 24, columnHeader: 'Country' });
await page.keyboard.press('Meta+ArrowUp');
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+ArrowUp' : 'Control+ArrowUp');
await grid.cell.verifyCellActiveSelected({ index: 0, columnHeader: 'Country' });
// Cmd + down arrow
await page.keyboard.press('Meta+ArrowDown');
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+ArrowDown' : 'Control+ArrowDown');
await grid.cell.verifyCellActiveSelected({ index: 24, columnHeader: 'Country' });
// Enter to edit and Esc to cancel
@ -97,7 +97,7 @@ test.describe('Verify shortcuts', () => {
header: 'Algeria',
});
await dashboard.expandedForm.fillField({ columnTitle: 'Country', value: 'NewAlgeria' });
await page.keyboard.press('Meta+Enter');
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+Enter' : 'Control+Enter');
await page.waitForTimeout(2000);
await grid.cell.verify({ index: 1, columnHeader: 'Country', value: 'NewAlgeria' });
});

Loading…
Cancel
Save