Browse Source

test: cleanup

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5847/head
Raju Udava 1 year ago committed by mertmit
parent
commit
9870d1e8a6
  1. 7
      tests/playwright/pages/Dashboard/common/Cell/DateCell.ts
  2. 10
      tests/playwright/pages/Dashboard/common/Cell/RatingCell.ts
  3. 90
      tests/playwright/tests/db/keyboardShortcuts.spec.ts

7
tests/playwright/pages/Dashboard/common/Cell/DateCell.ts

@ -1,5 +1,6 @@
import { CellPageObject } from '.';
import BasePage from '../../../Base';
import { expect } from '@playwright/test';
export class DateCellPageObject extends BasePage {
readonly cell: CellPageObject;
@ -20,6 +21,12 @@ export class DateCellPageObject extends BasePage {
});
}
async verify({ index, columnHeader, date }: { index: number; columnHeader: string; date: string }) {
const cell = await this.get({ index, columnHeader });
await cell.scrollIntoViewIfNeeded();
await expect(cell.locator(`[title="${date}"]`)).toBeVisible();
}
async selectDate({
// date in format `YYYY-MM-DD`
date,

10
tests/playwright/pages/Dashboard/common/Cell/RatingCell.ts

@ -22,10 +22,10 @@ export class RatingCellPageObject extends BasePage {
});
}
async verify({ index, columnHeader, rating }: { index?: number; columnHeader: string; rating: number }) {
await this.get({ index, columnHeader }).scrollIntoViewIfNeeded();
await expect(await this.get({ index, columnHeader }).locator(`div[role="radio"][aria-checked="true"]`)).toHaveCount(
rating
);
async verify({ index, columnHeader, rating }: { index: number; columnHeader: string; rating: number }) {
const cell = await this.get({ index, columnHeader });
await cell.scrollIntoViewIfNeeded();
const ratingCount = await cell.locator(`li.ant-rate-star.ant-rate-star-full`).count();
await expect(ratingCount).toBe(rating);
}
}

90
tests/playwright/tests/db/keyboardShortcuts.spec.ts

@ -20,32 +20,32 @@ test.describe('Verify shortcuts', () => {
test('Verify shortcuts', async ({ page }) => {
await dashboard.treeView.openTable({ title: 'Country' });
// create new table
await page.keyboard.press('Alt+t');
await keyPress(page, 'Alt+t');
await dashboard.treeView.createTable({ title: 'New Table', skipOpeningModal: true });
await dashboard.treeView.verifyTable({ title: 'New Table' });
// create new row
await grid.column.clickColumnHeader({ title: 'Title' });
await page.waitForTimeout(2000);
await page.keyboard.press('Alt+r');
await keyPress(page, 'Alt+r');
await grid.editRow({ index: 0, value: 'New Row' });
await grid.verifyRowCount({ count: 1 });
// create new column
await page.keyboard.press('Alt+c');
await keyPress(page, 'Alt+c');
await grid.column.fillTitle({ title: 'New Column' });
await grid.column.save();
await grid.column.verify({ title: 'New Column' });
// fullscreen
await page.keyboard.press('Alt+f');
await keyPress(page, 'Alt+f');
await dashboard.treeView.verifyVisibility({
isVisible: false,
});
await dashboard.viewSidebar.verifyVisibility({
isVisible: false,
});
await page.keyboard.press('Alt+f');
await keyPress(page, 'Alt+f');
await dashboard.treeView.verifyVisibility({
isVisible: true,
});
@ -54,7 +54,7 @@ test.describe('Verify shortcuts', () => {
});
// invite team member
await page.keyboard.press('Alt+i');
await keyPress(page, 'Alt+i');
await dashboard.settings.teams.invite({
email: 'new@example.com',
role: 'editor',
@ -71,37 +71,37 @@ test.describe('Verify shortcuts', () => {
await page.waitForTimeout(1500);
await grid.cell.click({ index: 0, columnHeader: 'Country' });
await page.waitForTimeout(1500);
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+ArrowRight' : 'Control+ArrowRight');
await keyPress(page, 'Meta+ArrowRight');
await grid.cell.verifyCellActiveSelected({ index: 0, columnHeader: 'City List' });
// Cmd + Right arrow
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+ArrowLeft' : 'Control+ArrowLeft');
await keyPress(page, 'Meta+ArrowLeft');
await grid.cell.verifyCellActiveSelected({ index: 0, columnHeader: 'Country' });
// Cmd + up arrow
await grid.cell.click({ index: 24, columnHeader: 'Country' });
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+ArrowUp' : 'Control+ArrowUp');
await keyPress(page, 'Meta+ArrowUp');
await grid.cell.verifyCellActiveSelected({ index: 0, columnHeader: 'Country' });
// Cmd + down arrow
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+ArrowDown' : 'Control+ArrowDown');
await keyPress(page, 'Meta+ArrowDown');
await grid.cell.verifyCellActiveSelected({ index: 24, columnHeader: 'Country' });
// Enter to edit and Esc to cancel
await grid.cell.click({ index: 0, columnHeader: 'Country' });
await page.keyboard.press('Enter');
await keyPress(page, 'Enter');
await page.keyboard.type('New');
await page.keyboard.press('Escape');
await keyPress(page, 'Escape');
await grid.cell.verify({ index: 0, columnHeader: 'Country', value: 'AfghanistanNew' });
// Space to open expanded row and Meta + Space to save
await grid.cell.click({ index: 1, columnHeader: 'Country' });
await page.keyboard.press('Space');
await keyPress(page, 'Space');
await dashboard.expandedForm.verify({
header: 'Algeria',
});
await dashboard.expandedForm.fillField({ columnTitle: 'Country', value: 'NewAlgeria' });
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+Enter' : 'Control+Enter');
await keyPress(page, 'Meta+Enter');
await page.waitForTimeout(2000);
await grid.cell.verify({ index: 1, columnHeader: 'Country', value: 'NewAlgeria' });
});
@ -110,6 +110,60 @@ test.describe('Verify shortcuts', () => {
const today = new Date().toISOString().slice(0, 10);
async function verifyCellContents({ rowIndex }: { rowIndex: number }) {
const responseTable = [
{ type: 'SingleLineText', value: 'SingleLineText' },
{ type: 'LongText', value: 'LongText' },
{ type: 'SingleSelect', value: 'Option1' },
{ type: 'MultiSelect', value: `Option1\nOption2` },
{ type: 'Number', value: '123' },
{ type: 'PhoneNumber', value: '987654321' },
{ type: 'Email', value: 'test@example.com' },
{ type: 'URL', value: 'nocodb.com' },
{ type: 'Decimal', value: '1.12' },
{ type: 'Percent', value: '80' },
{ type: 'Currency', value: 20 },
{ type: 'Duration', value: '00:08' },
{ type: 'Rating', value: 4 },
{ type: 'Checkbox', value: 'true' },
{ type: 'Date', value: today },
{ type: 'Attachment', value: 1 },
];
for (const { type, value } of responseTable) {
if (type === 'Rating') {
await dashboard.grid.cell.rating.verify({
index: rowIndex,
columnHeader: type,
rating: value,
});
} else if (type === 'Checkbox') {
await dashboard.grid.cell.checkbox.verifyChecked({
index: rowIndex,
columnHeader: type,
});
} else if (type === 'Date') {
await dashboard.grid.cell.date.verify({
index: rowIndex,
columnHeader: type,
date: value,
});
} else if (type === 'Attachment') {
await dashboard.grid.cell.attachment.verifyFileCount({
index: rowIndex,
columnHeader: type,
count: value,
});
} else {
await dashboard.grid.cell.verify({
index: rowIndex,
columnHeader: type,
value,
});
}
}
}
async function verifyClipContents({ rowIndex }: { rowIndex: number }) {
const responseTable = [
{ type: 'SingleLineText', value: 'SingleLineText' },
{ type: 'LongText', value: '"LongText"' },
@ -295,21 +349,21 @@ test.describe('Verify shortcuts', () => {
});
test('single cell- all data types', async () => {
await verifyCellContents({ rowIndex: 0 });
await verifyClipContents({ rowIndex: 0 });
});
test('multiple cells - horizontal, all data types', async ({ page }) => {
// click first cell, press `Ctrl A` and `Ctrl C`
await grid.cell.click({ index: 0, columnHeader: 'Id' });
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+a' : 'Control+a');
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+c' : 'Control+c');
await keyPress(page, 'Meta+a');
await keyPress(page, 'Meta+c');
/////////////////////////////////////////////////////////////////////////
// horizontal multiple cells selection : copy paste
// add new row, click on first cell, paste
await grid.addRowRightClickMenu(0, 'Id');
await page.keyboard.press((await grid.isMacOs()) ? 'Meta+v' : 'Control+v');
await keyPress(page, 'Meta+v');
await verifyCellContents({ rowIndex: 1 });
// reload page

Loading…
Cancel
Save