Browse Source

refactor: test corrections

pull/6644/head
Pranav C 11 months ago
parent
commit
fc579bb3a4
  1. 2
      packages/nc-gui/components/dashboard/TreeView/ProjectNode.vue
  2. 4
      packages/nc-gui/components/dlg/AirtableImport.vue
  3. 2
      packages/nc-gui/components/general/HelpAndSupport.vue
  4. 2
      packages/nocodb/src/models/Base.ts
  5. 2
      packages/nocodb/tests/unit/factory/table.ts
  6. 2
      packages/nocodb/tests/unit/rest/tests/attachment.test.ts
  7. 26
      packages/nocodb/tests/unit/rest/tests/table.test.ts
  8. 2
      tests/playwright/pages/Dashboard/Settings/Miscellaneous.ts
  9. 2
      tests/playwright/pages/Dashboard/ShareProjectButton/index.ts
  10. 2
      tests/playwright/pages/Dashboard/Sidebar/index.ts
  11. 2
      tests/playwright/pages/Dashboard/TreeView.ts
  12. 10
      tests/playwright/pages/ProjectsPage/index.ts
  13. 6
      tests/playwright/pages/WorkspacePage/ContainerPage.ts
  14. 2
      tests/playwright/tests/db/features/swagger.spec.ts

2
packages/nc-gui/components/dashboard/TreeView/ProjectNode.vue

@ -514,7 +514,7 @@ const projectDelete = () => {
@click.stop=" @click.stop="
() => { () => {
$e('c:base:api-docs') $e('c:base:api-docs')
openLink(`/api/v1/db/meta/bases/${base.id}/swagger`, appInfo.ncSiteUrl) openLink(`/api/v1/db/meta/projects/${base.id}/swagger`, appInfo.ncSiteUrl)
} }
" "
> >

4
packages/nc-gui/components/dlg/AirtableImport.vue

@ -132,7 +132,7 @@ async function createOrUpdate() {
body: payload, body: payload,
}) })
} else { } else {
syncSource.value = await $fetch(`/api/v1/db/meta/bases/${baseId}/syncs/${sourceId}`, { syncSource.value = await $fetch(`/api/v1/db/meta/projects/${baseId}/syncs/${sourceId}`, {
baseURL, baseURL,
method: 'POST', method: 'POST',
headers: { 'xc-auth': $state.token.value as string }, headers: { 'xc-auth': $state.token.value as string },
@ -184,7 +184,7 @@ async function listenForUpdates() {
} }
async function loadSyncSrc() { async function loadSyncSrc() {
const data: any = await $fetch(`/api/v1/db/meta/bases/${baseId}/syncs/${sourceId}`, { const data: any = await $fetch(`/api/v1/db/meta/projects/${baseId}/syncs/${sourceId}`, {
baseURL, baseURL,
method: 'GET', method: 'GET',
headers: { 'xc-auth': $state.token.value as string }, headers: { 'xc-auth': $state.token.value as string },

2
packages/nc-gui/components/general/HelpAndSupport.vue

@ -10,7 +10,7 @@ const { base } = storeToRefs(useBase())
const route = useRoute() const route = useRoute()
const openSwaggerLink = () => { const openSwaggerLink = () => {
openLink(`./api/v1/db/meta/bases/${route.params.baseId}/swagger`, appInfo.value.ncSiteUrl) openLink(`./api/v1/db/meta/projects/${route.params.baseId}/swagger`, appInfo.value.ncSiteUrl)
} }
</script> </script>

2
packages/nocodb/src/models/Base.ts

@ -387,7 +387,7 @@ export default class Base implements BaseType {
return baseData?.id && this.get(baseData?.id, ncMeta); return baseData?.id && this.get(baseData?.id, ncMeta);
} }
static async getByTitleOrId(titleOrId: string, ncMeta = Noco.ncMeta) { static async getByTitleOrId(titleOrId: string, ncMeta = Noco.ncMeta) {
const baseId = const baseId =
titleOrId && titleOrId &&
(await NocoCache.get( (await NocoCache.get(

2
packages/nocodb/tests/unit/factory/table.ts

@ -12,7 +12,7 @@ const defaultTableValue = (context) => ({
const createTable = async (context, base, args = {}) => { const createTable = async (context, base, args = {}) => {
const defaultValue = defaultTableValue(context); const defaultValue = defaultTableValue(context);
const response = await request(context.app) const response = await request(context.app)
.post(`/api/v1/db/meta/bases/${base.id}/tables`) .post(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ ...defaultValue, ...args }); .send({ ...defaultValue, ...args });

2
packages/nocodb/tests/unit/rest/tests/attachment.test.ts

@ -134,7 +134,7 @@ function attachmentTests() {
// invite user to base with editor role // invite user to base with editor role
await request(context.app) await request(context.app)
.post(`/api/v1/db/meta/bases/${newProject.id}/users`) .post(`/api/v1/db/meta/projects/${newProject.id}/users`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ .send({
roles: ProjectRoles.EDITOR, roles: ProjectRoles.EDITOR,

26
packages/nocodb/tests/unit/rest/tests/table.test.ts

@ -40,7 +40,7 @@ function tableStaticTests() {
it('Get table list', async function () { it('Get table list', async function () {
const response = await request(context.app) const response = await request(context.app)
.get(`/api/v1/db/meta/bases/${base.id}/tables`) .get(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({}) .send({})
.expect(200); .expect(200);
@ -50,7 +50,7 @@ function tableStaticTests() {
it('Create table with no table name', async function () { it('Create table with no table name', async function () {
const response = await request(context.app) const response = await request(context.app)
.post(`/api/v1/db/meta/bases/${base.id}/tables`) .post(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ .send({
table_name: undefined, table_name: undefined,
@ -79,7 +79,7 @@ function tableStaticTests() {
it('Create table with same table name', async function () { it('Create table with same table name', async function () {
const response = await request(context.app) const response = await request(context.app)
.post(`/api/v1/db/meta/bases/${base.id}/tables`) .post(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ .send({
table_name: table.table_name, table_name: table.table_name,
@ -101,7 +101,7 @@ function tableStaticTests() {
it('Create table with same title', async function () { it('Create table with same title', async function () {
const response = await request(context.app) const response = await request(context.app)
.post(`/api/v1/db/meta/bases/${base.id}/tables`) .post(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ .send({
table_name: 'New_table_name', table_name: 'New_table_name',
@ -123,7 +123,7 @@ function tableStaticTests() {
it('Create table with title length more than the limit', async function () { it('Create table with title length more than the limit', async function () {
const response = await request(context.app) const response = await request(context.app)
.post(`/api/v1/db/meta/bases/${base.id}/tables`) .post(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ .send({
table_name: 'a'.repeat(256), table_name: 'a'.repeat(256),
@ -145,7 +145,7 @@ function tableStaticTests() {
it('Create table with title having leading white space', async function () { it('Create table with title having leading white space', async function () {
const response = await request(context.app) const response = await request(context.app)
.post(`/api/v1/db/meta/bases/${base.id}/tables`) .post(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ .send({
table_name: 'table_name_with_whitespace ', table_name: 'table_name_with_whitespace ',
@ -186,7 +186,7 @@ function tableTest() {
it('Create table', async function () { it('Create table', async function () {
const response = await request(context.app) const response = await request(context.app)
.post(`/api/v1/db/meta/bases/${base.id}/tables`) .post(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ .send({
table_name: 'table2', table_name: 'table2',
@ -282,7 +282,7 @@ function tableTest() {
it('Add and delete view should update hasNonDefaultViews', async () => { it('Add and delete view should update hasNonDefaultViews', async () => {
let response = await request(context.app) let response = await request(context.app)
.get(`/api/v1/db/meta/bases/${base.id}/tables`) .get(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({}) .send({})
.expect(200); .expect(200);
@ -296,7 +296,7 @@ function tableTest() {
}); });
response = await request(context.app) response = await request(context.app)
.get(`/api/v1/db/meta/bases/${base.id}/tables`) .get(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({}) .send({})
.expect(200); .expect(200);
@ -306,7 +306,7 @@ function tableTest() {
await deleteView(context, { viewId: view.id }); await deleteView(context, { viewId: view.id });
response = await request(context.app) response = await request(context.app)
.get(`/api/v1/db/meta/bases/${base.id}/tables`) .get(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({}) .send({})
.expect(200); .expect(200);
@ -316,7 +316,7 @@ function tableTest() {
it('Project with empty meta should update hasNonDefaultViews', async () => { it('Project with empty meta should update hasNonDefaultViews', async () => {
let response = await request(context.app) let response = await request(context.app)
.get(`/api/v1/db/meta/bases/${base.id}/tables`) .get(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({}) .send({})
.expect(200); .expect(200);
@ -337,7 +337,7 @@ function tableTest() {
}); });
response = await request(context.app) response = await request(context.app)
.get(`/api/v1/db/meta/bases/${base.id}/tables`) .get(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({}) .send({})
.expect(200); .expect(200);
@ -347,7 +347,7 @@ function tableTest() {
await deleteView(context, { viewId: view.id }); await deleteView(context, { viewId: view.id });
response = await request(context.app) response = await request(context.app)
.get(`/api/v1/db/meta/bases/${base.id}/tables`) .get(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({}) .send({})
.expect(200); .expect(200);

2
tests/playwright/pages/Dashboard/Settings/Miscellaneous.ts

@ -25,7 +25,7 @@ export class MiscSettingsPage extends BasePage {
async clickShowNullEmptyFilters() { async clickShowNullEmptyFilters() {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => this.get().locator('input[type="checkbox"]').last().click(), uiAction: () => this.get().locator('input[type="checkbox"]').last().click(),
requestUrlPathToMatch: '/api/v1/db/meta/bases', requestUrlPathToMatch: '/api/v1/db/meta/projects',
httpMethodsToMatch: ['PATCH'], httpMethodsToMatch: ['PATCH'],
}); });
} }

2
tests/playwright/pages/Dashboard/ShareProjectButton/index.ts

@ -108,7 +108,7 @@ export class ShareProjectButtonPage extends BasePage {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => this.rootPage.getByTestId('docs-base-share-public-toggle').click(), uiAction: () => this.rootPage.getByTestId('docs-base-share-public-toggle').click(),
httpMethodsToMatch: ['PATCH'], httpMethodsToMatch: ['PATCH'],
requestUrlPathToMatch: `//api/v1/db/meta/bases`, requestUrlPathToMatch: `//api/v1/db/meta/projects`,
}); });
} }

2
tests/playwright/pages/Dashboard/Sidebar/index.ts

@ -74,7 +74,7 @@ export class SidebarPage extends BasePage {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => this.dashboard.get().getByTestId('docs-create-proj-dlg-create-btn').click(), uiAction: () => this.dashboard.get().getByTestId('docs-create-proj-dlg-create-btn').click(),
httpMethodsToMatch: ['POST'], httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: `/api/v1/db/meta/bases/`, requestUrlPathToMatch: `/api/v1/db/meta/projects/`,
}); });
if (type === ProjectTypes.DOCUMENTATION) { if (type === ProjectTypes.DOCUMENTATION) {

2
tests/playwright/pages/Dashboard/TreeView.ts

@ -143,7 +143,7 @@ export class TreeViewPage extends BasePage {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => this.dashboard.get().locator('button:has-text("Create Table")').click(), uiAction: () => this.dashboard.get().locator('button:has-text("Create Table")').click(),
httpMethodsToMatch: ['POST'], httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: `/api/v1/db/meta/bases/`, requestUrlPathToMatch: `/api/v1/db/meta/projects/`,
responseJsonMatcher: json => json.title === title && json.type === 'table', responseJsonMatcher: json => json.title === title && json.type === 'table',
}); });

10
tests/playwright/pages/ProjectsPage/index.ts

@ -41,7 +41,7 @@ export class ProjectsPage extends BasePage {
await this.waitForResponse({ await this.waitForResponse({
uiAction: createProjectSubmitAction, uiAction: createProjectSubmitAction,
httpMethodsToMatch: ['POST'], httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: '/api/v1/db/meta/bases/', requestUrlPathToMatch: '/api/v1/db/meta/projects/',
}); });
// wait for dashboard to render // wait for dashboard to render
@ -103,7 +103,7 @@ export class ProjectsPage extends BasePage {
const reloadUiAction = () => this.get().locator('[data-testid="bases-reload-button"]').click(); const reloadUiAction = () => this.get().locator('[data-testid="bases-reload-button"]').click();
await this.waitForResponse({ await this.waitForResponse({
uiAction: reloadUiAction, uiAction: reloadUiAction,
requestUrlPathToMatch: '//api/v1/db/meta/bases', requestUrlPathToMatch: '//api/v1/db/meta/projects',
httpMethodsToMatch: ['GET'], httpMethodsToMatch: ['GET'],
}); });
} }
@ -145,7 +145,7 @@ export class ProjectsPage extends BasePage {
} }
const isRequiredResponse = const isRequiredResponse =
res.request().url().includes('//api/v1/db/meta/bases') && res.request().url().includes('/api/v1/db/meta/projects') &&
['GET'].includes(res.request().method()) && ['GET'].includes(res.request().method()) &&
json?.title === title; json?.title === title;
@ -180,7 +180,7 @@ export class ProjectsPage extends BasePage {
await this.waitForResponse({ await this.waitForResponse({
uiAction: deleteProjectAction, uiAction: deleteProjectAction,
httpMethodsToMatch: ['DELETE'], httpMethodsToMatch: ['DELETE'],
requestUrlPathToMatch: '/api/v1/db/meta/bases/', requestUrlPathToMatch: '/api/v1/db/meta/projects/',
}); });
await this.get().locator('.ant-table-row', { hasText: title }).waitFor({ state: 'hidden' }); await this.get().locator('.ant-table-row', { hasText: title }).waitFor({ state: 'hidden' });
@ -212,7 +212,7 @@ export class ProjectsPage extends BasePage {
const submitAction = () => base.locator('input.nc-metadb-base-name').press('Enter'); const submitAction = () => base.locator('input.nc-metadb-base-name').press('Enter');
await this.waitForResponse({ await this.waitForResponse({
uiAction: submitAction, uiAction: submitAction,
requestUrlPathToMatch: '/api/v1/db/meta/bases/', requestUrlPathToMatch: '/api/v1/db/meta/projects/',
httpMethodsToMatch: ['PATCH'], httpMethodsToMatch: ['PATCH'],
}); });
} }

6
tests/playwright/pages/WorkspacePage/ContainerPage.ts

@ -140,7 +140,7 @@ export class ContainerPage extends BasePage {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => this.rootPage.locator('.nc-metadb-base-name').press('Enter'), uiAction: () => this.rootPage.locator('.nc-metadb-base-name').press('Enter'),
httpMethodsToMatch: ['POST'], httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: `/api/v1/db/meta/bases`, requestUrlPathToMatch: `/api/v1/db/meta/projects`,
}); });
} }
@ -154,7 +154,7 @@ export class ContainerPage extends BasePage {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => row.locator('td.ant-table-cell').nth(0).locator('input').press('Enter'), uiAction: () => row.locator('td.ant-table-cell').nth(0).locator('input').press('Enter'),
httpMethodsToMatch: ['PATCH'], httpMethodsToMatch: ['PATCH'],
requestUrlPathToMatch: `/api/v1/db/meta/bases/`, requestUrlPathToMatch: `/api/v1/db/meta/projects/`,
}); });
} }
@ -185,7 +185,7 @@ export class ContainerPage extends BasePage {
await this.waitForResponse({ await this.waitForResponse({
uiAction: () => this.rootPage.locator('.ant-modal-content').locator('button:has-text("Delete")').click(), uiAction: () => this.rootPage.locator('.ant-modal-content').locator('button:has-text("Delete")').click(),
httpMethodsToMatch: ['DELETE'], httpMethodsToMatch: ['DELETE'],
requestUrlPathToMatch: `/api/v1/db/meta/bases/`, requestUrlPathToMatch: `/api/v1/db/meta/projects/`,
}); });
} }

2
tests/playwright/tests/db/features/swagger.spec.ts

@ -17,7 +17,7 @@ test.describe('Swagger', () => {
test('Create column', async () => { test('Create column', async () => {
// access swagger link // access swagger link
const link = `http://localhost:8080/api/v1/db/meta/bases/${context.base.id}/swagger`; const link = `http://localhost:8080/api/v1/db/meta/projects/${context.base.id}/swagger`;
await dashboard.rootPage.goto(link); await dashboard.rootPage.goto(link);
const swagger = dashboard.rootPage; const swagger = dashboard.rootPage;

Loading…
Cancel
Save