Browse Source

Merge branch 'feat/keyboard-manoeuvre' of https://github.com/nocodb/nocodb into feat/keyboard-manoeuvre

pull/4482/head
Wing-Kam Wong 2 years ago
parent
commit
13ab32b5ca
  1. 8
      tests/playwright/pages/Base.ts
  2. 3
      tests/playwright/pages/Dashboard/common/Cell/index.ts
  3. 11
      tests/playwright/tests/keyboardShortcuts.spec.ts

8
tests/playwright/pages/Base.ts

@ -84,4 +84,12 @@ export default abstract class BasePage {
async getClipboardText() { async getClipboardText() {
return await this.rootPage.evaluate(() => navigator.clipboard.readText()); 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');
}
} }

3
tests/playwright/pages/Dashboard/common/Cell/index.ts

@ -31,7 +31,8 @@ export class CellPageObject extends BasePage {
} }
async click({ index, columnHeader }: { index: number; columnHeader: string }) { async click({ index, columnHeader }: { index: number; columnHeader: string }) {
return await this.get({ index, columnHeader }).click(); await this.get({ index, columnHeader }).click();
await (await this.get({ index, columnHeader }).elementHandle()).waitForElementState('stable');
} }
async dblclick({ index, columnHeader }: { index?: number; columnHeader: string }) { async dblclick({ index, columnHeader }: { index?: number; columnHeader: string }) {

11
tests/playwright/tests/keyboardShortcuts.spec.ts

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

Loading…
Cancel
Save