Browse Source

test: fix single select record insert using api

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

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

@ -31,23 +31,11 @@ test.describe('Multi select', () => {
options: ['Option 1', 'Option 2'], options: ['Option 1', 'Option 2'],
}); });
api = new Api({ api = context.api;
baseURL: `http://localhost:8080/`,
headers: {
'xc-auth': context.token,
},
});
const tables = await api.dbTable.list(context.base.id); const tables = await api.dbTable.list(context.base.id);
tableId = tables.list.find((table: any) => table.title === 'sheet1').id; tableId = tables.list.find((table: any) => table.title === 'sheet1').id;
await addRecordUsingAPI(context, tableId, [ await addRecordUsingAPI(context, tableId, [{ Id: 1, Title: `Row 0` }]);
{
Id: 1,
Title: `Row 0`,
},
]);
// page reload
await page.reload(); 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 { GridPage } from '../../../pages/Dashboard/Grid';
import setup, { unsetup } from '../../../setup'; import setup, { unsetup } from '../../../setup';
import { ToolbarPage } from '../../../pages/Dashboard/common/Toolbar'; import { ToolbarPage } from '../../../pages/Dashboard/common/Toolbar';
import { Api } from 'nocodb-sdk';
test.describe('Single select', () => { test.describe('Single select', () => {
let dashboard: DashboardPage, grid: GridPage; let dashboard: DashboardPage, grid: GridPage;
let context: any; let context: any;
let api: Api<any>;
let tableId: string;
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
context = await setup({ page, isEmptyProject: true }); context = await setup({ page, isEmptyProject: true });
dashboard = new DashboardPage(page, context.base); dashboard = new DashboardPage(page, context.base);
grid = dashboard.grid; grid = dashboard.grid;
api = context.api;
await dashboard.treeView.createTable({ title: 'sheet1', baseTitle: context.base.title }); await dashboard.treeView.createTable({ title: 'sheet1', baseTitle: context.base.title });
@ -20,7 +24,11 @@ test.describe('Single select', () => {
columnTitle: 'SingleSelect', columnTitle: 'SingleSelect',
options: ['Option 1', 'Option 2'], 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 () => { test.afterEach(async () => {
@ -120,12 +128,15 @@ test.describe('Single select - filter & sort', () => {
let dashboard: DashboardPage, grid: GridPage, toolbar: ToolbarPage; let dashboard: DashboardPage, grid: GridPage, toolbar: ToolbarPage;
let context: any; let context: any;
let api: Api<any>;
let tableId: string;
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
context = await setup({ page }); context = await setup({ page });
dashboard = new DashboardPage(page, context.base); dashboard = new DashboardPage(page, context.base);
toolbar = dashboard.grid.toolbar; toolbar = dashboard.grid.toolbar;
grid = dashboard.grid; grid = dashboard.grid;
api = context.api;
await dashboard.treeView.createTable({ title: 'sheet1', baseTitle: context.base.title }); await dashboard.treeView.createTable({ title: 'sheet1', baseTitle: context.base.title });
@ -134,10 +145,21 @@ test.describe('Single select - filter & sort', () => {
columnTitle: 'SingleSelect', columnTitle: 'SingleSelect',
options: ['foo', 'bar', 'baz'], options: ['foo', 'bar', 'baz'],
}); });
await grid.addNewRow({ index: 0, value: '1' });
await grid.addNewRow({ index: 1, value: '2' }); const tables = await api.dbTable.list(context.base.id);
await grid.addNewRow({ index: 2, value: '3' }); tableId = tables.list.find((table: any) => table.title === 'sheet1').id;
await grid.addNewRow({ index: 3, value: '4' }); 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: 1, columnHeader: 'SingleSelect', option: 'foo', multiSelect: false });
await grid.cell.selectOption.select({ index: 2, columnHeader: 'SingleSelect', option: 'bar', 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()) { if (isEE()) {
workspacePage = new WorkspacePage(page); workspacePage = new WorkspacePage(page);
collaborationPage = workspacePage.collaboration; collaborationPage = workspacePage.collaboration;
api = context.api;
api = new Api({
baseURL: `http://localhost:8080/`,
headers: {
'xc-auth': context.token,
},
});
for (let i = 0; i < roleDb.length; i++) { for (let i = 0; i < roleDb.length; i++) {
try { try {

Loading…
Cancel
Save