Browse Source

test: bulk update- select based

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
test/pw-duplicate-check
Raju Udava 1 year ago
parent
commit
65fa0b3ef0
  1. 12
      tests/playwright/pages/Dashboard/BulkUpdate/index.ts
  2. 2
      tests/playwright/pages/Dashboard/common/Cell/SelectOptionCell.ts
  3. 83
      tests/playwright/tests/db/bulkUpdate.spec.ts

12
tests/playwright/pages/Dashboard/BulkUpdate/index.ts

@ -118,6 +118,18 @@ export class BulkUpdatePage extends BasePage {
await timePanel.nth(1).locator('li').nth(+time[1]).click(); await timePanel.nth(1).locator('li').nth(+time[1]).click();
await picker.locator('.ant-picker-ok').click(); await picker.locator('.ant-picker-ok').click();
break; break;
case 'singleSelect':
picker = this.rootPage.locator('.ant-select-dropdown.active');
await picker.waitFor();
await picker.locator(`.nc-select-option-SingleSelect-${value}`).click();
break;
case 'multiSelect':
picker = this.rootPage.locator('.ant-select-dropdown.active');
await picker.waitFor();
for (const val of value.split(',')) {
await picker.locator(`.nc-select-option-MultiSelect-${val}`).click();
}
break;
} }
} }

2
tests/playwright/pages/Dashboard/common/Cell/SelectOptionCell.ts

@ -126,7 +126,7 @@ export class SelectOptionCellPageObject extends BasePage {
await expect(this.rootPage.locator(`div.ant-select-item-option`).nth(counter)).toHaveText(option); await expect(this.rootPage.locator(`div.ant-select-item-option`).nth(counter)).toHaveText(option);
counter++; counter++;
} }
await this.get({ index, columnHeader }).click(); await this.rootPage.keyboard.press('Escape');
await this.rootPage.locator(`.nc-dropdown-single-select-cell`).nth(index).waitFor({ state: 'hidden' }); await this.rootPage.locator(`.nc-dropdown-single-select-cell`).nth(index).waitFor({ state: 'hidden' });
} }

83
tests/playwright/tests/db/bulkUpdate.spec.ts

@ -10,7 +10,6 @@ test.describe('Bulk update', () => {
let bulkUpdateForm: BulkUpdatePage; let bulkUpdateForm: BulkUpdatePage;
let context: any; let context: any;
let api: Api<any>; let api: Api<any>;
let records: any[];
let table; let table;
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
@ -26,7 +25,6 @@ test.describe('Bulk update', () => {
}); });
table = await createDemoTable({ context, type: 'textBased', recordCnt: 50 }); table = await createDemoTable({ context, type: 'textBased', recordCnt: 50 });
records = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list;
await page.reload(); await page.reload();
await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.closeTab({ title: 'Team & Auth' });
@ -102,7 +100,7 @@ test.describe('Bulk update', () => {
// verify api response // verify api response
const updatedRecords = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list; const updatedRecords = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list;
for (let i = 0; i < records.length; i++) { for (let i = 0; i < updatedRecords.length; i++) {
for (let j = 0; j < fields.length; j++) { for (let j = 0; j < fields.length; j++) {
expect(updatedRecords[i][fields[j]]).toEqual(fieldsFillText[j]); expect(updatedRecords[i][fields[j]]).toEqual(fieldsFillText[j]);
} }
@ -115,7 +113,6 @@ test.describe('Bulk update - Number based', () => {
let bulkUpdateForm: BulkUpdatePage; let bulkUpdateForm: BulkUpdatePage;
let context: any; let context: any;
let api: Api<any>; let api: Api<any>;
let records: any[];
let table; let table;
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
@ -131,7 +128,6 @@ test.describe('Bulk update - Number based', () => {
}); });
table = await createDemoTable({ context, type: 'numberBased', recordCnt: 50 }); table = await createDemoTable({ context, type: 'numberBased', recordCnt: 50 });
records = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list;
await page.reload(); await page.reload();
await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.closeTab({ title: 'Team & Auth' });
@ -176,7 +172,7 @@ test.describe('Bulk update - Number based', () => {
// duration in seconds // duration in seconds
const APIResponse = [1, 1.1, 1.1, 10, 60000, 3, 2024, '10:10:00']; const APIResponse = [1, 1.1, 1.1, 10, 60000, 3, 2024, '10:10:00'];
const updatedRecords = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list; const updatedRecords = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list;
for (let i = 0; i < records.length; i++) { for (let i = 0; i < updatedRecords.length; i++) {
for (let j = 0; j < fields.length; j++) { for (let j = 0; j < fields.length; j++) {
if (fields[j] === 'Time') { if (fields[j] === 'Time') {
expect(updatedRecords[i][fields[j]]).toContain(APIResponse[j]); expect(updatedRecords[i][fields[j]]).toContain(APIResponse[j]);
@ -187,3 +183,78 @@ test.describe('Bulk update - Number based', () => {
} }
}); });
}); });
test.describe('Bulk update - Select based', () => {
let dashboard: DashboardPage;
let bulkUpdateForm: BulkUpdatePage;
let context: any;
let api: Api<any>;
let table;
test.beforeEach(async ({ page }) => {
context = await setup({ page, isEmptyProject: true });
dashboard = new DashboardPage(page, context.project);
bulkUpdateForm = dashboard.bulkUpdateForm;
api = new Api({
baseURL: `http://localhost:8080/`,
headers: {
'xc-auth': context.token,
},
});
table = await createDemoTable({ context, type: 'selectBased', recordCnt: 50 });
await page.reload();
await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'selectBased' });
// Open bulk update form
await dashboard.grid.updateAll();
});
test('Select based', async () => {
const fields = ['SingleSelect', 'MultiSelect'];
const fieldsFillText = ['jan', 'jan,feb,mar'];
const fieldsFillType = ['singleSelect', 'multiSelect'];
// move all fields to active
for (let i = 0; i < fields.length; i++) {
await bulkUpdateForm.addField(0);
}
// fill all fields
for (let i = 0; i < fields.length; i++) {
await bulkUpdateForm.fillField({ columnTitle: fields[i], value: fieldsFillText[i], type: fieldsFillType[i] });
}
// save form
await bulkUpdateForm.save({ awaitResponse: true });
// verify data on grid
const displayOptions = ['jan', 'feb', 'mar'];
for (let i = 0; i < fields.length; i++) {
if (fieldsFillType[i] === 'singleSelect') {
await dashboard.grid.cell.selectOption.verify({
index: 5,
columnHeader: fields[i],
option: fieldsFillText[i],
});
} else {
await dashboard.grid.cell.selectOption.verifyOptions({
index: 5,
columnHeader: fields[i],
options: displayOptions,
});
}
}
// verify api response
const updatedRecords = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list;
for (let i = 0; i < updatedRecords.length; i++) {
for (let j = 0; j < fields.length; j++) {
expect(updatedRecords[i][fields[j]]).toContain(fieldsFillText[j]);
}
}
});
});

Loading…
Cancel
Save