ToolJet/server/test/services/app_import_export.service.spec.ts

323 lines
12 KiB
TypeScript
Raw Normal View History

import {
clearDB,
createUser,
createNestAppInstance,
createApplication,
createApplicationVersion,
createDataQuery,
createDataSource,
generateAppDefaults,
createAppEnvironments,
getAppWithAllDetails,
} from '../test.helper';
import { INestApplication } from '@nestjs/common';
import { getManager, In } from 'typeorm';
import { App } from 'src/entities/app.entity';
import { GroupPermission } from 'src/entities/group_permission.entity';
import { AppImportExportService } from '@services/app_import_export.service';
import { AppGroupPermission } from 'src/entities/app_group_permission.entity';
describe('AppImportExportService', () => {
let nestApp: INestApplication;
let service: AppImportExportService;
beforeEach(async () => {
await clearDB();
});
beforeAll(async () => {
nestApp = await createNestAppInstance();
service = nestApp.get<AppImportExportService>(AppImportExportService);
});
describe('.export', () => {
it('should export app with empty related associations', async () => {
const adminUserData = await createUser(nestApp, {
email: 'admin@tooljet.io',
groups: ['all_users', 'admin'],
});
const adminUser = adminUserData.user;
const { application: app } = await generateAppDefaults(nestApp, adminUserData.user, {
isAppPublic: true,
isDataSourceNeeded: false,
isQueryNeeded: false,
});
Feature - Multi Environment support (#4833) * initial commit * multi env changes * multi-env changes * entity fixes * data query changes * fix * trying to avoid conflict with EE * moved version creation to app creation function * fixing some issues * execution of data query * revert options changes * changed migration * fixed some migration issues: testing migration * multi env support * app import export fix * fixes * migration fixes * removed plugins from data query * fixing some migration issues * fixes * remove console log * fix * front end api changes * backward compatibility for app import * Fixed a bug * correcting some mistakes * Added constraints and fixed some issues * changes * fix for data source listing * fixing version operation issues * remove kind from data query * removed kind from data query * fixes * fixes * fix for version creation * migration fixes * Fixed preview and run query issues * Fix: new version and event query id issue * fixed rest api oauth issue - next test refresh token * import export changes * fixes for app import * import fix * added await for for loops * fix * fix for migration * Fixed backend oauth-envId issue * import export changes * migration fixes * fix * fix * fix for app import from 0.9.0 * test case fixes * test case fixes * making app name mandatory for import * adding type for options * fix: imported apps query linking issues * review changes * lint issue fixes * added on delete cascade Co-authored-by: Muhsin Shah <muhsinshah21@gmail.com>
2022-12-09 14:53:42 +00:00
const { appV2: result } = await service.export(adminUser, app.id);
expect(result.id).toBe(app.id);
expect(result.name).toBe(app.name);
expect(result.isPublic).toBe(app.isPublic);
expect(result.organizationId).toBe(app.organizationId);
expect(result.currentVersionId).toBe(null);
expect(result['dataQueries']).toEqual([]);
expect(result['dataSources']).toEqual([]);
});
it('should export app', async () => {
const adminUserData = await createUser(nestApp, {
email: 'admin@tooljet.io',
groups: ['all_users', 'admin'],
});
const adminUser = adminUserData.user;
const { application } = await generateAppDefaults(nestApp, adminUserData.user, {
isAppPublic: true,
});
const exportedApp = await getAppWithAllDetails(application.id);
Feature - Multi Environment support (#4833) * initial commit * multi env changes * multi-env changes * entity fixes * data query changes * fix * trying to avoid conflict with EE * moved version creation to app creation function * fixing some issues * execution of data query * revert options changes * changed migration * fixed some migration issues: testing migration * multi env support * app import export fix * fixes * migration fixes * removed plugins from data query * fixing some migration issues * fixes * remove console log * fix * front end api changes * backward compatibility for app import * Fixed a bug * correcting some mistakes * Added constraints and fixed some issues * changes * fix for data source listing * fixing version operation issues * remove kind from data query * removed kind from data query * fixes * fixes * fix for version creation * migration fixes * Fixed preview and run query issues * Fix: new version and event query id issue * fixed rest api oauth issue - next test refresh token * import export changes * fixes for app import * import fix * added await for for loops * fix * fix for migration * Fixed backend oauth-envId issue * import export changes * migration fixes * fix * fix * fix for app import from 0.9.0 * test case fixes * test case fixes * making app name mandatory for import * adding type for options * fix: imported apps query linking issues * review changes * lint issue fixes * added on delete cascade Co-authored-by: Muhsin Shah <muhsinshah21@gmail.com>
2022-12-09 14:53:42 +00:00
const { appV2: result } = await service.export(adminUser, exportedApp.id);
expect(result.id).toBe(exportedApp.id);
expect(result.name).toBe(exportedApp.name);
expect(result.isPublic).toBe(exportedApp.isPublic);
expect(result.organizationId).toBe(exportedApp.organizationId);
expect(result.currentVersionId).toBe(null);
expect(result.appVersions).toEqual(exportedApp.appVersions);
expect(result['dataQueries']).toEqual(exportedApp['dataQueries']);
expect(result['dataSources']).toEqual(exportedApp['dataSources']);
});
it('should export app with filtered version', async () => {
const adminUserData = await createUser(nestApp, {
email: 'admin@tooljet.io',
groups: ['all_users', 'admin'],
});
const adminUser = adminUserData.user;
[Improvements] Environment changes (#6762) * Added priority, enabled, current_environment_id columns - added data-migrations to backfill the priority and current environment id for each version * working on multi environments improvement - added checks for promoted env - promote env feature - released app & production env check - promoted version definition check * added import support * working on migration issues * fixed failing migration * fixed failing migration once again * Fixed possible bugs - seed - test case helpers - app version release * fixed migration bug * working on migration progress * working on migration progress class * added migration progress * fixed unit tests * fixed e2e cases * added default priority * added PR changes * changed import logic * added global datasource design and api changes * changed default env if the id is null * added unique constraint and a bug fix * changed app versions api - added current environment id to the where conditions * fixed failing test cases * added new test cases * added new api changes * added back the enabled check * fixed test case * change: added environment to create versions dto * typo: environmentId * added new api for fetching versions * added appVersions count changes to CE * Changed app versions by environmentid logic * added PR changes for EE * fixed wrong promoted env id issue * fix: can't switch to staging * added import export changes - update delete modal text * added EE import export code, modal updated text * added common migration code for CE and EE * fixes - enable run button for released version - disable change datasource for queries * changed released version popup design to new EE design * add: hide delete icons for released version
2023-07-11 04:40:03 +00:00
const application = await createApplication(
nestApp,
{
user: adminUser,
name: 'sample app',
isPublic: true,
},
false
);
[Feature] :: Global datasources (#5504) * add: columns and migrations for data queries and sources * add: migrations for app environments * fix: datasources and queries api * fix: import apis * add: radixui colors * create: global datasource page * fix: version creation not including global datasources queries * fix: version deletion failure * fix: ui and other bugs * add: check for abilities on global ds * fix: bugs * fix: existing test cases * fix: migration and bugs * fix: rest api oauthorize bugs * hide: add button for local ds * fix: query bugs * fix: new organization environment creation * fix: local ds label showing for new apps * fix: on page load queries for preview app and published app * fix: import bugs from v1 * fix: merge conflicts * fix: import apis * fix: apss with mulit envs * fix: ui bugs * fix: environments not being created on db:seed * fix: ui bugs * fix: route settings for global datasources * fix: customer dashboard template * fix: local ds queries not being saved * fix: runpy issues * changes: ui * fix: migration issues * fix: ui * hide datasources when no local datasources * fix: test cases * fix: unit test cases and global queries on app import/export * cleanup * add: package-lock file * undo: migration rename * cleanup * fix: ui bugs * migration fixes * fix: dark mode issues * fix: change datasource failing on query create mode * fix: workspace selector issues * fix: clickoutside for change scope option * migration changes * fix: open api issue * reverting configs changes * [Fix] Global datasources & Environment Id issue (#5830) * fix: oauth env id issue * code changes --------- Co-authored-by: gsmithun4 <gsmithun4@gmail.com> Co-authored-by: Muhsin Shah <muhsinshah21@gmail.com>
2023-03-24 16:11:21 +00:00
await createAppEnvironments(nestApp, adminUser.organizationId);
[Improvements] Environment changes (#6762) * Added priority, enabled, current_environment_id columns - added data-migrations to backfill the priority and current environment id for each version * working on multi environments improvement - added checks for promoted env - promote env feature - released app & production env check - promoted version definition check * added import support * working on migration issues * fixed failing migration * fixed failing migration once again * Fixed possible bugs - seed - test case helpers - app version release * fixed migration bug * working on migration progress * working on migration progress class * added migration progress * fixed unit tests * fixed e2e cases * added default priority * added PR changes * changed import logic * added global datasource design and api changes * changed default env if the id is null * added unique constraint and a bug fix * changed app versions api - added current environment id to the where conditions * fixed failing test cases * added new test cases * added new api changes * added back the enabled check * fixed test case * change: added environment to create versions dto * typo: environmentId * added new api for fetching versions * added appVersions count changes to CE * Changed app versions by environmentid logic * added PR changes for EE * fixed wrong promoted env id issue * fix: can't switch to staging * added import export changes - update delete modal text * added EE import export code, modal updated text * added common migration code for CE and EE * fixes - enable run button for released version - disable change datasource for queries * changed released version popup design to new EE design * add: hide delete icons for released version
2023-07-11 04:40:03 +00:00
const appVersion1 = await createApplicationVersion(nestApp, application, { name: 'v1', definition: {} });
const dataSource1 = await createDataSource(nestApp, {
appVersion: appVersion1,
kind: 'test_kind',
name: 'test_name_1',
});
const dataQuery1 = await createDataQuery(nestApp, {
dataSource: dataSource1,
Feature: Import export tjdb schema (#5752) * add ability to import export app and tjdb schema * init * feat ::global settings popover new ui * feat :: ui for version export modal * fix :: import export modal * cleanup * ui updates * header footer style fixes * closing settings modal while showing export modal * style fix header * feat :: added button to download table schema * fix :: styling for fx * add ability to import and export apps with tjdb schema * handle duplicate table in workspace * fix table rename * fix selected table on edit and delete * fix invalid toast on table delete * fix column default value * handle exports to strip '::' and quotes * make import/export backward compatible * handle page redirects based on resource import * handle import without tjdb schema * fix column delete and addition * make data migrations to be run per organizations * wip * update migration * fix credentials to be included * fix specific version export * make use of apps ability for import export resource * fix import navigation * fix lint * fix failing tests * fix lint * enable tjdb for public apps * update export error message on tjdb table blank * fix table not selected after creation * fix :: styling for imp exp modal , and functionality bug fixes after dev merge * fixes blank slate and columns selection * fix table delete * fix invalid toast on table edit * fix column information missing tjdb query manager * make ds imports to either reuse global or create * export only unique table ids * create default datasources if not present in export data * reuse existing table on imports * add timestamp to table name if name already exists * add ability to clone with tjdb * make imports work with marketplace plugin * skip dataqueries for which plugins are not installed * fix filter input width * fix failing spec * fix marketplace plugin installation in diff workspaces * fix check for plugin installed in workspace * fix export when table name is empty --------- Co-authored-by: stepinfwd <stepinfwd@gmail.com>
2023-08-28 15:53:15 +00:00
appVersion: appVersion1,
name: 'test_query_1',
kind: 'test_kind',
});
const appVersion2 = await createApplicationVersion(nestApp, application, {
name: 'v2',
definition: { hello: 'world' },
});
const dataSource2 = await createDataSource(nestApp, {
appVersion: appVersion2,
kind: 'test_kind',
name: 'test_name_2',
});
const dataQuery2 = await createDataQuery(nestApp, {
Feature: Import export tjdb schema (#5752) * add ability to import export app and tjdb schema * init * feat ::global settings popover new ui * feat :: ui for version export modal * fix :: import export modal * cleanup * ui updates * header footer style fixes * closing settings modal while showing export modal * style fix header * feat :: added button to download table schema * fix :: styling for fx * add ability to import and export apps with tjdb schema * handle duplicate table in workspace * fix table rename * fix selected table on edit and delete * fix invalid toast on table delete * fix column default value * handle exports to strip '::' and quotes * make import/export backward compatible * handle page redirects based on resource import * handle import without tjdb schema * fix column delete and addition * make data migrations to be run per organizations * wip * update migration * fix credentials to be included * fix specific version export * make use of apps ability for import export resource * fix import navigation * fix lint * fix failing tests * fix lint * enable tjdb for public apps * update export error message on tjdb table blank * fix table not selected after creation * fix :: styling for imp exp modal , and functionality bug fixes after dev merge * fixes blank slate and columns selection * fix table delete * fix invalid toast on table edit * fix column information missing tjdb query manager * make ds imports to either reuse global or create * export only unique table ids * create default datasources if not present in export data * reuse existing table on imports * add timestamp to table name if name already exists * add ability to clone with tjdb * make imports work with marketplace plugin * skip dataqueries for which plugins are not installed * fix filter input width * fix failing spec * fix marketplace plugin installation in diff workspaces * fix check for plugin installed in workspace * fix export when table name is empty --------- Co-authored-by: stepinfwd <stepinfwd@gmail.com>
2023-08-28 15:53:15 +00:00
appVersion: appVersion2,
dataSource: dataSource2,
name: 'test_query_2',
});
const exportedApp = await getManager().findOneOrFail(App, {
where: { id: application.id },
});
Feature: Import export tjdb schema (#5752) * add ability to import export app and tjdb schema * init * feat ::global settings popover new ui * feat :: ui for version export modal * fix :: import export modal * cleanup * ui updates * header footer style fixes * closing settings modal while showing export modal * style fix header * feat :: added button to download table schema * fix :: styling for fx * add ability to import and export apps with tjdb schema * handle duplicate table in workspace * fix table rename * fix selected table on edit and delete * fix invalid toast on table delete * fix column default value * handle exports to strip '::' and quotes * make import/export backward compatible * handle page redirects based on resource import * handle import without tjdb schema * fix column delete and addition * make data migrations to be run per organizations * wip * update migration * fix credentials to be included * fix specific version export * make use of apps ability for import export resource * fix import navigation * fix lint * fix failing tests * fix lint * enable tjdb for public apps * update export error message on tjdb table blank * fix table not selected after creation * fix :: styling for imp exp modal , and functionality bug fixes after dev merge * fixes blank slate and columns selection * fix table delete * fix invalid toast on table edit * fix column information missing tjdb query manager * make ds imports to either reuse global or create * export only unique table ids * create default datasources if not present in export data * reuse existing table on imports * add timestamp to table name if name already exists * add ability to clone with tjdb * make imports work with marketplace plugin * skip dataqueries for which plugins are not installed * fix filter input width * fix failing spec * fix marketplace plugin installation in diff workspaces * fix check for plugin installed in workspace * fix export when table name is empty --------- Co-authored-by: stepinfwd <stepinfwd@gmail.com>
2023-08-28 15:53:15 +00:00
let { appV2: result } = await service.export(adminUser, exportedApp.id, { version_id: appVersion1.id });
expect(result.id).toBe(exportedApp.id);
expect(result.name).toBe(exportedApp.name);
expect(result.isPublic).toBe(exportedApp.isPublic);
expect(result.organizationId).toBe(exportedApp.organizationId);
expect(result.currentVersionId).toBe(null);
expect(result['dataQueries'].length).toBe(1);
expect(result['dataQueries'][0].name).toEqual(dataQuery1.name);
expect(result['dataSources'].length).toBe(1);
expect(result['dataSources'][0].name).toEqual(dataSource1.name);
expect(result.appVersions.length).toBe(1);
expect(result.appVersions[0].name).toEqual(appVersion1.name);
Feature: Import export tjdb schema (#5752) * add ability to import export app and tjdb schema * init * feat ::global settings popover new ui * feat :: ui for version export modal * fix :: import export modal * cleanup * ui updates * header footer style fixes * closing settings modal while showing export modal * style fix header * feat :: added button to download table schema * fix :: styling for fx * add ability to import and export apps with tjdb schema * handle duplicate table in workspace * fix table rename * fix selected table on edit and delete * fix invalid toast on table delete * fix column default value * handle exports to strip '::' and quotes * make import/export backward compatible * handle page redirects based on resource import * handle import without tjdb schema * fix column delete and addition * make data migrations to be run per organizations * wip * update migration * fix credentials to be included * fix specific version export * make use of apps ability for import export resource * fix import navigation * fix lint * fix failing tests * fix lint * enable tjdb for public apps * update export error message on tjdb table blank * fix table not selected after creation * fix :: styling for imp exp modal , and functionality bug fixes after dev merge * fixes blank slate and columns selection * fix table delete * fix invalid toast on table edit * fix column information missing tjdb query manager * make ds imports to either reuse global or create * export only unique table ids * create default datasources if not present in export data * reuse existing table on imports * add timestamp to table name if name already exists * add ability to clone with tjdb * make imports work with marketplace plugin * skip dataqueries for which plugins are not installed * fix filter input width * fix failing spec * fix marketplace plugin installation in diff workspaces * fix check for plugin installed in workspace * fix export when table name is empty --------- Co-authored-by: stepinfwd <stepinfwd@gmail.com>
2023-08-28 15:53:15 +00:00
const res = await service.export(adminUser, exportedApp.id, { version_id: appVersion2.id });
Feature - Multi Environment support (#4833) * initial commit * multi env changes * multi-env changes * entity fixes * data query changes * fix * trying to avoid conflict with EE * moved version creation to app creation function * fixing some issues * execution of data query * revert options changes * changed migration * fixed some migration issues: testing migration * multi env support * app import export fix * fixes * migration fixes * removed plugins from data query * fixing some migration issues * fixes * remove console log * fix * front end api changes * backward compatibility for app import * Fixed a bug * correcting some mistakes * Added constraints and fixed some issues * changes * fix for data source listing * fixing version operation issues * remove kind from data query * removed kind from data query * fixes * fixes * fix for version creation * migration fixes * Fixed preview and run query issues * Fix: new version and event query id issue * fixed rest api oauth issue - next test refresh token * import export changes * fixes for app import * import fix * added await for for loops * fix * fix for migration * Fixed backend oauth-envId issue * import export changes * migration fixes * fix * fix * fix for app import from 0.9.0 * test case fixes * test case fixes * making app name mandatory for import * adding type for options * fix: imported apps query linking issues * review changes * lint issue fixes * added on delete cascade Co-authored-by: Muhsin Shah <muhsinshah21@gmail.com>
2022-12-09 14:53:42 +00:00
result = res.appV2;
expect(result.id).toBe(exportedApp.id);
expect(result.name).toBe(exportedApp.name);
expect(result.isPublic).toBe(exportedApp.isPublic);
expect(result.organizationId).toBe(exportedApp.organizationId);
expect(result.currentVersionId).toBe(null);
expect(result['dataQueries'].length).toBe(1);
expect(result['dataQueries'][0].name).toEqual(dataQuery2.name);
expect(result['dataSources'].length).toBe(1);
expect(result['dataSources'][0].name).toEqual(dataSource2.name);
expect(result.appVersions.length).toBe(1);
expect(result.appVersions[0].name).toEqual(appVersion2.name);
});
});
describe('.import', () => {
it('should throw error with invalid params', async () => {
const adminUserData = await createUser(nestApp, {
email: 'admin@tooljet.io',
groups: ['all_users', 'admin'],
});
const adminUser = adminUserData.user;
const appName = 'my app';
await expect(service.import(adminUser, 'hello world', appName)).rejects.toThrow('Invalid params for app import');
});
it('should import app with empty related associations', async () => {
const adminUserData = await createUser(nestApp, {
email: 'admin@tooljet.io',
groups: ['all_users', 'admin'],
});
const adminUser = adminUserData.user;
const { application: app } = await generateAppDefaults(nestApp, adminUserData.user, {
isAppPublic: true,
isDataSourceNeeded: false,
isQueryNeeded: false,
});
Feature - Multi Environment support (#4833) * initial commit * multi env changes * multi-env changes * entity fixes * data query changes * fix * trying to avoid conflict with EE * moved version creation to app creation function * fixing some issues * execution of data query * revert options changes * changed migration * fixed some migration issues: testing migration * multi env support * app import export fix * fixes * migration fixes * removed plugins from data query * fixing some migration issues * fixes * remove console log * fix * front end api changes * backward compatibility for app import * Fixed a bug * correcting some mistakes * Added constraints and fixed some issues * changes * fix for data source listing * fixing version operation issues * remove kind from data query * removed kind from data query * fixes * fixes * fix for version creation * migration fixes * Fixed preview and run query issues * Fix: new version and event query id issue * fixed rest api oauth issue - next test refresh token * import export changes * fixes for app import * import fix * added await for for loops * fix * fix for migration * Fixed backend oauth-envId issue * import export changes * migration fixes * fix * fix * fix for app import from 0.9.0 * test case fixes * test case fixes * making app name mandatory for import * adding type for options * fix: imported apps query linking issues * review changes * lint issue fixes * added on delete cascade Co-authored-by: Muhsin Shah <muhsinshah21@gmail.com>
2022-12-09 14:53:42 +00:00
const { appV2: exportedApp } = await service.export(adminUser, app.id);
const appName = 'my app';
const result = await service.import(adminUser, exportedApp, appName);
const importedApp = await getAppWithAllDetails(result.id);
expect(importedApp.id == exportedApp.id).toBeFalsy();
expect(importedApp.name).toContain(exportedApp.name);
expect(importedApp.isPublic).toBeFalsy();
expect(importedApp.organizationId).toBe(exportedApp.organizationId);
expect(importedApp.currentVersionId).toBe(null);
expect(importedApp['dataQueries']).toEqual([]);
2023-09-21 11:14:27 +00:00
// there will be 5 data sources created automatically when a user creates a new app.
expect(importedApp['dataSources'].length).toEqual(5);
// assert group permissions are valid
const appGroupPermissions = await getManager().find(AppGroupPermission, {
appId: importedApp.id,
});
const groupPermissionIds = appGroupPermissions.map((agp) => agp.groupPermissionId);
const groupPermissions = await getManager().find(GroupPermission, {
id: In(groupPermissionIds),
});
expect(new Set(groupPermissions.map((gp) => gp.organizationId))).toEqual(new Set([adminUser.organizationId]));
expect(new Set(groupPermissions.map((gp) => gp.group))).toEqual(new Set(['admin']));
});
it('should import app with related associations', async () => {
const adminUserData = await createUser(nestApp, {
email: 'admin@tooljet.io',
groups: ['all_users', 'admin'],
});
const adminUser = adminUserData.user;
const { application, appVersion: applicationVersion } = await generateAppDefaults(nestApp, adminUserData.user, {
isDataSourceNeeded: false,
isQueryNeeded: false,
});
2023-09-21 11:14:27 +00:00
//create default 5 datasources
const firstDs = await createDataSource(nestApp, {
name: 'runpydefault',
kind: 'runpy',
type: 'static',
appVersion: applicationVersion,
});
await createDataSource(nestApp, {
name: 'restapidefault',
kind: 'restapi',
type: 'static',
appVersion: applicationVersion,
});
await createDataSource(nestApp, {
name: 'runjsdefault',
kind: 'runjs',
type: 'static',
appVersion: applicationVersion,
});
await createDataSource(nestApp, {
name: 'tooljetdbdefault',
kind: 'tooljetdb',
type: 'static',
appVersion: applicationVersion,
});
2023-09-21 11:14:27 +00:00
await createDataSource(nestApp, {
name: 'workflowsdefault',
kind: 'workflows',
type: 'static',
appVersion: applicationVersion,
});
//create default dataQuery
await createDataQuery(nestApp, {
dataSource: firstDs,
Feature: Import export tjdb schema (#5752) * add ability to import export app and tjdb schema * init * feat ::global settings popover new ui * feat :: ui for version export modal * fix :: import export modal * cleanup * ui updates * header footer style fixes * closing settings modal while showing export modal * style fix header * feat :: added button to download table schema * fix :: styling for fx * add ability to import and export apps with tjdb schema * handle duplicate table in workspace * fix table rename * fix selected table on edit and delete * fix invalid toast on table delete * fix column default value * handle exports to strip '::' and quotes * make import/export backward compatible * handle page redirects based on resource import * handle import without tjdb schema * fix column delete and addition * make data migrations to be run per organizations * wip * update migration * fix credentials to be included * fix specific version export * make use of apps ability for import export resource * fix import navigation * fix lint * fix failing tests * fix lint * enable tjdb for public apps * update export error message on tjdb table blank * fix table not selected after creation * fix :: styling for imp exp modal , and functionality bug fixes after dev merge * fixes blank slate and columns selection * fix table delete * fix invalid toast on table edit * fix column information missing tjdb query manager * make ds imports to either reuse global or create * export only unique table ids * create default datasources if not present in export data * reuse existing table on imports * add timestamp to table name if name already exists * add ability to clone with tjdb * make imports work with marketplace plugin * skip dataqueries for which plugins are not installed * fix filter input width * fix failing spec * fix marketplace plugin installation in diff workspaces * fix check for plugin installed in workspace * fix export when table name is empty --------- Co-authored-by: stepinfwd <stepinfwd@gmail.com>
2023-08-28 15:53:15 +00:00
appVersion: applicationVersion,
options: {},
});
Feature - Multi Environment support (#4833) * initial commit * multi env changes * multi-env changes * entity fixes * data query changes * fix * trying to avoid conflict with EE * moved version creation to app creation function * fixing some issues * execution of data query * revert options changes * changed migration * fixed some migration issues: testing migration * multi env support * app import export fix * fixes * migration fixes * removed plugins from data query * fixing some migration issues * fixes * remove console log * fix * front end api changes * backward compatibility for app import * Fixed a bug * correcting some mistakes * Added constraints and fixed some issues * changes * fix for data source listing * fixing version operation issues * remove kind from data query * removed kind from data query * fixes * fixes * fix for version creation * migration fixes * Fixed preview and run query issues * Fix: new version and event query id issue * fixed rest api oauth issue - next test refresh token * import export changes * fixes for app import * import fix * added await for for loops * fix * fix for migration * Fixed backend oauth-envId issue * import export changes * migration fixes * fix * fix * fix for app import from 0.9.0 * test case fixes * test case fixes * making app name mandatory for import * adding type for options * fix: imported apps query linking issues * review changes * lint issue fixes * added on delete cascade Co-authored-by: Muhsin Shah <muhsinshah21@gmail.com>
2022-12-09 14:53:42 +00:00
const { appV2: exportedApp } = await service.export(adminUser, application.id);
const appName = 'my app';
const result = await service.import(adminUser, exportedApp, appName);
const importedApp = await getAppWithAllDetails(result.id);
expect(importedApp.id == exportedApp.id).toBeFalsy();
expect(importedApp.name).toContain(exportedApp.name);
expect(importedApp.isPublic).toBeFalsy();
expect(importedApp.organizationId).toBe(exportedApp.organizationId);
expect(importedApp.currentVersionId).toBe(null);
// assert relations
const appVersion = importedApp.appVersions[0];
expect(appVersion.appId).toEqual(importedApp.id);
const dataQuery = importedApp['dataQueries'][0];
Feature: Import export tjdb schema (#5752) * add ability to import export app and tjdb schema * init * feat ::global settings popover new ui * feat :: ui for version export modal * fix :: import export modal * cleanup * ui updates * header footer style fixes * closing settings modal while showing export modal * style fix header * feat :: added button to download table schema * fix :: styling for fx * add ability to import and export apps with tjdb schema * handle duplicate table in workspace * fix table rename * fix selected table on edit and delete * fix invalid toast on table delete * fix column default value * handle exports to strip '::' and quotes * make import/export backward compatible * handle page redirects based on resource import * handle import without tjdb schema * fix column delete and addition * make data migrations to be run per organizations * wip * update migration * fix credentials to be included * fix specific version export * make use of apps ability for import export resource * fix import navigation * fix lint * fix failing tests * fix lint * enable tjdb for public apps * update export error message on tjdb table blank * fix table not selected after creation * fix :: styling for imp exp modal , and functionality bug fixes after dev merge * fixes blank slate and columns selection * fix table delete * fix invalid toast on table edit * fix column information missing tjdb query manager * make ds imports to either reuse global or create * export only unique table ids * create default datasources if not present in export data * reuse existing table on imports * add timestamp to table name if name already exists * add ability to clone with tjdb * make imports work with marketplace plugin * skip dataqueries for which plugins are not installed * fix filter input width * fix failing spec * fix marketplace plugin installation in diff workspaces * fix check for plugin installed in workspace * fix export when table name is empty --------- Co-authored-by: stepinfwd <stepinfwd@gmail.com>
2023-08-28 15:53:15 +00:00
const dataSourceForTheDataQuery = importedApp['dataSources'].find((ds) => ds.id === dataQuery.dataSourceId);
expect(dataSourceForTheDataQuery).toBeDefined();
// assert all fields except primary keys, foreign keys and timestamps are same
const deleteFieldsNotToCheck = (entity) => {
delete entity.id;
delete entity.appId;
delete entity.dataSourceId;
delete entity.appVersionId;
delete entity.createdAt;
delete entity.updatedAt;
return entity;
};
const importedAppVersions = importedApp.appVersions.map((version) => deleteFieldsNotToCheck(version));
const exportedAppVersions = exportedApp.appVersions.map((version) => deleteFieldsNotToCheck(version));
const importedDataSources = importedApp['dataSources'].map((source) => deleteFieldsNotToCheck(source));
const exportedDataSources = exportedApp['dataSources'].map((source) => deleteFieldsNotToCheck(source));
const importedDataQueries = importedApp['dataQueries'].map((query) => deleteFieldsNotToCheck(query));
const exportedDataQueries = exportedApp['dataQueries'].map((query) => deleteFieldsNotToCheck(query));
Feature: Import export tjdb schema (#5752) * add ability to import export app and tjdb schema * init * feat ::global settings popover new ui * feat :: ui for version export modal * fix :: import export modal * cleanup * ui updates * header footer style fixes * closing settings modal while showing export modal * style fix header * feat :: added button to download table schema * fix :: styling for fx * add ability to import and export apps with tjdb schema * handle duplicate table in workspace * fix table rename * fix selected table on edit and delete * fix invalid toast on table delete * fix column default value * handle exports to strip '::' and quotes * make import/export backward compatible * handle page redirects based on resource import * handle import without tjdb schema * fix column delete and addition * make data migrations to be run per organizations * wip * update migration * fix credentials to be included * fix specific version export * make use of apps ability for import export resource * fix import navigation * fix lint * fix failing tests * fix lint * enable tjdb for public apps * update export error message on tjdb table blank * fix table not selected after creation * fix :: styling for imp exp modal , and functionality bug fixes after dev merge * fixes blank slate and columns selection * fix table delete * fix invalid toast on table edit * fix column information missing tjdb query manager * make ds imports to either reuse global or create * export only unique table ids * create default datasources if not present in export data * reuse existing table on imports * add timestamp to table name if name already exists * add ability to clone with tjdb * make imports work with marketplace plugin * skip dataqueries for which plugins are not installed * fix filter input width * fix failing spec * fix marketplace plugin installation in diff workspaces * fix check for plugin installed in workspace * fix export when table name is empty --------- Co-authored-by: stepinfwd <stepinfwd@gmail.com>
2023-08-28 15:53:15 +00:00
expect(new Set(importedAppVersions)).toEqual(new Set(exportedAppVersions));
expect(new Set(importedDataSources)).toEqual(new Set(exportedDataSources));
expect(new Set(importedDataQueries)).toEqual(new Set(exportedDataQueries));
// assert group permissions are valid
const appGroupPermissions = await getManager().find(AppGroupPermission, {
appId: importedApp.id,
});
const groupPermissionIds = appGroupPermissions.map((agp) => agp.groupPermissionId);
const groupPermissions = await getManager().find(GroupPermission, {
id: In(groupPermissionIds),
});
expect(new Set(groupPermissions.map((gp) => gp.organizationId))).toEqual(new Set([adminUser.organizationId]));
expect(new Set(groupPermissions.map((gp) => gp.group))).toEqual(new Set(['admin']));
});
});
afterAll(async () => {
await nestApp.close();
});
});