Browse Source

test: bulk update - text based

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
test/pw-duplicate-check
Raju Udava 2 years ago
parent
commit
9fa90ec93b
  1. 29
      tests/playwright/pages/Dashboard/BulkUpdate/index.ts
  2. 45
      tests/playwright/tests/db/bulkUpdate.spec.ts

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

@ -85,34 +85,15 @@ export class BulkUpdatePage extends BasePage {
async fillField({ columnTitle, value, type = 'text' }: { columnTitle: string; value: string; type?: string }) {
const field = this.form.locator(`[data-testid="nc-form-input-${columnTitle}"]`);
await field.hover();
await field.click();
switch (type) {
case 'text':
await field.locator('input').waitFor();
await field.locator('input').fill(value);
break;
case 'geodata': {
const [lat, long] = value.split(',');
await this.rootPage.locator(`[data-testid="nc-geo-data-set-location-button"]`).click();
await this.rootPage.locator(`[data-testid="nc-geo-data-latitude"]`).fill(lat);
await this.rootPage.locator(`[data-testid="nc-geo-data-longitude"]`).fill(long);
await this.rootPage.locator(`[data-testid="nc-geo-data-save"]`).click();
break;
}
case 'belongsTo':
await field.locator('.nc-action-icon').click();
await this.dashboard.linkRecord.select(value);
break;
case 'hasMany':
case 'manyToMany':
await field.locator(`[data-testid="nc-child-list-button-link-to"]`).click();
await this.dashboard.linkRecord.select(value);
break;
case 'dateTime':
await field.locator('.nc-cell').click();
// eslint-disable-next-line no-case-declarations
const dateTimeObj = new DateTimeCellPageObject(this.dashboard.grid.cell);
await dateTimeObj.selectDate({ date: value.slice(0, 10) });
await dateTimeObj.selectTime({ hour: +value.slice(11, 13), minute: +value.slice(14, 16) });
await dateTimeObj.save();
case 'longText':
await field.locator('textarea').waitFor();
await field.locator('textarea').fill(value);
break;
}
}

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

@ -11,6 +11,7 @@ test.describe('Bulk update', () => {
let context: any;
let api: Api<any>;
let records: any[];
let table;
test.beforeEach(async ({ page }) => {
context = await setup({ page, isEmptyProject: true });
@ -24,8 +25,8 @@ test.describe('Bulk update', () => {
},
});
const table = await createDemoTable({ context, type: 'textBased', recordCnt: 50 });
records = await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 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 dashboard.closeTab({ title: 'Team & Auth' });
@ -73,4 +74,44 @@ test.describe('Bulk update', () => {
'URL',
]);
});
test('Text based', async () => {
await bulkUpdateForm.addField(0);
await bulkUpdateForm.addField(0);
await bulkUpdateForm.addField(0);
await bulkUpdateForm.addField(0);
await bulkUpdateForm.addField(0);
await bulkUpdateForm.fillField({ columnTitle: 'SingleLineText', value: 'SingleLineText', type: 'text' });
await bulkUpdateForm.fillField({ columnTitle: 'Email', value: 'a@b.com', type: 'text' });
await bulkUpdateForm.fillField({ columnTitle: 'PhoneNumber', value: '987654321', type: 'text' });
await bulkUpdateForm.fillField({ columnTitle: 'URL', value: 'htps://www.google.com', type: 'text' });
await bulkUpdateForm.fillField({
columnTitle: 'MultiLineText',
value: 'Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. ',
type: 'longText',
});
await bulkUpdateForm.save({ awaitResponse: true });
await dashboard.grid.cell.verify({ index: 5, columnHeader: 'SingleLineText', value: 'SingleLineText' });
await dashboard.grid.cell.verify({ index: 5, columnHeader: 'Email', value: 'a@b.com' });
await dashboard.grid.cell.verify({ index: 5, columnHeader: 'PhoneNumber', value: '987654321' });
await dashboard.grid.cell.verify({ index: 5, columnHeader: 'URL', value: 'htps://www.google.com' });
await dashboard.grid.cell.verify({
index: 5,
columnHeader: 'MultiLineText',
value: 'Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. ',
});
const updatedRecords = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list;
for (let i = 0; i < records.length; i++) {
expect(updatedRecords[i].SingleLineText).toEqual('SingleLineText');
expect(updatedRecords[i].Email).toEqual('a@b.com');
expect(updatedRecords[i].PhoneNumber).toEqual('987654321');
expect(updatedRecords[i].URL).toEqual('htps://www.google.com');
expect(updatedRecords[i].MultiLineText).toEqual(
'Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. '
);
}
});
});

Loading…
Cancel
Save