Browse Source

test: fix single select record insert using api

pull/8380/head
Raju Udava 5 months ago
parent
commit
30e79b1a28
  1. 4
      tests/playwright/setup/index.ts
  2. 16
      tests/playwright/tests/db/columns/columnMultiSelect.spec.ts
  3. 32
      tests/playwright/tests/db/columns/columnSingleSelect.spec.ts
  4. 8
      tests/playwright/tests/db/columns/columnUserSelect.spec.ts

4
tests/playwright/setup/index.ts

@ -155,6 +155,7 @@ export interface NcContext {
workspace: WorkspaceType;
defaultProjectTitle: string;
defaultTableTitle: string;
api: Api<any>;
}
selectors.setTestIdAttribute('data-testid');
@ -344,7 +345,7 @@ async function localInit({
// get current user information
const user = await api.auth.me();
return { data: { base, user, workspace, token }, status: 200 };
return { data: { base, user, workspace, token, api }, status: 200 };
} catch (e) {
console.error(`Error resetting base: ${process.env.TEST_PARALLEL_INDEX}`, e);
return { data: {}, status: 500 };
@ -477,6 +478,7 @@ const setup = async ({
workspace,
defaultProjectTitle: 'Getting Started',
defaultTableTitle: 'Features',
api: response?.data?.api,
} as NcContext;
};

16
tests/playwright/tests/db/columns/columnMultiSelect.spec.ts

@ -31,23 +31,11 @@ test.describe('Multi select', () => {
options: ['Option 1', 'Option 2'],
});
api = new Api({
baseURL: `http://localhost:8080/`,
headers: {
'xc-auth': context.token,
},
});
api = context.api;
const tables = await api.dbTable.list(context.base.id);
tableId = tables.list.find((table: any) => table.title === 'sheet1').id;
await addRecordUsingAPI(context, tableId, [
{
Id: 1,
Title: `Row 0`,
},
]);
// page reload
await addRecordUsingAPI(context, tableId, [{ Id: 1, Title: `Row 0` }]);
await page.reload();
});

32
tests/playwright/tests/db/columns/columnSingleSelect.spec.ts

@ -3,15 +3,19 @@ import { DashboardPage } from '../../../pages/Dashboard';
import { GridPage } from '../../../pages/Dashboard/Grid';
import setup, { unsetup } from '../../../setup';
import { ToolbarPage } from '../../../pages/Dashboard/common/Toolbar';
import { Api } from 'nocodb-sdk';
test.describe('Single select', () => {
let dashboard: DashboardPage, grid: GridPage;
let context: any;
let api: Api<any>;
let tableId: string;
test.beforeEach(async ({ page }) => {
context = await setup({ page, isEmptyProject: true });
dashboard = new DashboardPage(page, context.base);
grid = dashboard.grid;
api = context.api;
await dashboard.treeView.createTable({ title: 'sheet1', baseTitle: context.base.title });
@ -20,7 +24,11 @@ test.describe('Single select', () => {
columnTitle: 'SingleSelect',
options: ['Option 1', 'Option 2'],
});
await grid.addNewRow({ index: 0, value: 'Row 0' });
const tables = await api.dbTable.list(context.base.id);
tableId = tables.list.find((table: any) => table.title === 'sheet1').id;
await api.dbTableRow.bulkCreate('noco', context.base.id, tableId, [{ Id: 1, Title: `Row 0` }]);
await page.reload();
});
test.afterEach(async () => {
@ -120,12 +128,15 @@ test.describe('Single select - filter & sort', () => {
let dashboard: DashboardPage, grid: GridPage, toolbar: ToolbarPage;
let context: any;
let api: Api<any>;
let tableId: string;
test.beforeEach(async ({ page }) => {
context = await setup({ page });
dashboard = new DashboardPage(page, context.base);
toolbar = dashboard.grid.toolbar;
grid = dashboard.grid;
api = context.api;
await dashboard.treeView.createTable({ title: 'sheet1', baseTitle: context.base.title });
@ -134,10 +145,21 @@ test.describe('Single select - filter & sort', () => {
columnTitle: 'SingleSelect',
options: ['foo', 'bar', 'baz'],
});
await grid.addNewRow({ index: 0, value: '1' });
await grid.addNewRow({ index: 1, value: '2' });
await grid.addNewRow({ index: 2, value: '3' });
await grid.addNewRow({ index: 3, value: '4' });
const tables = await api.dbTable.list(context.base.id);
tableId = tables.list.find((table: any) => table.title === 'sheet1').id;
await api.dbTableRow.bulkCreate('noco', context.base.id, tableId, [
{ Id: 1, Title: '1' },
{ Id: 2, Title: '2' },
{ Id: 3, Title: '3' },
{ Id: 4, Title: '4' },
]);
await page.reload();
// await grid.addNewRow({ index: 0, value: '1' });
// await grid.addNewRow({ index: 1, value: '2' });
// await grid.addNewRow({ index: 2, value: '3' });
// await grid.addNewRow({ index: 3, value: '4' });
await grid.cell.selectOption.select({ index: 1, columnHeader: 'SingleSelect', option: 'foo', multiSelect: false });
await grid.cell.selectOption.select({ index: 2, columnHeader: 'SingleSelect', option: 'bar', multiSelect: false });

8
tests/playwright/tests/db/columns/columnUserSelect.spec.ts

@ -33,13 +33,7 @@ async function beforeEachInit({ page }: { page: any }) {
if (isEE()) {
workspacePage = new WorkspacePage(page);
collaborationPage = workspacePage.collaboration;
api = new Api({
baseURL: `http://localhost:8080/`,
headers: {
'xc-auth': context.token,
},
});
api = context.api;
for (let i = 0; i < roleDb.length; i++) {
try {

Loading…
Cancel
Save