Browse Source

fix: group-by menu test cases

pull/7173/head
Ramesh Mane 12 months ago
parent
commit
ba5e520526
  1. 2
      packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
  2. 82
      tests/playwright/pages/Dashboard/common/Toolbar/Groupby.ts
  3. 6
      tests/playwright/pages/Dashboard/common/Toolbar/index.ts
  4. 8
      tests/playwright/tests/db/general/groupCRUD.spec.ts
  5. 36
      tests/playwright/tests/db/general/toolbarOperations.spec.ts
  6. 8
      tests/playwright/tests/db/views/viewGridShare.spec.ts

2
packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue

@ -247,7 +247,7 @@ watch(meta, async () => {
<div <div
v-else v-else
:class="{ ' min-w-[400px]': _groupBy.length }" :class="{ ' min-w-[400px]': _groupBy.length }"
class="flex flex-col bg-white overflow-auto menu-filter-dropdown max-h-[max(80vh,500px)] py-6 pl-6" class="flex flex-col bg-white overflow-auto nc-group-by-list menu-filter-dropdown max-h-[max(80vh,500px)] py-6 pl-6"
data-testid="nc-group-by-menu" data-testid="nc-group-by-menu"
> >
<div <div

82
tests/playwright/pages/Dashboard/common/Toolbar/Groupby.ts

@ -12,7 +12,7 @@ export class ToolbarGroupByPage extends BasePage {
} }
get() { get() {
return this.rootPage.locator(`.nc-group-by-menu-btn`); return this.rootPage.locator(`[data-testid="nc-group-by-menu"]`);
} }
async verify({ index, column, direction }: { index: number; column: string; direction: string }) { async verify({ index, column, direction }: { index: number; column: string; direction: string }) {
@ -26,13 +26,22 @@ export class ToolbarGroupByPage extends BasePage {
} }
async reset() { async reset() {
// open group-by menu
await this.toolbar.clickGroupBy();
const groupByCount = await this.rootPage.locator('.nc-group-by-item-remove-btn').count(); const groupByCount = await this.rootPage.locator('.nc-group-by-item-remove-btn').count();
for (let i = groupByCount - 1; i > -1; i--) { for (let i = groupByCount - 1; i > -1; i--) {
await this.rootPage.locator('.nc-group-by-item-remove-btn').nth(i).click(); await this.rootPage.locator('.nc-group-by-item-remove-btn').nth(i).click();
} }
// close group-by menu
await this.toolbar.clickGroupBy();
await this.toolbar.parent.waitLoading();
} }
async update({ index, title, ascending }: { index: number; title: string; ascending: boolean }) { async update({ index, title, ascending }: { index: number; title: string; ascending: boolean }) {
await this.toolbar.clickGroupBy();
// Update the Column and Direction of the Group By at the given index // Update the Column and Direction of the Group By at the given index
await this.rootPage.locator('.nc-sort-field-select').nth(index).click(); await this.rootPage.locator('.nc-sort-field-select').nth(index).click();
await this.rootPage await this.rootPage
@ -47,24 +56,59 @@ export class ToolbarGroupByPage extends BasePage {
.locator('.ant-select-item') .locator('.ant-select-item')
.nth(ascending ? 0 : 1) .nth(ascending ? 0 : 1)
.click(); .click();
await this.toolbar.parent.dashboard.waitForLoaderToDisappear();
// close group-by menu
await this.toolbar.clickGroupBy();
await this.toolbar.parent.waitLoading();
} }
async add({ title, ascending, locallySaved }: { title: string; ascending: boolean; locallySaved: boolean }) { async add({ title, ascending, locallySaved }: { title: string; ascending: boolean; locallySaved: boolean }) {
const addGroupBtn = this.toolbar.rootPage.locator(`.nc-add-group-btn`); // open group-by menu
if (!(await addGroupBtn.isDisabled())) { await this.toolbar.clickGroupBy();
await addGroupBtn.click();
// Check if create group-by modal is open or group-by list is open
let isGroupByListOpen = false;
for (let i = 0; i < 3; i++) {
const groupByList = this.rootPage.locator('.nc-group-by-list');
if (await groupByList.isVisible()) {
isGroupByListOpen = true;
break;
}
const searchInput = this.rootPage.locator('.nc-group-by-create-modal');
if (await searchInput.isVisible()) {
isGroupByListOpen = false;
break;
}
await this.rootPage.waitForTimeout(150);
} }
// read content of the dropdown
const col = await this.rootPage.locator('.nc-sort-field-select').last().textContent(); if (isGroupByListOpen) {
if (col !== title) { await this.get().locator('button:has-text("Add subgroup")').click();
await this.rootPage.locator('.nc-sort-field-select').last().click();
await this.rootPage
.locator('div.ant-select-dropdown.nc-dropdown-toolbar-field-list')
.locator(`div[label="${title}"]`)
.last()
.click();
} }
const regexTitle = new RegExp(`^${title}`);
await this.rootPage
.locator('.nc-group-by-create-modal')
.locator('.nc-group-by-column-search-item >> div', { hasText: regexTitle })
.scrollIntoViewIfNeeded();
// select column
const selectColumn = async () =>
await this.rootPage
.locator('.nc-group-by-create-modal')
.locator('.nc-group-by-column-search-item >> div', { hasText: regexTitle })
.click({ force: true });
await this.waitForResponse({
uiAction: selectColumn,
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`,
});
await this.rootPage.locator('.nc-sort-dir-select').last().click(); await this.rootPage.locator('.nc-sort-dir-select').last().click();
const selectSortDirection = () => const selectSortDirection = () =>
this.rootPage this.rootPage
@ -79,9 +123,21 @@ export class ToolbarGroupByPage extends BasePage {
httpMethodsToMatch: ['GET'], httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`, requestUrlPathToMatch: locallySaved ? `/api/v1/db/public/` : `/api/v1/db/data/noco/`,
}); });
await this.toolbar.parent.dashboard.waitForLoaderToDisappear();
// close group-by menu
await this.toolbar.clickGroupBy();
await this.toolbar.parent.waitLoading();
} }
async remove({ index }: { index: number }) { async remove({ index }: { index: number }) {
// open group-by menu
await this.toolbar.clickGroupBy();
await this.rootPage.locator('.nc-group-by-item-remove-btn').nth(index).click(); await this.rootPage.locator('.nc-group-by-item-remove-btn').nth(index).click();
// close group-by menu
await this.toolbar.clickGroupBy();
await this.toolbar.parent.waitLoading();
} }
} }

6
tests/playwright/pages/Dashboard/common/Toolbar/index.ts

@ -119,9 +119,11 @@ export class ToolbarPage extends BasePage {
} }
async clickGroupBy() { async clickGroupBy() {
const menuOpen = this.groupBy.get().isVisible(); const menuOpen = await this.groupBy.get().isVisible();
await this.get().locator(`button.nc-group-by-menu-btn`).click(); await this.get().locator(`button.nc-group-by-menu-btn`).click();
if (!menuOpen) {
// Wait for the menu to close
if (menuOpen) {
await this.groupBy.get().waitFor({ state: 'hidden' }); await this.groupBy.get().waitFor({ state: 'hidden' });
} }
} }

8
tests/playwright/tests/db/general/groupCRUD.spec.ts

@ -47,8 +47,6 @@ test.describe('GroupBy CRUD Operations', () => {
await toolbar.sort.add({ title: 'Sub_Group', ascending: true, locallySaved: false }); await toolbar.sort.add({ title: 'Sub_Group', ascending: true, locallySaved: false });
await toolbar.clickGroupBy();
await toolbar.groupBy.add({ title: 'Category', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Category', ascending: false, locallySaved: false });
await dashboard.grid.groupPage.openGroup({ indexMap: [2] }); await dashboard.grid.groupPage.openGroup({ indexMap: [2] });
@ -116,8 +114,6 @@ test.describe('GroupBy CRUD Operations', () => {
await toolbar.sort.add({ title: 'Sub_Category', ascending: true, locallySaved: false }); await toolbar.sort.add({ title: 'Sub_Category', ascending: true, locallySaved: false });
await toolbar.clickGroupBy();
await toolbar.groupBy.add({ title: 'Category', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Category', ascending: false, locallySaved: false });
await toolbar.groupBy.add({ title: 'Sub_Group', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Sub_Group', ascending: false, locallySaved: false });
@ -186,8 +182,6 @@ test.describe('GroupBy CRUD Operations', () => {
await toolbar.sort.add({ title: 'Item', ascending: true, locallySaved: false }); await toolbar.sort.add({ title: 'Item', ascending: true, locallySaved: false });
await toolbar.clickGroupBy();
await toolbar.groupBy.add({ title: 'Category', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Category', ascending: false, locallySaved: false });
await toolbar.groupBy.add({ title: 'Sub_Group', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Sub_Group', ascending: false, locallySaved: false });
await toolbar.groupBy.add({ title: 'Sub_Category', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Sub_Category', ascending: false, locallySaved: false });
@ -255,8 +249,6 @@ test.describe('GroupBy CRUD Operations', () => {
test('Single GroupBy CRUD Operations - Links', async ({ page }) => { test('Single GroupBy CRUD Operations - Links', async ({ page }) => {
await dashboard.treeView.openTable({ title: 'Film' }); await dashboard.treeView.openTable({ title: 'Film' });
await toolbar.clickGroupBy();
await toolbar.groupBy.add({ title: 'Actors', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Actors', ascending: false, locallySaved: false });
await dashboard.grid.groupPage.openGroup({ indexMap: [2] }); await dashboard.grid.groupPage.openGroup({ indexMap: [2] });

36
tests/playwright/tests/db/general/toolbarOperations.spec.ts

@ -32,14 +32,9 @@ test.describe('Toolbar operations (GRID)', () => {
// Open Table // Open Table
await dashboard.treeView.openTable({ title: 'Film' }); await dashboard.treeView.openTable({ title: 'Film' });
// Open GroupBy Menu
await toolbar.clickGroupBy();
// GroupBy Category Descending Order // GroupBy Category Descending Order
await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false });
await toolbar.clickGroupBy();
// Hide Field and Verify // Hide Field and Verify
await toolbar.fields.toggle({ title: 'Description' }); await toolbar.fields.toggle({ title: 'Description' });
await dashboard.grid.column.verify({ await dashboard.grid.column.verify({
@ -165,16 +160,10 @@ test.describe('Toolbar operations (GRID)', () => {
// Open Table // Open Table
await dashboard.treeView.openTable({ title: 'Film' }); await dashboard.treeView.openTable({ title: 'Film' });
// Open GroupBy Menu
await toolbar.clickGroupBy();
// GroupBy Category Descending Order // GroupBy Category Descending Order
await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false });
await toolbar.groupBy.add({ title: 'RentalDuration', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'RentalDuration', ascending: false, locallySaved: false });
// Close GroupBy Menu
await toolbar.clickGroupBy();
// Hide Field and Verify // Hide Field and Verify
await toolbar.fields.toggle({ title: 'Description' }); await toolbar.fields.toggle({ title: 'Description' });
await dashboard.grid.column.verify({ await dashboard.grid.column.verify({
@ -315,9 +304,6 @@ test.describe('Toolbar operations (GRID)', () => {
await dashboard.grid.column.save({ isUpdated: true }); await dashboard.grid.column.save({ isUpdated: true });
} }
// Open GroupBy Menu
await toolbar.clickGroupBy();
// GroupBy Category Descending Order // GroupBy Category Descending Order
await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false });
await toolbar.groupBy.add({ title: 'RentalDuration', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'RentalDuration', ascending: false, locallySaved: false });
@ -464,11 +450,8 @@ test.describe('Toolbar operations (GRID)', () => {
await dashboard.grid.column.save({ isUpdated: true }); await dashboard.grid.column.save({ isUpdated: true });
} }
// Open GroupBy Menu
await toolbar.clickGroupBy();
await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false });
await toolbar.groupBy.add({ title: 'RentalDuration', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'RentalDuration', ascending: false, locallySaved: false });
await toolbar.clickGroupBy();
await dashboard.grid.groupPage.openGroup({ indexMap: [5, 0] }); await dashboard.grid.groupPage.openGroup({ indexMap: [5, 0] });
@ -479,12 +462,8 @@ test.describe('Toolbar operations (GRID)', () => {
value: 'ALLEY EVOLUTION', value: 'ALLEY EVOLUTION',
}); });
await toolbar.clickGroupBy();
await toolbar.groupBy.update({ index: 0, title: 'ReleaseYear', ascending: false }); await toolbar.groupBy.update({ index: 0, title: 'ReleaseYear', ascending: false });
await toolbar.clickGroupBy();
await dashboard.grid.groupPage.openGroup({ indexMap: [0, 1] }); await dashboard.grid.groupPage.openGroup({ indexMap: [0, 1] });
await dashboard.grid.groupPage.validateFirstRow({ await dashboard.grid.groupPage.validateFirstRow({
@ -494,8 +473,6 @@ test.describe('Toolbar operations (GRID)', () => {
value: 'ACADEMY DINOSAUR', value: 'ACADEMY DINOSAUR',
}); });
await toolbar.clickGroupBy();
await toolbar.groupBy.update({ index: 1, title: 'Length', ascending: false }); await toolbar.groupBy.update({ index: 1, title: 'Length', ascending: false });
await dashboard.grid.groupPage.openGroup({ indexMap: [0, 5] }); await dashboard.grid.groupPage.openGroup({ indexMap: [0, 5] });
@ -511,10 +488,7 @@ test.describe('Toolbar operations (GRID)', () => {
if (enableQuickRun()) test.skip(); if (enableQuickRun()) test.skip();
await dashboard.treeView.openTable({ title: 'Film' }); await dashboard.treeView.openTable({ title: 'Film' });
// Open GroupBy Menu
await toolbar.clickGroupBy();
await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false });
await toolbar.clickGroupBy();
await dashboard.viewSidebar.createGridView({ title: 'Test' }); await dashboard.viewSidebar.createGridView({ title: 'Test' });
await dashboard.rootPage.waitForTimeout(500); await dashboard.rootPage.waitForTimeout(500);
@ -538,10 +512,7 @@ test.describe('Toolbar operations (GRID)', () => {
await dashboard.treeView.openTable({ title: 'Film' }); await dashboard.treeView.openTable({ title: 'Film' });
await dashboard.viewSidebar.createGridView({ title: 'Film Grid' }); await dashboard.viewSidebar.createGridView({ title: 'Film Grid' });
// Open GroupBy Menu
await toolbar.clickGroupBy();
await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false });
await toolbar.clickGroupBy();
await dashboard.viewSidebar.copyView({ title: 'Film Grid' }); await dashboard.viewSidebar.copyView({ title: 'Film Grid' });
@ -561,11 +532,8 @@ test.describe('Toolbar operations (GRID)', () => {
if (enableQuickRun()) test.skip(); if (enableQuickRun()) test.skip();
await dashboard.treeView.openTable({ title: 'Film' }); await dashboard.treeView.openTable({ title: 'Film' });
// Open GroupBy Menu
await toolbar.clickGroupBy();
await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'Length', ascending: false, locallySaved: false });
await toolbar.groupBy.add({ title: 'RentalDuration', ascending: false, locallySaved: false }); await toolbar.groupBy.add({ title: 'RentalDuration', ascending: false, locallySaved: false });
await toolbar.clickGroupBy();
await dashboard.grid.groupPage.openGroup({ indexMap: [0, 0] }); await dashboard.grid.groupPage.openGroup({ indexMap: [0, 0] });
@ -576,9 +544,7 @@ test.describe('Toolbar operations (GRID)', () => {
value: 'CONTROL ANTHEM', value: 'CONTROL ANTHEM',
}); });
await toolbar.clickGroupBy();
await toolbar.groupBy.remove({ index: 1 }); await toolbar.groupBy.remove({ index: 1 });
await toolbar.clickGroupBy();
await dashboard.grid.groupPage.validateFirstRow({ await dashboard.grid.groupPage.validateFirstRow({
indexMap: [0], indexMap: [0],
@ -587,9 +553,7 @@ test.describe('Toolbar operations (GRID)', () => {
value: 'CHICAGO NORTH', value: 'CHICAGO NORTH',
}); });
await toolbar.clickGroupBy();
await toolbar.groupBy.remove({ index: 0 }); await toolbar.groupBy.remove({ index: 0 });
await toolbar.clickGroupBy();
await dashboard.grid.cell.verify({ await dashboard.grid.cell.verify({
index: 0, index: 0,

8
tests/playwright/tests/db/views/viewGridShare.spec.ts

@ -16,14 +16,13 @@ test.describe('Shared view', () => {
test('Grid Share with GroupBy', async ({ page }) => { test('Grid Share with GroupBy', async ({ page }) => {
await dashboard.treeView.openTable({ title: 'Film' }); await dashboard.treeView.openTable({ title: 'Film' });
await dashboard.grid.toolbar.clickGroupBy();
await dashboard.grid.toolbar.groupBy.add({ await dashboard.grid.toolbar.groupBy.add({
title: 'Title', title: 'Title',
ascending: false, ascending: false,
locallySaved: false, locallySaved: false,
}); });
await dashboard.grid.toolbar.clickGroupBy();
await dashboard.grid.toolbar.sort.add({ await dashboard.grid.toolbar.sort.add({
title: 'Title', title: 'Title',
ascending: false, ascending: false,
@ -76,7 +75,7 @@ test.describe('Shared view', () => {
await page.reload(); await page.reload();
await dashboard.treeView.openTable({ title: 'Film' }); await dashboard.treeView.openTable({ title: 'Film' });
await dashboard.grid.toolbar.clickGroupBy();
await dashboard.grid.toolbar.groupBy.update({ await dashboard.grid.toolbar.groupBy.update({
index: 0, index: 0,
title: 'Length', title: 'Length',
@ -102,9 +101,8 @@ test.describe('Shared view', () => {
await page.waitForTimeout(5000); await page.waitForTimeout(5000);
await dashboard.treeView.openTable({ title: 'Film' }); await dashboard.treeView.openTable({ title: 'Film' });
await dashboard.grid.toolbar.clickGroupBy();
await dashboard.grid.toolbar.groupBy.remove({ index: 0 }); await dashboard.grid.toolbar.groupBy.remove({ index: 0 });
await dashboard.grid.toolbar.clickGroupBy();
await page.goto(sharedLink); await page.goto(sharedLink);
await page.reload(); await page.reload();

Loading…
Cancel
Save