Browse Source

fix(nc-gui): cmd l tests

pull/7625/head
DarkPhoenix2704 9 months ago
parent
commit
9c701b1332
  1. 9
      packages/nc-gui/components/cmd-l/index.vue
  2. 2
      tests/playwright/pages/Dashboard/Command/CmdJPage.ts
  3. 3
      tests/playwright/pages/Dashboard/Command/CmdKPage.ts
  4. 9
      tests/playwright/pages/Dashboard/Command/CmdLPage.ts
  5. 98
      tests/playwright/tests/db/features/command.spec.ts

9
packages/nc-gui/components/cmd-l/index.vue

@ -137,7 +137,6 @@ onClickOutside(modalEl, () => {
})
useEventListener('keydown', (e: KeyboardEvent) => {
console.log(e.key)
if (e.key === 'Escape') {
hide()
} else if (e.key === 'Enter') {
@ -152,21 +151,21 @@ useEventListener('keydown', (e: KeyboardEvent) => {
if (!vOpen.value) return
e.preventDefault()
moveDown()
} else if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key === 'l') {
} else if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === 'l') {
if (!user.value) return
if (!vOpen.value) {
vOpen.value = true
} else {
moveUp()
}
} else if ((e.metaKey || e.ctrlKey) && e.key === 'l') {
} else if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'l') {
if (!user.value) return
if (!vOpen.value) {
vOpen.value = true
} else moveDown()
} else if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
} else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'k') {
hide()
} else if ((e.ctrlKey || e.metaKey) && e.key === 'j') {
} else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'j') {
hide()
} else if (vOpen.value) {
cmdInputEl.value?.focus()

2
tests/playwright/pages/Dashboard/Command/CmdJPage.ts

@ -14,7 +14,7 @@ export class CmdJ extends BasePage {
}
async openCmdJ() {
await this.dashboardPage.rootPage.keyboard.press(this.isMacOs() ? 'Meta+J' : 'Control+J');
await this.dashboardPage.rootPage.keyboard.press((await this.isMacOs()) ? 'Meta+J' : 'Control+J');
// await this.dashboardPage.rootPage.waitForSelector('.DocSearch-Input');
}

3
tests/playwright/pages/Dashboard/Command/CmdKPage.ts

@ -14,8 +14,7 @@ export class CmdK extends BasePage {
}
async openCmdK() {
await this.dashboardPage.rootPage.keyboard.press(this.isMacOs() ? 'Meta+K' : 'Control+K');
// await this.dashboardPage.rootPage.waitForSelector('.DocSearch-Input');
await this.dashboardPage.rootPage.keyboard.press((await this.isMacOs()) ? 'Meta+K' : 'Control+K');
}
async searchText(text: string) {

9
tests/playwright/pages/Dashboard/Command/CmdLPage.ts

@ -1,5 +1,6 @@
import BasePage from '../../Base';
import { DashboardPage } from '..';
import { expect } from '@playwright/test';
export class CmdL extends BasePage {
readonly dashboardPage: DashboardPage;
@ -14,17 +15,15 @@ export class CmdL extends BasePage {
}
async openCmdL() {
await this.dashboardPage.rootPage.keyboard.press(this.isMacOs() ? 'Meta+L' : 'Control+L');
await this.dashboardPage.rootPage.keyboard.press((await this.isMacOs()) ? 'Meta+l' : 'Control+l');
}
async isCmdLVisible() {
const isVisible = this.get();
return await isVisible.count();
await expect(this.get()).toBeVisible();
}
async isCmdLNotVisible() {
const isNotVisible = this.get();
return await isNotVisible.count();
await expect(this.get()).toBeHidden();
}
async moveDown() {

98
tests/playwright/tests/db/features/command.spec.ts

@ -0,0 +1,98 @@
import { expect, test } from '@playwright/test';
import { DashboardPage } from '../../../pages/Dashboard';
import setup, { unsetup } from '../../../setup';
test.describe('Command Shortcuts', () => {
let dashboard: DashboardPage;
let context: any;
test.beforeEach(async ({ page }) => {
context = await setup({ page, isEmptyProject: false, isSuperUser: true });
dashboard = new DashboardPage(page, context.base);
});
test.afterEach(async () => {
await unsetup(context);
});
test('Verify Command J Docs', async ({ page }) => {
await page.waitForTimeout(1000);
await dashboard.cmdJ.openCmdJ();
await expect(dashboard.cmdJ.get()).toBeVisible();
await dashboard.cmdJ.searchText('Column');
await page.keyboard.press('Escape');
await expect(dashboard.cmdJ.get()).toBeHidden();
await dashboard.signOut();
await page.waitForTimeout(2000);
await dashboard.cmdJ.openCmdJ();
await expect(dashboard.cmdJ.get()).toBeHidden();
});
test('Verify Command K', async ({ page }) => {
await page.waitForTimeout(1000);
await dashboard.cmdK.openCmdK();
await expect(dashboard.cmdK.get()).toBeVisible();
await page.keyboard.press('Escape');
await expect(dashboard.cmdK.get()).toBeHidden();
await dashboard.cmdK.openCmdK();
await dashboard.cmdK.searchText('CustomerList');
await expect(dashboard.get().locator('.nc-active-view-title')).toContainText('Default View');
await dashboard.signOut();
await page.waitForTimeout(1000);
await dashboard.cmdK.openCmdK();
await expect(dashboard.cmdK.get()).toBeHidden();
});
test('Verify Command L Recent Switch', async ({ page }) => {
await page.waitForTimeout(1000);
await dashboard.cmdL.openCmdL();
await dashboard.cmdL.isCmdLVisible();
await page.keyboard.press('Escape');
await dashboard.cmdL.isCmdLNotVisible();
await dashboard.treeView.openTable({ title: 'Actor' });
await dashboard.treeView.openTable({ title: 'Address' });
await dashboard.treeView.openTable({ title: 'Category' });
await dashboard.treeView.openTable({ title: 'City' });
await dashboard.treeView.openTable({ title: 'Country' });
await page.waitForTimeout(1000);
await dashboard.cmdL.openCmdL();
await page.waitForTimeout(1000);
await dashboard.cmdL.moveDown();
await dashboard.cmdL.moveDown();
await dashboard.cmdL.moveDown();
await dashboard.cmdL.openRecent();
await page.waitForTimeout(1000);
expect(await dashboard.cmdL.getActiveViewTitle()).toBe('Default View');
expect(await dashboard.cmdL.getActiveTableTitle()).toBe('Address');
await dashboard.signOut();
await dashboard.cmdL.openCmdL();
await dashboard.cmdL.isCmdLNotVisible();
});
});
Loading…
Cancel
Save