Browse Source

test: undo-redo for links

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5848/head
Raju Udava 1 year ago committed by Pranav C
parent
commit
77f5986b0f
  1. 5
      tests/playwright/pages/Dashboard/common/Cell/index.ts
  2. 39
      tests/playwright/tests/db/undo-redo.spec.ts

5
tests/playwright/pages/Dashboard/common/Cell/index.ts

@ -329,12 +329,13 @@ export class CellPageObject extends BasePage {
async unlinkVirtualCell({ index, columnHeader }: CellProps) {
const cell = this.get({ index, columnHeader });
await cell.click();
await cell.locator('.nc-datatype-link').click();
await this.waitForResponse({
uiAction: () => cell.locator('.unlink-icon').first().click(),
uiAction: () => this.rootPage.locator(`[data-testid="nc-child-list-icon-unlink"]`).first().click(),
requestUrlPathToMatch: '/api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'],
});
await this.rootPage.keyboard.press('Escape');
}
async verifyRoleAccess(param: { role: string }) {

39
tests/playwright/tests/db/undo-redo.spec.ts

@ -546,18 +546,35 @@ test.describe('Undo Redo - LTAR', () => {
// inserted values
const expectedValues = [...values];
const currentRecords: Record<string, any> = await api.dbTableRow.list('noco', context.project.id, countryTable.id, {
fields: ['CityList'],
limit: 100,
});
try {
const currentRecords: Record<string, any> = await api.dbTableRow.list(
'noco',
context.project.id,
countryTable.id,
{
fields: ['CityList'],
limit: 100,
}
);
expect(currentRecords.list.length).toBe(4);
expect(currentRecords.list[0].CityList).toBe(expectedValues.length);
} catch (e) {
console.log(e);
}
// verify if expectedValues array includes all the values in currentRecords
// currentRecords [ { Id: 1, City: 'Mumbai' }, { Id: 3, City: 'Delhi' } ]
// expectedValues [ 'Mumbai', 'Delhi' ]
currentRecords.list[0].CityList.forEach((record: any) => {
expect(expectedValues).toContain(record.City);
});
expect(currentRecords.list[0].CityList.length).toBe(expectedValues.length);
if (expectedValues.length > 0) {
// read nested records associated with first record
const nestedRecords: Record<string, any> = await api.dbTableRow.nestedList(
'noco',
context.project.id,
countryTable.id,
1,
'hm',
'CityList'
);
const cities = nestedRecords.list.map((record: any) => record.City);
expect(cities).toEqual(expectedValues);
}
}
async function undo({ page, values }: { page: Page; values: string[] }) {

Loading…
Cancel
Save