From 43c980f399f11862917145d8962d37b2a462d603 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Tue, 4 Nov 2025 15:28:08 +0000 Subject: [PATCH 01/14] moved table settings into separate common settings folder --- backend/src/app.module.ts | 2 +- .../global-database-context.interface.ts | 4 +-- .../application/global-database-context.ts | 9 +++--- .../company-info/company-info.module.ts | 2 +- .../entities/connection/connection.entity.ts | 2 +- .../entities/connection/connection.module.ts | 2 +- .../custom-field/custom-field.module.ts | 2 +- .../custom-field/custom-fields.entity.ts | 2 +- .../custom-field-repository-extension.ts | 2 +- .../create-custom-fields.use.case.ts | 6 ++-- .../use-cases/delete-custom-field.use.case.ts | 7 ++--- .../entities/demo-data/demo-data.service.ts | 4 +-- backend/src/entities/group/group.module.ts | 2 +- .../entities/permission/permission.module.ts | 2 +- .../shared-jobs/shared-jobs.service.ts | 4 +-- .../table-action.entity.ts | 4 +-- .../entities/table-logs/table-logs.module.ts | 2 +- .../entities/table-logs/table-logs.service.ts | 2 +- .../dto/create-table-settings.dto.ts | 6 ++-- .../{ => common-table-settings}/dto/index.ts | 0 ...le-settings-custom-repository-extension.ts | 6 ++-- .../table-settings.repository.interface.ts | 6 ++-- .../table-settings.controller.ts | 24 ++++++++-------- .../table-settings.entity.ts | 10 +++---- .../table-settings.module.ts | 28 +++++++++---------- .../create-table-settings.use.case.ts | 12 ++++---- .../delete-table-settings.use.case.ts | 12 ++++---- .../use-cases/find-table-settings.use.case.ts | 14 +++++----- .../update-table-settings.use.case.ts | 14 +++++----- .../use-cases/use-cases.interface.ts | 10 +++---- .../utils/build-empty-table-settings.ts | 2 +- .../utils/build-found-table-settings-ds.ts | 4 +-- .../utils/build-new-table-settings-entity.ts | 4 +-- backend/src/entities/table/table.module.ts | 2 +- .../find-tables-in-connection-v2.use.case.ts | 2 +- .../find-tables-in-connection.use.case.ts | 2 +- .../use-cases/get-table-rows.use.case.ts | 2 +- .../utils/find-autocomplete-fields.util.ts | 2 +- .../table/utils/find-ordering-field.util.ts | 2 +- .../table/utils/form-full-table-structure.ts | 2 +- backend/src/entities/user/user.module.ts | 2 +- .../user/utils/build-test-table-settings.ts | 4 +-- ...able-widgets-custom-repsitory-extension.ts | 2 +- .../entities/widget/table-widget.entity.ts | 2 +- ...te-update-delete-table-widgets.use.case.ts | 6 ++-- .../table-setting-for-test-connections.ts | 2 +- .../table-settings-field-validator.ts | 4 +-- 47 files changed, 123 insertions(+), 125 deletions(-) rename backend/src/entities/table-settings/{ => common-table-settings}/dto/create-table-settings.dto.ts (70%) rename backend/src/entities/table-settings/{ => common-table-settings}/dto/index.ts (100%) rename backend/src/entities/table-settings/{ => common-table-settings}/repository/table-settings-custom-repository-extension.ts (95%) rename backend/src/entities/table-settings/{ => common-table-settings}/repository/table-settings.repository.interface.ts (84%) rename backend/src/entities/table-settings/{ => common-table-settings}/table-settings.controller.ts (91%) rename backend/src/entities/table-settings/{ => common-table-settings}/table-settings.entity.ts (86%) rename backend/src/entities/table-settings/{ => common-table-settings}/table-settings.module.ts (65%) rename backend/src/entities/table-settings/{ => common-table-settings}/use-cases/create-table-settings.use.case.ts (82%) rename backend/src/entities/table-settings/{ => common-table-settings}/use-cases/delete-table-settings.use.case.ts (70%) rename backend/src/entities/table-settings/{ => common-table-settings}/use-cases/find-table-settings.use.case.ts (74%) rename backend/src/entities/table-settings/{ => common-table-settings}/use-cases/update-table-settings.use.case.ts (82%) rename backend/src/entities/table-settings/{ => common-table-settings}/use-cases/use-cases.interface.ts (56%) rename backend/src/entities/table-settings/{ => common-table-settings}/utils/build-empty-table-settings.ts (94%) rename backend/src/entities/table-settings/{ => common-table-settings}/utils/build-found-table-settings-ds.ts (90%) rename backend/src/entities/table-settings/{ => common-table-settings}/utils/build-new-table-settings-entity.ts (91%) diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index 6660a4b40..1215d5f00 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -25,7 +25,7 @@ import { TableTriggersModule } from './entities/table-actions/table-action-rules import { TableActionModule } from './entities/table-actions/table-actions-module/table-action.module.js'; import { TableFiltersModule } from './entities/table-filters/table-filters.module.js'; import { TableLogsModule } from './entities/table-logs/table-logs.module.js'; -import { TableSettingsModule } from './entities/table-settings/table-settings.module.js'; +import { TableSettingsModule } from './entities/table-settings/common-table-settings/table-settings.module.js'; import { TableModule } from './entities/table/table.module.js'; import { UserActionModule } from './entities/user-actions/user-action.module.js'; import { UserModule } from './entities/user/user.module.js'; diff --git a/backend/src/common/application/global-database-context.interface.ts b/backend/src/common/application/global-database-context.interface.ts index 08245f31a..9c6a206d2 100644 --- a/backend/src/common/application/global-database-context.interface.ts +++ b/backend/src/common/application/global-database-context.interface.ts @@ -30,8 +30,8 @@ import { ITableFiltersCustomRepository } from '../../entities/table-filters/repo import { TableFiltersEntity } from '../../entities/table-filters/table-filters.entity.js'; import { TableInfoEntity } from '../../entities/table-info/table-info.entity.js'; import { ITableLogsRepository } from '../../entities/table-logs/repository/table-logs-repository.interface.js'; -import { ITableSettingsRepository } from '../../entities/table-settings/repository/table-settings.repository.interface.js'; -import { TableSettingsEntity } from '../../entities/table-settings/table-settings.entity.js'; +import { ITableSettingsRepository } from '../../entities/table-settings/common-table-settings/repository/table-settings.repository.interface.js'; +import { TableSettingsEntity } from '../../entities/table-settings/common-table-settings/table-settings.entity.js'; import { IUserAccessRepository } from '../../entities/user-access/repository/user-access.repository.interface.js'; import { IUserActionRepository } from '../../entities/user-actions/repository/user-action.repository.interface.js'; import { IUserRepository } from '../../entities/user/repository/user.repository.interface.js'; diff --git a/backend/src/common/application/global-database-context.ts b/backend/src/common/application/global-database-context.ts index d8e229214..fd80d43d0 100644 --- a/backend/src/common/application/global-database-context.ts +++ b/backend/src/common/application/global-database-context.ts @@ -32,9 +32,9 @@ import { TableInfoEntity } from '../../entities/table-info/table-info.entity.js' import { tableLogsCustomRepositoryExtension } from '../../entities/table-logs/repository/table-logs-custom-repository-extension.js'; import { ITableLogsRepository } from '../../entities/table-logs/repository/table-logs-repository.interface.js'; import { TableLogsEntity } from '../../entities/table-logs/table-logs.entity.js'; -import { tableSettingsCustomRepositoryExtension } from '../../entities/table-settings/repository/table-settings-custom-repository-extension.js'; -import { ITableSettingsRepository } from '../../entities/table-settings/repository/table-settings.repository.interface.js'; -import { TableSettingsEntity } from '../../entities/table-settings/table-settings.entity.js'; +import { tableSettingsCustomRepositoryExtension } from '../../entities/table-settings/common-table-settings/repository/table-settings-custom-repository-extension.js'; +import { ITableSettingsRepository } from '../../entities/table-settings/common-table-settings/repository/table-settings.repository.interface.js'; +import { TableSettingsEntity } from '../../entities/table-settings/common-table-settings/table-settings.entity.js'; import { userAccessCustomReposiotoryExtension } from '../../entities/user-access/repository/user-access-custom-repository-extension.js'; import { IUserAccessRepository } from '../../entities/user-access/repository/user-access.repository.interface.js'; import { userActionCustomRepositoryExtension } from '../../entities/user-actions/repository/user-action-custom-repository-extension.js'; @@ -262,7 +262,8 @@ export class GlobalDatabaseContext implements IGlobalDatabaseContext { return this._userInvitationRepository; } - public get connectionPropertiesRepository(): Repository & IConnectionPropertiesRepository { + public get connectionPropertiesRepository(): Repository & + IConnectionPropertiesRepository { return this._connectionPropertiesRepository; } diff --git a/backend/src/entities/company-info/company-info.module.ts b/backend/src/entities/company-info/company-info.module.ts index 68b21a776..1d32327b2 100644 --- a/backend/src/entities/company-info/company-info.module.ts +++ b/backend/src/entities/company-info/company-info.module.ts @@ -10,7 +10,7 @@ import { GroupEntity } from '../group/group.entity.js'; import { LogOutEntity } from '../log-out/log-out.entity.js'; import { PermissionEntity } from '../permission/permission.entity.js'; import { TableLogsEntity } from '../table-logs/table-logs.entity.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; import { UserEntity } from '../user/user.entity.js'; import { TableWidgetEntity } from '../widget/table-widget.entity.js'; import { CompanyInfoController } from './company-info.controller.js'; diff --git a/backend/src/entities/connection/connection.entity.ts b/backend/src/entities/connection/connection.entity.ts index aab4d6de6..6e2be1c4b 100644 --- a/backend/src/entities/connection/connection.entity.ts +++ b/backend/src/entities/connection/connection.entity.ts @@ -19,7 +19,7 @@ import { ConnectionPropertiesEntity } from '../connection-properties/connection- import { GroupEntity } from '../group/group.entity.js'; import { TableInfoEntity } from '../table-info/table-info.entity.js'; import { TableLogsEntity } from '../table-logs/table-logs.entity.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; import { UserEntity } from '../user/user.entity.js'; import { CompanyInfoEntity } from '../company-info/company-info.entity.js'; import { ActionRulesEntity } from '../table-actions/table-action-rules-module/action-rules.entity.js'; diff --git a/backend/src/entities/connection/connection.module.ts b/backend/src/entities/connection/connection.module.ts index ea2bfb5be..37722c2ff 100644 --- a/backend/src/entities/connection/connection.module.ts +++ b/backend/src/entities/connection/connection.module.ts @@ -11,7 +11,7 @@ import { GroupEntity } from '../group/group.entity.js'; import { LogOutEntity } from '../log-out/log-out.entity.js'; import { PermissionEntity } from '../permission/permission.entity.js'; import { TableLogsEntity } from '../table-logs/table-logs.entity.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; import { UserEntity } from '../user/user.entity.js'; import { UserModule } from '../user/user.module.js'; import { TableWidgetEntity } from '../widget/table-widget.entity.js'; diff --git a/backend/src/entities/custom-field/custom-field.module.ts b/backend/src/entities/custom-field/custom-field.module.ts index c46239502..648af3e70 100644 --- a/backend/src/entities/custom-field/custom-field.module.ts +++ b/backend/src/entities/custom-field/custom-field.module.ts @@ -10,7 +10,7 @@ import { GroupEntity } from '../group/group.entity.js'; import { LogOutEntity } from '../log-out/log-out.entity.js'; import { PermissionEntity } from '../permission/permission.entity.js'; import { TableLogsEntity } from '../table-logs/table-logs.entity.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; import { UserEntity } from '../user/user.entity.js'; import { UserModule } from '../user/user.module.js'; import { TableWidgetEntity } from '../widget/table-widget.entity.js'; diff --git a/backend/src/entities/custom-field/custom-fields.entity.ts b/backend/src/entities/custom-field/custom-fields.entity.ts index 6b47a3adf..09f7742b5 100644 --- a/backend/src/entities/custom-field/custom-fields.entity.ts +++ b/backend/src/entities/custom-field/custom-fields.entity.ts @@ -1,5 +1,5 @@ import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, Relation } from 'typeorm'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; @Entity('customFields') export class CustomFieldsEntity { diff --git a/backend/src/entities/custom-field/repository/custom-field-repository-extension.ts b/backend/src/entities/custom-field/repository/custom-field-repository-extension.ts index 924cc641e..48b1ca8eb 100644 --- a/backend/src/entities/custom-field/repository/custom-field-repository-extension.ts +++ b/backend/src/entities/custom-field/repository/custom-field-repository-extension.ts @@ -1,4 +1,4 @@ -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; import { CustomFieldsEntity } from '../custom-fields.entity.js'; export const cusomFieldsCustomRepositoryExtension = { diff --git a/backend/src/entities/custom-field/use-cases/create-custom-fields.use.case.ts b/backend/src/entities/custom-field/use-cases/create-custom-fields.use.case.ts index 95bdefa66..7ac06aace 100644 --- a/backend/src/entities/custom-field/use-cases/create-custom-fields.use.case.ts +++ b/backend/src/entities/custom-field/use-cases/create-custom-fields.use.case.ts @@ -4,9 +4,9 @@ import { IGlobalDatabaseContext } from '../../../common/application/global-datab import { BaseType } from '../../../common/data-injection.tokens.js'; import { CreateTableSettingsDs } from '../../table-settings/application/data-structures/create-table-settings.ds.js'; import { FoundTableSettingsDs } from '../../table-settings/application/data-structures/found-table-settings.ds.js'; -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; -import { buildEmptyTableSettings } from '../../table-settings/utils/build-empty-table-settings.js'; -import { buildFoundTableSettingsDs } from '../../table-settings/utils/build-found-table-settings-ds.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; +import { buildEmptyTableSettings } from '../../table-settings/common-table-settings/utils/build-empty-table-settings.js'; +import { buildFoundTableSettingsDs } from '../../table-settings/common-table-settings/utils/build-found-table-settings-ds.js'; import { CreateCustomFieldsDs } from '../application/data-structures/create-custom-fields.ds.js'; import { buildNewCustomFieldsEntity } from '../utils/build-new-custom-fields-entity.js'; import { validateCreateCustomFieldDto } from '../utils/validate-create-custom-field-dto.js'; diff --git a/backend/src/entities/custom-field/use-cases/delete-custom-field.use.case.ts b/backend/src/entities/custom-field/use-cases/delete-custom-field.use.case.ts index ae940b4a2..dec3bf15b 100644 --- a/backend/src/entities/custom-field/use-cases/delete-custom-field.use.case.ts +++ b/backend/src/entities/custom-field/use-cases/delete-custom-field.use.case.ts @@ -5,7 +5,7 @@ import { IGlobalDatabaseContext } from '../../../common/application/global-datab import { BaseType } from '../../../common/data-injection.tokens.js'; import { Messages } from '../../../exceptions/text/messages.js'; import { FoundTableSettingsDs } from '../../table-settings/application/data-structures/found-table-settings.ds.js'; -import { buildFoundTableSettingsDs } from '../../table-settings/utils/build-found-table-settings-ds.js'; +import { buildFoundTableSettingsDs } from '../../table-settings/common-table-settings/utils/build-found-table-settings-ds.js'; import { DeleteCustomFieldsDs } from '../application/data-structures/delete-custom-fields.ds.js'; import { IDeleteCustomField } from './custom-field-use-cases.interface.js'; @@ -47,9 +47,8 @@ export class DeleteCustomFieldUseCase const delIndex = tableSettingsToUpdate.custom_fields.findIndex((field) => field.id === fieldId); tableSettingsToUpdate.custom_fields.splice(delIndex, 1); await this._dbContext.customFieldsRepository.removeCustomFieldsEntity(fieldToDelete); - const updatedTableSettings = await this._dbContext.tableSettingsRepository.saveNewOrUpdatedSettings( - tableSettingsToUpdate, - ); + const updatedTableSettings = + await this._dbContext.tableSettingsRepository.saveNewOrUpdatedSettings(tableSettingsToUpdate); return buildFoundTableSettingsDs(updatedTableSettings); } } diff --git a/backend/src/entities/demo-data/demo-data.service.ts b/backend/src/entities/demo-data/demo-data.service.ts index 21c72f120..53793eb02 100644 --- a/backend/src/entities/demo-data/demo-data.service.ts +++ b/backend/src/entities/demo-data/demo-data.service.ts @@ -21,8 +21,8 @@ import { } from '../table-actions/table-action-rules-module/application/data-structures/create-action-rules.ds.js'; import { buildEmptyActionRule } from '../table-actions/table-action-rules-module/utils/build-empty-action-rule.util.js'; import { CreateTableSettingsDs } from '../table-settings/application/data-structures/create-table-settings.ds.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; -import { buildNewTableSettingsEntity } from '../table-settings/utils/build-new-table-settings-entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; +import { buildNewTableSettingsEntity } from '../table-settings/common-table-settings/utils/build-new-table-settings-entity.js'; import { buildConnectionEntitiesFromTestDtos } from '../user/utils/build-connection-entities-from-test-dtos.js'; import { buildDefaultAdminGroups } from '../user/utils/build-default-admin-groups.js'; import { buildDefaultAdminPermissions } from '../user/utils/build-default-admin-permissions.js'; diff --git a/backend/src/entities/group/group.module.ts b/backend/src/entities/group/group.module.ts index a92b1ef03..4d4b01fcb 100644 --- a/backend/src/entities/group/group.module.ts +++ b/backend/src/entities/group/group.module.ts @@ -7,7 +7,7 @@ import { AgentModule } from '../agent/agent.module.js'; import { ConnectionEntity } from '../connection/connection.entity.js'; import { LogOutEntity } from '../log-out/log-out.entity.js'; import { PermissionEntity } from '../permission/permission.entity.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; import { UserEntity } from '../user/user.entity.js'; import { UserModule } from '../user/user.module.js'; import { GroupController } from './group.controller.js'; diff --git a/backend/src/entities/permission/permission.module.ts b/backend/src/entities/permission/permission.module.ts index 1fa5066b2..2e62f24bd 100644 --- a/backend/src/entities/permission/permission.module.ts +++ b/backend/src/entities/permission/permission.module.ts @@ -11,7 +11,7 @@ import { GroupEntity } from '../group/group.entity.js'; import { GroupModule } from '../group/group.module.js'; import { LogOutEntity } from '../log-out/log-out.entity.js'; import { TableLogsEntity } from '../table-logs/table-logs.entity.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; import { UserEntity } from '../user/user.entity.js'; import { TableWidgetEntity } from '../widget/table-widget.entity.js'; import { PermissionController } from './permission.controller.js'; diff --git a/backend/src/entities/shared-jobs/shared-jobs.service.ts b/backend/src/entities/shared-jobs/shared-jobs.service.ts index 360a493ec..add6a6f2a 100644 --- a/backend/src/entities/shared-jobs/shared-jobs.service.ts +++ b/backend/src/entities/shared-jobs/shared-jobs.service.ts @@ -6,8 +6,8 @@ import PQueue from 'p-queue'; import { IGlobalDatabaseContext } from '../../common/application/global-database-context.interface.js'; import { BaseType } from '../../common/data-injection.tokens.js'; import { ValidationHelper } from '../../helpers/validators/validation-helper.js'; -import { buildEmptyTableSettings } from '../table-settings/utils/build-empty-table-settings.js'; -import { buildNewTableSettingsEntity } from '../table-settings/utils/build-new-table-settings-entity.js'; +import { buildEmptyTableSettings } from '../table-settings/common-table-settings/utils/build-empty-table-settings.js'; +import { buildNewTableSettingsEntity } from '../table-settings/common-table-settings/utils/build-new-table-settings-entity.js'; import { ConnectionEntity } from '../connection/connection.entity.js'; import { TableWidgetEntity } from '../widget/table-widget.entity.js'; import { WidgetTypeEnum } from '../../enums/widget-type.enum.js'; diff --git a/backend/src/entities/table-actions/table-actions-module/table-action.entity.ts b/backend/src/entities/table-actions/table-actions-module/table-action.entity.ts index 35d9f2b96..a493c5af6 100644 --- a/backend/src/entities/table-actions/table-actions-module/table-action.entity.ts +++ b/backend/src/entities/table-actions/table-actions-module/table-action.entity.ts @@ -10,11 +10,11 @@ import { PrimaryGeneratedColumn, Relation, } from 'typeorm'; -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; import { ActionRulesEntity } from '../table-action-rules-module/action-rules.entity.js'; import { TableActionMethodEnum } from '../../../enums/table-action-method-enum.js'; import { Encryptor } from '../../../helpers/encryption/encryptor.js'; - + @Entity('table_actions') export class TableActionEntity { @PrimaryGeneratedColumn('uuid') diff --git a/backend/src/entities/table-logs/table-logs.module.ts b/backend/src/entities/table-logs/table-logs.module.ts index 64b31ec0b..1ab38b151 100644 --- a/backend/src/entities/table-logs/table-logs.module.ts +++ b/backend/src/entities/table-logs/table-logs.module.ts @@ -4,7 +4,7 @@ import { AuthMiddleware } from '../../authorization/index.js'; import { GlobalDatabaseContext } from '../../common/application/global-database-context.js'; import { BaseType, UseCaseType } from '../../common/data-injection.tokens.js'; import { LogOutEntity } from '../log-out/log-out.entity.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; import { UserEntity } from '../user/user.entity.js'; import { TableLogsController } from './table-logs.controller.js'; import { TableLogsEntity } from './table-logs.entity.js'; diff --git a/backend/src/entities/table-logs/table-logs.service.ts b/backend/src/entities/table-logs/table-logs.service.ts index f341f6837..58a84b8d3 100644 --- a/backend/src/entities/table-logs/table-logs.service.ts +++ b/backend/src/entities/table-logs/table-logs.service.ts @@ -6,7 +6,7 @@ import { Repository } from 'typeorm'; import { LogOperationTypeEnum, OperationResultStatusEnum } from '../../enums/index.js'; import { Constants } from '../../helpers/constants/constants.js'; import { ConnectionEntity } from '../connection/connection.entity.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; import { UserEntity } from '../user/user.entity.js'; import { CreateLogRecordDs } from './application/data-structures/create-log-record.ds.js'; import { CreatedLogRecordDs } from './application/data-structures/created-log-record.ds.js'; diff --git a/backend/src/entities/table-settings/dto/create-table-settings.dto.ts b/backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts similarity index 70% rename from backend/src/entities/table-settings/dto/create-table-settings.dto.ts rename to backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts index 346f766e2..5acaf21b2 100644 --- a/backend/src/entities/table-settings/dto/create-table-settings.dto.ts +++ b/backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts @@ -1,6 +1,6 @@ -import { CustomFieldsEntity } from '../../custom-field/custom-fields.entity.js'; -import { QueryOrderingEnum } from '../../../enums/index.js'; -import { TableWidgetEntity } from '../../widget/table-widget.entity.js'; +import { CustomFieldsEntity } from '../../../custom-field/custom-fields.entity.js'; +import { QueryOrderingEnum } from '../../../../enums/index.js'; +import { TableWidgetEntity } from '../../../widget/table-widget.entity.js'; export class CreateTableSettingsDto { connection_id: string; diff --git a/backend/src/entities/table-settings/dto/index.ts b/backend/src/entities/table-settings/common-table-settings/dto/index.ts similarity index 100% rename from backend/src/entities/table-settings/dto/index.ts rename to backend/src/entities/table-settings/common-table-settings/dto/index.ts diff --git a/backend/src/entities/table-settings/repository/table-settings-custom-repository-extension.ts b/backend/src/entities/table-settings/common-table-settings/repository/table-settings-custom-repository-extension.ts similarity index 95% rename from backend/src/entities/table-settings/repository/table-settings-custom-repository-extension.ts rename to backend/src/entities/table-settings/common-table-settings/repository/table-settings-custom-repository-extension.ts index c0aefcb7b..ae590b827 100644 --- a/backend/src/entities/table-settings/repository/table-settings-custom-repository-extension.ts +++ b/backend/src/entities/table-settings/common-table-settings/repository/table-settings-custom-repository-extension.ts @@ -1,7 +1,7 @@ import { HttpException, HttpStatus } from '@nestjs/common'; -import { Messages } from '../../../exceptions/text/messages.js'; -import { ConnectionEntity } from '../../connection/connection.entity.js'; -import { CreateTableSettingsDs } from '../application/data-structures/create-table-settings.ds.js'; +import { Messages } from '../../../../exceptions/text/messages.js'; +import { ConnectionEntity } from '../../../connection/connection.entity.js'; +import { CreateTableSettingsDs } from '../../application/data-structures/create-table-settings.ds.js'; import { TableSettingsEntity } from '../table-settings.entity.js'; import { buildNewTableSettingsEntity } from '../utils/build-new-table-settings-entity.js'; import { FoundTableSettingsData, ITableSettingsRepository } from './table-settings.repository.interface.js'; diff --git a/backend/src/entities/table-settings/repository/table-settings.repository.interface.ts b/backend/src/entities/table-settings/common-table-settings/repository/table-settings.repository.interface.ts similarity index 84% rename from backend/src/entities/table-settings/repository/table-settings.repository.interface.ts rename to backend/src/entities/table-settings/common-table-settings/repository/table-settings.repository.interface.ts index 983964f48..86639828d 100644 --- a/backend/src/entities/table-settings/repository/table-settings.repository.interface.ts +++ b/backend/src/entities/table-settings/common-table-settings/repository/table-settings.repository.interface.ts @@ -1,6 +1,6 @@ -import { CustomFieldsEntity } from '../../custom-field/custom-fields.entity.js'; -import { TableWidgetEntity } from '../../widget/table-widget.entity.js'; -import { CreateTableSettingsDs } from '../application/data-structures/create-table-settings.ds.js'; +import { CustomFieldsEntity } from '../../../custom-field/custom-fields.entity.js'; +import { TableWidgetEntity } from '../../../widget/table-widget.entity.js'; +import { CreateTableSettingsDs } from '../../application/data-structures/create-table-settings.ds.js'; import { TableSettingsEntity } from '../table-settings.entity.js'; export type FoundTableSettingsData = { diff --git a/backend/src/entities/table-settings/table-settings.controller.ts b/backend/src/entities/table-settings/common-table-settings/table-settings.controller.ts similarity index 91% rename from backend/src/entities/table-settings/table-settings.controller.ts rename to backend/src/entities/table-settings/common-table-settings/table-settings.controller.ts index 95471b3d7..956e9a07b 100644 --- a/backend/src/entities/table-settings/table-settings.controller.ts +++ b/backend/src/entities/table-settings/common-table-settings/table-settings.controller.ts @@ -14,18 +14,18 @@ import { } from '@nestjs/common'; import { HttpException } from '@nestjs/common/exceptions/http.exception.js'; import { ApiBearerAuth, ApiBody, ApiOperation, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger'; -import { UseCaseType } from '../../common/data-injection.tokens.js'; -import { MasterPassword, QueryTableName, QueryUuid, UserId } from '../../decorators/index.js'; -import { InTransactionEnum, QueryOrderingEnum } from '../../enums/index.js'; -import { Messages } from '../../exceptions/text/messages.js'; -import { ConnectionEditGuard, ConnectionReadGuard } from '../../guards/index.js'; -import { toPrettyErrorsMsg } from '../../helpers/index.js'; -import { SentryInterceptor } from '../../interceptors/index.js'; -import { CustomFieldsEntity } from '../custom-field/custom-fields.entity.js'; -import { CreateTableSettingsDs } from './application/data-structures/create-table-settings.ds.js'; -import { DeleteTableSettingsDs } from './application/data-structures/delete-table-settings.ds.js'; -import { FindTableSettingsDs } from './application/data-structures/find-table-settings.ds.js'; -import { FoundTableSettingsDs } from './application/data-structures/found-table-settings.ds.js'; +import { UseCaseType } from '../../../common/data-injection.tokens.js'; +import { MasterPassword, QueryTableName, QueryUuid, UserId } from '../../../decorators/index.js'; +import { InTransactionEnum, QueryOrderingEnum } from '../../../enums/index.js'; +import { Messages } from '../../../exceptions/text/messages.js'; +import { ConnectionEditGuard, ConnectionReadGuard } from '../../../guards/index.js'; +import { toPrettyErrorsMsg } from '../../../helpers/index.js'; +import { SentryInterceptor } from '../../../interceptors/index.js'; +import { CustomFieldsEntity } from '../../custom-field/custom-fields.entity.js'; +import { CreateTableSettingsDs } from '../application/data-structures/create-table-settings.ds.js'; +import { DeleteTableSettingsDs } from '../application/data-structures/delete-table-settings.ds.js'; +import { FindTableSettingsDs } from '../application/data-structures/find-table-settings.ds.js'; +import { FoundTableSettingsDs } from '../application/data-structures/found-table-settings.ds.js'; import { CreateTableSettingsDto } from './dto/index.js'; import { ICreateTableSettings, diff --git a/backend/src/entities/table-settings/table-settings.entity.ts b/backend/src/entities/table-settings/common-table-settings/table-settings.entity.ts similarity index 86% rename from backend/src/entities/table-settings/table-settings.entity.ts rename to backend/src/entities/table-settings/common-table-settings/table-settings.entity.ts index d0147a3ca..756b50139 100644 --- a/backend/src/entities/table-settings/table-settings.entity.ts +++ b/backend/src/entities/table-settings/common-table-settings/table-settings.entity.ts @@ -1,10 +1,10 @@ import { Transform } from 'class-transformer'; import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn, Relation, Unique } from 'typeorm'; -import { QueryOrderingEnum } from '../../enums/index.js'; -import { ConnectionEntity } from '../connection/connection.entity.js'; -import { CustomFieldsEntity } from '../custom-field/custom-fields.entity.js'; -import { TableActionEntity } from '../table-actions/table-actions-module/table-action.entity.js'; -import { TableWidgetEntity } from '../widget/table-widget.entity.js'; +import { QueryOrderingEnum } from '../../../enums/index.js'; +import { ConnectionEntity } from '../../connection/connection.entity.js'; +import { CustomFieldsEntity } from '../../custom-field/custom-fields.entity.js'; +import { TableActionEntity } from '../../table-actions/table-actions-module/table-action.entity.js'; +import { TableWidgetEntity } from '../../widget/table-widget.entity.js'; @Entity('tableSettings') @Unique(['connection_id', 'table_name']) diff --git a/backend/src/entities/table-settings/table-settings.module.ts b/backend/src/entities/table-settings/common-table-settings/table-settings.module.ts similarity index 65% rename from backend/src/entities/table-settings/table-settings.module.ts rename to backend/src/entities/table-settings/common-table-settings/table-settings.module.ts index da17043a8..854451731 100644 --- a/backend/src/entities/table-settings/table-settings.module.ts +++ b/backend/src/entities/table-settings/common-table-settings/table-settings.module.ts @@ -1,19 +1,19 @@ import { MiddlewareConsumer, Module, RequestMethod } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; -import { AuthMiddleware } from '../../authorization/index.js'; -import { GlobalDatabaseContext } from '../../common/application/global-database-context.js'; -import { BaseType, UseCaseType } from '../../common/data-injection.tokens.js'; -import { AgentModule } from '../agent/agent.module.js'; -import { ConnectionPropertiesEntity } from '../connection-properties/connection-properties.entity.js'; -import { ConnectionEntity } from '../connection/connection.entity.js'; -import { CustomFieldsEntity } from '../custom-field/custom-fields.entity.js'; -import { GroupEntity } from '../group/group.entity.js'; -import { LogOutEntity } from '../log-out/log-out.entity.js'; -import { PermissionEntity } from '../permission/permission.entity.js'; -import { TableLogsEntity } from '../table-logs/table-logs.entity.js'; -import { UserEntity } from '../user/user.entity.js'; -import { UserModule } from '../user/user.module.js'; -import { TableWidgetEntity } from '../widget/table-widget.entity.js'; +import { AuthMiddleware } from '../../../authorization/index.js'; +import { GlobalDatabaseContext } from '../../../common/application/global-database-context.js'; +import { BaseType, UseCaseType } from '../../../common/data-injection.tokens.js'; +import { AgentModule } from '../../agent/agent.module.js'; +import { ConnectionPropertiesEntity } from '../../connection-properties/connection-properties.entity.js'; +import { ConnectionEntity } from '../../connection/connection.entity.js'; +import { CustomFieldsEntity } from '../../custom-field/custom-fields.entity.js'; +import { GroupEntity } from '../../group/group.entity.js'; +import { LogOutEntity } from '../../log-out/log-out.entity.js'; +import { PermissionEntity } from '../../permission/permission.entity.js'; +import { TableLogsEntity } from '../../table-logs/table-logs.entity.js'; +import { UserEntity } from '../../user/user.entity.js'; +import { UserModule } from '../../user/user.module.js'; +import { TableWidgetEntity } from '../../widget/table-widget.entity.js'; import { TableSettingsController } from './table-settings.controller.js'; import { TableSettingsEntity } from './table-settings.entity.js'; import { CreateTableSettingsUseCase } from './use-cases/create-table-settings.use.case.js'; diff --git a/backend/src/entities/table-settings/use-cases/create-table-settings.use.case.ts b/backend/src/entities/table-settings/common-table-settings/use-cases/create-table-settings.use.case.ts similarity index 82% rename from backend/src/entities/table-settings/use-cases/create-table-settings.use.case.ts rename to backend/src/entities/table-settings/common-table-settings/use-cases/create-table-settings.use.case.ts index 4a0c5199e..bb16590f5 100644 --- a/backend/src/entities/table-settings/use-cases/create-table-settings.use.case.ts +++ b/backend/src/entities/table-settings/common-table-settings/use-cases/create-table-settings.use.case.ts @@ -1,12 +1,12 @@ import { HttpStatus, Inject, Injectable, Scope } from '@nestjs/common'; import { HttpException } from '@nestjs/common/exceptions/http.exception.js'; -import AbstractUseCase from '../../../common/abstract-use.case.js'; -import { IGlobalDatabaseContext } from '../../../common/application/global-database-context.interface.js'; -import { BaseType } from '../../../common/data-injection.tokens.js'; +import AbstractUseCase from '../../../../common/abstract-use.case.js'; +import { IGlobalDatabaseContext } from '../../../../common/application/global-database-context.interface.js'; +import { BaseType } from '../../../../common/data-injection.tokens.js'; import { getDataAccessObject } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/create-data-access-object.js'; -import { toPrettyErrorsMsg } from '../../../helpers/index.js'; -import { CreateTableSettingsDs } from '../application/data-structures/create-table-settings.ds.js'; -import { FoundTableSettingsDs } from '../application/data-structures/found-table-settings.ds.js'; +import { toPrettyErrorsMsg } from '../../../../helpers/index.js'; +import { CreateTableSettingsDs } from '../../application/data-structures/create-table-settings.ds.js'; +import { FoundTableSettingsDs } from '../../application/data-structures/found-table-settings.ds.js'; import { buildFoundTableSettingsDs } from '../utils/build-found-table-settings-ds.js'; import { buildNewTableSettingsEntity } from '../utils/build-new-table-settings-entity.js'; import { ICreateTableSettings } from './use-cases.interface.js'; diff --git a/backend/src/entities/table-settings/use-cases/delete-table-settings.use.case.ts b/backend/src/entities/table-settings/common-table-settings/use-cases/delete-table-settings.use.case.ts similarity index 70% rename from backend/src/entities/table-settings/use-cases/delete-table-settings.use.case.ts rename to backend/src/entities/table-settings/common-table-settings/use-cases/delete-table-settings.use.case.ts index 5057700ff..cde7f1020 100644 --- a/backend/src/entities/table-settings/use-cases/delete-table-settings.use.case.ts +++ b/backend/src/entities/table-settings/common-table-settings/use-cases/delete-table-settings.use.case.ts @@ -1,10 +1,10 @@ import { HttpException, HttpStatus, Inject, Injectable, Scope } from '@nestjs/common'; -import AbstractUseCase from '../../../common/abstract-use.case.js'; -import { IGlobalDatabaseContext } from '../../../common/application/global-database-context.interface.js'; -import { BaseType } from '../../../common/data-injection.tokens.js'; -import { Messages } from '../../../exceptions/text/messages.js'; -import { DeleteTableSettingsDs } from '../application/data-structures/delete-table-settings.ds.js'; -import { FoundTableSettingsDs } from '../application/data-structures/found-table-settings.ds.js'; +import AbstractUseCase from '../../../../common/abstract-use.case.js'; +import { IGlobalDatabaseContext } from '../../../../common/application/global-database-context.interface.js'; +import { BaseType } from '../../../../common/data-injection.tokens.js'; +import { Messages } from '../../../../exceptions/text/messages.js'; +import { DeleteTableSettingsDs } from '../../application/data-structures/delete-table-settings.ds.js'; +import { FoundTableSettingsDs } from '../../application/data-structures/found-table-settings.ds.js'; import { buildFoundTableSettingsDs } from '../utils/build-found-table-settings-ds.js'; import { IDeleteTableSettings } from './use-cases.interface.js'; diff --git a/backend/src/entities/table-settings/use-cases/find-table-settings.use.case.ts b/backend/src/entities/table-settings/common-table-settings/use-cases/find-table-settings.use.case.ts similarity index 74% rename from backend/src/entities/table-settings/use-cases/find-table-settings.use.case.ts rename to backend/src/entities/table-settings/common-table-settings/use-cases/find-table-settings.use.case.ts index 0ac916dec..5422d3ed7 100644 --- a/backend/src/entities/table-settings/use-cases/find-table-settings.use.case.ts +++ b/backend/src/entities/table-settings/common-table-settings/use-cases/find-table-settings.use.case.ts @@ -1,14 +1,14 @@ import { Inject, Injectable, NotFoundException } from '@nestjs/common'; -import AbstractUseCase from '../../../common/abstract-use.case.js'; -import { IGlobalDatabaseContext } from '../../../common/application/global-database-context.interface.js'; -import { BaseType } from '../../../common/data-injection.tokens.js'; -import { FindTableSettingsDs } from '../application/data-structures/find-table-settings.ds.js'; -import { FoundTableSettingsDs } from '../application/data-structures/found-table-settings.ds.js'; +import AbstractUseCase from '../../../../common/abstract-use.case.js'; +import { IGlobalDatabaseContext } from '../../../../common/application/global-database-context.interface.js'; +import { BaseType } from '../../../../common/data-injection.tokens.js'; +import { FindTableSettingsDs } from '../../application/data-structures/find-table-settings.ds.js'; +import { FoundTableSettingsDs } from '../../application/data-structures/found-table-settings.ds.js'; import { buildFoundTableSettingsDs } from '../utils/build-found-table-settings-ds.js'; import { IFindTableSettings } from './use-cases.interface.js'; -import { Messages } from '../../../exceptions/text/messages.js'; +import { Messages } from '../../../../exceptions/text/messages.js'; import { getDataAccessObject } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/create-data-access-object.js'; -import { findAvailableFields } from '../../table/utils/find-available-fields.utils.js'; +import { findAvailableFields } from '../../../table/utils/find-available-fields.utils.js'; @Injectable() export class FindTableSettingsUseCase diff --git a/backend/src/entities/table-settings/use-cases/update-table-settings.use.case.ts b/backend/src/entities/table-settings/common-table-settings/use-cases/update-table-settings.use.case.ts similarity index 82% rename from backend/src/entities/table-settings/use-cases/update-table-settings.use.case.ts rename to backend/src/entities/table-settings/common-table-settings/use-cases/update-table-settings.use.case.ts index debf189c1..f39e57873 100644 --- a/backend/src/entities/table-settings/use-cases/update-table-settings.use.case.ts +++ b/backend/src/entities/table-settings/common-table-settings/use-cases/update-table-settings.use.case.ts @@ -1,13 +1,13 @@ import { HttpStatus, Inject, Injectable, Scope } from '@nestjs/common'; import { HttpException } from '@nestjs/common/exceptions/http.exception.js'; -import AbstractUseCase from '../../../common/abstract-use.case.js'; -import { IGlobalDatabaseContext } from '../../../common/application/global-database-context.interface.js'; -import { BaseType } from '../../../common/data-injection.tokens.js'; +import AbstractUseCase from '../../../../common/abstract-use.case.js'; +import { IGlobalDatabaseContext } from '../../../../common/application/global-database-context.interface.js'; +import { BaseType } from '../../../../common/data-injection.tokens.js'; import { getDataAccessObject } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/create-data-access-object.js'; -import { Messages } from '../../../exceptions/text/messages.js'; -import { toPrettyErrorsMsg } from '../../../helpers/index.js'; -import { CreateTableSettingsDs } from '../application/data-structures/create-table-settings.ds.js'; -import { FoundTableSettingsDs } from '../application/data-structures/found-table-settings.ds.js'; +import { Messages } from '../../../../exceptions/text/messages.js'; +import { toPrettyErrorsMsg } from '../../../../helpers/index.js'; +import { CreateTableSettingsDs } from '../../application/data-structures/create-table-settings.ds.js'; +import { FoundTableSettingsDs } from '../../application/data-structures/found-table-settings.ds.js'; import { buildFoundTableSettingsDs } from '../utils/build-found-table-settings-ds.js'; import { buildNewTableSettingsEntity } from '../utils/build-new-table-settings-entity.js'; import { IUpdateTableSettings } from './use-cases.interface.js'; diff --git a/backend/src/entities/table-settings/use-cases/use-cases.interface.ts b/backend/src/entities/table-settings/common-table-settings/use-cases/use-cases.interface.ts similarity index 56% rename from backend/src/entities/table-settings/use-cases/use-cases.interface.ts rename to backend/src/entities/table-settings/common-table-settings/use-cases/use-cases.interface.ts index 5917a6677..7c43f68b5 100644 --- a/backend/src/entities/table-settings/use-cases/use-cases.interface.ts +++ b/backend/src/entities/table-settings/common-table-settings/use-cases/use-cases.interface.ts @@ -1,8 +1,8 @@ -import { InTransactionEnum } from '../../../enums/index.js'; -import { CreateTableSettingsDs } from '../application/data-structures/create-table-settings.ds.js'; -import { DeleteTableSettingsDs } from '../application/data-structures/delete-table-settings.ds.js'; -import { FindTableSettingsDs } from '../application/data-structures/find-table-settings.ds.js'; -import { FoundTableSettingsDs } from '../application/data-structures/found-table-settings.ds.js'; +import { InTransactionEnum } from '../../../../enums/index.js'; +import { CreateTableSettingsDs } from '../../application/data-structures/create-table-settings.ds.js'; +import { DeleteTableSettingsDs } from '../../application/data-structures/delete-table-settings.ds.js'; +import { FindTableSettingsDs } from '../../application/data-structures/find-table-settings.ds.js'; +import { FoundTableSettingsDs } from '../../application/data-structures/found-table-settings.ds.js'; export interface IFindTableSettings { execute(inputData: FindTableSettingsDs, inTransaction: InTransactionEnum): Promise; diff --git a/backend/src/entities/table-settings/utils/build-empty-table-settings.ts b/backend/src/entities/table-settings/common-table-settings/utils/build-empty-table-settings.ts similarity index 94% rename from backend/src/entities/table-settings/utils/build-empty-table-settings.ts rename to backend/src/entities/table-settings/common-table-settings/utils/build-empty-table-settings.ts index 6b1f7ae37..d1197a719 100644 --- a/backend/src/entities/table-settings/utils/build-empty-table-settings.ts +++ b/backend/src/entities/table-settings/common-table-settings/utils/build-empty-table-settings.ts @@ -1,4 +1,4 @@ -import { CreateTableSettingsDs } from '../application/data-structures/create-table-settings.ds.js'; +import { CreateTableSettingsDs } from '../../application/data-structures/create-table-settings.ds.js'; export function buildEmptyTableSettings(connectionId: string, tableName: string): CreateTableSettingsDs { return { diff --git a/backend/src/entities/table-settings/utils/build-found-table-settings-ds.ts b/backend/src/entities/table-settings/common-table-settings/utils/build-found-table-settings-ds.ts similarity index 90% rename from backend/src/entities/table-settings/utils/build-found-table-settings-ds.ts rename to backend/src/entities/table-settings/common-table-settings/utils/build-found-table-settings-ds.ts index ae8ffb2eb..10eb15fd5 100644 --- a/backend/src/entities/table-settings/utils/build-found-table-settings-ds.ts +++ b/backend/src/entities/table-settings/common-table-settings/utils/build-found-table-settings-ds.ts @@ -1,5 +1,5 @@ -import { ConnectionEntity } from '../../connection/connection.entity.js'; -import { FoundTableSettingsDs } from '../application/data-structures/found-table-settings.ds.js'; +import { ConnectionEntity } from '../../../connection/connection.entity.js'; +import { FoundTableSettingsDs } from '../../application/data-structures/found-table-settings.ds.js'; import { TableSettingsEntity } from '../table-settings.entity.js'; export function buildFoundTableSettingsDs(tableSettings: TableSettingsEntity): FoundTableSettingsDs { diff --git a/backend/src/entities/table-settings/utils/build-new-table-settings-entity.ts b/backend/src/entities/table-settings/common-table-settings/utils/build-new-table-settings-entity.ts similarity index 91% rename from backend/src/entities/table-settings/utils/build-new-table-settings-entity.ts rename to backend/src/entities/table-settings/common-table-settings/utils/build-new-table-settings-entity.ts index 1fdef0450..6b546eee3 100644 --- a/backend/src/entities/table-settings/utils/build-new-table-settings-entity.ts +++ b/backend/src/entities/table-settings/common-table-settings/utils/build-new-table-settings-entity.ts @@ -1,5 +1,5 @@ -import { ConnectionEntity } from '../../connection/connection.entity.js'; -import { CreateTableSettingsDs } from '../application/data-structures/create-table-settings.ds.js'; +import { ConnectionEntity } from '../../../connection/connection.entity.js'; +import { CreateTableSettingsDs } from '../../application/data-structures/create-table-settings.ds.js'; import { TableSettingsEntity } from '../table-settings.entity.js'; export function buildNewTableSettingsEntity( diff --git a/backend/src/entities/table/table.module.ts b/backend/src/entities/table/table.module.ts index b7ee5a2e7..719983a8c 100644 --- a/backend/src/entities/table/table.module.ts +++ b/backend/src/entities/table/table.module.ts @@ -11,7 +11,7 @@ import { GroupEntity } from '../group/group.entity.js'; import { LogOutEntity } from '../log-out/log-out.entity.js'; import { PermissionEntity } from '../permission/permission.entity.js'; import { TableLogsEntity } from '../table-logs/table-logs.entity.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; import { UserEntity } from '../user/user.entity.js'; import { UserModule } from '../user/user.module.js'; import { TableWidgetEntity } from '../widget/table-widget.entity.js'; diff --git a/backend/src/entities/table/use-cases/find-tables-in-connection-v2.use.case.ts b/backend/src/entities/table/use-cases/find-tables-in-connection-v2.use.case.ts index 3184bc34e..0365ce048 100644 --- a/backend/src/entities/table/use-cases/find-tables-in-connection-v2.use.case.ts +++ b/backend/src/entities/table/use-cases/find-tables-in-connection-v2.use.case.ts @@ -20,7 +20,7 @@ import { isTestConnectionUtil } from '../../connection/utils/is-test-connection- import { WinstonLogger } from '../../logging/winston-logger.js'; import { ITableAndViewPermissionData } from '../../permission/permission.interface.js'; import { TableInfoEntity } from '../../table-info/table-info.entity.js'; -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; import { FindTablesDs } from '../application/data-structures/find-tables.ds.js'; import { FoundTableDs, FoundTablesWithCategoriesDS } from '../application/data-structures/found-table.ds.js'; import { buildTableFieldInfoEntity, buildTableInfoEntity } from '../utils/save-tables-info-in-database.util.js'; diff --git a/backend/src/entities/table/use-cases/find-tables-in-connection.use.case.ts b/backend/src/entities/table/use-cases/find-tables-in-connection.use.case.ts index d603434cf..2b6f3d89d 100644 --- a/backend/src/entities/table/use-cases/find-tables-in-connection.use.case.ts +++ b/backend/src/entities/table/use-cases/find-tables-in-connection.use.case.ts @@ -18,7 +18,7 @@ import { ConnectionEntity } from '../../connection/connection.entity.js'; import { isTestConnectionUtil } from '../../connection/utils/is-test-connection-util.js'; import { ITableAndViewPermissionData } from '../../permission/permission.interface.js'; import { TableInfoEntity } from '../../table-info/table-info.entity.js'; -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; import { FindTablesDs } from '../application/data-structures/find-tables.ds.js'; import { FoundTableDs } from '../application/data-structures/found-table.ds.js'; import { buildTableFieldInfoEntity, buildTableInfoEntity } from '../utils/save-tables-info-in-database.util.js'; diff --git a/backend/src/entities/table/use-cases/get-table-rows.use.case.ts b/backend/src/entities/table/use-cases/get-table-rows.use.case.ts index 07bcf6675..7170b72f5 100644 --- a/backend/src/entities/table/use-cases/get-table-rows.use.case.ts +++ b/backend/src/entities/table/use-cases/get-table-rows.use.case.ts @@ -28,7 +28,7 @@ import { AmplitudeService } from '../../amplitude/amplitude.service.js'; import { buildActionEventDto } from '../../table-actions/table-action-rules-module/utils/build-found-action-event-dto.util.js'; import { buildCreatedTableFilterRO } from '../../table-filters/utils/build-created-table-filters-response-object.util.js'; import { TableLogsService } from '../../table-logs/table-logs.service.js'; -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; import { FoundTableRowsDs } from '../application/data-structures/found-table-rows.ds.js'; import { GetTableRowsDs } from '../application/data-structures/get-table-rows.ds.js'; import { FilteringFieldsDs, ForeignKeyDSInfo } from '../table-datastructures.js'; diff --git a/backend/src/entities/table/utils/find-autocomplete-fields.util.ts b/backend/src/entities/table/utils/find-autocomplete-fields.util.ts index 69bf36a39..a26dd65ef 100644 --- a/backend/src/entities/table/utils/find-autocomplete-fields.util.ts +++ b/backend/src/entities/table/utils/find-autocomplete-fields.util.ts @@ -1,4 +1,4 @@ -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; import { AutocompleteFieldsDs } from '../application/data-structures/found-table-rows.ds.js'; import { HttpException, HttpStatus } from '@nestjs/common'; import { Messages } from '../../../exceptions/text/messages.js'; diff --git a/backend/src/entities/table/utils/find-ordering-field.util.ts b/backend/src/entities/table/utils/find-ordering-field.util.ts index bb8c012ea..7f6c0496c 100644 --- a/backend/src/entities/table/utils/find-ordering-field.util.ts +++ b/backend/src/entities/table/utils/find-ordering-field.util.ts @@ -1,4 +1,4 @@ -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; import { OrderingFiledDs } from '../application/data-structures/found-table-rows.ds.js'; import { HttpException, HttpStatus } from '@nestjs/common'; import { Messages } from '../../../exceptions/text/messages.js'; diff --git a/backend/src/entities/table/utils/form-full-table-structure.ts b/backend/src/entities/table/utils/form-full-table-structure.ts index bad9da8c8..c5a2c9863 100644 --- a/backend/src/entities/table/utils/form-full-table-structure.ts +++ b/backend/src/entities/table/utils/form-full-table-structure.ts @@ -1,4 +1,4 @@ -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; import { FullTableStructureDs } from '../application/data-structures/found-table-structure.ds.js'; import { checkFieldAutoincrement } from '../../../helpers/index.js'; import { TableStructureDS } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/data-structures/table-structure.ds.js'; diff --git a/backend/src/entities/user/user.module.ts b/backend/src/entities/user/user.module.ts index 371520fe5..c53a575c2 100644 --- a/backend/src/entities/user/user.module.ts +++ b/backend/src/entities/user/user.module.ts @@ -11,7 +11,7 @@ import { GroupEntity } from '../group/group.entity.js'; import { LogOutEntity } from '../log-out/log-out.entity.js'; import { PermissionEntity } from '../permission/permission.entity.js'; import { TableLogsEntity } from '../table-logs/table-logs.entity.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; import { TableWidgetEntity } from '../widget/table-widget.entity.js'; import { ChangeUserNameUseCase } from './use-cases/change-user-name-use.case.js'; import { ChangeUsualPasswordUseCase } from './use-cases/change-usual-password-use.case.js'; diff --git a/backend/src/entities/user/utils/build-test-table-settings.ts b/backend/src/entities/user/utils/build-test-table-settings.ts index b2fb9ec84..b6f6bc584 100644 --- a/backend/src/entities/user/utils/build-test-table-settings.ts +++ b/backend/src/entities/user/utils/build-test-table-settings.ts @@ -1,8 +1,8 @@ import { ConnectionEntity } from '../../connection/connection.entity.js'; import { TableSettingForTestConnections } from '../../../helpers/constants/table-setting-for-test-connections.js'; import { Constants } from '../../../helpers/constants/constants.js'; -import { CreateTableSettingsDto } from '../../table-settings/dto/index.js'; -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; +import { CreateTableSettingsDto } from '../../table-settings/common-table-settings/dto/index.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; export function buildTestTableSettings(connections: Array): Array> { const testTablesSettingsEntities: Array> = []; diff --git a/backend/src/entities/widget/repository/table-widgets-custom-repsitory-extension.ts b/backend/src/entities/widget/repository/table-widgets-custom-repsitory-extension.ts index f00d5dbeb..5d049dab8 100644 --- a/backend/src/entities/widget/repository/table-widgets-custom-repsitory-extension.ts +++ b/backend/src/entities/widget/repository/table-widgets-custom-repsitory-extension.ts @@ -1,4 +1,4 @@ -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; import { TableWidgetEntity } from '../table-widget.entity.js'; export const tableWidgetsCustomRepositoryExtension = { diff --git a/backend/src/entities/widget/table-widget.entity.ts b/backend/src/entities/widget/table-widget.entity.ts index 53d5b795d..4a71b0a7a 100644 --- a/backend/src/entities/widget/table-widget.entity.ts +++ b/backend/src/entities/widget/table-widget.entity.ts @@ -11,7 +11,7 @@ import { Relation, } from 'typeorm'; import { WidgetTypeEnum } from '../../enums/index.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; @Entity('table_widget') export class TableWidgetEntity { diff --git a/backend/src/entities/widget/use-cases/create-update-delete-table-widgets.use.case.ts b/backend/src/entities/widget/use-cases/create-update-delete-table-widgets.use.case.ts index d69b3ba67..1f82255f9 100644 --- a/backend/src/entities/widget/use-cases/create-update-delete-table-widgets.use.case.ts +++ b/backend/src/entities/widget/use-cases/create-update-delete-table-widgets.use.case.ts @@ -4,9 +4,9 @@ import AbstractUseCase from '../../../common/abstract-use.case.js'; import { IGlobalDatabaseContext } from '../../../common/application/global-database-context.interface.js'; import { BaseType } from '../../../common/data-injection.tokens.js'; import { toPrettyErrorsMsg } from '../../../helpers/index.js'; -import { TableSettingsEntity } from '../../table-settings/table-settings.entity.js'; -import { buildEmptyTableSettingsWithEmptyWidgets } from '../../table-settings/utils/build-empty-table-settings.js'; -import { buildNewTableSettingsEntity } from '../../table-settings/utils/build-new-table-settings-entity.js'; +import { TableSettingsEntity } from '../../table-settings/common-table-settings/table-settings.entity.js'; +import { buildEmptyTableSettingsWithEmptyWidgets } from '../../table-settings/common-table-settings/utils/build-empty-table-settings.js'; +import { buildNewTableSettingsEntity } from '../../table-settings/common-table-settings/utils/build-new-table-settings-entity.js'; import { CreateTableWidgetsDs } from '../application/data-sctructures/create-table-widgets.ds.js'; import { FoundTableWidgetsDs } from '../application/data-sctructures/found-table-widgets.ds.js'; import { buildFoundTableWidgetDs } from '../utils/build-found-table-widget-ds.js'; diff --git a/backend/src/helpers/constants/table-setting-for-test-connections.ts b/backend/src/helpers/constants/table-setting-for-test-connections.ts index aaf94f5b8..caba65641 100644 --- a/backend/src/helpers/constants/table-setting-for-test-connections.ts +++ b/backend/src/helpers/constants/table-setting-for-test-connections.ts @@ -1,4 +1,4 @@ -import { CreateTableSettingsDto } from '../../entities/table-settings/dto/index.js'; +import { CreateTableSettingsDto } from '../../entities/table-settings/common-table-settings/dto/index.js'; import { QueryOrderingEnum } from '../../enums/index.js'; export const TableSettingForTestConnections = { diff --git a/backend/src/helpers/validators/table-settings-field-validator.ts b/backend/src/helpers/validators/table-settings-field-validator.ts index f030fb6b4..8cd78b224 100644 --- a/backend/src/helpers/validators/table-settings-field-validator.ts +++ b/backend/src/helpers/validators/table-settings-field-validator.ts @@ -1,5 +1,5 @@ import { PrimaryKeyDS } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/data-structures/primary-key.ds.js'; -import { CreateTableSettingsDto } from '../../entities/table-settings/dto/index.js'; +import { CreateTableSettingsDto } from '../../entities/table-settings/common-table-settings/dto/index.js'; import { QueryOrderingEnum } from '../../enums/index.js'; import { Messages } from '../../exceptions/text/messages.js'; import { isObjectEmpty } from '../is-object-empty.js'; @@ -9,7 +9,6 @@ export function tableSettingsFieldValidator( primaryColumns: Array, settings: CreateTableSettingsDto, ): Array { - const errorMessages = []; if (isObjectEmpty(settings)) { return errorMessages; @@ -149,5 +148,4 @@ export function tableSettingsFieldValidator( } return errorMessages; - } From 34aedc76671b8e6396af641310d1ef6b37c88ae5 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Fri, 7 Nov 2025 07:54:31 +0000 Subject: [PATCH 02/14] personal table settings (continue) --- .../global-database-context.interface.ts | 3 + .../application/global-database-context.ts | 12 ++ backend/src/common/data-injection.tokens.ts | 5 + .../entities/connection/connection.entity.ts | 4 + .../entities/demo-data/demo-data.service.ts | 85 +---------- .../create-table-settings.ds.ts | 13 -- .../found-table-settings.ds.ts | 13 -- .../dto/create-table-settings.dto.ts | 21 --- .../table-settings.controller.ts | 8 -- .../table-settings.entity.ts | 17 --- .../use-cases/find-table-settings.use.case.ts | 12 +- .../utils/build-empty-table-settings.ts | 8 -- .../utils/build-found-table-settings-ds.ts | 8 -- .../utils/build-new-table-settings-entity.ts | 8 -- .../find-personal-table-settings.ds.ts | 6 + .../dto/found-personal-table-settings.dto.ts | 25 ++++ .../personal-table-settings.controller.ts | 79 ++++++++++ .../personal-table-settings.entity.ts | 50 +++++++ .../personal-table-settings.module.ts | 0 ...le-settings-custom-repository-extension.ts | 22 +++ ...nal-table-settings.repository.interface.ts | 9 ++ .../find-personal-table-settings.use.case.ts | 47 ++++++ ...onal-table-settings.use-cases.interface.ts | 16 +++ .../utils/build-found-table-settings-dto.ts | 16 +++ .../use-cases/add-row-in-table.use.case.ts | 16 ++- .../bulk-update-rows-in-table.use.case.ts | 7 +- .../delete-row-from-table.use.case.ts | 24 ++-- .../delete-rows-from-table.use.case.ts | 12 +- .../export-csv-from-table.use.case.ts | 12 +- .../get-row-by-primary-key.use.case.ts | 12 +- .../use-cases/get-table-rows.use.case.ts | 26 ++-- .../use-cases/get-table-structure.use.case.ts | 18 +-- .../use-cases/update-row-in-table.use.case.ts | 15 +- backend/src/entities/user/user.entity.ts | 4 + .../user/utils/build-test-table-settings.ts | 4 - backend/src/exceptions/text/messages.ts | 1 + .../table-setting-for-test-connections.ts | 41 ------ .../table-settings-field-validator.ts | 26 ---- ...RemovePropertiesFromTableSettingsEntity.ts | 41 ++++++ ...on-saas-user-admin-permissions-e2e.test.ts | 15 -- ...as-user-group-edit-permissions-e2e.test.ts | 4 - .../saas-tests/table-postgres-e2e.test.ts | 135 +++++++++--------- .../user-admin-permissions-e2e.test.ts | 16 --- .../user-group-edit-permissions-e2e.test.ts | 4 - backend/test/mock.factory.ts | 26 +++- .../data-structures/table-settings.ds.ts | 17 --- .../table-settings.ds.builder.ts | 52 +++++++ 47 files changed, 582 insertions(+), 433 deletions(-) create mode 100644 backend/src/entities/table-settings/personal-table-settings/data-structures/find-personal-table-settings.ds.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/dto/found-personal-table-settings.dto.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/personal-table-settings.controller.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/personal-table-settings.entity.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/personal-table-settings.module.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/repository/personal-table-settings-custom-repository-extension.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/repository/personal-table-settings.repository.interface.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/use-cases/personal-table-settings.use-cases.interface.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/utils/build-found-table-settings-dto.ts create mode 100644 backend/src/migrations/1762424200184-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts create mode 100644 shared-code/src/helpers/data-structures-builders/table-settings.ds.builder.ts diff --git a/backend/src/common/application/global-database-context.interface.ts b/backend/src/common/application/global-database-context.interface.ts index 9c6a206d2..24456aa72 100644 --- a/backend/src/common/application/global-database-context.interface.ts +++ b/backend/src/common/application/global-database-context.interface.ts @@ -48,6 +48,8 @@ import { IDatabaseContext } from '../database-context.interface.js'; import { TableCategoriesEntity } from '../../entities/table-categories/table-categories.entity.js'; import { ITableCategoriesCustomRepository } from '../../entities/table-categories/repository/table-categories-repository.interface.js'; import { ConnectionPropertiesEntity } from '../../entities/connection-properties/connection-properties.entity.js'; +import { IPersonalTableSettingsRepository } from '../../entities/table-settings/personal-table-settings/repository/personal-table-settings.repository.interface.js'; +import { PersonalTableSettingsEntity } from '../../entities/table-settings/personal-table-settings/personal-table-settings.entity.js'; export interface IGlobalDatabaseContext extends IDatabaseContext { userRepository: Repository & IUserRepository; @@ -83,4 +85,5 @@ export interface IGlobalDatabaseContext extends IDatabaseContext { tableFiltersRepository: Repository & ITableFiltersCustomRepository; aiResponsesToUserRepository: Repository & IAiResponsesToUserRepository; tableCategoriesRepository: Repository & ITableCategoriesCustomRepository; + personalTableSettingsRepository: Repository & IPersonalTableSettingsRepository; } diff --git a/backend/src/common/application/global-database-context.ts b/backend/src/common/application/global-database-context.ts index fd80d43d0..e2199d7a0 100644 --- a/backend/src/common/application/global-database-context.ts +++ b/backend/src/common/application/global-database-context.ts @@ -90,6 +90,9 @@ import { aiResponsesToUserRepositoryExtension } from '../../entities/ai/ai-data- import { TableCategoriesEntity } from '../../entities/table-categories/table-categories.entity.js'; import { ITableCategoriesCustomRepository } from '../../entities/table-categories/repository/table-categories-repository.interface.js'; import { tableCategoriesCustomRepositoryExtension } from '../../entities/table-categories/repository/table-categories-repository.extension.js'; +import { PersonalTableSettingsEntity } from '../../entities/table-settings/personal-table-settings/personal-table-settings.entity.js'; +import { IPersonalTableSettingsRepository } from '../../entities/table-settings/personal-table-settings/repository/personal-table-settings.repository.interface.js'; +import { personalTableSettingsCustomRepositoryExtension } from '../../entities/table-settings/personal-table-settings/repository/personal-table-settings-custom-repository-extension.js'; @Injectable({ scope: Scope.REQUEST }) export class GlobalDatabaseContext implements IGlobalDatabaseContext { @@ -128,6 +131,7 @@ export class GlobalDatabaseContext implements IGlobalDatabaseContext { private _tableFiltersRepository: Repository & ITableFiltersCustomRepository; private _aiResponsesToUserRepository: Repository & IAiResponsesToUserRepository; private _tableCategoriesRepository: Repository & ITableCategoriesCustomRepository; + private _personalTableSettingsRepository: Repository & IPersonalTableSettingsRepository; public constructor( @Inject(BaseType.DATA_SOURCE) @@ -216,6 +220,9 @@ export class GlobalDatabaseContext implements IGlobalDatabaseContext { this._tableCategoriesRepository = this.appDataSource .getRepository(TableCategoriesEntity) .extend(tableCategoriesCustomRepositoryExtension); + this._personalTableSettingsRepository = this.appDataSource + .getRepository(PersonalTableSettingsEntity) + .extend(personalTableSettingsCustomRepositoryExtension); } public get userRepository(): Repository & IUserRepository { @@ -351,6 +358,11 @@ export class GlobalDatabaseContext implements IGlobalDatabaseContext { return this._tableCategoriesRepository; } + public get personalTableSettingsRepository(): Repository & + IPersonalTableSettingsRepository { + return this._personalTableSettingsRepository; + } + public startTransaction(): Promise { this._queryRunner = this.appDataSource.createQueryRunner(); this._queryRunner.startTransaction(); diff --git a/backend/src/common/data-injection.tokens.ts b/backend/src/common/data-injection.tokens.ts index 241b4d9f1..c2a2a0da4 100644 --- a/backend/src/common/data-injection.tokens.ts +++ b/backend/src/common/data-injection.tokens.ts @@ -73,6 +73,11 @@ export enum UseCaseType { UPDATE_TABLE_SETTINGS = 'UPDATE_TABLE_SETTINGS', DELETE_TABLE_SETTINGS = 'DELETE_TABLE_SETTINGS', + FIND_PERSONAL_TABLE_SETTINGS = 'FIND_PERSONAL_TABLE_SETTINGS', + CREATE_PERSONAL_TABLE_SETTINGS = 'CREATE_PERSONAL_TABLE_SETTINGS', + UPDATE_PERSONAL_TABLE_SETTINGS = 'UPDATE_PERSONAL_TABLE_SETTINGS', + DELETE_PERSONAL_TABLE_SETTINGS = 'DELETE_PERSONAL_TABLE_SETTINGS', + GET_HELLO = 'GET_HELLO', CREATE_USER_ACTION = 'CREATE_USER_ACTION', diff --git a/backend/src/entities/connection/connection.entity.ts b/backend/src/entities/connection/connection.entity.ts index 6e2be1c4b..b3cad30f0 100644 --- a/backend/src/entities/connection/connection.entity.ts +++ b/backend/src/entities/connection/connection.entity.ts @@ -26,6 +26,7 @@ import { ActionRulesEntity } from '../table-actions/table-action-rules-module/ac import { nanoid } from 'nanoid'; import { Constants } from '../../helpers/constants/constants.js'; import { TableFiltersEntity } from '../table-filters/table-filters.entity.js'; +import { PersonalTableSettingsEntity } from '../table-settings/personal-table-settings/personal-table-settings.entity.js'; @Entity('connection') export class ConnectionEntity { @@ -220,6 +221,9 @@ export class ConnectionEntity { @OneToMany((_) => TableSettingsEntity, (settings) => settings.connection_id) settings: Relation[]; + @OneToMany((_) => PersonalTableSettingsEntity, (personal_table_settings) => personal_table_settings.connection) + personal_table_settings: Relation[]; + @OneToMany((_) => TableLogsEntity, (logs) => logs.connection_id) logs: Relation[]; diff --git a/backend/src/entities/demo-data/demo-data.service.ts b/backend/src/entities/demo-data/demo-data.service.ts index 53793eb02..4433674d6 100644 --- a/backend/src/entities/demo-data/demo-data.service.ts +++ b/backend/src/entities/demo-data/demo-data.service.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { ConnectionTypesEnum } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/enums/connection-types-enum.js'; import { IGlobalDatabaseContext } from '../../common/application/global-database-context.interface.js'; import { BaseType } from '../../common/data-injection.tokens.js'; -import { QueryOrderingEnum } from '../../enums/query-ordering.enum.js'; +import { FilterCriteriaEnum } from '../../enums/filter-criteria.enum.js'; import { TableActionEventEnum } from '../../enums/table-action-event-enum.js'; import { TableActionTypeEnum } from '../../enums/table-action-type.enum.js'; import { isTest } from '../../helpers/app/is-test.js'; @@ -20,6 +20,8 @@ import { CreateTableActionEventDS, } from '../table-actions/table-action-rules-module/application/data-structures/create-action-rules.ds.js'; import { buildEmptyActionRule } from '../table-actions/table-action-rules-module/utils/build-empty-action-rule.util.js'; +import { CreateTableFilterDs } from '../table-filters/application/data-structures/create-table-filters.ds.js'; +import { buildNewTableFiltersEntity } from '../table-filters/utils/build-new-table-filters-entity.util.js'; import { CreateTableSettingsDs } from '../table-settings/application/data-structures/create-table-settings.ds.js'; import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; import { buildNewTableSettingsEntity } from '../table-settings/common-table-settings/utils/build-new-table-settings-entity.js'; @@ -28,9 +30,6 @@ import { buildDefaultAdminGroups } from '../user/utils/build-default-admin-group import { buildDefaultAdminPermissions } from '../user/utils/build-default-admin-permissions.js'; import { CreateTableWidgetDs } from '../widget/application/data-sctructures/create-table-widgets.ds.js'; import { buildNewTableWidgetEntity } from '../widget/utils/build-new-table-widget-entity.js'; -import { CreateTableFilterDs } from '../table-filters/application/data-structures/create-table-filters.ds.js'; -import { FilterCriteriaEnum } from '../../enums/filter-criteria.enum.js'; -import { buildNewTableFiltersEntity } from '../table-filters/utils/build-new-table-filters-entity.util.js'; @Injectable() export class DemoDataService { @@ -109,10 +108,6 @@ export class DemoDataService { display_name: '', search_fields: [], excluded_fields: [], - list_fields: ['title', 'start_time', 'end_time', 'space_id', 'image_url', 'organizer_id', 'description', 'id'], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: ['title', 'description'], @@ -135,10 +130,6 @@ export class DemoDataService { display_name: '', search_fields: ['event_id', 'user_id', 'guest_name', 'guest_email', 'status'], excluded_fields: [], - list_fields: ['user_id', 'guest_name', 'status', 'guest_email', 'event_id', 'created_at', 'id'], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: ['event_id', 'user_id', 'guest_name', 'guest_email'], @@ -161,10 +152,6 @@ export class DemoDataService { display_name: null, search_fields: [], excluded_fields: [], - list_fields: [], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: null, readonly_fields: [], sortable_by: [], autocomplete_columns: [], @@ -187,10 +174,6 @@ export class DemoDataService { display_name: '', search_fields: ['name', 'address', 'city', 'country'], excluded_fields: [], - list_fields: [], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: ['name', 'address', 'city', 'country'], @@ -213,10 +196,6 @@ export class DemoDataService { display_name: '', search_fields: ['user_id', 'space_id', 'membership_type'], excluded_fields: [], - list_fields: ['user_id', 'start_date', 'end_date', 'space_id', 'membership_type', 'id'], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: ['user_id', 'space_id'], @@ -239,10 +218,6 @@ export class DemoDataService { display_name: '', search_fields: ['location_id', 'name', 'type', 'description'], excluded_fields: [], - list_fields: ['name', 'type', 'price_per_hour', 'capacity', 'location_id', 'description', 'id'], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: ['location_id', 'name', 'description'], @@ -265,10 +240,6 @@ export class DemoDataService { display_name: '', search_fields: [], excluded_fields: [], - list_fields: [], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: [], @@ -291,10 +262,6 @@ export class DemoDataService { display_name: '', search_fields: ['name', 'email', 'phone'], excluded_fields: [], - list_fields: [], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: ['name', 'email', 'phone'], @@ -757,10 +724,6 @@ export class DemoDataService { display_name: null, search_fields: [], excluded_fields: [], - list_fields: ['user_id', 'course_id', 'certificate_url', 'issued_at', 'id'], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: [], @@ -783,10 +746,6 @@ export class DemoDataService { display_name: null, search_fields: [], excluded_fields: [], - list_fields: [], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: null, readonly_fields: [], sortable_by: [], autocomplete_columns: [], @@ -809,10 +768,6 @@ export class DemoDataService { display_name: null, search_fields: [], excluded_fields: [], - list_fields: ['position', 'title', 'course_id', 'description', 'id'], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: [], @@ -835,10 +790,6 @@ export class DemoDataService { display_name: null, search_fields: [], excluded_fields: [], - list_fields: ['title', 'description', 'language', 'level', 'price', 'is_published', 'created_at', 'id'], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: [], @@ -861,10 +812,6 @@ export class DemoDataService { display_name: '', search_fields: [], excluded_fields: [], - list_fields: ['user_id', 'course_id', 'progress', 'completed', 'enrolled_at', 'id'], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: [], @@ -887,10 +834,6 @@ export class DemoDataService { display_name: null, search_fields: [], excluded_fields: [], - list_fields: ['title', 'module_id', 'content', 'video_url', 'duration', 'position', 'content_url', 'id'], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: null, readonly_fields: [], sortable_by: [], autocomplete_columns: [], @@ -913,10 +856,6 @@ export class DemoDataService { display_name: null, search_fields: [], excluded_fields: [], - list_fields: ['user_id', 'quiz_id', 'score', 'started_at', 'completed_at', 'id'], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: null, readonly_fields: ['completed_at'], sortable_by: [], autocomplete_columns: [], @@ -939,10 +878,6 @@ export class DemoDataService { display_name: null, search_fields: ['lesson_id', 'title'], excluded_fields: [], - list_fields: ['title', 'lesson_id', 'max_score', 'questions', 'id'], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: null, readonly_fields: [], sortable_by: [], autocomplete_columns: ['title'], @@ -965,20 +900,6 @@ export class DemoDataService { display_name: '', search_fields: ['role', 'full_name', 'email', 'bio'], excluded_fields: [], - list_fields: [ - 'full_name', - 'role', - 'email', - 'bio', - 'date_of_birth', - 'created_at', - 'last_login', - 'password_hash', - 'id', - ], - list_per_page: null, - ordering: QueryOrderingEnum.ASC, - ordering_field: '', readonly_fields: [], sortable_by: [], autocomplete_columns: ['role', 'full_name', 'email', 'bio'], diff --git a/backend/src/entities/table-settings/application/data-structures/create-table-settings.ds.ts b/backend/src/entities/table-settings/application/data-structures/create-table-settings.ds.ts index 54cc254af..940728e69 100644 --- a/backend/src/entities/table-settings/application/data-structures/create-table-settings.ds.ts +++ b/backend/src/entities/table-settings/application/data-structures/create-table-settings.ds.ts @@ -1,5 +1,4 @@ import { ApiProperty } from '@nestjs/swagger'; -import { QueryOrderingEnum } from '../../../../enums/index.js'; import { CustomFieldsEntity } from '../../../custom-field/custom-fields.entity.js'; import { TableActionEntity } from '../../../table-actions/table-actions-module/table-action.entity.js'; import { TableWidgetEntity } from '../../../widget/table-widget.entity.js'; @@ -28,20 +27,8 @@ export class CreateTableSettingsDs { @ApiProperty() identity_column: string; - @ApiProperty({ isArray: true, type: 'string' }) - list_fields: Array; - - @ApiProperty() - list_per_page: number; - masterPwd: string; - @ApiProperty({ enum: QueryOrderingEnum }) - ordering: QueryOrderingEnum; - - @ApiProperty() - ordering_field: string; - @ApiProperty({ isArray: true, type: 'string' }) readonly_fields: Array; diff --git a/backend/src/entities/table-settings/application/data-structures/found-table-settings.ds.ts b/backend/src/entities/table-settings/application/data-structures/found-table-settings.ds.ts index bfa89efff..38912f375 100644 --- a/backend/src/entities/table-settings/application/data-structures/found-table-settings.ds.ts +++ b/backend/src/entities/table-settings/application/data-structures/found-table-settings.ds.ts @@ -1,5 +1,4 @@ import { ApiProperty } from '@nestjs/swagger'; -import { QueryOrderingEnum } from '../../../../enums/index.js'; import { CustomFieldsEntity } from '../../../custom-field/custom-fields.entity.js'; import { TableActionEntity } from '../../../table-actions/table-actions-module/table-action.entity.js'; import { TableWidgetEntity } from '../../../widget/table-widget.entity.js'; @@ -20,21 +19,9 @@ export class FoundTableSettingsDs { @ApiProperty({ isArray: true, type: String }) excluded_fields: Array; - @ApiProperty({ isArray: true, type: String }) - list_fields: Array; - @ApiProperty({ isArray: true, type: String }) identification_fields: Array; - @ApiProperty() - list_per_page: number; - - @ApiProperty({ enum: QueryOrderingEnum }) - ordering: QueryOrderingEnum; - - @ApiProperty() - ordering_field: string; - @ApiProperty() identity_column: string; diff --git a/backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts b/backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts index 5acaf21b2..267e69108 100644 --- a/backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts +++ b/backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts @@ -1,39 +1,18 @@ import { CustomFieldsEntity } from '../../../custom-field/custom-fields.entity.js'; -import { QueryOrderingEnum } from '../../../../enums/index.js'; import { TableWidgetEntity } from '../../../widget/table-widget.entity.js'; export class CreateTableSettingsDto { connection_id: string; - table_name: string; - display_name: string; - search_fields: string[]; - excluded_fields: string[]; - - list_fields: string[]; - identification_fields: string[]; - - list_per_page: number; - - ordering: QueryOrderingEnum; - - ordering_field: string; - identity_column; - readonly_fields: string[]; - sortable_by: string[]; - autocomplete_columns: string[]; - custom_fields?: CustomFieldsEntity[]; - table_widgets?: TableWidgetEntity[]; - columns_view?: string[]; } diff --git a/backend/src/entities/table-settings/common-table-settings/table-settings.controller.ts b/backend/src/entities/table-settings/common-table-settings/table-settings.controller.ts index 956e9a07b..bcf5c5b74 100644 --- a/backend/src/entities/table-settings/common-table-settings/table-settings.controller.ts +++ b/backend/src/entities/table-settings/common-table-settings/table-settings.controller.ts @@ -129,10 +129,6 @@ export class TableSettingsController { connection_id: connectionId, search_fields: search_fields, excluded_fields: excluded_fields, - list_fields: list_fields, - list_per_page: list_per_page, - ordering: ordering, - ordering_field: ordering_field, readonly_fields: readonly_fields, sortable_by: sortable_by, autocomplete_columns: autocomplete_columns, @@ -212,11 +208,7 @@ export class TableSettingsController { excluded_fields: excluded_fields, identification_fields: identification_fields, identity_column: identity_column, - list_fields: list_fields, - list_per_page: list_per_page, masterPwd: masterPwd, - ordering: ordering, - ordering_field: ordering_field, readonly_fields: readonly_fields, search_fields: search_fields, sensitive_fields: sensitive_fields, diff --git a/backend/src/entities/table-settings/common-table-settings/table-settings.entity.ts b/backend/src/entities/table-settings/common-table-settings/table-settings.entity.ts index 756b50139..f1f437864 100644 --- a/backend/src/entities/table-settings/common-table-settings/table-settings.entity.ts +++ b/backend/src/entities/table-settings/common-table-settings/table-settings.entity.ts @@ -1,6 +1,5 @@ import { Transform } from 'class-transformer'; import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn, Relation, Unique } from 'typeorm'; -import { QueryOrderingEnum } from '../../../enums/index.js'; import { ConnectionEntity } from '../../connection/connection.entity.js'; import { CustomFieldsEntity } from '../../custom-field/custom-fields.entity.js'; import { TableActionEntity } from '../../table-actions/table-actions-module/table-action.entity.js'; @@ -24,25 +23,9 @@ export class TableSettingsEntity { @Column('varchar', { array: true, default: {} }) excluded_fields: string[]; - @Column('varchar', { array: true, default: {} }) - list_fields: string[]; - @Column('varchar', { array: true, default: {} }) identification_fields: string[]; - @Column('int', { default: null }) - list_per_page: number; - - @Column('enum', { - nullable: false, - enum: QueryOrderingEnum, - default: QueryOrderingEnum.ASC, - }) - ordering!: QueryOrderingEnum; - - @Column('varchar', { default: null }) - ordering_field: string; - @Column({ default: null }) identity_column: string; diff --git a/backend/src/entities/table-settings/common-table-settings/use-cases/find-table-settings.use.case.ts b/backend/src/entities/table-settings/common-table-settings/use-cases/find-table-settings.use.case.ts index 5422d3ed7..c1d9e97e6 100644 --- a/backend/src/entities/table-settings/common-table-settings/use-cases/find-table-settings.use.case.ts +++ b/backend/src/entities/table-settings/common-table-settings/use-cases/find-table-settings.use.case.ts @@ -2,13 +2,11 @@ import { Inject, Injectable, NotFoundException } from '@nestjs/common'; import AbstractUseCase from '../../../../common/abstract-use.case.js'; import { IGlobalDatabaseContext } from '../../../../common/application/global-database-context.interface.js'; import { BaseType } from '../../../../common/data-injection.tokens.js'; +import { Messages } from '../../../../exceptions/text/messages.js'; import { FindTableSettingsDs } from '../../application/data-structures/find-table-settings.ds.js'; import { FoundTableSettingsDs } from '../../application/data-structures/found-table-settings.ds.js'; import { buildFoundTableSettingsDs } from '../utils/build-found-table-settings-ds.js'; import { IFindTableSettings } from './use-cases.interface.js'; -import { Messages } from '../../../../exceptions/text/messages.js'; -import { getDataAccessObject } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/create-data-access-object.js'; -import { findAvailableFields } from '../../../table/utils/find-available-fields.utils.js'; @Injectable() export class FindTableSettingsUseCase @@ -35,14 +33,6 @@ export class FindTableSettingsUseCase if (!foundConnection) { throw new NotFoundException(Messages.CONNECTION_NOT_FOUND); } - const dao = getDataAccessObject(foundConnection); - const tableStructure = await dao.getTableStructure(tableName, null); - - const availableFields = findAvailableFields(tableSettings, tableStructure); - if (tableSettings.list_fields?.length && tableSettings.list_fields?.length !== availableFields.length) { - tableSettings.list_fields = availableFields; - await this._dbContext.tableSettingsRepository.saveNewOrUpdatedSettings(tableSettings); - } return buildFoundTableSettingsDs(tableSettings); } diff --git a/backend/src/entities/table-settings/common-table-settings/utils/build-empty-table-settings.ts b/backend/src/entities/table-settings/common-table-settings/utils/build-empty-table-settings.ts index d1197a719..103b499a2 100644 --- a/backend/src/entities/table-settings/common-table-settings/utils/build-empty-table-settings.ts +++ b/backend/src/entities/table-settings/common-table-settings/utils/build-empty-table-settings.ts @@ -10,11 +10,7 @@ export function buildEmptyTableSettings(connectionId: string, tableName: string) excluded_fields: undefined, identification_fields: undefined, identity_column: undefined, - list_fields: undefined, - list_per_page: undefined, masterPwd: undefined, - ordering: undefined, - ordering_field: undefined, readonly_fields: undefined, search_fields: undefined, sensitive_fields: undefined, @@ -46,11 +42,7 @@ export function buildEmptyTableSettingsWithEmptyWidgets( excluded_fields: undefined, identification_fields: undefined, identity_column: undefined, - list_fields: undefined, - list_per_page: undefined, masterPwd: undefined, - ordering: undefined, - ordering_field: undefined, readonly_fields: undefined, search_fields: undefined, sensitive_fields: undefined, diff --git a/backend/src/entities/table-settings/common-table-settings/utils/build-found-table-settings-ds.ts b/backend/src/entities/table-settings/common-table-settings/utils/build-found-table-settings-ds.ts index 10eb15fd5..7345a9c19 100644 --- a/backend/src/entities/table-settings/common-table-settings/utils/build-found-table-settings-ds.ts +++ b/backend/src/entities/table-settings/common-table-settings/utils/build-found-table-settings-ds.ts @@ -9,11 +9,7 @@ export function buildFoundTableSettingsDs(tableSettings: TableSettingsEntity): F display_name, search_fields, excluded_fields, - list_fields, identification_fields, - list_per_page, - ordering, - ordering_field, identity_column, readonly_fields, sensitive_fields, @@ -40,11 +36,7 @@ export function buildFoundTableSettingsDs(tableSettings: TableSettingsEntity): F display_name: display_name, search_fields: search_fields, excluded_fields: excluded_fields, - list_fields: list_fields, identification_fields: identification_fields, - list_per_page: list_per_page, - ordering: ordering, - ordering_field: ordering_field, identity_column: identity_column, readonly_fields: readonly_fields, sensitive_fields: sensitive_fields, diff --git a/backend/src/entities/table-settings/common-table-settings/utils/build-new-table-settings-entity.ts b/backend/src/entities/table-settings/common-table-settings/utils/build-new-table-settings-entity.ts index 6b546eee3..622f30478 100644 --- a/backend/src/entities/table-settings/common-table-settings/utils/build-new-table-settings-entity.ts +++ b/backend/src/entities/table-settings/common-table-settings/utils/build-new-table-settings-entity.ts @@ -15,10 +15,6 @@ export function buildNewTableSettingsEntity( excluded_fields, identification_fields, identity_column, - list_fields, - list_per_page, - ordering, - ordering_field, readonly_fields, search_fields, sortable_by, @@ -38,10 +34,6 @@ export function buildNewTableSettingsEntity( newSettings.table_name = table_name; newSettings.search_fields = search_fields; newSettings.excluded_fields = excluded_fields; - newSettings.list_fields = list_fields; - newSettings.list_per_page = list_per_page; - newSettings.ordering = ordering; - newSettings.ordering_field = ordering_field; newSettings.readonly_fields = readonly_fields; newSettings.sortable_by = sortable_by; newSettings.autocomplete_columns = autocomplete_columns; diff --git a/backend/src/entities/table-settings/personal-table-settings/data-structures/find-personal-table-settings.ds.ts b/backend/src/entities/table-settings/personal-table-settings/data-structures/find-personal-table-settings.ds.ts new file mode 100644 index 000000000..aefcf5c3c --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/data-structures/find-personal-table-settings.ds.ts @@ -0,0 +1,6 @@ +export class FindPersonalTableSettingsDs { + connectionId: string; + userId: string; + tableName: string; + masterPassword: string; +} diff --git a/backend/src/entities/table-settings/personal-table-settings/dto/found-personal-table-settings.dto.ts b/backend/src/entities/table-settings/personal-table-settings/dto/found-personal-table-settings.dto.ts new file mode 100644 index 000000000..50914df68 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/dto/found-personal-table-settings.dto.ts @@ -0,0 +1,25 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { QueryOrderingEnum } from '../../../../enums/query-ordering.enum.js'; + +export class FoundPersonalTableSettingsDto { + @ApiProperty({ type: String, description: 'The entity id' }) + id: string; + + @ApiProperty({ type: String, description: 'The table name' }) + table_name: string; + + @ApiProperty({ type: String, enum: ['ASC', 'DESC'], description: 'The ordering direction' }) + ordering: QueryOrderingEnum; + + @ApiProperty({ type: String, description: 'The ordering field' }) + ordering_field: string; + + @ApiProperty({ type: Number, description: 'The number of items per page' }) + list_per_page: number; + + @ApiProperty({ type: [String], description: 'The list of fields to display in the table' }) + list_fields: string[]; + + @ApiProperty({ type: Boolean, description: 'Whether to use original column names' }) + original_names: boolean; +} diff --git a/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.controller.ts b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.controller.ts new file mode 100644 index 000000000..a1c5a7c02 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.controller.ts @@ -0,0 +1,79 @@ +import { + Controller, + Get, + HttpException, + HttpStatus, + Inject, + Injectable, + UseGuards, + UseInterceptors, +} from '@nestjs/common'; +import { ApiBearerAuth, ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger'; +import { SentryInterceptor } from '../../../interceptors/sentry.interceptor.js'; +import { UseCaseType } from '../../../common/data-injection.tokens.js'; +import { + ICreatePersonalTableSettings, + IDeletePersonalTableSettings, + IFindPersonalTableSettings, + IUpdatePersonalTableSettings, +} from './use-cases/personal-table-settings.use-cases.interface.js'; +import { TableReadGuard } from '../../../guards/table-read.guard.js'; +import { UserId } from '../../../decorators/user-id.decorator.js'; +import { QueryUuid } from '../../../decorators/query-uuid.decorator.js'; +import { QueryTableName } from '../../../decorators/query-table-name.decorator.js'; +import { MasterPassword } from '../../../decorators/master-password.decorator.js'; +import { Messages } from '../../../exceptions/text/messages.js'; +import { InTransactionEnum } from '../../../enums/in-transaction.enum.js'; +import { FindPersonalTableSettingsDs } from './data-structures/find-personal-table-settings.ds.js'; +import { FoundPersonalTableSettingsDto } from './dto/found-personal-table-settings.dto.js'; + +@UseInterceptors(SentryInterceptor) +@Controller() +@ApiBearerAuth() +@ApiTags('Personal table settings') +@Injectable() +export class PersonalTableSettingsController { + constructor( + @Inject(UseCaseType.FIND_TABLE_SETTINGS) + private readonly findPersonalTableSettingsUseCase: IFindPersonalTableSettings, + @Inject(UseCaseType.CREATE_TABLE_SETTINGS) + private readonly createPersonalTableSettingsUseCase: ICreatePersonalTableSettings, + @Inject(UseCaseType.UPDATE_TABLE_SETTINGS) + private readonly updatePersonalTableSettingsUseCase: IUpdatePersonalTableSettings, + @Inject(UseCaseType.DELETE_TABLE_SETTINGS) + private readonly deletePersonalTableSettingsUseCase: IDeletePersonalTableSettings, + ) {} + + @ApiOperation({ summary: 'Find personal users table settings' }) + @ApiResponse({ + status: 200, + description: 'Table settings found.', + // type: FoundTableSettingsDs, + }) + @ApiParam({ name: 'connectionId', required: true }) + @ApiQuery({ name: 'tableName', required: true }) + @UseGuards(TableReadGuard) + @Get('/settings/personal/:connectionId') + async findAll( + @QueryUuid('connectionId') connectionId: string, + @QueryTableName() tableName: string, + @MasterPassword() masterPwd: string, + @UserId() userId: string, + ): Promise { + if (!connectionId) { + throw new HttpException( + { + message: Messages.CONNECTION_ID_MISSING, + }, + HttpStatus.BAD_REQUEST, + ); + } + const inputData: FindPersonalTableSettingsDs = { + connectionId, + tableName, + userId, + masterPassword: masterPwd, + }; + return await this.findPersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF); + } +} diff --git a/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.entity.ts b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.entity.ts new file mode 100644 index 000000000..df3616639 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.entity.ts @@ -0,0 +1,50 @@ +import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, Relation } from 'typeorm'; +import { QueryOrderingEnum } from '../../../enums/query-ordering.enum.js'; +import { ConnectionEntity } from '../../connection/connection.entity.js'; +import { UserEntity } from '../../user/user.entity.js'; + +@Entity('personal_table_settings') +export class PersonalTableSettingsEntity { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ default: null }) + table_name: string; + + @Column('enum', { + nullable: false, + enum: QueryOrderingEnum, + default: QueryOrderingEnum.ASC, + }) + ordering!: QueryOrderingEnum; + + @Column('varchar', { default: null }) + ordering_field: string; + + @Column('int', { default: null }) + list_per_page: number; + + @Column('varchar', { array: true, default: {} }) + list_fields: string[]; + + @Column('boolean', { default: false }) + original_names: boolean; + + @ManyToOne((_) => ConnectionEntity, (connection) => connection.personal_table_settings, { + onDelete: 'CASCADE', + }) + @JoinColumn({ name: 'connection_id' }) + connection: Relation; + + @Column() + connection_id: string; + + @ManyToOne((_) => UserEntity, (user) => user.personal_table_settings, { + onDelete: 'CASCADE', + }) + @JoinColumn({ name: 'user_id' }) + user: Relation; + + @Column() + user_id: string; +} diff --git a/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.module.ts b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.module.ts new file mode 100644 index 000000000..e69de29bb diff --git a/backend/src/entities/table-settings/personal-table-settings/repository/personal-table-settings-custom-repository-extension.ts b/backend/src/entities/table-settings/personal-table-settings/repository/personal-table-settings-custom-repository-extension.ts new file mode 100644 index 000000000..cfd4f1d97 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/repository/personal-table-settings-custom-repository-extension.ts @@ -0,0 +1,22 @@ +import { PersonalTableSettingsEntity } from '../personal-table-settings.entity.js'; +import { IPersonalTableSettingsRepository } from './personal-table-settings.repository.interface.js'; + +export const personalTableSettingsCustomRepositoryExtension: IPersonalTableSettingsRepository = { + async findUserTableSettings( + userId: string, + connectionId: string, + tableName: string, + ): Promise { + const qb = this.createQueryBuilder('personal_table_settings'); + qb.where('personal_table_settings.user_id = :userId', { + userId, + }); + qb.andWhere('personal_table_settings.connection_id = :connectionId', { + connectionId, + }); + qb.andWhere('personal_table_settings.table_name = :tableName', { + tableName, + }); + return await qb.getOne(); + }, +}; diff --git a/backend/src/entities/table-settings/personal-table-settings/repository/personal-table-settings.repository.interface.ts b/backend/src/entities/table-settings/personal-table-settings/repository/personal-table-settings.repository.interface.ts new file mode 100644 index 000000000..2920239bb --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/repository/personal-table-settings.repository.interface.ts @@ -0,0 +1,9 @@ +import { PersonalTableSettingsEntity } from '../personal-table-settings.entity.js'; + +export interface IPersonalTableSettingsRepository { + findUserTableSettings( + userId: string, + connectionId: string, + tableName: string, + ): Promise; +} diff --git a/backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts b/backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts new file mode 100644 index 000000000..9df6416f1 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts @@ -0,0 +1,47 @@ +import { Inject, Injectable, NotFoundException } from '@nestjs/common'; +import AbstractUseCase from '../../../../common/abstract-use.case.js'; +import { FoundPersonalTableSettingsDto } from '../dto/found-personal-table-settings.dto.js'; +import { FindPersonalTableSettingsDs } from '../data-structures/find-personal-table-settings.ds.js'; +import { IFindPersonalTableSettings } from './personal-table-settings.use-cases.interface.js'; +import { IGlobalDatabaseContext } from '../../../../common/application/global-database-context.interface.js'; +import { BaseType } from '../../../../common/data-injection.tokens.js'; +import { Messages } from '../../../../exceptions/text/messages.js'; +import { buildFoundTableSettingsDto } from '../utils/build-found-table-settings-dto.js'; + +@Injectable() +export class FindPersonalTableSettingsUseCase + extends AbstractUseCase + implements IFindPersonalTableSettings +{ + constructor( + @Inject(BaseType.GLOBAL_DB_CONTEXT) + protected _dbContext: IGlobalDatabaseContext, + ) { + super(); + } + + public async implementation(inputData: FindPersonalTableSettingsDs): Promise { + const { connectionId, userId, tableName, masterPassword } = inputData; + + const foundConnection = await this._dbContext.connectionRepository.findAndDecryptConnection( + connectionId, + masterPassword, + ); + + if (!foundConnection) { + throw new NotFoundException(Messages.CONNECTION_NOT_FOUND); + } + + const foundPersonalTableSettings = await this._dbContext.personalTableSettingsRepository.findUserTableSettings( + connectionId, + tableName, + userId, + ); + + if (!foundPersonalTableSettings) { + throw new NotFoundException(Messages.PERSONAL_TABLE_SETTINGS_NOT_FOUND); + } + + return buildFoundTableSettingsDto(foundPersonalTableSettings); + } +} diff --git a/backend/src/entities/table-settings/personal-table-settings/use-cases/personal-table-settings.use-cases.interface.ts b/backend/src/entities/table-settings/personal-table-settings/use-cases/personal-table-settings.use-cases.interface.ts new file mode 100644 index 000000000..a552fb183 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/use-cases/personal-table-settings.use-cases.interface.ts @@ -0,0 +1,16 @@ +import { InTransactionEnum } from '../../../../enums/in-transaction.enum.js'; +import { FindPersonalTableSettingsDs } from '../data-structures/find-personal-table-settings.ds.js'; +import { FoundPersonalTableSettingsDto } from '../dto/found-personal-table-settings.dto.js'; + +export interface IFindPersonalTableSettings { + execute( + inputData: FindPersonalTableSettingsDs, + inTransaction: InTransactionEnum, + ): Promise; +} + +export interface ICreatePersonalTableSettings {} + +export interface IUpdatePersonalTableSettings {} + +export interface IDeletePersonalTableSettings {} diff --git a/backend/src/entities/table-settings/personal-table-settings/utils/build-found-table-settings-dto.ts b/backend/src/entities/table-settings/personal-table-settings/utils/build-found-table-settings-dto.ts new file mode 100644 index 000000000..0dc083572 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/utils/build-found-table-settings-dto.ts @@ -0,0 +1,16 @@ +import { FoundPersonalTableSettingsDto } from '../dto/found-personal-table-settings.dto.js'; +import { PersonalTableSettingsEntity } from '../personal-table-settings.entity.js'; + +export function buildFoundTableSettingsDto( + personalTableSettings: PersonalTableSettingsEntity, +): FoundPersonalTableSettingsDto { + return { + id: personalTableSettings.id, + table_name: personalTableSettings.table_name, + ordering: personalTableSettings.ordering, + ordering_field: personalTableSettings.ordering_field, + list_per_page: personalTableSettings.list_per_page, + list_fields: personalTableSettings.list_fields, + original_names: personalTableSettings.original_names, + }; +} diff --git a/backend/src/entities/table/use-cases/add-row-in-table.use.case.ts b/backend/src/entities/table/use-cases/add-row-in-table.use.case.ts index 37d9d30cf..ee39f2117 100644 --- a/backend/src/entities/table/use-cases/add-row-in-table.use.case.ts +++ b/backend/src/entities/table/use-cases/add-row-in-table.use.case.ts @@ -4,6 +4,7 @@ import { ForeignKeyWithAutocompleteColumnsDS } from '@rocketadmin/shared-code/di import { ForeignKeyDS } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/data-structures/foreign-key.ds.js'; import { IDataAccessObjectAgent } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/interfaces/data-access-object-agent.interface.js'; import { IDataAccessObject } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/interfaces/data-access-object.interface.js'; +import { buildDAOsTableSettingsDs } from '@rocketadmin/shared-code/dist/src/helpers/data-structures-builders/table-settings.ds.builder.js'; import AbstractUseCase from '../../../common/abstract-use.case.js'; import { IGlobalDatabaseContext } from '../../../common/application/global-database-context.interface.js'; import { BaseType } from '../../../common/data-injection.tokens.js'; @@ -14,6 +15,7 @@ import { WidgetTypeEnum, } from '../../../enums/index.js'; import { TableActionEventEnum } from '../../../enums/table-action-event-enum.js'; +import { NonAvailableInFreePlanException } from '../../../exceptions/custom-exceptions/non-available-in-free-plan-exception.js'; import { Messages } from '../../../exceptions/text/messages.js'; import { isConnectionTypeAgent, isObjectEmpty, toPrettyErrorsMsg } from '../../../helpers/index.js'; import { AmplitudeService } from '../../amplitude/amplitude.service.js'; @@ -22,6 +24,7 @@ import { TableActionActivationService } from '../../table-actions/table-actions- import { TableLogsService } from '../../table-logs/table-logs.service.js'; import { AddRowInTableDs } from '../application/data-structures/add-row-in-table.ds.js'; import { ForeignKeyDSInfo, ReferencedTableNamesAndColumnsDs, TableRowRODs } from '../table-datastructures.js'; +import { convertBinaryDataInRowUtil } from '../utils/convert-binary-data-in-row.util.js'; import { convertHexDataInRowUtil } from '../utils/convert-hex-data-in-row.util.js'; import { formFullTableStructure } from '../utils/form-full-table-structure.js'; import { hashPasswordsInRowUtil } from '../utils/hash-passwords-in-row.util.js'; @@ -29,8 +32,6 @@ import { processUuidsInRowUtil } from '../utils/process-uuids-in-row-util.js'; import { removePasswordsFromRowsUtil } from '../utils/remove-password-from-row.util.js'; import { validateTableRowUtil } from '../utils/validate-table-row.util.js'; import { IAddRowInTable } from './table-use-cases.interface.js'; -import { NonAvailableInFreePlanException } from '../../../exceptions/custom-exceptions/non-available-in-free-plan-exception.js'; -import { convertBinaryDataInRowUtil } from '../utils/convert-binary-data-in-row.util.js'; @Injectable() export class AddRowInTableUseCase extends AbstractUseCase implements IAddRowInTable { @@ -93,6 +94,7 @@ export class AddRowInTableUseCase extends AbstractUseCase = {}; let addedRowPrimaryKey: Record; + const builtDAOsTableSettings = buildDAOsTableSettingsDs(tableSettings, personalTableSettings); try { row = await hashPasswordsInRowUtil(row, tableWidgets); row = processUuidsInRowUtil(row, tableWidgets); @@ -212,7 +216,7 @@ export class AddRowInTableUseCase extends AbstractUseCase; if (addedRowPrimaryKey && !isObjectEmpty(addedRowPrimaryKey)) { operationResult = OperationResultStatusEnum.successfully; - addedRow = await dao.getRowByPrimaryKey(tableName, addedRowPrimaryKey, tableSettings, userEmail); + addedRow = await dao.getRowByPrimaryKey(tableName, addedRowPrimaryKey, builtDAOsTableSettings, userEmail); addedRow = removePasswordsFromRowsUtil(addedRow, tableWidgets); addedRow = convertBinaryDataInRowUtil(addedRow, tableStructure); return { @@ -223,7 +227,7 @@ export class AddRowInTableUseCase extends AbstractUseCase 0 ? tableSettings.list_fields : [], + list_fields: personalTableSettings?.list_fields?.length > 0 ? personalTableSettings.list_fields : [], identity_column: tableSettings?.identity_column ? tableSettings.identity_column : null, referenced_table_names_and_columns: referencedTableNamesAndColumnsWithTablesDisplayNames, excluded_fields: tableSettings?.excluded_fields ? tableSettings.excluded_fields : [], @@ -232,9 +236,9 @@ export class AddRowInTableUseCase extends AbstractUseCase 0 ? tableSettings.sortable_by : [], - ordering: tableSettings?.ordering ? tableSettings.ordering : undefined, + ordering: personalTableSettings?.ordering ? personalTableSettings.ordering : undefined, identity_column: tableSettings?.identity_column ? tableSettings.identity_column : null, - list_fields: tableSettings?.list_fields?.length > 0 ? tableSettings.list_fields : [], + list_fields: personalTableSettings?.list_fields?.length > 0 ? personalTableSettings.list_fields : [], allow_csv_export: tableSettings ? tableSettings.allow_csv_export : true, allow_csv_import: tableSettings ? tableSettings.allow_csv_import : true, can_delete: tableSettings ? tableSettings.can_delete : true, diff --git a/backend/src/entities/table/use-cases/bulk-update-rows-in-table.use.case.ts b/backend/src/entities/table/use-cases/bulk-update-rows-in-table.use.case.ts index 3a54783f9..ea5c3a3d0 100644 --- a/backend/src/entities/table/use-cases/bulk-update-rows-in-table.use.case.ts +++ b/backend/src/entities/table/use-cases/bulk-update-rows-in-table.use.case.ts @@ -17,6 +17,7 @@ import { processUuidsInRowUtil } from '../utils/process-uuids-in-row-util.js'; import { OperationResultStatusEnum } from '../../../enums/operation-result-status.enum.js'; import { LogOperationTypeEnum } from '../../../enums/log-operation-type.enum.js'; import { NonAvailableInFreePlanException } from '../../../exceptions/custom-exceptions/non-available-in-free-plan-exception.js'; +import { buildDAOsTableSettingsDs } from '@rocketadmin/shared-code/dist/src/helpers/data-structures-builders/table-settings.ds.builder.js'; @Injectable() export class BulkUpdateRowsInTableUseCase @@ -74,10 +75,11 @@ export class BulkUpdateRowsInTableUseCase ); } - const [tableStructure, primaryColumns, tableSettings, tableWidgets] = await Promise.all([ + const [tableStructure, primaryColumns, tableSettings, personalTableSettings, tableWidgets] = await Promise.all([ dao.getTableStructure(tableName, userEmail), dao.getTablePrimaryColumns(tableName, userEmail), this._dbContext.tableSettingsRepository.findTableSettings(connectionId, tableName), + this._dbContext.personalTableSettingsRepository.findUserTableSettings(userId, connectionId, tableName), this._dbContext.tableWidgetsRepository.findTableWidgets(connectionId, tableName), ]); @@ -99,8 +101,9 @@ export class BulkUpdateRowsInTableUseCase } } + const builtDAOsTableSettings = buildDAOsTableSettingsDs(tableSettings, personalTableSettings); const oldRowsData: Array> = await Promise.all( - primaryKeys.map((primaryKey) => dao.getRowByPrimaryKey(tableName, primaryKey, tableSettings, userEmail)), + primaryKeys.map((primaryKey) => dao.getRowByPrimaryKey(tableName, primaryKey, builtDAOsTableSettings, userEmail)), ); try { diff --git a/backend/src/entities/table/use-cases/delete-row-from-table.use.case.ts b/backend/src/entities/table/use-cases/delete-row-from-table.use.case.ts index ce0af758f..a56a5b8f0 100644 --- a/backend/src/entities/table/use-cases/delete-row-from-table.use.case.ts +++ b/backend/src/entities/table/use-cases/delete-row-from-table.use.case.ts @@ -1,24 +1,25 @@ import { HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common'; +import { getDataAccessObject } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/create-data-access-object.js'; +import { buildDAOsTableSettingsDs } from '@rocketadmin/shared-code/dist/src/helpers/data-structures-builders/table-settings.ds.builder.js'; import AbstractUseCase from '../../../common/abstract-use.case.js'; import { IGlobalDatabaseContext } from '../../../common/application/global-database-context.interface.js'; import { BaseType } from '../../../common/data-injection.tokens.js'; -import { getDataAccessObject } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/create-data-access-object.js'; import { AmplitudeEventTypeEnum, LogOperationTypeEnum, OperationResultStatusEnum } from '../../../enums/index.js'; +import { TableActionEventEnum } from '../../../enums/table-action-event-enum.js'; +import { DeleteRowException } from '../../../exceptions/custom-exceptions/delete-row-exception.js'; +import { ExceptionOperations } from '../../../exceptions/custom-exceptions/exception-operation.js'; +import { NonAvailableInFreePlanException } from '../../../exceptions/custom-exceptions/non-available-in-free-plan-exception.js'; +import { UnknownSQLException } from '../../../exceptions/custom-exceptions/unknown-sql-exception.js'; import { Messages } from '../../../exceptions/text/messages.js'; import { compareArrayElements, isConnectionTypeAgent } from '../../../helpers/index.js'; import { AmplitudeService } from '../../amplitude/amplitude.service.js'; import { isTestConnectionUtil } from '../../connection/utils/is-test-connection-util.js'; +import { TableActionActivationService } from '../../table-actions/table-actions-module/table-action-activation.service.js'; import { TableLogsService } from '../../table-logs/table-logs.service.js'; import { DeleteRowFromTableDs } from '../application/data-structures/delete-row-from-table.ds.js'; import { DeletedRowFromTableDs } from '../application/data-structures/deleted-row-from-table.ds.js'; import { convertHexDataInPrimaryKeyUtil } from '../utils/convert-hex-data-in-primary-key.util.js'; import { IDeleteRowFromTable } from './table-use-cases.interface.js'; -import { DeleteRowException } from '../../../exceptions/custom-exceptions/delete-row-exception.js'; -import { UnknownSQLException } from '../../../exceptions/custom-exceptions/unknown-sql-exception.js'; -import { ExceptionOperations } from '../../../exceptions/custom-exceptions/exception-operation.js'; -import { TableActionEventEnum } from '../../../enums/table-action-event-enum.js'; -import { TableActionActivationService } from '../../table-actions/table-actions-module/table-action-activation.service.js'; -import { NonAvailableInFreePlanException } from '../../../exceptions/custom-exceptions/non-available-in-free-plan-exception.js'; @Injectable() export class DeleteRowFromTableUseCase @@ -115,10 +116,17 @@ export class DeleteRowFromTableUseCase HttpStatus.FORBIDDEN, ); } + const personalTableSettings = await this._dbContext.personalTableSettingsRepository.findUserTableSettings( + userId, + connectionId, + tableName, + ); + + const builtTableSettings = buildDAOsTableSettingsDs(tableSettings, personalTableSettings); let oldRowData: Record; try { - oldRowData = await dao.getRowByPrimaryKey(tableName, primaryKey, tableSettings, userEmail); + oldRowData = await dao.getRowByPrimaryKey(tableName, primaryKey, builtTableSettings, userEmail); } catch (e) { throw new UnknownSQLException(e.message, ExceptionOperations.FAILED_TO_DELETE_ROW_FROM_TABLE); } diff --git a/backend/src/entities/table/use-cases/delete-rows-from-table.use.case.ts b/backend/src/entities/table/use-cases/delete-rows-from-table.use.case.ts index abe8d45d0..398f37a60 100644 --- a/backend/src/entities/table/use-cases/delete-rows-from-table.use.case.ts +++ b/backend/src/entities/table/use-cases/delete-rows-from-table.use.case.ts @@ -14,6 +14,7 @@ import { convertHexDataInPrimaryKeyUtil } from '../utils/convert-hex-data-in-pri import { findObjectsWithProperties } from '../utils/find-objects-with-properties.js'; import { IDeleteRowsFromTable } from './table-use-cases.interface.js'; import { NonAvailableInFreePlanException } from '../../../exceptions/custom-exceptions/non-available-in-free-plan-exception.js'; +import { buildDAOsTableSettingsDs } from '@rocketadmin/shared-code/dist/src/helpers/data-structures-builders/table-settings.ds.builder.js'; type DeleteRowsFromTableResult = { operationStatusResult: OperationResultStatusEnum; @@ -77,10 +78,11 @@ export class DeleteRowsFromTableUseCase ); } - const [tableStructure, primaryColumns, tableSettings] = await Promise.all([ + const [tableStructure, primaryColumns, tableSettings, personalTableSettings] = await Promise.all([ dao.getTableStructure(tableName, userEmail), dao.getTablePrimaryColumns(tableName, userEmail), this._dbContext.tableSettingsRepository.findTableSettings(connectionId, tableName), + this._dbContext.personalTableSettingsRepository.findUserTableSettings(userId, connectionId, tableName), ]); if (tableSettings && !tableSettings?.can_delete) { @@ -116,8 +118,14 @@ export class DeleteRowsFromTableUseCase } }); let oldRowsData: Array>; + const builtDAOsTableSettings = buildDAOsTableSettingsDs(tableSettings, personalTableSettings); try { - oldRowsData = await dao.bulkGetRowsFromTableByPrimaryKeys(tableName, primaryKeys, tableSettings, userEmail); + oldRowsData = await dao.bulkGetRowsFromTableByPrimaryKeys( + tableName, + primaryKeys, + builtDAOsTableSettings, + userEmail, + ); } catch (error) { throw new HttpException( { diff --git a/backend/src/entities/table/use-cases/export-csv-from-table.use.case.ts b/backend/src/entities/table/use-cases/export-csv-from-table.use.case.ts index cc702d063..f4ce1e867 100644 --- a/backend/src/entities/table/use-cases/export-csv-from-table.use.case.ts +++ b/backend/src/entities/table/use-cases/export-csv-from-table.use.case.ts @@ -16,6 +16,7 @@ import { isObjectEmpty } from '../../../helpers/is-object-empty.js'; import { FilteringFieldsDs } from '../table-datastructures.js'; import { NonAvailableInFreePlanException } from '../../../exceptions/custom-exceptions/non-available-in-free-plan-exception.js'; import { slackPostMessage } from '../../../helpers/index.js'; +import { buildDAOsTableSettingsDs } from '@rocketadmin/shared-code/dist/src/helpers/data-structures-builders/table-settings.ds.builder.js'; @Injectable() export class ExportCSVFromTableUseCase @@ -55,9 +56,10 @@ export class ExportCSVFromTableUseCase } // eslint-disable-next-line prefer-const - let [tableSettings, tableStructure] = await Promise.all([ + let [tableSettings, tableStructure, personalTableSettings] = await Promise.all([ this._dbContext.tableSettingsRepository.findTableSettings(connectionId, tableName), dao.getTableStructure(tableName, userEmail), + this._dbContext.personalTableSettingsRepository.findUserTableSettings(userId, connectionId, tableName), ]); if (!tableSettings) { tableSettings = {} as any; @@ -78,9 +80,11 @@ export class ExportCSVFromTableUseCase const orderingField = findOrderingFieldUtil(query, tableStructure, tableSettings); + const builtDAOsTableSettings = buildDAOsTableSettingsDs(tableSettings, personalTableSettings); + if (orderingField) { - tableSettings.ordering_field = orderingField.field; - tableSettings.ordering = orderingField.value; + builtDAOsTableSettings.ordering_field = orderingField.field; + builtDAOsTableSettings.ordering = orderingField.value; } if (isHexString(searchingFieldValue)) { @@ -92,7 +96,7 @@ export class ExportCSVFromTableUseCase const rowsStream = await dao.getTableRowsStream( tableName, - tableSettings, + builtDAOsTableSettings, page, perPage, searchingFieldValue, diff --git a/backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts b/backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts index e349e3aeb..f2d25c4c8 100644 --- a/backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts +++ b/backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts @@ -25,6 +25,7 @@ import JSON5 from 'json5'; import { buildActionEventDto } from '../../table-actions/table-action-rules-module/utils/build-found-action-event-dto.util.js'; import { NonAvailableInFreePlanException } from '../../../exceptions/custom-exceptions/non-available-in-free-plan-exception.js'; import { findAvailableFields } from '../utils/find-available-fields.utils.js'; +import { buildDAOsTableSettingsDs } from '@rocketadmin/shared-code/dist/src/helpers/data-structures-builders/table-settings.ds.builder.js'; @Injectable() export class GetRowByPrimaryKeyUseCase @@ -73,6 +74,7 @@ export class GetRowByPrimaryKeyUseCase tableStructure, tableWidgets, tableSettings, + personalTableSettings, tableForeignKeys, tablePrimaryKeys, customActionEvents, @@ -82,6 +84,7 @@ export class GetRowByPrimaryKeyUseCase dao.getTableStructure(tableName, userEmail), this._dbContext.tableWidgetsRepository.findTableWidgets(connectionId, tableName), this._dbContext.tableSettingsRepository.findTableSettingsPure(connectionId, tableName), + this._dbContext.personalTableSettingsRepository.findUserTableSettings(userId, connectionId, tableName), dao.getTableForeignKeys(tableName, userEmail), dao.getTablePrimaryColumns(tableName, userEmail), this._dbContext.actionEventsRepository.findCustomEventsForTable(connectionId, tableName), @@ -155,8 +158,9 @@ export class GetRowByPrimaryKeyUseCase ); } let rowData: Record; + const builtDAOsTableSettings = buildDAOsTableSettingsDs(tableSettings, personalTableSettings); try { - rowData = await dao.getRowByPrimaryKey(tableName, primaryKey, tableSettings, userEmail); + rowData = await dao.getRowByPrimaryKey(tableName, primaryKey, builtDAOsTableSettings, userEmail); } catch (e) { throw new UnknownSQLException(e.message, ExceptionOperations.FAILED_TO_GET_ROW_BY_PRIMARY_KEY); } @@ -217,7 +221,7 @@ export class GetRowByPrimaryKeyUseCase structure: formedTableStructure, table_widgets: tableWidgets, readonly_fields: tableSettings?.readonly_fields ? tableSettings.readonly_fields : [], - list_fields: findAvailableFields(tableSettings, tableStructure), + list_fields: findAvailableFields(builtDAOsTableSettings, tableStructure), action_events: customActionEvents.map((event) => buildActionEventDto(event)), table_actions: customActionEvents.map((el) => buildActionEventDto(el)), identity_column: tableSettings?.identity_column ? tableSettings.identity_column : null, @@ -230,9 +234,9 @@ export class GetRowByPrimaryKeyUseCase can_add: tableSettings ? tableSettings.can_add : true, table_settings: { sortable_by: tableSettings?.sortable_by?.length > 0 ? tableSettings.sortable_by : [], - ordering: tableSettings?.ordering ? tableSettings.ordering : undefined, + ordering: personalTableSettings?.ordering ? personalTableSettings.ordering : undefined, identity_column: tableSettings?.identity_column ? tableSettings.identity_column : null, - list_fields: tableSettings?.list_fields?.length > 0 ? tableSettings.list_fields : [], + list_fields: personalTableSettings?.list_fields?.length > 0 ? personalTableSettings.list_fields : [], allow_csv_export: tableSettings ? tableSettings.allow_csv_export : true, allow_csv_import: tableSettings ? tableSettings.allow_csv_import : true, can_delete: tableSettings ? tableSettings.can_delete : true, diff --git a/backend/src/entities/table/use-cases/get-table-rows.use.case.ts b/backend/src/entities/table/use-cases/get-table-rows.use.case.ts index 7170b72f5..5f08c1b15 100644 --- a/backend/src/entities/table/use-cases/get-table-rows.use.case.ts +++ b/backend/src/entities/table/use-cases/get-table-rows.use.case.ts @@ -41,6 +41,8 @@ import { processRowsUtil } from '../utils/process-found-rows-util.js'; import { IGetTableRows } from './table-use-cases.interface.js'; import { ConnectionTypesEnum } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/enums/connection-types-enum.js'; import { findAvailableFields } from '../utils/find-available-fields.utils.js'; +import { buildDAOsTableSettingsDs } from '@rocketadmin/shared-code/dist/src/helpers/data-structures-builders/table-settings.ds.builder.js'; +import { PersonalTableSettingsEntity } from '../../table-settings/personal-table-settings/personal-table-settings.entity.js'; @Injectable() export class GetTableRowsUseCase extends AbstractUseCase implements IGetTableRows { @@ -98,6 +100,7 @@ export class GetTableRowsUseCase extends AbstractUseCase = isObjectEmpty(filters) ? findFilteringFieldsUtil(query, tableStructure) @@ -123,6 +127,8 @@ export class GetTableRowsUseCase extends AbstractUseCase Constants.LARGE_DATASET_ROW_LIMIT; - const listFields = findAvailableFields(tableSettings, tableStructure); + const listFields = findAvailableFields(builtDAOsTableSettings, tableStructure); const actionEventsDtos = customActionEvents.map((el) => buildActionEventDto(el)); const savedFiltersRO = savedTableFilters.map((el) => buildCreatedTableFilterRO(el)); @@ -222,8 +229,8 @@ export class GetTableRowsUseCase extends AbstractUseCase 0 ? tableSettings.sortable_by : [], - ordering_field: tableSettings.ordering_field ? tableSettings.ordering_field : undefined, - ordering: tableSettings.ordering ? tableSettings.ordering : undefined, + ordering_field: personalTableSettings.ordering_field ? personalTableSettings.ordering_field : undefined, + ordering: personalTableSettings.ordering ? personalTableSettings.ordering : undefined, columns_view: tableSettings.columns_view ? tableSettings.columns_view : undefined, structure: formedTableStructure, foreignKeys: tableForeignKeys, @@ -243,9 +250,9 @@ export class GetTableRowsUseCase extends AbstractUseCase 0 ? tableSettings.sortable_by : [], - ordering: tableSettings.ordering ? tableSettings.ordering : undefined, + ordering: personalTableSettings.ordering ? personalTableSettings.ordering : undefined, identity_column: tableSettings.identity_column ? tableSettings.identity_column : null, - list_fields: tableSettings?.list_fields?.length > 0 ? tableSettings.list_fields : [], + list_fields: personalTableSettings?.list_fields?.length > 0 ? personalTableSettings.list_fields : [], allow_csv_export: allowCsvExport, allow_csv_import: allowCsvImport, can_delete: can_delete, @@ -291,11 +298,12 @@ export class GetTableRowsUseCase extends AbstractUseCase { const foreignTableSettings = foreignTableSettingsMap.get(foreignKey.referenced_table_name); + const builtDAOsForeignTableSettings = buildDAOsTableSettingsDs(foreignTableSettings, {} as any); const identityColumns = await this.getBatchedIdentityColumns( Array.from(values), foreignKey, dao, - foreignTableSettings, + builtDAOsForeignTableSettings, userEmail, ); return { foreignKey, identityColumns }; diff --git a/backend/src/entities/table/use-cases/get-table-structure.use.case.ts b/backend/src/entities/table/use-cases/get-table-structure.use.case.ts index 784173c68..6e22e7b44 100644 --- a/backend/src/entities/table/use-cases/get-table-structure.use.case.ts +++ b/backend/src/entities/table/use-cases/get-table-structure.use.case.ts @@ -67,13 +67,15 @@ export class GetTableStructureUseCase userEmail = await this._dbContext.userRepository.getUserEmailOrReturnNull(userId); } // eslint-disable-next-line prefer-const - let [tableSettings, tablePrimaryColumns, tableForeignKeys, tableStructure, tableWidgets] = await Promise.all([ - this._dbContext.tableSettingsRepository.findTableSettings(connectionId, tableName), - dao.getTablePrimaryColumns(tableName, userEmail), - dao.getTableForeignKeys(tableName, userEmail), - dao.getTableStructure(tableName, userEmail), - this._dbContext.tableWidgetsRepository.findTableWidgets(connectionId, tableName), - ]); + let [tableSettings, personalTableSettings, tablePrimaryColumns, tableForeignKeys, tableStructure, tableWidgets] = + await Promise.all([ + this._dbContext.tableSettingsRepository.findTableSettings(connectionId, tableName), + this._dbContext.personalTableSettingsRepository.findUserTableSettings(userId, connectionId, tableName), + dao.getTablePrimaryColumns(tableName, userEmail), + dao.getTableForeignKeys(tableName, userEmail), + dao.getTableStructure(tableName, userEmail), + this._dbContext.tableWidgetsRepository.findTableWidgets(connectionId, tableName), + ]); const foreignKeysFromWidgets: Array = tableWidgets .filter((widget) => widget.widget_type === WidgetTypeEnum.Foreign_key) .map((widget) => { @@ -132,7 +134,7 @@ export class GetTableStructureUseCase foreignKeys: transformedTableForeignKeys, readonly_fields: readonly_fields, table_widgets: tableWidgets?.length > 0 ? tableWidgets.map((widget) => buildFoundTableWidgetDs(widget)) : [], - list_fields: tableSettings?.list_fields ? tableSettings.list_fields : [], + list_fields: personalTableSettings?.list_fields ? personalTableSettings.list_fields : [], display_name: tableSettings?.display_name ? tableSettings.display_name : null, excluded_fields: tableSettings?.excluded_fields ? tableSettings.excluded_fields : [], }; diff --git a/backend/src/entities/table/use-cases/update-row-in-table.use.case.ts b/backend/src/entities/table/use-cases/update-row-in-table.use.case.ts index e5a45e362..2fa0e2846 100644 --- a/backend/src/entities/table/use-cases/update-row-in-table.use.case.ts +++ b/backend/src/entities/table/use-cases/update-row-in-table.use.case.ts @@ -39,6 +39,7 @@ import { processUuidsInRowUtil } from '../utils/process-uuids-in-row-util.js'; import { removePasswordsFromRowsUtil } from '../utils/remove-password-from-row.util.js'; import { IUpdateRowInTable } from './table-use-cases.interface.js'; import { NonAvailableInFreePlanException } from '../../../exceptions/custom-exceptions/non-available-in-free-plan-exception.js'; +import { buildDAOsTableSettingsDs } from '@rocketadmin/shared-code/dist/src/helpers/data-structures-builders/table-settings.ds.builder.js'; @Injectable() export class UpdateRowInTableUseCase @@ -98,6 +99,7 @@ export class UpdateRowInTableUseCase tableStructure, tableWidgets, tableSettings, + personalTableSettings, tableForeignKeys, tablePrimaryKeys, referencedTableNamesAndColumns, @@ -105,11 +107,14 @@ export class UpdateRowInTableUseCase dao.getTableStructure(tableName, userEmail), this._dbContext.tableWidgetsRepository.findTableWidgets(connectionId, tableName), this._dbContext.tableSettingsRepository.findTableSettings(connectionId, tableName), + this._dbContext.personalTableSettingsRepository.findUserTableSettings(userId, connectionId, tableName), dao.getTableForeignKeys(tableName, userEmail), dao.getTablePrimaryColumns(tableName, userEmail), dao.getReferencedTableNamesAndColumns(tableName, userEmail), ]); + const builtDAOsTableSettings = buildDAOsTableSettingsDs(tableSettings, personalTableSettings); + for (const referencedTable of referencedTableNamesAndColumns) { referencedTable.referenced_by = await Promise.all( referencedTable.referenced_by.map(async (referencedByTable) => { @@ -237,7 +242,7 @@ export class UpdateRowInTableUseCase let oldRowData: Record; try { - oldRowData = await dao.getRowByPrimaryKey(tableName, primaryKey, tableSettings, userEmail); + oldRowData = await dao.getRowByPrimaryKey(tableName, primaryKey, builtDAOsTableSettings, userEmail); } catch (e) { throw new UnknownSQLException(e.message, ExceptionOperations.FAILED_TO_UPDATE_ROW_IN_TABLE); } @@ -269,7 +274,7 @@ export class UpdateRowInTableUseCase row = processUuidsInRowUtil(row, tableWidgets); await dao.updateRowInTable(tableName, row, primaryKey, userEmail); operationResult = OperationResultStatusEnum.successfully; - let updatedRow = await dao.getRowByPrimaryKey(tableName, futurePrimaryKey, tableSettings, userEmail); + let updatedRow = await dao.getRowByPrimaryKey(tableName, futurePrimaryKey, builtDAOsTableSettings, userEmail); updatedRow = removePasswordsFromRowsUtil(updatedRow, tableWidgets); updatedRow = convertBinaryDataInRowUtil(updatedRow, tableStructure); return { @@ -280,7 +285,7 @@ export class UpdateRowInTableUseCase table_widgets: tableWidgets, display_name: tableSettings?.display_name ? tableSettings.display_name : null, readonly_fields: tableSettings?.readonly_fields ? tableSettings.readonly_fields : [], - list_fields: tableSettings?.list_fields?.length > 0 ? tableSettings.list_fields : [], + list_fields: personalTableSettings?.list_fields?.length > 0 ? personalTableSettings.list_fields : [], identity_column: tableSettings?.identity_column ? tableSettings.identity_column : null, referenced_table_names_and_columns: referencedTableNamesAndColumnsWithTablesDisplayNames, excluded_fields: tableSettings?.excluded_fields ? tableSettings.excluded_fields : [], @@ -289,9 +294,9 @@ export class UpdateRowInTableUseCase can_add: tableSettings ? tableSettings.can_add : true, table_settings: { sortable_by: tableSettings?.sortable_by?.length > 0 ? tableSettings.sortable_by : [], - ordering: tableSettings?.ordering ? tableSettings.ordering : undefined, + ordering: personalTableSettings?.ordering ? personalTableSettings.ordering : undefined, identity_column: tableSettings?.identity_column ? tableSettings.identity_column : null, - list_fields: tableSettings?.list_fields?.length > 0 ? tableSettings.list_fields : [], + list_fields: personalTableSettings?.list_fields?.length > 0 ? personalTableSettings.list_fields : [], allow_csv_export: tableSettings ? tableSettings.allow_csv_export : true, allow_csv_import: tableSettings ? tableSettings.allow_csv_import : true, can_delete: tableSettings ? tableSettings.can_delete : true, diff --git a/backend/src/entities/user/user.entity.ts b/backend/src/entities/user/user.entity.ts index 2f89f3beb..ed1d8062d 100644 --- a/backend/src/entities/user/user.entity.ts +++ b/backend/src/entities/user/user.entity.ts @@ -26,6 +26,7 @@ import { UserRoleEnum } from './enums/user-role.enum.js'; import { ExternalRegistrationProviderEnum } from './enums/external-registration-provider.enum.js'; import { UserApiKeyEntity } from '../api-key/api-key.entity.js'; import { AiResponsesToUserEntity } from '../ai/ai-data-entities/ai-reponses-to-user/ai-responses-to-user.entity.js'; +import { PersonalTableSettingsEntity } from '../table-settings/personal-table-settings/personal-table-settings.entity.js'; @Entity('user') export class UserEntity { @@ -119,6 +120,9 @@ export class UserEntity { @OneToMany((_) => AiResponsesToUserEntity, (response) => response.user) ai_responses: Relation[]; + @OneToMany((_) => PersonalTableSettingsEntity, (personal_table_settings) => personal_table_settings.connection) + personal_table_settings: Relation[]; + @Column({ default: false, type: 'boolean' }) isActive: boolean; diff --git a/backend/src/entities/user/utils/build-test-table-settings.ts b/backend/src/entities/user/utils/build-test-table-settings.ts index b6f6bc584..78d3e6ada 100644 --- a/backend/src/entities/user/utils/build-test-table-settings.ts +++ b/backend/src/entities/user/utils/build-test-table-settings.ts @@ -49,10 +49,6 @@ function tableSettingsDtosToTableSettingsEntity( newSettings.table_name = tableSetting.table_name; newSettings.search_fields = tableSetting.search_fields; newSettings.excluded_fields = tableSetting.excluded_fields; - newSettings.list_fields = tableSetting.list_fields; - newSettings.list_per_page = tableSetting.list_per_page; - newSettings.ordering = tableSetting.ordering; - newSettings.ordering_field = tableSetting.ordering_field; newSettings.readonly_fields = tableSetting.readonly_fields; newSettings.sortable_by = tableSetting.sortable_by; newSettings.autocomplete_columns = tableSetting.autocomplete_columns; diff --git a/backend/src/exceptions/text/messages.ts b/backend/src/exceptions/text/messages.ts index d6cb4b471..3d5f1e6ef 100644 --- a/backend/src/exceptions/text/messages.ts +++ b/backend/src/exceptions/text/messages.ts @@ -368,4 +368,5 @@ export const Messages = { INVALID_REQUEST_DOMAIN: `Invalid request domain`, INVALID_REQUEST_DOMAIN_FORMAT: `Invalid request domain format`, FEATURE_NON_AVAILABLE_IN_FREE_PLAN: `This feature is not available in free plan.`, + PERSONAL_TABLE_SETTINGS_NOT_FOUND: 'Personal table settings with this parameters not found', }; diff --git a/backend/src/helpers/constants/table-setting-for-test-connections.ts b/backend/src/helpers/constants/table-setting-for-test-connections.ts index caba65641..27bebeb69 100644 --- a/backend/src/helpers/constants/table-setting-for-test-connections.ts +++ b/backend/src/helpers/constants/table-setting-for-test-connections.ts @@ -1,5 +1,4 @@ import { CreateTableSettingsDto } from '../../entities/table-settings/common-table-settings/dto/index.js'; -import { QueryOrderingEnum } from '../../enums/index.js'; export const TableSettingForTestConnections = { // create table settings dtos for mysql database @@ -11,11 +10,7 @@ export const TableSettingForTestConnections = { newTableSettingsDto.display_name = 'Registered users'; newTableSettingsDto.search_fields = ['FirstName', 'LastName', 'Email']; newTableSettingsDto.excluded_fields = ['Password']; - newTableSettingsDto.list_fields = undefined; newTableSettingsDto.identification_fields = undefined; - newTableSettingsDto.list_per_page = 20; - newTableSettingsDto.ordering = QueryOrderingEnum.ASC; - newTableSettingsDto.ordering_field = 'UserID'; newTableSettingsDto.identity_column = undefined; newTableSettingsDto.readonly_fields = ['ProfileImage', 'UserID']; newTableSettingsDto.sortable_by = ['UserID', 'FirstName', 'LastName', 'DateRegistered']; @@ -42,11 +37,7 @@ export const TableSettingForTestConnections = { newTableSettingsDto.display_name = undefined; newTableSettingsDto.search_fields = ['VendorName']; newTableSettingsDto.excluded_fields = undefined; - newTableSettingsDto.list_fields = undefined; newTableSettingsDto.identification_fields = undefined; - newTableSettingsDto.list_per_page = 25; - newTableSettingsDto.ordering = QueryOrderingEnum.DESC; - newTableSettingsDto.ordering_field = 'VendorID'; newTableSettingsDto.identity_column = undefined; newTableSettingsDto.readonly_fields = ['VendorID']; newTableSettingsDto.sortable_by = ['ContactEmail']; @@ -64,11 +55,7 @@ export const TableSettingForTestConnections = { newTableSettingsDto.display_name = 'Product categories'; newTableSettingsDto.search_fields = ['CategoryName']; newTableSettingsDto.excluded_fields = undefined; - newTableSettingsDto.list_fields = undefined; newTableSettingsDto.identification_fields = undefined; - newTableSettingsDto.list_per_page = 30; - newTableSettingsDto.ordering = QueryOrderingEnum.ASC; - newTableSettingsDto.ordering_field = 'CategoryID'; newTableSettingsDto.identity_column = undefined; newTableSettingsDto.readonly_fields = ['CategoryID']; newTableSettingsDto.sortable_by = ['CategoryID', 'CategoryName']; @@ -86,11 +73,7 @@ export const TableSettingForTestConnections = { newTableSettingsDto.display_name = undefined; newTableSettingsDto.search_fields = ['ProductName']; newTableSettingsDto.excluded_fields = undefined; - newTableSettingsDto.list_fields = undefined; newTableSettingsDto.identification_fields = undefined; - newTableSettingsDto.list_per_page = 60; - newTableSettingsDto.ordering = QueryOrderingEnum.ASC; - newTableSettingsDto.ordering_field = 'Price'; newTableSettingsDto.identity_column = undefined; newTableSettingsDto.readonly_fields = undefined; newTableSettingsDto.sortable_by = ['Price', 'ProductName', 'VendorID']; @@ -108,11 +91,7 @@ export const TableSettingForTestConnections = { newTableSettingsDto.display_name = 'Created orders'; newTableSettingsDto.search_fields = ['ShippingAddress']; newTableSettingsDto.excluded_fields = undefined; - newTableSettingsDto.list_fields = undefined; newTableSettingsDto.identification_fields = undefined; - newTableSettingsDto.list_per_page = 60; - newTableSettingsDto.ordering = QueryOrderingEnum.DESC; - newTableSettingsDto.ordering_field = 'OrderDate'; newTableSettingsDto.identity_column = undefined; newTableSettingsDto.readonly_fields = undefined; newTableSettingsDto.sortable_by = ['TotalAmount', 'OrderDate', 'OrderStatus']; @@ -130,11 +109,7 @@ export const TableSettingForTestConnections = { newTableSettingsDto.display_name = 'Details of orders'; newTableSettingsDto.search_fields = ['OrderID', 'ProductID', 'Price']; newTableSettingsDto.excluded_fields = undefined; - newTableSettingsDto.list_fields = undefined; newTableSettingsDto.identification_fields = undefined; - newTableSettingsDto.list_per_page = 10; - newTableSettingsDto.ordering = QueryOrderingEnum.ASC; - newTableSettingsDto.ordering_field = 'OrderID'; newTableSettingsDto.identity_column = undefined; newTableSettingsDto.readonly_fields = undefined; newTableSettingsDto.sortable_by = ['OrderID', 'ProductID', 'Price', 'Quantity']; @@ -152,11 +127,7 @@ export const TableSettingForTestConnections = { newTableSettingsDto.display_name = 'Product reviews'; newTableSettingsDto.search_fields = ['ProductID', 'Comment']; newTableSettingsDto.excluded_fields = undefined; - newTableSettingsDto.list_fields = undefined; newTableSettingsDto.identification_fields = undefined; - newTableSettingsDto.list_per_page = 10; - newTableSettingsDto.ordering = QueryOrderingEnum.ASC; - newTableSettingsDto.ordering_field = 'Rating'; newTableSettingsDto.identity_column = undefined; newTableSettingsDto.readonly_fields = undefined; newTableSettingsDto.sortable_by = ['Rating', 'ProductID', 'UserID', 'ReviewID']; @@ -174,11 +145,7 @@ export const TableSettingForTestConnections = { newTableSettingsDto.display_name = undefined; newTableSettingsDto.search_fields = ['OrderID', 'PaymentDate']; newTableSettingsDto.excluded_fields = undefined; - newTableSettingsDto.list_fields = undefined; newTableSettingsDto.identification_fields = undefined; - newTableSettingsDto.list_per_page = 10; - newTableSettingsDto.ordering = QueryOrderingEnum.ASC; - newTableSettingsDto.ordering_field = 'PaymentDate'; newTableSettingsDto.identity_column = undefined; newTableSettingsDto.readonly_fields = undefined; newTableSettingsDto.sortable_by = ['PaymentDate', 'OrderID', 'Amount']; @@ -196,11 +163,7 @@ export const TableSettingForTestConnections = { newTableSettingsDto.display_name = 'Discounts and coupons'; newTableSettingsDto.search_fields = ['CouponID', 'CouponCode']; newTableSettingsDto.excluded_fields = undefined; - newTableSettingsDto.list_fields = undefined; newTableSettingsDto.identification_fields = undefined; - newTableSettingsDto.list_per_page = 15; - newTableSettingsDto.ordering = QueryOrderingEnum.ASC; - newTableSettingsDto.ordering_field = 'ExpiryDate'; newTableSettingsDto.identity_column = undefined; newTableSettingsDto.readonly_fields = undefined; newTableSettingsDto.sortable_by = ['ExpiryDate', 'MinimumOrderAmount', 'DiscountAmount']; @@ -218,11 +181,7 @@ export const TableSettingForTestConnections = { newTableSettingsDto.display_name = 'Shipping details'; newTableSettingsDto.search_fields = ['OrderID', 'TrackingNumber']; newTableSettingsDto.excluded_fields = undefined; - newTableSettingsDto.list_fields = undefined; newTableSettingsDto.identification_fields = undefined; - newTableSettingsDto.list_per_page = 50; - newTableSettingsDto.ordering = QueryOrderingEnum.ASC; - newTableSettingsDto.ordering_field = 'ShippingDate'; newTableSettingsDto.identity_column = undefined; newTableSettingsDto.readonly_fields = undefined; newTableSettingsDto.sortable_by = ['ShippingDate', 'EstimatedDeliveryDate']; diff --git a/backend/src/helpers/validators/table-settings-field-validator.ts b/backend/src/helpers/validators/table-settings-field-validator.ts index 8cd78b224..24d03fcd7 100644 --- a/backend/src/helpers/validators/table-settings-field-validator.ts +++ b/backend/src/helpers/validators/table-settings-field-validator.ts @@ -1,6 +1,5 @@ import { PrimaryKeyDS } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/data-structures/primary-key.ds.js'; import { CreateTableSettingsDto } from '../../entities/table-settings/common-table-settings/dto/index.js'; -import { QueryOrderingEnum } from '../../enums/index.js'; import { Messages } from '../../exceptions/text/messages.js'; import { isObjectEmpty } from '../is-object-empty.js'; @@ -16,12 +15,8 @@ export function tableSettingsFieldValidator( const { search_fields, excluded_fields, - list_fields, readonly_fields, sortable_by, - ordering_field, - ordering, - list_per_page, identification_fields, columns_view, identity_column, @@ -39,10 +34,6 @@ export function tableSettingsFieldValidator( errorMessages.push(Messages.MUST_BE_ARRAY(`excluded_fields`)); } - if (list_fields && !Array.isArray(list_fields)) { - errorMessages.push(Messages.MUST_BE_ARRAY(`list_fields`)); - } - if (identification_fields && !Array.isArray(identification_fields)) { errorMessages.push(Messages.MUST_BE_ARRAY('identification_fields')); } @@ -83,11 +74,9 @@ export function tableSettingsFieldValidator( const errors = Array.prototype.concat( excludedFields(search_fields, columnNames), excludedFields(excluded_fields, columnNames), - excludedFields(list_fields, columnNames), excludedFields(identification_fields, columnNames), excludedFields(readonly_fields, columnNames), excludedFields(sortable_by, columnNames), - excludedFields([ordering_field], columnNames), excludedFields(columns_view, columnNames), excludedFields([identity_column], columnNames), ); @@ -96,16 +85,6 @@ export function tableSettingsFieldValidator( errorMessages.push(Messages.NO_SUCH_FIELDS_IN_TABLES(errors, settings.table_name)); } - if (ordering) { - if (!Object.keys(QueryOrderingEnum).find((key) => key === ordering)) { - errorMessages.push(Messages.ORDERING_FIELD_INCORRECT); - } - } - - if ((list_per_page && list_per_page < 0) || list_per_page === 0) { - errorMessages.push(Messages.LIST_PER_PAGE_INCORRECT); - } - if (excluded_fields) { for (const field of search_fields) { const index = excluded_fields.indexOf(field); @@ -114,11 +93,6 @@ export function tableSettingsFieldValidator( } } - const orderingFieldIndex = excluded_fields.indexOf(ordering_field); - if (orderingFieldIndex >= 0) { - errorMessages.push(Messages.CANT_ORDER_AND_EXCLUDE); - } - if (readonly_fields && readonly_fields.length > 0) { for (const field of readonly_fields) { const index = excluded_fields.indexOf(field); diff --git a/backend/src/migrations/1762424200184-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts b/backend/src/migrations/1762424200184-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts new file mode 100644 index 000000000..d768a5384 --- /dev/null +++ b/backend/src/migrations/1762424200184-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts @@ -0,0 +1,41 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity1762424200184 + implements MigrationInterface +{ + name = 'AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity1762424200184'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TYPE "public"."personal_table_settings_ordering_enum" AS ENUM('ASC', 'DESC')`); + await queryRunner.query( + `CREATE TABLE "personal_table_settings" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "table_name" character varying, "ordering" "public"."personal_table_settings_ordering_enum" NOT NULL DEFAULT 'ASC', "ordering_field" character varying, "list_per_page" integer, "list_fields" character varying array NOT NULL DEFAULT '{}', "original_names" boolean NOT NULL DEFAULT false, "connection_id" character varying NOT NULL, "user_id" uuid NOT NULL, CONSTRAINT "PK_9a4d9b32ced3b0514314a5dc49d" PRIMARY KEY ("id"))`, + ); + await queryRunner.query(`ALTER TABLE "tableSettings" DROP COLUMN "list_per_page"`); + await queryRunner.query(`ALTER TABLE "tableSettings" DROP COLUMN "ordering"`); + await queryRunner.query(`DROP TYPE "public"."tableSettings_ordering_enum"`); + await queryRunner.query(`ALTER TABLE "tableSettings" DROP COLUMN "list_fields"`); + await queryRunner.query(`ALTER TABLE "tableSettings" DROP COLUMN "ordering_field"`); + await queryRunner.query( + `ALTER TABLE "personal_table_settings" ADD CONSTRAINT "FK_8a64b754616c7c8e5e0e6bc4343" FOREIGN KEY ("connection_id") REFERENCES "connection"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "personal_table_settings" ADD CONSTRAINT "FK_d9c9dcfd4a151818428a9cf8025" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "personal_table_settings" DROP CONSTRAINT "FK_d9c9dcfd4a151818428a9cf8025"`); + await queryRunner.query(`ALTER TABLE "personal_table_settings" DROP CONSTRAINT "FK_8a64b754616c7c8e5e0e6bc4343"`); + await queryRunner.query(`ALTER TABLE "tableSettings" ADD "ordering_field" character varying`); + await queryRunner.query( + `ALTER TABLE "tableSettings" ADD "list_fields" character varying array NOT NULL DEFAULT '{}'`, + ); + await queryRunner.query(`CREATE TYPE "public"."tableSettings_ordering_enum" AS ENUM('ASC', 'DESC')`); + await queryRunner.query( + `ALTER TABLE "tableSettings" ADD "ordering" "public"."tableSettings_ordering_enum" NOT NULL DEFAULT 'ASC'`, + ); + await queryRunner.query(`ALTER TABLE "tableSettings" ADD "list_per_page" integer`); + await queryRunner.query(`DROP TABLE "personal_table_settings"`); + await queryRunner.query(`DROP TYPE "public"."personal_table_settings_ordering_enum"`); + } +} diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-user-admin-permissions-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-user-admin-permissions-e2e.test.ts index 098515fa1..39eafe9a7 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-user-admin-permissions-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-user-admin-permissions-e2e.test.ts @@ -3137,14 +3137,7 @@ test.serial(`${currentTest} should return table settings when it was created`, a t.is(getTableSettingsRO.display_name, createTableSettingsDTO.display_name); t.is(JSON.stringify(getTableSettingsRO.search_fields), JSON.stringify(createTableSettingsDTO.search_fields)); t.is(JSON.stringify(getTableSettingsRO.excluded_fields), JSON.stringify(createTableSettingsDTO.excluded_fields)); - t.is( - JSON.stringify(getTableSettingsRO.list_fields), - JSON.stringify(createTableSettingsDTO.list_fields.concat(['id', 'created_at', 'updated_at'])), - ); t.is(JSON.stringify(getTableSettingsRO.identification_fields), JSON.stringify([])); - t.is(getTableSettingsRO.list_per_page, createTableSettingsDTO.list_per_page); - t.is(getTableSettingsRO.ordering, createTableSettingsDTO.ordering); - t.is(getTableSettingsRO.ordering_field, createTableSettingsDTO.ordering_field); t.is(JSON.stringify(getTableSettingsRO.readonly_fields), JSON.stringify(createTableSettingsDTO.readonly_fields)); t.is(JSON.stringify(getTableSettingsRO.sortable_by), JSON.stringify(createTableSettingsDTO.sortable_by)); t.is(JSON.stringify(getTableSettingsRO.autocomplete_columns), JSON.stringify([])); @@ -3240,11 +3233,7 @@ test.serial(`${currentTest} should return created table settings`, async (t) => t.is(createTableSettingsRO.display_name, createTableSettingsDTO.display_name); t.is(JSON.stringify(createTableSettingsRO.search_fields), JSON.stringify(createTableSettingsDTO.search_fields)); t.is(JSON.stringify(createTableSettingsRO.excluded_fields), JSON.stringify(createTableSettingsDTO.excluded_fields)); - t.is(JSON.stringify(createTableSettingsRO.list_fields), JSON.stringify(createTableSettingsDTO.list_fields)); t.is(JSON.stringify(createTableSettingsRO.identification_fields), JSON.stringify([])); - t.is(createTableSettingsRO.list_per_page, createTableSettingsDTO.list_per_page); - t.is(createTableSettingsRO.ordering, createTableSettingsDTO.ordering); - t.is(createTableSettingsRO.ordering_field, createTableSettingsDTO.ordering_field); t.is(JSON.stringify(createTableSettingsRO.readonly_fields), JSON.stringify(createTableSettingsDTO.readonly_fields)); t.is(JSON.stringify(createTableSettingsRO.sortable_by), JSON.stringify(createTableSettingsDTO.sortable_by)); t.is(JSON.stringify(createTableSettingsRO.autocomplete_columns), JSON.stringify([])); @@ -3356,11 +3345,7 @@ test.serial(`${currentTest} should return updated table settings`, async (t) => t.is(updateTableSettingsRO.display_name, updateTableSettingsDTO.display_name); t.is(JSON.stringify(updateTableSettingsRO.search_fields), JSON.stringify(updateTableSettingsDTO.search_fields)); t.is(JSON.stringify(updateTableSettingsRO.excluded_fields), JSON.stringify(updateTableSettingsDTO.excluded_fields)); - t.is(JSON.stringify(updateTableSettingsRO.list_fields), JSON.stringify(updateTableSettingsDTO.list_fields)); // t.is(JSON.stringify(updateTableSettingsRO.identification_fields)).toBe(JSON.stringify([])); - t.is(updateTableSettingsRO.list_per_page, updateTableSettingsDTO.list_per_page); - t.is(updateTableSettingsRO.ordering, updateTableSettingsDTO.ordering); - t.is(updateTableSettingsRO.ordering_field, updateTableSettingsDTO.ordering_field); t.is(JSON.stringify(updateTableSettingsRO.readonly_fields), JSON.stringify(updateTableSettingsDTO.readonly_fields)); t.is(JSON.stringify(updateTableSettingsRO.sortable_by), JSON.stringify(updateTableSettingsDTO.sortable_by)); // t.is(JSON.stringify(updateTableSettingsRO.autocomplete_columns)).toBe(JSON.stringify([])); diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-user-group-edit-permissions-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-user-group-edit-permissions-e2e.test.ts index c40b01f1e..1bbc1a56e 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-user-group-edit-permissions-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-user-group-edit-permissions-e2e.test.ts @@ -2372,11 +2372,7 @@ test.serial(`${currentTest} 'should return table settings when it was created`, t.is(getTableSettingsRO.display_name, createTableSettingsDTO.display_name); t.is(JSON.stringify(getTableSettingsRO.search_fields), JSON.stringify(createTableSettingsDTO.search_fields)); t.is(JSON.stringify(getTableSettingsRO.excluded_fields), JSON.stringify(createTableSettingsDTO.excluded_fields)); - t.is(JSON.stringify(getTableSettingsRO.list_fields), JSON.stringify(createTableSettingsDTO.list_fields.concat(['id', 'created_at', 'updated_at']))); t.is(JSON.stringify(getTableSettingsRO.identification_fields), JSON.stringify([])); - t.is(getTableSettingsRO.list_per_page, createTableSettingsDTO.list_per_page); - t.is(getTableSettingsRO.ordering, createTableSettingsDTO.ordering); - t.is(getTableSettingsRO.ordering_field, createTableSettingsDTO.ordering_field); t.is(JSON.stringify(getTableSettingsRO.readonly_fields), JSON.stringify(createTableSettingsDTO.readonly_fields)); t.is(JSON.stringify(getTableSettingsRO.sortable_by), JSON.stringify(createTableSettingsDTO.sortable_by)); t.is(JSON.stringify(getTableSettingsRO.autocomplete_columns), JSON.stringify([])); diff --git a/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts index 0e9bbeb4c..761928670 100644 --- a/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts @@ -541,6 +541,9 @@ should return all found rows with pagination page=1 perPage=2`, .set('Accept', 'application/json'); t.is(createTableSettingsResponse.status, 201); + const createTableSettingsRO = JSON.parse(createTableSettingsResponse.text); + console.log('🚀 ~ createTableSettingsRO:', createTableSettingsRO); + const getTableRowsResponse = await request(app.getHttpServer()) .get( `/table/rows/${createConnectionRO.id}?tableName=${testTableName}&search=${testSearchedUserName}&page=1&perPage=2`, @@ -548,9 +551,11 @@ should return all found rows with pagination page=1 perPage=2`, .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') .set('Accept', 'application/json'); - t.is(getTableRowsResponse.status, 200); + const getTableRowsRO = JSON.parse(getTableRowsResponse.text); + console.log('🚀 ~ getTableRowsRO:', getTableRowsRO); + t.is(getTableRowsResponse.status, 200); t.is(typeof getTableRowsRO, 'object'); t.is(getTableRowsRO.hasOwnProperty('rows'), true); t.is(getTableRowsRO.hasOwnProperty('primaryColumns'), true); @@ -653,77 +658,77 @@ should return all found rows with pagination page=1 perPage=3`, }, ); -test.serial( - `${currentTest} without search and without pagination and with sorting -should return all found rows with sorting ids by DESC`, - async (t) => { - try { - const connectionToTestDB = getTestData(mockFactory).connectionToPostgres; - const firstUserToken = (await registerUserAndReturnUserInfo(app)).token; - const { testTableName, testTableColumnName } = await createTestTable(connectionToTestDB); +test.only(`${currentTest} without search and without pagination and with sorting +should return all found rows with sorting ids by DESC`, async (t) => { + try { + const connectionToTestDB = getTestData(mockFactory).connectionToPostgres; + const firstUserToken = (await registerUserAndReturnUserInfo(app)).token; + const { testTableName, testTableColumnName } = await createTestTable(connectionToTestDB); - testTables.push(testTableName); + testTables.push(testTableName); - const createConnectionResponse = await request(app.getHttpServer()) - .post('/connection') - .send(connectionToTestDB) - .set('Cookie', firstUserToken) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - const createConnectionRO = JSON.parse(createConnectionResponse.text); - t.is(createConnectionResponse.status, 201); + const createConnectionResponse = await request(app.getHttpServer()) + .post('/connection') + .send(connectionToTestDB) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + const createConnectionRO = JSON.parse(createConnectionResponse.text); + t.is(createConnectionResponse.status, 201); - const createTableSettingsDTO = mockFactory.generateTableSettings( - createConnectionRO.id, - testTableName, - [testTableColumnName], - undefined, - undefined, - 42, - QueryOrderingEnum.DESC, - 'id', - undefined, - undefined, - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + createConnectionRO.id, + testTableName, + [testTableColumnName], + undefined, + undefined, + 42, + QueryOrderingEnum.DESC, + 'id', + undefined, + undefined, + undefined, + undefined, + undefined, + ); - const createTableSettingsResponse = await request(app.getHttpServer()) - .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) - .send(createTableSettingsDTO) - .set('Cookie', firstUserToken) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(createTableSettingsResponse.status, 201); + const createTableSettingsResponse = await request(app.getHttpServer()) + .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) + .send(createTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + t.is(createTableSettingsResponse.status, 201); - const getTableRowsResponse = await request(app.getHttpServer()) - .get(`/table/rows/${createConnectionRO.id}?tableName=${testTableName}`) - .set('Cookie', firstUserToken) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(getTableRowsResponse.status, 200); - const getTableRowsRO = JSON.parse(getTableRowsResponse.text); + const getTableRowsResponse = await request(app.getHttpServer()) + .get(`/table/rows/${createConnectionRO.id}?tableName=${testTableName}`) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); - t.is(typeof getTableRowsRO, 'object'); - t.is(getTableRowsRO.hasOwnProperty('rows'), true); - t.is(getTableRowsRO.hasOwnProperty('primaryColumns'), true); - t.is(getTableRowsRO.hasOwnProperty('pagination'), true); - t.is(getTableRowsRO.rows.length, 42); - t.is(Object.keys(getTableRowsRO.rows[1]).length, 5); - t.is(getTableRowsRO.rows[0].id, 42); - t.is(getTableRowsRO.rows[1].id, 41); - t.is(getTableRowsRO.rows[41].id, 1); + const getTableRowsRO = JSON.parse(getTableRowsResponse.text); + console.log('🚀 ~ getTableRowsRO:', getTableRowsRO); - t.is(typeof getTableRowsRO.primaryColumns, 'object'); - t.is(getTableRowsRO.primaryColumns[0].hasOwnProperty('column_name'), true); - t.is(getTableRowsRO.primaryColumns[0].hasOwnProperty('data_type'), true); - } catch (e) { - console.error(e); - throw e; - } - }, -); + t.is(getTableRowsResponse.status, 200); + + t.is(typeof getTableRowsRO, 'object'); + t.is(getTableRowsRO.hasOwnProperty('rows'), true); + t.is(getTableRowsRO.hasOwnProperty('primaryColumns'), true); + t.is(getTableRowsRO.hasOwnProperty('pagination'), true); + t.is(getTableRowsRO.rows.length, 20); + t.is(Object.keys(getTableRowsRO.rows[1]).length, 5); + t.is(getTableRowsRO.rows[0].id, 42); + t.is(getTableRowsRO.rows[1].id, 41); + t.is(getTableRowsRO.rows[41].id, 1); + + t.is(typeof getTableRowsRO.primaryColumns, 'object'); + t.is(getTableRowsRO.primaryColumns[0].hasOwnProperty('column_name'), true); + t.is(getTableRowsRO.primaryColumns[0].hasOwnProperty('data_type'), true); + } catch (e) { + console.error(e); + throw e; + } +}); test.serial( `${currentTest} without search and without pagination and with sorting diff --git a/backend/test/ava-tests/saas-tests/user-admin-permissions-e2e.test.ts b/backend/test/ava-tests/saas-tests/user-admin-permissions-e2e.test.ts index 375821f8d..1e129e83c 100644 --- a/backend/test/ava-tests/saas-tests/user-admin-permissions-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/user-admin-permissions-e2e.test.ts @@ -3134,14 +3134,7 @@ test.serial(`${currentTest} should return table settings when it was created`, a t.is(getTableSettingsRO.display_name, createTableSettingsDTO.display_name); t.is(JSON.stringify(getTableSettingsRO.search_fields), JSON.stringify(createTableSettingsDTO.search_fields)); t.is(JSON.stringify(getTableSettingsRO.excluded_fields), JSON.stringify(createTableSettingsDTO.excluded_fields)); - t.is( - JSON.stringify(getTableSettingsRO.list_fields), - JSON.stringify(createTableSettingsDTO.list_fields.concat(['id', 'created_at', 'updated_at'])), - ); t.is(JSON.stringify(getTableSettingsRO.identification_fields), JSON.stringify([])); - t.is(getTableSettingsRO.list_per_page, createTableSettingsDTO.list_per_page); - t.is(getTableSettingsRO.ordering, createTableSettingsDTO.ordering); - t.is(getTableSettingsRO.ordering_field, createTableSettingsDTO.ordering_field); t.is(JSON.stringify(getTableSettingsRO.readonly_fields), JSON.stringify(createTableSettingsDTO.readonly_fields)); t.is(JSON.stringify(getTableSettingsRO.sortable_by), JSON.stringify(createTableSettingsDTO.sortable_by)); t.is(JSON.stringify(getTableSettingsRO.autocomplete_columns), JSON.stringify([])); @@ -3237,11 +3230,7 @@ test.serial(`${currentTest} should return created table settings`, async (t) => t.is(createTableSettingsRO.display_name, createTableSettingsDTO.display_name); t.is(JSON.stringify(createTableSettingsRO.search_fields), JSON.stringify(createTableSettingsDTO.search_fields)); t.is(JSON.stringify(createTableSettingsRO.excluded_fields), JSON.stringify(createTableSettingsDTO.excluded_fields)); - t.is(JSON.stringify(createTableSettingsRO.list_fields), JSON.stringify(createTableSettingsDTO.list_fields)); t.is(JSON.stringify(createTableSettingsRO.identification_fields), JSON.stringify([])); - t.is(createTableSettingsRO.list_per_page, createTableSettingsDTO.list_per_page); - t.is(createTableSettingsRO.ordering, createTableSettingsDTO.ordering); - t.is(createTableSettingsRO.ordering_field, createTableSettingsDTO.ordering_field); t.is(JSON.stringify(createTableSettingsRO.readonly_fields), JSON.stringify(createTableSettingsDTO.readonly_fields)); t.is(JSON.stringify(createTableSettingsRO.sortable_by), JSON.stringify(createTableSettingsDTO.sortable_by)); t.is(JSON.stringify(createTableSettingsRO.autocomplete_columns), JSON.stringify([])); @@ -3353,11 +3342,6 @@ test.serial(`${currentTest} should return updated table settings`, async (t) => t.is(updateTableSettingsRO.display_name, updateTableSettingsDTO.display_name); t.is(JSON.stringify(updateTableSettingsRO.search_fields), JSON.stringify(updateTableSettingsDTO.search_fields)); t.is(JSON.stringify(updateTableSettingsRO.excluded_fields), JSON.stringify(updateTableSettingsDTO.excluded_fields)); - t.is(JSON.stringify(updateTableSettingsRO.list_fields), JSON.stringify(updateTableSettingsDTO.list_fields)); - // t.is(JSON.stringify(updateTableSettingsRO.identification_fields)).toBe(JSON.stringify([])); - t.is(updateTableSettingsRO.list_per_page, updateTableSettingsDTO.list_per_page); - t.is(updateTableSettingsRO.ordering, updateTableSettingsDTO.ordering); - t.is(updateTableSettingsRO.ordering_field, updateTableSettingsDTO.ordering_field); t.is(JSON.stringify(updateTableSettingsRO.readonly_fields), JSON.stringify(updateTableSettingsDTO.readonly_fields)); t.is(JSON.stringify(updateTableSettingsRO.sortable_by), JSON.stringify(updateTableSettingsDTO.sortable_by)); // t.is(JSON.stringify(updateTableSettingsRO.autocomplete_columns)).toBe(JSON.stringify([])); diff --git a/backend/test/ava-tests/saas-tests/user-group-edit-permissions-e2e.test.ts b/backend/test/ava-tests/saas-tests/user-group-edit-permissions-e2e.test.ts index 72f8c4dd3..77ebdcdf2 100644 --- a/backend/test/ava-tests/saas-tests/user-group-edit-permissions-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/user-group-edit-permissions-e2e.test.ts @@ -2389,11 +2389,7 @@ test.serial(`${currentTest} 'should return table settings when it was created`, t.is(getTableSettingsRO.display_name, createTableSettingsDTO.display_name); t.is(JSON.stringify(getTableSettingsRO.search_fields), JSON.stringify(createTableSettingsDTO.search_fields)); t.is(JSON.stringify(getTableSettingsRO.excluded_fields), JSON.stringify(createTableSettingsDTO.excluded_fields)); - t.is(JSON.stringify(getTableSettingsRO.list_fields), JSON.stringify(createTableSettingsDTO.list_fields.concat(['id', 'created_at', 'updated_at']))); t.is(JSON.stringify(getTableSettingsRO.identification_fields), JSON.stringify([])); - t.is(getTableSettingsRO.list_per_page, createTableSettingsDTO.list_per_page); - t.is(getTableSettingsRO.ordering, createTableSettingsDTO.ordering); - t.is(getTableSettingsRO.ordering_field, createTableSettingsDTO.ordering_field); t.is(JSON.stringify(getTableSettingsRO.readonly_fields), JSON.stringify(createTableSettingsDTO.readonly_fields)); t.is(JSON.stringify(getTableSettingsRO.sortable_by), JSON.stringify(createTableSettingsDTO.sortable_by)); t.is(JSON.stringify(getTableSettingsRO.autocomplete_columns), JSON.stringify([])); diff --git a/backend/test/mock.factory.ts b/backend/test/mock.factory.ts index 76de3d559..941250dc3 100644 --- a/backend/test/mock.factory.ts +++ b/backend/test/mock.factory.ts @@ -522,6 +522,28 @@ export class MockFactory { }; } +// { +// id: 'e82ed355-94fd-46e5-b732-c0e8f01ccc96', +// table_name: 'capitulus_xiphias_rU6K_delectatio', +// display_name: 'test display name', +// search_fields: [ 'voluptas_adulatio' ], +// excluded_fields: [], +// identification_fields: [], +// identity_column: null, +// readonly_fields: [], +// sensitive_fields: null, +// sortable_by: [], +// autocomplete_columns: [], +// columns_view: null, +// connection_id: 'k7N6nja2', +// can_add: true, +// can_delete: true, +// can_update: true, +// icon: null, +// allow_csv_export: true, +// allow_csv_import: true +// } + generateTableSettings( connectionId: string, tableName: string, @@ -546,10 +568,6 @@ export class MockFactory { display_name: 'test display name', search_fields: searchedFields, excluded_fields: excludedFields, - list_fields: listFields, - list_per_page: listPerPage, - ordering: ordering, - ordering_field: orderingField, readonly_fields: readonlyFields, sortable_by: sortableBy, autocomplete_columns: autocompleteColumns, diff --git a/shared-code/src/data-access-layer/shared/data-structures/table-settings.ds.ts b/shared-code/src/data-access-layer/shared/data-structures/table-settings.ds.ts index fc3a19147..326b1988e 100644 --- a/shared-code/src/data-access-layer/shared/data-structures/table-settings.ds.ts +++ b/shared-code/src/data-access-layer/shared/data-structures/table-settings.ds.ts @@ -2,38 +2,21 @@ import { QueryOrderingEnum } from '../enums/query-ordering.enum.js'; export class TableSettingsDS { table_name: string; - display_name: string; - search_fields: Array; - excluded_fields: Array; - list_fields: Array; - identification_fields: Array; - list_per_page: number; - ordering: QueryOrderingEnum; - ordering_field: string; - identity_column: string; - readonly_fields: Array; - sortable_by: Array; - autocomplete_columns: Array; - columns_view: Array; - can_delete: boolean; - can_update: boolean; - can_add: boolean; - sensitive_fields: Array; } diff --git a/shared-code/src/helpers/data-structures-builders/table-settings.ds.builder.ts b/shared-code/src/helpers/data-structures-builders/table-settings.ds.builder.ts new file mode 100644 index 000000000..e037f975e --- /dev/null +++ b/shared-code/src/helpers/data-structures-builders/table-settings.ds.builder.ts @@ -0,0 +1,52 @@ +import { TableSettingsDS } from '../../data-access-layer/shared/data-structures/table-settings.ds.js'; +import { QueryOrderingEnum } from '../../data-access-layer/shared/enums/query-ordering.enum.js'; + +type CommonTableSettingsInput = { + table_name: string; + display_name: string; + search_fields: string[]; + excluded_fields: string[]; + identification_fields: string[]; + identity_column: string; + readonly_fields: string[]; + sortable_by: string[]; + autocomplete_columns: string[]; + columns_view: string[]; + can_delete: boolean; + can_update: boolean; + can_add: boolean; + sensitive_fields: string[]; +}; + +type PersonalTableSettingsInput = { + ordering: QueryOrderingEnum; + ordering_field: string; + list_per_page: number; + list_fields: string[]; +}; + +export function buildDAOsTableSettingsDs( + commonTableSettings: CommonTableSettingsInput | null, + personalTableSettings: PersonalTableSettingsInput | null, +): TableSettingsDS { + return { + table_name: commonTableSettings?.table_name, + display_name: commonTableSettings?.display_name, + search_fields: commonTableSettings?.search_fields, + excluded_fields: commonTableSettings?.excluded_fields, + list_fields: personalTableSettings?.list_fields || [], + identification_fields: commonTableSettings?.identification_fields, + list_per_page: personalTableSettings?.list_per_page, + ordering: personalTableSettings?.ordering, + ordering_field: personalTableSettings?.ordering_field, + identity_column: commonTableSettings?.identity_column, + readonly_fields: commonTableSettings?.readonly_fields, + sortable_by: commonTableSettings?.sortable_by, + autocomplete_columns: commonTableSettings?.autocomplete_columns, + columns_view: commonTableSettings?.columns_view, + can_delete: commonTableSettings?.can_delete, + can_update: commonTableSettings?.can_update, + can_add: commonTableSettings?.can_add, + sensitive_fields: commonTableSettings?.sensitive_fields, + }; +} From ae88b3f45d807634dcb9e1b2d4dec8184e139820 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Fri, 7 Nov 2025 15:38:49 +0000 Subject: [PATCH 03/14] personal table settings (continue) reworked migration realized use cases realized controller added module and ds/dtos --- backend/src/app.module.ts | 2 + backend/src/common/data-injection.tokens.ts | 3 +- .../entities/demo-data/demo-data.service.ts | 17 --- .../create-table-settings.ds.ts | 3 - .../dto/create-table-settings.dto.ts | 1 - .../table-settings.controller.ts | 16 +-- .../utils/build-empty-table-settings.ts | 2 - .../utils/build-new-table-settings-entity.ts | 2 - .../create-personal-table-settings.ds.ts | 22 ++++ .../dto/create-personal-table-settings.dto.ts | 25 ++++ .../dto/found-personal-table-settings.dto.ts | 7 +- .../personal-table-settings.controller.ts | 106 ++++++++++++++-- .../personal-table-settings.entity.ts | 3 + .../personal-table-settings.module.ts | 45 +++++++ ...update-personal-table-settings.use.case.ts | 118 ++++++++++++++++++ ...delete-personal-table-settings.use.case.ts | 37 ++++++ ...onal-table-settings.use-cases.interface.ts | 17 ++- .../utils/build-found-table-settings-dto.ts | 1 + .../user/utils/build-test-table-settings.ts | 1 - .../table-setting-for-test-connections.ts | 19 --- .../table-settings-field-validator.ts | 25 +--- ...emovePropertiesFromTableSettingsEntity.ts} | 6 +- 22 files changed, 371 insertions(+), 107 deletions(-) create mode 100644 backend/src/entities/table-settings/personal-table-settings/data-structures/create-personal-table-settings.ds.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts create mode 100644 backend/src/entities/table-settings/personal-table-settings/use-cases/delete-personal-table-settings.use.case.ts rename backend/src/migrations/{1762424200184-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts => 1762528788423-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts} (89%) diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index 1215d5f00..ee16e7ab2 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -39,6 +39,7 @@ import { GetHelloUseCase } from './use-cases-app/get-hello.use.case.js'; import { ThrottlerModule, ThrottlerGuard } from '@nestjs/throttler'; import { SharedJobsModule } from './entities/shared-jobs/shared-jobs.module.js'; import { TableCategoriesModule } from './entities/table-categories/table-categories.module.js'; +import { PersonalTableSettingsModule } from './entities/table-settings/personal-table-settings/personal-table-settings.module.js'; @Module({ imports: [ @@ -81,6 +82,7 @@ import { TableCategoriesModule } from './entities/table-categories/table-categor LoggingModule, SharedJobsModule, TableCategoriesModule, + PersonalTableSettingsModule, ], controllers: [AppController], providers: [ diff --git a/backend/src/common/data-injection.tokens.ts b/backend/src/common/data-injection.tokens.ts index c2a2a0da4..4a4c8b9ae 100644 --- a/backend/src/common/data-injection.tokens.ts +++ b/backend/src/common/data-injection.tokens.ts @@ -74,8 +74,7 @@ export enum UseCaseType { DELETE_TABLE_SETTINGS = 'DELETE_TABLE_SETTINGS', FIND_PERSONAL_TABLE_SETTINGS = 'FIND_PERSONAL_TABLE_SETTINGS', - CREATE_PERSONAL_TABLE_SETTINGS = 'CREATE_PERSONAL_TABLE_SETTINGS', - UPDATE_PERSONAL_TABLE_SETTINGS = 'UPDATE_PERSONAL_TABLE_SETTINGS', + CREATE_UPDATE_PERSONAL_TABLE_SETTINGS = 'CREATE_UPDATE_PERSONAL_TABLE_SETTINGS', DELETE_PERSONAL_TABLE_SETTINGS = 'DELETE_PERSONAL_TABLE_SETTINGS', GET_HELLO = 'GET_HELLO', diff --git a/backend/src/entities/demo-data/demo-data.service.ts b/backend/src/entities/demo-data/demo-data.service.ts index 4433674d6..d299e0bb5 100644 --- a/backend/src/entities/demo-data/demo-data.service.ts +++ b/backend/src/entities/demo-data/demo-data.service.ts @@ -112,7 +112,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: ['title', 'description'], identification_fields: [], - columns_view: ['space_id', 'title', 'start_time', 'end_time', 'image_url'], identity_column: 'title', can_delete: true, can_update: true, @@ -134,7 +133,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: ['event_id', 'user_id', 'guest_name', 'guest_email'], identification_fields: [], - columns_view: [], identity_column: 'user_id', can_delete: true, can_update: true, @@ -156,7 +154,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: [], identification_fields: [], - columns_view: null, identity_column: null, can_delete: true, can_update: true, @@ -178,7 +175,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: ['name', 'address', 'city', 'country'], identification_fields: [], - columns_view: ['name', 'address', 'city', 'country'], identity_column: 'name', can_delete: true, can_update: true, @@ -200,7 +196,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: ['user_id', 'space_id'], identification_fields: [], - columns_view: ['user_id', 'space_id', 'start_date', 'end_date', 'membership_type'], identity_column: 'user_id', can_delete: true, can_update: true, @@ -222,7 +217,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: ['location_id', 'name', 'description'], identification_fields: [], - columns_view: [], identity_column: 'name', can_delete: true, can_update: true, @@ -244,7 +238,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: [], identification_fields: [], - columns_view: [], identity_column: '', can_delete: true, can_update: true, @@ -266,7 +259,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: ['name', 'email', 'phone'], identification_fields: [], - columns_view: [], identity_column: 'name', can_delete: true, can_update: true, @@ -728,7 +720,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: [], identification_fields: [], - columns_view: ['user_id', 'course_id', 'issued_at', 'certificate_url'], identity_column: 'course_id', can_delete: true, can_update: true, @@ -750,7 +741,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: [], identification_fields: [], - columns_view: null, identity_column: 'user_id', can_delete: true, can_update: true, @@ -772,7 +762,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: [], identification_fields: [], - columns_view: [], identity_column: 'title', can_delete: true, can_update: true, @@ -794,7 +783,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: [], identification_fields: [], - columns_view: [], identity_column: 'title', can_delete: true, can_update: true, @@ -816,7 +804,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: [], identification_fields: [], - columns_view: [], identity_column: 'user_id', can_delete: true, can_update: true, @@ -838,7 +825,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: [], identification_fields: [], - columns_view: null, identity_column: 'title', can_delete: true, can_update: true, @@ -860,7 +846,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: [], identification_fields: [], - columns_view: null, identity_column: 'user_id', can_delete: true, can_update: true, @@ -882,7 +867,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: ['title'], identification_fields: [], - columns_view: null, identity_column: 'title', can_delete: true, can_update: true, @@ -904,7 +888,6 @@ export class DemoDataService { sortable_by: [], autocomplete_columns: ['role', 'full_name', 'email', 'bio'], identification_fields: [], - columns_view: ['role', 'full_name', 'email', 'date_of_birth'], identity_column: 'full_name', can_delete: true, can_update: true, diff --git a/backend/src/entities/table-settings/application/data-structures/create-table-settings.ds.ts b/backend/src/entities/table-settings/application/data-structures/create-table-settings.ds.ts index 940728e69..6b1facdb6 100644 --- a/backend/src/entities/table-settings/application/data-structures/create-table-settings.ds.ts +++ b/backend/src/entities/table-settings/application/data-structures/create-table-settings.ds.ts @@ -7,9 +7,6 @@ export class CreateTableSettingsDs { @ApiProperty({ isArray: true, type: 'string' }) autocomplete_columns: Array; - @ApiProperty({ isArray: true, type: 'string', required: false }) - columns_view?: Array; - connection_id: string; @ApiProperty({ isArray: true, required: false }) diff --git a/backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts b/backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts index 267e69108..8d5d7414b 100644 --- a/backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts +++ b/backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts @@ -14,5 +14,4 @@ export class CreateTableSettingsDto { autocomplete_columns: string[]; custom_fields?: CustomFieldsEntity[]; table_widgets?: TableWidgetEntity[]; - columns_view?: string[]; } diff --git a/backend/src/entities/table-settings/common-table-settings/table-settings.controller.ts b/backend/src/entities/table-settings/common-table-settings/table-settings.controller.ts index bcf5c5b74..57b5f1de3 100644 --- a/backend/src/entities/table-settings/common-table-settings/table-settings.controller.ts +++ b/backend/src/entities/table-settings/common-table-settings/table-settings.controller.ts @@ -16,7 +16,7 @@ import { HttpException } from '@nestjs/common/exceptions/http.exception.js'; import { ApiBearerAuth, ApiBody, ApiOperation, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger'; import { UseCaseType } from '../../../common/data-injection.tokens.js'; import { MasterPassword, QueryTableName, QueryUuid, UserId } from '../../../decorators/index.js'; -import { InTransactionEnum, QueryOrderingEnum } from '../../../enums/index.js'; +import { InTransactionEnum } from '../../../enums/index.js'; import { Messages } from '../../../exceptions/text/messages.js'; import { ConnectionEditGuard, ConnectionReadGuard } from '../../../guards/index.js'; import { toPrettyErrorsMsg } from '../../../helpers/index.js'; @@ -98,21 +98,15 @@ export class TableSettingsController { async createSettings( @QueryUuid('connectionId') connectionId: string, @QueryTableName() tableName: string, - @Body('search_fields') search_fields: Array, @Body('display_name') display_name: string, @Body('excluded_fields') excluded_fields: Array, - @Body('list_fields') list_fields: Array, @Body('identification_fields') identification_fields: Array, - @Body('list_per_page') list_per_page: number, - @Body('ordering') ordering: QueryOrderingEnum, - @Body('ordering_field') ordering_field: string, @Body('readonly_fields') readonly_fields: Array, @Body('sensitive_fields') sensitive_fields: Array, @Body('sortable_by') sortable_by: Array, @Body('autocomplete_columns') autocomplete_columns: Array, @Body('customFields') customFields: Array, - @Body('columns_view') columns_view: Array, @Body('identity_column') identity_column: string, @Body('can_delete') can_delete: boolean, @Body('can_update') can_update: boolean, @@ -135,7 +129,6 @@ export class TableSettingsController { custom_fields: customFields, identification_fields: identification_fields, sensitive_fields: sensitive_fields, - columns_view: columns_view, identity_column: identity_column, masterPwd: masterPwd, userId: userId, @@ -174,21 +167,15 @@ export class TableSettingsController { async updateSettings( @QueryUuid('connectionId') connectionId: string, @QueryTableName() tableName: string, - @Body('search_fields') search_fields: Array, @Body('display_name') display_name: string, @Body('excluded_fields') excluded_fields: Array, - @Body('list_fields') list_fields: Array, @Body('identification_fields') identification_fields: Array, - @Body('list_per_page') list_per_page: number, - @Body('ordering') ordering: QueryOrderingEnum, - @Body('ordering_field') ordering_field: string, @Body('readonly_fields') readonly_fields: Array, @Body('sensitive_fields') sensitive_fields: Array, @Body('sortable_by') sortable_by: Array, @Body('autocomplete_columns') autocomplete_columns: Array, @Body('customFields') customFields: Array, - @Body('columns_view') columns_view: Array, @Body('identity_column') identity_column: string, @Body('can_delete') can_delete: boolean, @Body('can_update') can_update: boolean, @@ -201,7 +188,6 @@ export class TableSettingsController { ): Promise { const inputData: CreateTableSettingsDs = { autocomplete_columns: autocomplete_columns, - columns_view: columns_view, connection_id: connectionId, custom_fields: customFields, display_name: display_name, diff --git a/backend/src/entities/table-settings/common-table-settings/utils/build-empty-table-settings.ts b/backend/src/entities/table-settings/common-table-settings/utils/build-empty-table-settings.ts index 103b499a2..ef6576894 100644 --- a/backend/src/entities/table-settings/common-table-settings/utils/build-empty-table-settings.ts +++ b/backend/src/entities/table-settings/common-table-settings/utils/build-empty-table-settings.ts @@ -3,7 +3,6 @@ import { CreateTableSettingsDs } from '../../application/data-structures/create- export function buildEmptyTableSettings(connectionId: string, tableName: string): CreateTableSettingsDs { return { autocomplete_columns: undefined, - columns_view: undefined, connection_id: connectionId, custom_fields: undefined, display_name: undefined, @@ -35,7 +34,6 @@ export function buildEmptyTableSettingsWithEmptyWidgets( ): CreateTableSettingsDs { return { autocomplete_columns: undefined, - columns_view: undefined, connection_id: connectionId, custom_fields: undefined, display_name: undefined, diff --git a/backend/src/entities/table-settings/common-table-settings/utils/build-new-table-settings-entity.ts b/backend/src/entities/table-settings/common-table-settings/utils/build-new-table-settings-entity.ts index 622f30478..a8ea49f3f 100644 --- a/backend/src/entities/table-settings/common-table-settings/utils/build-new-table-settings-entity.ts +++ b/backend/src/entities/table-settings/common-table-settings/utils/build-new-table-settings-entity.ts @@ -9,7 +9,6 @@ export function buildNewTableSettingsEntity( const newSettings = new TableSettingsEntity(); const { autocomplete_columns, - columns_view, custom_fields, display_name, excluded_fields, @@ -41,7 +40,6 @@ export function buildNewTableSettingsEntity( newSettings.table_widgets = table_widgets; newSettings.identification_fields = identification_fields; newSettings.sensitive_fields = sensitive_fields; - newSettings.columns_view = columns_view; newSettings.identity_column = identity_column; newSettings.table_actions = table_actions; newSettings.can_add = can_add; diff --git a/backend/src/entities/table-settings/personal-table-settings/data-structures/create-personal-table-settings.ds.ts b/backend/src/entities/table-settings/personal-table-settings/data-structures/create-personal-table-settings.ds.ts new file mode 100644 index 000000000..884f5bd9e --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/data-structures/create-personal-table-settings.ds.ts @@ -0,0 +1,22 @@ +import { QueryOrderingEnum } from '../../../../enums/query-ordering.enum.js'; + +export type PersonalTableSettingsMetadata = { + connection_id: string; + table_name: string; + user_id: string; + master_password: string; +}; + +export type PersonalTableSettingsData = { + ordering: QueryOrderingEnum | null; + ordering_field: string | null; + list_per_page: number | null; + columns_view: Array | null; + list_fields: Array | null; + original_names: boolean | null; +}; + +export class CreatePersonalTableSettingsDs { + table_settings_metadata: PersonalTableSettingsMetadata; + table_settings_data: PersonalTableSettingsData; +} diff --git a/backend/src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.ts b/backend/src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.ts new file mode 100644 index 000000000..1181acd86 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.ts @@ -0,0 +1,25 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { QueryOrderingEnum } from '../../../../enums/query-ordering.enum.js'; +import { IsEnum, IsOptional } from 'class-validator'; + +export class CreatePersonalTableSettingsDto { + @ApiProperty({ enumName: 'QueryOrderingEnum', enum: QueryOrderingEnum, description: 'The ordering direction' }) + @IsOptional() + @IsEnum(QueryOrderingEnum) + ordering: QueryOrderingEnum; + + @ApiProperty({ type: String, description: 'The ordering field' }) + ordering_field: string; + + @ApiProperty({ type: Number, description: 'The number of items per page' }) + list_per_page: number; + + @ApiProperty({ isArray: true, type: String, description: 'The columns view' }) + columns_view: Array; + + @ApiProperty({ type: [String], description: 'The order of columns' }) + list_fields: Array; + + @ApiProperty({ type: Boolean, description: 'Whether to use original column names' }) + original_names: boolean; +} diff --git a/backend/src/entities/table-settings/personal-table-settings/dto/found-personal-table-settings.dto.ts b/backend/src/entities/table-settings/personal-table-settings/dto/found-personal-table-settings.dto.ts index 50914df68..5d997b68e 100644 --- a/backend/src/entities/table-settings/personal-table-settings/dto/found-personal-table-settings.dto.ts +++ b/backend/src/entities/table-settings/personal-table-settings/dto/found-personal-table-settings.dto.ts @@ -17,8 +17,11 @@ export class FoundPersonalTableSettingsDto { @ApiProperty({ type: Number, description: 'The number of items per page' }) list_per_page: number; - @ApiProperty({ type: [String], description: 'The list of fields to display in the table' }) - list_fields: string[]; + @ApiProperty({ isArray: true, type: String, description: 'The columns view' }) + columns_view: Array; + + @ApiProperty({ type: [String], description: 'The order of columns' }) + list_fields: Array; @ApiProperty({ type: Boolean, description: 'Whether to use original column names' }) original_names: boolean; diff --git a/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.controller.ts b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.controller.ts index a1c5a7c02..5d8884a45 100644 --- a/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.controller.ts +++ b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.controller.ts @@ -1,31 +1,35 @@ import { + Body, Controller, + Delete, Get, HttpException, HttpStatus, Inject, Injectable, + Put, UseGuards, UseInterceptors, } from '@nestjs/common'; -import { ApiBearerAuth, ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger'; +import { ApiBearerAuth, ApiBody, ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger'; import { SentryInterceptor } from '../../../interceptors/sentry.interceptor.js'; import { UseCaseType } from '../../../common/data-injection.tokens.js'; import { - ICreatePersonalTableSettings, + ICreateUpdatePersonalTableSettings, IDeletePersonalTableSettings, IFindPersonalTableSettings, - IUpdatePersonalTableSettings, } from './use-cases/personal-table-settings.use-cases.interface.js'; import { TableReadGuard } from '../../../guards/table-read.guard.js'; import { UserId } from '../../../decorators/user-id.decorator.js'; -import { QueryUuid } from '../../../decorators/query-uuid.decorator.js'; import { QueryTableName } from '../../../decorators/query-table-name.decorator.js'; import { MasterPassword } from '../../../decorators/master-password.decorator.js'; import { Messages } from '../../../exceptions/text/messages.js'; import { InTransactionEnum } from '../../../enums/in-transaction.enum.js'; import { FindPersonalTableSettingsDs } from './data-structures/find-personal-table-settings.ds.js'; import { FoundPersonalTableSettingsDto } from './dto/found-personal-table-settings.dto.js'; +import { SlugUuid } from '../../../decorators/slug-uuid.decorator.js'; +import { CreatePersonalTableSettingsDs } from './data-structures/create-personal-table-settings.ds.js'; +import { CreatePersonalTableSettingsDto } from './dto/create-personal-table-settings.dto.js'; @UseInterceptors(SentryInterceptor) @Controller() @@ -34,28 +38,26 @@ import { FoundPersonalTableSettingsDto } from './dto/found-personal-table-settin @Injectable() export class PersonalTableSettingsController { constructor( - @Inject(UseCaseType.FIND_TABLE_SETTINGS) + @Inject(UseCaseType.FIND_PERSONAL_TABLE_SETTINGS) private readonly findPersonalTableSettingsUseCase: IFindPersonalTableSettings, - @Inject(UseCaseType.CREATE_TABLE_SETTINGS) - private readonly createPersonalTableSettingsUseCase: ICreatePersonalTableSettings, - @Inject(UseCaseType.UPDATE_TABLE_SETTINGS) - private readonly updatePersonalTableSettingsUseCase: IUpdatePersonalTableSettings, - @Inject(UseCaseType.DELETE_TABLE_SETTINGS) + @Inject(UseCaseType.CREATE_UPDATE_PERSONAL_TABLE_SETTINGS) + private readonly createUpdatePersonalTableSettingsUseCase: ICreateUpdatePersonalTableSettings, + @Inject(UseCaseType.DELETE_PERSONAL_TABLE_SETTINGS) private readonly deletePersonalTableSettingsUseCase: IDeletePersonalTableSettings, ) {} - @ApiOperation({ summary: 'Find personal users table settings' }) + @ApiOperation({ summary: 'Find user personal table settings' }) @ApiResponse({ status: 200, description: 'Table settings found.', - // type: FoundTableSettingsDs, + type: FoundPersonalTableSettingsDto, }) @ApiParam({ name: 'connectionId', required: true }) @ApiQuery({ name: 'tableName', required: true }) @UseGuards(TableReadGuard) @Get('/settings/personal/:connectionId') async findAll( - @QueryUuid('connectionId') connectionId: string, + @SlugUuid('connectionId') connectionId: string, @QueryTableName() tableName: string, @MasterPassword() masterPwd: string, @UserId() userId: string, @@ -76,4 +78,82 @@ export class PersonalTableSettingsController { }; return await this.findPersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF); } + + @ApiOperation({ summary: 'Create or update user personal table settings' }) + @ApiResponse({ + status: 200, + description: 'Table settings crated/updated.', + type: FoundPersonalTableSettingsDto, + }) + @ApiBody({ type: CreatePersonalTableSettingsDto }) + @ApiParam({ name: 'connectionId', required: true }) + @ApiQuery({ name: 'tableName', required: true }) + @UseGuards(TableReadGuard) + @Put('/settings/personal/:connectionId') + async createOrUpdate( + @SlugUuid('connectionId') connectionId: string, + @QueryTableName() tableName: string, + @MasterPassword() masterPwd: string, + @UserId() userId: string, + @Body() personalSettingsData: CreatePersonalTableSettingsDto, + ): Promise { + if (!connectionId) { + throw new HttpException( + { + message: Messages.CONNECTION_ID_MISSING, + }, + HttpStatus.BAD_REQUEST, + ); + } + const inputData: CreatePersonalTableSettingsDs = { + table_settings_metadata: { + connection_id: connectionId, + table_name: tableName, + user_id: userId, + master_password: masterPwd, + }, + table_settings_data: { + columns_view: personalSettingsData.columns_view || null, + list_fields: personalSettingsData.list_fields || null, + list_per_page: personalSettingsData.list_per_page || null, + ordering: personalSettingsData.ordering || null, + ordering_field: personalSettingsData.ordering_field || null, + original_names: personalSettingsData.original_names || null, + }, + }; + return await this.createUpdatePersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF); + } + + @ApiOperation({ summary: 'Clear user personal table settings' }) + @ApiResponse({ + status: 200, + description: 'Table settings removed.', + type: FoundPersonalTableSettingsDto, + }) + @ApiParam({ name: 'connectionId', required: true }) + @ApiQuery({ name: 'tableName', required: true }) + @UseGuards(TableReadGuard) + @Delete('/settings/personal/:connectionId') + async clearTableSettings( + @SlugUuid('connectionId') connectionId: string, + @QueryTableName() tableName: string, + @MasterPassword() masterPwd: string, + @UserId() userId: string, + ): Promise { + if (!connectionId) { + throw new HttpException( + { + message: Messages.CONNECTION_ID_MISSING, + }, + HttpStatus.BAD_REQUEST, + ); + } + const inputData: FindPersonalTableSettingsDs = { + connectionId, + tableName, + userId, + masterPassword: masterPwd, + }; + return await this.deletePersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF); + } } diff --git a/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.entity.ts b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.entity.ts index df3616639..18a724ac6 100644 --- a/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.entity.ts +++ b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.entity.ts @@ -27,6 +27,9 @@ export class PersonalTableSettingsEntity { @Column('varchar', { array: true, default: {} }) list_fields: string[]; + @Column({ type: 'varchar', array: true, default: {} }) + columns_view: Array; + @Column('boolean', { default: false }) original_names: boolean; diff --git a/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.module.ts b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.module.ts index e69de29bb..4ee488227 100644 --- a/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.module.ts +++ b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.module.ts @@ -0,0 +1,45 @@ +import { MiddlewareConsumer, Module, RequestMethod } from '@nestjs/common'; +import { GlobalDatabaseContext } from '../../../common/application/global-database-context.js'; +import { BaseType, UseCaseType } from '../../../common/data-injection.tokens.js'; +import { FindPersonalTableSettingsUseCase } from './use-cases/find-personal-table-settings.use.case.js'; +import { CreateUpdatePersonalTableSettingsUseCase } from './use-cases/create-update-personal-table-settings.use.case.js'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { PersonalTableSettingsController } from './personal-table-settings.controller.js'; +import { AuthMiddleware } from '../../../authorization/auth.middleware.js'; +import { UserEntity } from '../../user/user.entity.js'; +import { LogOutEntity } from '../../log-out/log-out.entity.js'; + +@Module({ + imports: [TypeOrmModule.forFeature([UserEntity, LogOutEntity])], + providers: [ + { + provide: BaseType.GLOBAL_DB_CONTEXT, + useClass: GlobalDatabaseContext, + }, + { + provide: UseCaseType.FIND_PERSONAL_TABLE_SETTINGS, + useClass: FindPersonalTableSettingsUseCase, + }, + { + provide: UseCaseType.CREATE_UPDATE_PERSONAL_TABLE_SETTINGS, + useClass: CreateUpdatePersonalTableSettingsUseCase, + }, + { + provide: UseCaseType.DELETE_PERSONAL_TABLE_SETTINGS, + useClass: CreateUpdatePersonalTableSettingsUseCase, + }, + ], + controllers: [PersonalTableSettingsController], + exports: [], +}) +export class PersonalTableSettingsModule { + public configure(consumer: MiddlewareConsumer): any { + consumer + .apply(AuthMiddleware) + .forRoutes( + { path: '/settings/personal/:connectionId', method: RequestMethod.GET }, + { path: '/settings/personal/:connectionId', method: RequestMethod.PUT }, + { path: '/settings/personal/:connectionId', method: RequestMethod.DELETE }, + ); + } +} diff --git a/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts b/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts new file mode 100644 index 000000000..8cf67519d --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts @@ -0,0 +1,118 @@ +import { BadRequestException, Inject, Injectable, Scope } from '@nestjs/common'; +import { IGlobalDatabaseContext } from '../../../../common/application/global-database-context.interface.js'; +import { BaseType } from '../../../../common/data-injection.tokens.js'; +import AbstractUseCase from '../../../../common/abstract-use.case.js'; +import { FoundPersonalTableSettingsDto } from '../dto/found-personal-table-settings.dto.js'; +import { + CreatePersonalTableSettingsDs, + PersonalTableSettingsData, +} from '../data-structures/create-personal-table-settings.ds.js'; +import { ICreateUpdatePersonalTableSettings } from './personal-table-settings.use-cases.interface.js'; +import { ConnectionEntity } from '../../../connection/connection.entity.js'; +import { getDataAccessObject } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/create-data-access-object.js'; + +@Injectable({ scope: Scope.REQUEST }) +export class CreateUpdatePersonalTableSettingsUseCase + extends AbstractUseCase + implements ICreateUpdatePersonalTableSettings +{ + constructor( + @Inject(BaseType.GLOBAL_DB_CONTEXT) + protected _dbContext: IGlobalDatabaseContext, + ) { + super(); + } + + public async implementation( + personalTableSettingsData: CreatePersonalTableSettingsDs, + ): Promise { + const { + table_settings_metadata: { connection_id, master_password, table_name, user_id }, + table_settings_data, + } = personalTableSettingsData; + + const foundConnection = await this._dbContext.connectionRepository.findAndDecryptConnection( + connection_id, + master_password, + ); + + await this.validatePersonalTableSettingsData(table_settings_data, foundConnection, table_name); + + const foundTableSettings = await this._dbContext.personalTableSettingsRepository.findUserTableSettings( + connection_id, + table_name, + user_id, + ); + + const settings = + foundTableSettings || + this._dbContext.personalTableSettingsRepository.create({ + connection_id, + table_name, + user_id, + }); + + Object.assign(settings, table_settings_data); + return await this._dbContext.personalTableSettingsRepository.save(settings); + } + + private async validatePersonalTableSettingsData( + settingsData: PersonalTableSettingsData, + connection: ConnectionEntity, + tableName: string, + ): Promise { + const { columns_view, list_fields, list_per_page, ordering, ordering_field, original_names } = settingsData; + const dao = getDataAccessObject(connection); + const tableStructure = await dao.getTableStructure(tableName, null); + const tableColumnNames = tableStructure.map((col) => col.column_name); + const errors = []; + + if (columns_view !== null && columns_view !== undefined) { + const invalidColumns = columns_view.filter((col) => !tableColumnNames.includes(col)); + if (invalidColumns.length > 0) { + errors.push(`Invalid columns in columns_view: ${invalidColumns.join(', ')}`); + } + } + + if (list_fields !== null && list_fields !== undefined) { + const invalidFields = list_fields.filter((field) => !tableColumnNames.includes(field)); + if (invalidFields.length > 0) { + errors.push(`Invalid columns in list_fields: ${invalidFields.join(', ')}`); + } + } + + if (list_per_page !== null && list_per_page !== undefined) { + if (typeof list_per_page !== 'number' || list_per_page < 1 || list_per_page > 1000) { + errors.push('list_per_page must be a number between 1 and 1000'); + } + } + + if (ordering !== null && ordering !== undefined) { + const validOrderings = ['ASC', 'DESC']; + if (!validOrderings.includes(ordering)) { + errors.push(`ordering must be one of: ${validOrderings.join(', ')}`); + } + } + + if (ordering_field !== null && ordering_field !== undefined) { + if (!tableColumnNames.includes(ordering_field)) { + errors.push(`Invalid ordering_field: ${ordering_field}`); + } + } + + if (original_names !== null && original_names !== undefined) { + if (typeof original_names !== 'object' || Array.isArray(original_names)) { + errors.push('original_names must be an object'); + } else { + const invalidKeys = Object.keys(original_names).filter((key) => !tableColumnNames.includes(key)); + if (invalidKeys.length > 0) { + errors.push(`Invalid columns in original_names: ${invalidKeys.join(', ')}`); + } + } + } + + if (errors.length > 0) { + throw new BadRequestException(`Validation failed: ${errors.join('; ')}`); + } + } +} diff --git a/backend/src/entities/table-settings/personal-table-settings/use-cases/delete-personal-table-settings.use.case.ts b/backend/src/entities/table-settings/personal-table-settings/use-cases/delete-personal-table-settings.use.case.ts new file mode 100644 index 000000000..0359f812d --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/use-cases/delete-personal-table-settings.use.case.ts @@ -0,0 +1,37 @@ +import { Inject, Injectable, Scope } from '@nestjs/common'; +import AbstractUseCase from '../../../../common/abstract-use.case.js'; +import { FindPersonalTableSettingsDs } from '../data-structures/find-personal-table-settings.ds.js'; +import { FoundPersonalTableSettingsDto } from '../dto/found-personal-table-settings.dto.js'; +import { IDeletePersonalTableSettings } from './personal-table-settings.use-cases.interface.js'; +import { BaseType } from '../../../../common/data-injection.tokens.js'; +import { IGlobalDatabaseContext } from '../../../../common/application/global-database-context.interface.js'; +import { buildFoundTableSettingsDto } from '../utils/build-found-table-settings-dto.js'; + +@Injectable({ scope: Scope.REQUEST }) +export class DeletePersonalTableSettingsUseCase + extends AbstractUseCase + implements IDeletePersonalTableSettings +{ + constructor( + @Inject(BaseType.GLOBAL_DB_CONTEXT) + protected _dbContext: IGlobalDatabaseContext, + ) { + super(); + } + + public async implementation(inputData: FindPersonalTableSettingsDs): Promise { + const { connectionId, userId, tableName } = inputData; + + const foundPersonalTableSettings = await this._dbContext.personalTableSettingsRepository.findUserTableSettings( + connectionId, + tableName, + userId, + ); + + if (foundPersonalTableSettings) { + await this._dbContext.personalTableSettingsRepository.remove(foundPersonalTableSettings); + } + + return buildFoundTableSettingsDto(foundPersonalTableSettings); + } +} diff --git a/backend/src/entities/table-settings/personal-table-settings/use-cases/personal-table-settings.use-cases.interface.ts b/backend/src/entities/table-settings/personal-table-settings/use-cases/personal-table-settings.use-cases.interface.ts index a552fb183..fb1e6310a 100644 --- a/backend/src/entities/table-settings/personal-table-settings/use-cases/personal-table-settings.use-cases.interface.ts +++ b/backend/src/entities/table-settings/personal-table-settings/use-cases/personal-table-settings.use-cases.interface.ts @@ -1,4 +1,5 @@ import { InTransactionEnum } from '../../../../enums/in-transaction.enum.js'; +import { CreatePersonalTableSettingsDs } from '../data-structures/create-personal-table-settings.ds.js'; import { FindPersonalTableSettingsDs } from '../data-structures/find-personal-table-settings.ds.js'; import { FoundPersonalTableSettingsDto } from '../dto/found-personal-table-settings.dto.js'; @@ -9,8 +10,16 @@ export interface IFindPersonalTableSettings { ): Promise; } -export interface ICreatePersonalTableSettings {} - -export interface IUpdatePersonalTableSettings {} +export interface ICreateUpdatePersonalTableSettings { + execute( + inputData: CreatePersonalTableSettingsDs, + inTransaction: InTransactionEnum, + ): Promise; +} -export interface IDeletePersonalTableSettings {} +export interface IDeletePersonalTableSettings { + execute( + inputData: FindPersonalTableSettingsDs, + inTransaction: InTransactionEnum, + ): Promise; +} diff --git a/backend/src/entities/table-settings/personal-table-settings/utils/build-found-table-settings-dto.ts b/backend/src/entities/table-settings/personal-table-settings/utils/build-found-table-settings-dto.ts index 0dc083572..f1337b397 100644 --- a/backend/src/entities/table-settings/personal-table-settings/utils/build-found-table-settings-dto.ts +++ b/backend/src/entities/table-settings/personal-table-settings/utils/build-found-table-settings-dto.ts @@ -12,5 +12,6 @@ export function buildFoundTableSettingsDto( list_per_page: personalTableSettings.list_per_page, list_fields: personalTableSettings.list_fields, original_names: personalTableSettings.original_names, + columns_view: personalTableSettings.columns_view, }; } diff --git a/backend/src/entities/user/utils/build-test-table-settings.ts b/backend/src/entities/user/utils/build-test-table-settings.ts index 78d3e6ada..09bc3cd44 100644 --- a/backend/src/entities/user/utils/build-test-table-settings.ts +++ b/backend/src/entities/user/utils/build-test-table-settings.ts @@ -55,7 +55,6 @@ function tableSettingsDtosToTableSettingsEntity( newSettings.custom_fields = tableSetting.custom_fields; newSettings.table_widgets = tableSetting.table_widgets; newSettings.identification_fields = tableSetting.identification_fields; - newSettings.columns_view = tableSetting.columns_view; newSettings.identity_column = tableSetting.identity_column; tableSettingsEntities.push(newSettings); } diff --git a/backend/src/helpers/constants/table-setting-for-test-connections.ts b/backend/src/helpers/constants/table-setting-for-test-connections.ts index 27bebeb69..c605c7795 100644 --- a/backend/src/helpers/constants/table-setting-for-test-connections.ts +++ b/backend/src/helpers/constants/table-setting-for-test-connections.ts @@ -17,16 +17,6 @@ export const TableSettingForTestConnections = { newTableSettingsDto.autocomplete_columns = ['FirstName', 'LastName']; newTableSettingsDto.custom_fields = undefined; newTableSettingsDto.table_widgets = undefined; - newTableSettingsDto.columns_view = [ - 'Email', - 'FirstName', - 'LastName', - 'DateRegistered', - 'LastLoginDate', - 'ProfileImage', - 'Role', - 'UserID', - ]; return newTableSettingsDto; }, @@ -44,7 +34,6 @@ export const TableSettingForTestConnections = { newTableSettingsDto.autocomplete_columns = ['VendorName']; newTableSettingsDto.custom_fields = undefined; newTableSettingsDto.table_widgets = undefined; - newTableSettingsDto.columns_view = undefined; return newTableSettingsDto; }, @@ -62,7 +51,6 @@ export const TableSettingForTestConnections = { newTableSettingsDto.autocomplete_columns = undefined; newTableSettingsDto.custom_fields = undefined; newTableSettingsDto.table_widgets = undefined; - newTableSettingsDto.columns_view = undefined; return newTableSettingsDto; }, @@ -80,7 +68,6 @@ export const TableSettingForTestConnections = { newTableSettingsDto.autocomplete_columns = undefined; newTableSettingsDto.custom_fields = undefined; newTableSettingsDto.table_widgets = undefined; - newTableSettingsDto.columns_view = undefined; return newTableSettingsDto; }, @@ -98,7 +85,6 @@ export const TableSettingForTestConnections = { newTableSettingsDto.autocomplete_columns = undefined; newTableSettingsDto.custom_fields = undefined; newTableSettingsDto.table_widgets = undefined; - newTableSettingsDto.columns_view = undefined; return newTableSettingsDto; }, @@ -116,7 +102,6 @@ export const TableSettingForTestConnections = { newTableSettingsDto.autocomplete_columns = undefined; newTableSettingsDto.custom_fields = undefined; newTableSettingsDto.table_widgets = undefined; - newTableSettingsDto.columns_view = undefined; return newTableSettingsDto; }, @@ -134,7 +119,6 @@ export const TableSettingForTestConnections = { newTableSettingsDto.autocomplete_columns = undefined; newTableSettingsDto.custom_fields = undefined; newTableSettingsDto.table_widgets = undefined; - newTableSettingsDto.columns_view = undefined; return newTableSettingsDto; }, @@ -152,7 +136,6 @@ export const TableSettingForTestConnections = { newTableSettingsDto.autocomplete_columns = undefined; newTableSettingsDto.custom_fields = undefined; newTableSettingsDto.table_widgets = undefined; - newTableSettingsDto.columns_view = undefined; return newTableSettingsDto; }, @@ -170,7 +153,6 @@ export const TableSettingForTestConnections = { newTableSettingsDto.autocomplete_columns = undefined; newTableSettingsDto.custom_fields = undefined; newTableSettingsDto.table_widgets = undefined; - newTableSettingsDto.columns_view = undefined; return newTableSettingsDto; }, @@ -188,7 +170,6 @@ export const TableSettingForTestConnections = { newTableSettingsDto.autocomplete_columns = undefined; newTableSettingsDto.custom_fields = undefined; newTableSettingsDto.table_widgets = undefined; - newTableSettingsDto.columns_view = undefined; return newTableSettingsDto; }, diff --git a/backend/src/helpers/validators/table-settings-field-validator.ts b/backend/src/helpers/validators/table-settings-field-validator.ts index 24d03fcd7..c0f753303 100644 --- a/backend/src/helpers/validators/table-settings-field-validator.ts +++ b/backend/src/helpers/validators/table-settings-field-validator.ts @@ -12,15 +12,8 @@ export function tableSettingsFieldValidator( if (isObjectEmpty(settings)) { return errorMessages; } - const { - search_fields, - excluded_fields, - readonly_fields, - sortable_by, - identification_fields, - columns_view, - identity_column, - } = settings; + const { search_fields, excluded_fields, readonly_fields, sortable_by, identification_fields, identity_column } = + settings; const columnNames = tableStructure.map((column) => { return column.column_name; @@ -46,10 +39,6 @@ export function tableSettingsFieldValidator( errorMessages.push(Messages.MUST_BE_ARRAY(`sortable_by`)); } - if (columns_view && !Array.isArray(columns_view)) { - errorMessages.push(Messages.MUST_BE_ARRAY(`columns_view`)); - } - if (errorMessages.length > 0) { return errorMessages; } @@ -77,7 +66,6 @@ export function tableSettingsFieldValidator( excludedFields(identification_fields, columnNames), excludedFields(readonly_fields, columnNames), excludedFields(sortable_by, columnNames), - excludedFields(columns_view, columnNames), excludedFields([identity_column], columnNames), ); @@ -102,15 +90,6 @@ export function tableSettingsFieldValidator( } } - if (columns_view && columns_view.length > 0) { - for (const field of columns_view) { - const index = excluded_fields.indexOf(field); - if (index >= 0) { - errorMessages.push(Messages.CANT_VIEW_AND_EXCLUDE(field)); - } - } - } - if (primaryColumns && primaryColumns.length > 0) { for (const column of primaryColumns) { const index = excluded_fields.indexOf(column.column_name); diff --git a/backend/src/migrations/1762424200184-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts b/backend/src/migrations/1762528788423-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts similarity index 89% rename from backend/src/migrations/1762424200184-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts rename to backend/src/migrations/1762528788423-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts index d768a5384..b1cbab031 100644 --- a/backend/src/migrations/1762424200184-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts +++ b/backend/src/migrations/1762528788423-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts @@ -1,14 +1,14 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -export class AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity1762424200184 +export class AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity1762528788423 implements MigrationInterface { - name = 'AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity1762424200184'; + name = 'AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity1762528788423'; public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TYPE "public"."personal_table_settings_ordering_enum" AS ENUM('ASC', 'DESC')`); await queryRunner.query( - `CREATE TABLE "personal_table_settings" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "table_name" character varying, "ordering" "public"."personal_table_settings_ordering_enum" NOT NULL DEFAULT 'ASC', "ordering_field" character varying, "list_per_page" integer, "list_fields" character varying array NOT NULL DEFAULT '{}', "original_names" boolean NOT NULL DEFAULT false, "connection_id" character varying NOT NULL, "user_id" uuid NOT NULL, CONSTRAINT "PK_9a4d9b32ced3b0514314a5dc49d" PRIMARY KEY ("id"))`, + `CREATE TABLE "personal_table_settings" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "table_name" character varying, "ordering" "public"."personal_table_settings_ordering_enum" NOT NULL DEFAULT 'ASC', "ordering_field" character varying, "list_per_page" integer, "list_fields" character varying array NOT NULL DEFAULT '{}', "columns_view" character varying array NOT NULL DEFAULT '{}', "original_names" boolean NOT NULL DEFAULT false, "connection_id" character varying NOT NULL, "user_id" uuid NOT NULL, CONSTRAINT "PK_9a4d9b32ced3b0514314a5dc49d" PRIMARY KEY ("id"))`, ); await queryRunner.query(`ALTER TABLE "tableSettings" DROP COLUMN "list_per_page"`); await queryRunner.query(`ALTER TABLE "tableSettings" DROP COLUMN "ordering"`); From f47fb4015dbde7c84c60aad9e41adec810aec7c7 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Fri, 7 Nov 2025 15:58:10 +0000 Subject: [PATCH 04/14] refactor: update FindPersonalTableSettingsUseCase to return empty object when settings not found; --- .../use-cases/find-personal-table-settings.use.case.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts b/backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts index 9df6416f1..217685142 100644 --- a/backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts +++ b/backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts @@ -39,7 +39,7 @@ export class FindPersonalTableSettingsUseCase ); if (!foundPersonalTableSettings) { - throw new NotFoundException(Messages.PERSONAL_TABLE_SETTINGS_NOT_FOUND); + return {} as FoundPersonalTableSettingsDto; } return buildFoundTableSettingsDto(foundPersonalTableSettings); From c9124a72aa7df716a1175503ae0503b32cbf70e4 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Mon, 10 Nov 2025 12:49:49 +0000 Subject: [PATCH 05/14] refactor: improve personal table settings use cases and add utility for entity creation added tests --- ...update-personal-table-settings.use.case.ts | 26 +- .../find-personal-table-settings.use.case.ts | 8 +- ...new-personal-table-settings-entity.util.ts | 16 ++ .../table-settings-personal-e2e.test.ts | 226 ++++++++++++++++++ 4 files changed, 258 insertions(+), 18 deletions(-) create mode 100644 backend/src/entities/table-settings/personal-table-settings/utils/build-new-personal-table-settings-entity.util.ts create mode 100644 backend/test/ava-tests/saas-tests/table-settings-personal-e2e.test.ts diff --git a/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts b/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts index 8cf67519d..0296ad381 100644 --- a/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts +++ b/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts @@ -1,15 +1,16 @@ import { BadRequestException, Inject, Injectable, Scope } from '@nestjs/common'; +import { getDataAccessObject } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/create-data-access-object.js'; +import AbstractUseCase from '../../../../common/abstract-use.case.js'; import { IGlobalDatabaseContext } from '../../../../common/application/global-database-context.interface.js'; import { BaseType } from '../../../../common/data-injection.tokens.js'; -import AbstractUseCase from '../../../../common/abstract-use.case.js'; -import { FoundPersonalTableSettingsDto } from '../dto/found-personal-table-settings.dto.js'; +import { ConnectionEntity } from '../../../connection/connection.entity.js'; import { CreatePersonalTableSettingsDs, PersonalTableSettingsData, } from '../data-structures/create-personal-table-settings.ds.js'; +import { FoundPersonalTableSettingsDto } from '../dto/found-personal-table-settings.dto.js'; +import { buildNewPersonalTableSettingsEntity } from '../utils/build-new-personal-table-settings-entity.util.js'; import { ICreateUpdatePersonalTableSettings } from './personal-table-settings.use-cases.interface.js'; -import { ConnectionEntity } from '../../../connection/connection.entity.js'; -import { getDataAccessObject } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/create-data-access-object.js'; @Injectable({ scope: Scope.REQUEST }) export class CreateUpdatePersonalTableSettingsUseCase @@ -39,20 +40,17 @@ export class CreateUpdatePersonalTableSettingsUseCase await this.validatePersonalTableSettingsData(table_settings_data, foundConnection, table_name); const foundTableSettings = await this._dbContext.personalTableSettingsRepository.findUserTableSettings( + user_id, connection_id, table_name, - user_id, ); - const settings = - foundTableSettings || - this._dbContext.personalTableSettingsRepository.create({ - connection_id, - table_name, - user_id, - }); - - Object.assign(settings, table_settings_data); + const settings = foundTableSettings || {}; + const newSettingsEntity = buildNewPersonalTableSettingsEntity(table_settings_data); + newSettingsEntity.connection_id = foundConnection.id; + newSettingsEntity.table_name = table_name; + newSettingsEntity.user_id = user_id; + Object.assign(settings, newSettingsEntity); return await this._dbContext.personalTableSettingsRepository.save(settings); } diff --git a/backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts b/backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts index 217685142..d789656f8 100644 --- a/backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts +++ b/backend/src/entities/table-settings/personal-table-settings/use-cases/find-personal-table-settings.use.case.ts @@ -1,12 +1,12 @@ import { Inject, Injectable, NotFoundException } from '@nestjs/common'; import AbstractUseCase from '../../../../common/abstract-use.case.js'; -import { FoundPersonalTableSettingsDto } from '../dto/found-personal-table-settings.dto.js'; -import { FindPersonalTableSettingsDs } from '../data-structures/find-personal-table-settings.ds.js'; -import { IFindPersonalTableSettings } from './personal-table-settings.use-cases.interface.js'; import { IGlobalDatabaseContext } from '../../../../common/application/global-database-context.interface.js'; import { BaseType } from '../../../../common/data-injection.tokens.js'; import { Messages } from '../../../../exceptions/text/messages.js'; +import { FindPersonalTableSettingsDs } from '../data-structures/find-personal-table-settings.ds.js'; +import { FoundPersonalTableSettingsDto } from '../dto/found-personal-table-settings.dto.js'; import { buildFoundTableSettingsDto } from '../utils/build-found-table-settings-dto.js'; +import { IFindPersonalTableSettings } from './personal-table-settings.use-cases.interface.js'; @Injectable() export class FindPersonalTableSettingsUseCase @@ -33,9 +33,9 @@ export class FindPersonalTableSettingsUseCase } const foundPersonalTableSettings = await this._dbContext.personalTableSettingsRepository.findUserTableSettings( + userId, connectionId, tableName, - userId, ); if (!foundPersonalTableSettings) { diff --git a/backend/src/entities/table-settings/personal-table-settings/utils/build-new-personal-table-settings-entity.util.ts b/backend/src/entities/table-settings/personal-table-settings/utils/build-new-personal-table-settings-entity.util.ts new file mode 100644 index 000000000..16d626211 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/utils/build-new-personal-table-settings-entity.util.ts @@ -0,0 +1,16 @@ +import { PersonalTableSettingsData } from '../data-structures/create-personal-table-settings.ds.js'; +import { PersonalTableSettingsEntity } from '../personal-table-settings.entity.js'; + +export function buildNewPersonalTableSettingsEntity( + personalSettingsData: PersonalTableSettingsData, +): PersonalTableSettingsEntity { + const newEntity = new PersonalTableSettingsEntity(); + Object.assign(newEntity, personalSettingsData); + Object.keys(personalSettingsData).forEach((key) => { + if (personalSettingsData[key as keyof PersonalTableSettingsData] === null) { + // eslint-disable-next-line security/detect-object-injection + delete (newEntity as any)[key]; + } + }); + return newEntity; +} diff --git a/backend/test/ava-tests/saas-tests/table-settings-personal-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-settings-personal-e2e.test.ts new file mode 100644 index 000000000..d07404ad8 --- /dev/null +++ b/backend/test/ava-tests/saas-tests/table-settings-personal-e2e.test.ts @@ -0,0 +1,226 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { faker } from '@faker-js/faker'; +import { INestApplication, ValidationPipe } from '@nestjs/common'; +import { Test } from '@nestjs/testing'; +import test from 'ava'; +import cookieParser from 'cookie-parser'; +import request from 'supertest'; +import { ApplicationModule } from '../../../src/app.module.js'; +import { QueryOrderingEnum } from '../../../src/enums/index.js'; +import { AllExceptionsFilter } from '../../../src/exceptions/all-exceptions.filter.js'; +import { Messages } from '../../../src/exceptions/text/messages.js'; +import { Cacher } from '../../../src/helpers/cache/cacher.js'; +import { DatabaseModule } from '../../../src/shared/database/database.module.js'; +import { DatabaseService } from '../../../src/shared/database/database.service.js'; +import { MockFactory } from '../../mock.factory.js'; +import { getTestData } from '../../utils/get-test-data.js'; +import { registerUserAndReturnUserInfo } from '../../utils/register-user-and-return-user-info.js'; +import { TestUtils } from '../../utils/test.utils.js'; +import { ValidationException } from '../../../src/exceptions/custom-exceptions/validation-exception.js'; +import { ValidationError } from 'class-validator'; +import { WinstonLogger } from '../../../src/entities/logging/winston-logger.js'; +import { createTestTable } from '../../utils/create-test-table.js'; +import { CreatePersonalTableSettingsDto } from '../../../src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.js'; +import { FoundPersonalTableSettingsDto } from '../../../src/entities/table-settings/personal-table-settings/dto/found-personal-table-settings.dto.js'; + +const mockFactory = new MockFactory(); +let app: INestApplication; +let testUtils: TestUtils; +let currentTest; + +test.before(async () => { + const moduleFixture = await Test.createTestingModule({ + imports: [ApplicationModule, DatabaseModule], + providers: [DatabaseService, TestUtils], + }).compile(); + app = moduleFixture.createNestApplication(); + testUtils = moduleFixture.get(TestUtils); + + app.use(cookieParser()); + app.useGlobalFilters(new AllExceptionsFilter(app.get(WinstonLogger))); + app.useGlobalPipes( + new ValidationPipe({ + exceptionFactory(validationErrors: ValidationError[] = []) { + return new ValidationException(validationErrors); + }, + }), + ); + await app.init(); + app.getHttpServer().listen(0); +}); + +test.after(async () => { + try { + await Cacher.clearAllCache(); + await app.close(); + } catch (e) { + console.error('After tests error ' + e); + } +}); + +currentTest = 'PUT /settings/personal/:connectionId'; + +test.serial(`${currentTest} should return created personal table settings`, async (t) => { + const connectionToTestDB = getTestData(mockFactory).connectionToPostgres; + const firstUserToken = (await registerUserAndReturnUserInfo(app)).token; + const { testTableName, testTableColumnName, testTableSecondColumnName } = await createTestTable(connectionToTestDB); + + const createConnectionResponse = await request(app.getHttpServer()) + .post('/connection') + .send(connectionToTestDB) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + const createConnectionRO = JSON.parse(createConnectionResponse.text); + t.is(createConnectionResponse.status, 201); + + const createPersonalTableSettingsDTO: CreatePersonalTableSettingsDto = { + columns_view: [testTableColumnName, testTableSecondColumnName, 'id'], + list_fields: [testTableSecondColumnName, testTableColumnName, 'id'], + list_per_page: 32, + ordering: QueryOrderingEnum.ASC, + ordering_field: testTableColumnName, + original_names: false, + }; + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + const createPersonalTableSettingsRO: FoundPersonalTableSettingsDto = JSON.parse( + createPersonalTableSettingsResponse.text, + ); + t.is(createPersonalTableSettingsResponse.status, 200); + t.deepEqual(createPersonalTableSettingsRO.columns_view, createPersonalTableSettingsDTO.columns_view); + t.deepEqual(createPersonalTableSettingsRO.list_fields, createPersonalTableSettingsDTO.list_fields); + t.is(createPersonalTableSettingsRO.list_per_page, createPersonalTableSettingsDTO.list_per_page); + t.is(createPersonalTableSettingsRO.ordering, createPersonalTableSettingsDTO.ordering); + t.is(createPersonalTableSettingsRO.ordering_field, createPersonalTableSettingsDTO.ordering_field); + t.is(createPersonalTableSettingsRO.original_names, createPersonalTableSettingsDTO.original_names); + + // should update found personal table settings + const updatedPersonalTableSettingsDTO = { + list_per_page: 52, + ordering: QueryOrderingEnum.DESC, + }; + const updatePersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(updatedPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + const updatePersonalTableSettingsRO: FoundPersonalTableSettingsDto = JSON.parse( + updatePersonalTableSettingsResponse.text, + ); + t.is(updatePersonalTableSettingsResponse.status, 200); + t.deepEqual(updatePersonalTableSettingsRO.columns_view, createPersonalTableSettingsDTO.columns_view); + t.deepEqual(updatePersonalTableSettingsRO.list_fields, createPersonalTableSettingsDTO.list_fields); + t.is(updatePersonalTableSettingsRO.list_per_page, updatedPersonalTableSettingsDTO.list_per_page); + t.is(updatePersonalTableSettingsRO.ordering, updatedPersonalTableSettingsDTO.ordering); + t.is(updatePersonalTableSettingsRO.ordering_field, createPersonalTableSettingsDTO.ordering_field); + t.is(updatePersonalTableSettingsRO.original_names, createPersonalTableSettingsDTO.original_names); +}); + +currentTest = 'GET /settings/personal/:connectionId'; + +test.serial(`${currentTest} should return found personal table settings`, async (t) => { + const connectionToTestDB = getTestData(mockFactory).connectionToPostgres; + const firstUserToken = (await registerUserAndReturnUserInfo(app)).token; + const { testTableName, testTableColumnName, testTableSecondColumnName } = await createTestTable(connectionToTestDB); + + const createConnectionResponse = await request(app.getHttpServer()) + .post('/connection') + .send(connectionToTestDB) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + const createConnectionRO = JSON.parse(createConnectionResponse.text); + t.is(createConnectionResponse.status, 201); + + const createPersonalTableSettingsDTO: CreatePersonalTableSettingsDto = { + columns_view: [testTableColumnName, testTableSecondColumnName, 'id'], + list_fields: [testTableSecondColumnName, testTableColumnName, 'id'], + list_per_page: 32, + ordering: QueryOrderingEnum.ASC, + ordering_field: testTableColumnName, + original_names: false, + }; + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + const createPersonalTableSettingsRO: FoundPersonalTableSettingsDto = JSON.parse( + createPersonalTableSettingsResponse.text, + ); + t.is(createPersonalTableSettingsResponse.status, 200); + t.deepEqual(createPersonalTableSettingsRO.columns_view, createPersonalTableSettingsDTO.columns_view); + t.deepEqual(createPersonalTableSettingsRO.list_fields, createPersonalTableSettingsDTO.list_fields); + t.is(createPersonalTableSettingsRO.list_per_page, createPersonalTableSettingsDTO.list_per_page); + t.is(createPersonalTableSettingsRO.ordering, createPersonalTableSettingsDTO.ordering); + t.is(createPersonalTableSettingsRO.ordering_field, createPersonalTableSettingsDTO.ordering_field); + t.is(createPersonalTableSettingsRO.original_names, createPersonalTableSettingsDTO.original_names); + + const findPersonalTableSettingsResponse = await request(app.getHttpServer()) + .get(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + const findPersonalTableSettingsRO: FoundPersonalTableSettingsDto = JSON.parse(findPersonalTableSettingsResponse.text); + t.is(findPersonalTableSettingsResponse.status, 200); + t.deepEqual(findPersonalTableSettingsRO.columns_view, createPersonalTableSettingsDTO.columns_view); + t.deepEqual(findPersonalTableSettingsRO.list_fields, createPersonalTableSettingsDTO.list_fields); + t.is(findPersonalTableSettingsRO.list_per_page, createPersonalTableSettingsDTO.list_per_page); + t.is(findPersonalTableSettingsRO.ordering, createPersonalTableSettingsDTO.ordering); + t.is(findPersonalTableSettingsRO.ordering_field, createPersonalTableSettingsDTO.ordering_field); + t.is(findPersonalTableSettingsRO.original_names, createPersonalTableSettingsDTO.original_names); +}); + +test.serial(`${currentTest} should return empty object when personal table settings wasn't created`, async (t) => { + const connectionToTestDB = getTestData(mockFactory).connectionToPostgres; + const firstUserToken = (await registerUserAndReturnUserInfo(app)).token; + const { testTableName, testTableColumnName, testTableSecondColumnName } = await createTestTable(connectionToTestDB); + + const createConnectionResponse = await request(app.getHttpServer()) + .post('/connection') + .send(connectionToTestDB) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + const createConnectionRO = JSON.parse(createConnectionResponse.text); + t.is(createConnectionResponse.status, 201); + + const createPersonalTableSettingsDTO: CreatePersonalTableSettingsDto = { + columns_view: [testTableColumnName, testTableSecondColumnName, 'id'], + list_fields: [testTableSecondColumnName, testTableColumnName, 'id'], + list_per_page: 32, + ordering: QueryOrderingEnum.ASC, + ordering_field: testTableColumnName, + original_names: false, + }; + + const findPersonalTableSettingsResponse = await request(app.getHttpServer()) + .get(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + const findPersonalTableSettingsRO: FoundPersonalTableSettingsDto = JSON.parse(findPersonalTableSettingsResponse.text); + t.is(findPersonalTableSettingsResponse.status, 200); + t.deepEqual(findPersonalTableSettingsRO, {}); +}); From 8116e3add28bb0b6b85ee393ba7dc7e92985e28d Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Fri, 14 Nov 2025 08:19:58 +0000 Subject: [PATCH 06/14] fix table settings tests (in progress) --- .../non-saas-table-cassandra.e2e.test.ts | 421 +++++++++++-- .../non-saas-table-ibmdb2-e2e.test.ts | 417 +++++++++++-- .../non-saas-table-mongodb-e2e.test.ts | 398 ++++++++++-- .../non-saas-table-mssql-e2e.test.ts | 398 ++++++++++-- .../non-saas-table-mssql-schema-e2e.test.ts | 398 ++++++++++-- .../non-saas-table-mysql-e2e.test.ts | 171 ++++- .../saas-tests/connection-e2e.test.ts | 1 - .../table-cassandra-agent.e2e.test.ts | 422 +++++++++++-- .../saas-tests/table-cassandra.e2e.test.ts | 421 +++++++++++-- .../saas-tests/table-dynamodb-e2e.test.ts | 583 ++++++++++++++---- .../table-elasticsearch-e2e.test.ts | 417 +++++++++++-- .../saas-tests/table-filters-e2e-test.ts | 19 +- .../saas-tests/table-ibmdb2-agent-e2e.test.ts | 436 +++++++++++-- .../saas-tests/table-ibmdb2-e2e.test.ts | 436 +++++++++++-- .../table-mongodb-agent-e2e.test.ts | 417 +++++++++++-- .../saas-tests/table-mongodb-e2e.test.ts | 417 +++++++++++-- .../saas-tests/table-mssql-agent-e2e.test.ts | 417 +++++++++++-- .../saas-tests/table-mssql-e2e.test.ts | 436 +++++++++++-- .../saas-tests/table-mssql-schema-e2e.test.ts | 398 ++++++++++-- .../saas-tests/table-mysql-agent-e2e.test.ts | 417 +++++++++++-- .../saas-tests/table-mysql-e2e.test.ts | 436 +++++++++++-- .../saas-tests/table-oracle-agent-e2e.test.ts | 417 +++++++++++-- .../saas-tests/table-oracledb-e2e.test.ts | 455 ++++++++++++-- .../table-oracledb-schema-e2e.test.ts | 398 ++++++++++-- .../table-postgres-agent-e2e.test.ts | 417 +++++++++++-- .../saas-tests/table-postgres-e2e.test.ts | 498 ++++++++++++--- .../table-postgres-encrypted-e2e.test.ts | 398 ++++++++++-- .../table-postgres-schema-e2e.test.ts | 398 ++++++++++-- .../saas-tests/table-redis-agent-e2e.test.ts | 417 +++++++++++-- .../saas-tests/table-redis-e2e.test.ts | 417 +++++++++++-- .../saas-tests/table-settings-e2e.test.ts | 56 -- backend/test/mock.factory.ts | 81 ++- 32 files changed, 10027 insertions(+), 1801 deletions(-) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-cassandra.e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-cassandra.e2e.test.ts index 5ac8c76e1..fbfe8971a 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-cassandra.e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-cassandra.e2e.test.ts @@ -251,16 +251,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -323,16 +336,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -397,16 +423,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -474,16 +513,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -552,16 +604,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -630,16 +695,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -715,16 +793,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -797,16 +888,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -878,16 +982,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -958,16 +1075,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1036,16 +1166,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1122,16 +1265,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1198,16 +1354,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1275,16 +1444,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1350,16 +1532,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1437,16 +1632,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1517,16 +1725,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1593,16 +1814,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1658,16 +1892,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3497,10 +3744,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3509,6 +3752,23 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i false, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + undefined, + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3553,16 +3813,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3622,16 +3895,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3729,10 +4015,6 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3741,6 +4023,23 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, true, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + undefined, + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-ibmdb2-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-ibmdb2-e2e.test.ts index f5d83979a..33ad69dc8 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-ibmdb2-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-ibmdb2-e2e.test.ts @@ -251,16 +251,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['ID'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -324,16 +337,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['ID'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -398,16 +424,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['ID'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -475,16 +514,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -554,16 +606,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -633,16 +698,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -706,16 +784,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -778,16 +869,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -849,16 +953,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -920,16 +1037,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -992,16 +1122,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1068,16 +1211,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1142,16 +1298,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1219,16 +1388,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1294,16 +1476,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1376,16 +1571,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1459,16 +1667,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1538,16 +1759,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1617,16 +1851,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1676,16 +1923,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1740,16 +2000,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1806,16 +2079,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3448,16 +3734,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-mongodb-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-mongodb-e2e.test.ts index efed56704..f69779ec4 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-mongodb-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-mongodb-e2e.test.ts @@ -252,16 +252,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['_id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -324,16 +337,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['_id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -398,16 +424,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['_id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -475,16 +514,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -553,16 +605,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -631,16 +696,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -703,16 +781,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -779,16 +870,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -854,16 +958,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -929,16 +1046,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1005,16 +1135,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1085,16 +1228,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1160,16 +1316,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1240,16 +1409,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1317,16 +1499,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1402,16 +1597,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1490,16 +1698,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1576,16 +1797,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1635,16 +1869,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1699,16 +1946,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1765,16 +2025,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3561,16 +3834,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-mssql-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-mssql-e2e.test.ts index 7ab5a4e93..daee288a7 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-mssql-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-mssql-e2e.test.ts @@ -248,16 +248,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -320,16 +333,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -394,16 +420,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -471,16 +510,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -549,16 +601,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -627,16 +692,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -699,16 +777,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -771,16 +862,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -842,16 +946,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -913,16 +1030,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -985,16 +1115,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1061,16 +1204,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1135,16 +1291,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1212,16 +1381,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1287,16 +1469,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1369,16 +1564,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1452,16 +1660,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1531,16 +1752,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1610,16 +1844,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1669,16 +1916,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1733,16 +1993,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1799,16 +2072,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-mssql-schema-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-mssql-schema-e2e.test.ts index 7bfcaff85..68c3f2266 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-mssql-schema-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-mssql-schema-e2e.test.ts @@ -249,16 +249,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -321,16 +334,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -395,16 +421,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -472,16 +511,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -550,16 +602,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -628,16 +693,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -700,16 +778,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -772,16 +863,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -843,16 +947,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -914,16 +1031,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -986,16 +1116,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1062,16 +1205,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1136,16 +1292,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1213,16 +1382,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1288,16 +1470,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1370,16 +1565,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1453,16 +1661,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1532,16 +1753,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1611,16 +1845,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1670,16 +1917,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1734,16 +1994,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1800,16 +2073,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-mysql-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-mysql-e2e.test.ts index d7c0f4d79..4e9f4bfec 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-mysql-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-mysql-e2e.test.ts @@ -246,16 +246,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -318,16 +331,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -392,16 +418,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -469,16 +508,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -547,16 +599,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -625,16 +690,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -697,16 +775,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -769,16 +860,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -840,16 +944,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -910,17 +1027,31 @@ test.serial( testTableName, [testTableColumnName], undefined, + undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/connection-e2e.test.ts b/backend/test/ava-tests/saas-tests/connection-e2e.test.ts index 0e8afe3c4..366eb4de1 100644 --- a/backend/test/ava-tests/saas-tests/connection-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/connection-e2e.test.ts @@ -21,7 +21,6 @@ import { registerUserAndReturnUserInfo, } from '../../utils/register-user-and-return-user-info.js'; import { TestUtils } from '../../utils/test.utils.js'; -import { WinstonLogger } from '../../../src/entities/logging/winston-logger.js'; const mockFactory = new MockFactory(); let app: INestApplication; diff --git a/backend/test/ava-tests/saas-tests/table-cassandra-agent.e2e.test.ts b/backend/test/ava-tests/saas-tests/table-cassandra-agent.e2e.test.ts index 4c48d80a6..ea4c8806f 100644 --- a/backend/test/ava-tests/saas-tests/table-cassandra-agent.e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-cassandra-agent.e2e.test.ts @@ -97,7 +97,6 @@ test.serial(`${currentTest} should return list of tables in connection`, async ( .set('Content-Type', 'application/json') .set('Accept', 'application/json'); const createConnectionRO = JSON.parse(createConnectionResponse.text); - console.log('🚀 ~ test.only ~ createConnectionRO:', createConnectionRO); t.is(createConnectionResponse.status, 201); const getTablesResponse = await request(app.getHttpServer()) @@ -247,16 +246,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -315,16 +327,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -385,16 +410,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -458,16 +496,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -532,16 +583,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -606,16 +670,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -687,16 +764,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -765,16 +855,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -842,16 +945,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -918,16 +1034,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -992,16 +1121,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1074,16 +1216,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1146,16 +1301,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1219,16 +1387,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1290,16 +1471,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1373,16 +1567,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1449,16 +1656,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1521,16 +1741,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1582,16 +1815,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3210,10 +3456,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3222,6 +3464,23 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i false, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + undefined, + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3262,16 +3521,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3327,16 +3599,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3430,10 +3715,6 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3442,6 +3723,23 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, true, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + undefined, + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-cassandra.e2e.test.ts b/backend/test/ava-tests/saas-tests/table-cassandra.e2e.test.ts index df7951acc..3926af0a9 100644 --- a/backend/test/ava-tests/saas-tests/table-cassandra.e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-cassandra.e2e.test.ts @@ -249,16 +249,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -323,16 +336,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -397,16 +423,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -474,16 +513,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -552,16 +604,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -630,16 +695,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -715,16 +793,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -797,16 +888,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -878,16 +982,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -958,16 +1075,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1036,16 +1166,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1122,16 +1265,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1198,16 +1354,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1275,16 +1444,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1350,16 +1532,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1437,16 +1632,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1517,16 +1725,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1593,16 +1814,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1658,16 +1892,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3497,10 +3744,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3509,6 +3752,23 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i false, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + undefined, + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3553,16 +3813,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3622,16 +3895,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3729,10 +4015,6 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3741,6 +4023,23 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, true, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + undefined, + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-dynamodb-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-dynamodb-e2e.test.ts index 60cd5300e..58be837dc 100644 --- a/backend/test/ava-tests/saas-tests/table-dynamodb-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-dynamodb-e2e.test.ts @@ -227,16 +227,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -296,16 +309,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -370,16 +396,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -447,16 +486,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -525,16 +577,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -603,16 +668,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -675,16 +753,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -751,16 +842,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -826,16 +930,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -901,16 +1018,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -977,16 +1107,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1057,16 +1200,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1132,16 +1288,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1212,16 +1381,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1289,16 +1471,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1375,16 +1570,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1463,16 +1671,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1526,95 +1747,109 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC }, ); -test.serial(`${currentTest} with search, with pagination, with sorting and with filtering by id -should return all found rows with search, pagination: page=1, perPage=2 and DESC sorting and with multi filtering`, async (t) => { - try { - const connectionToTestDB = getTestData(mockFactory).dynamoDBConnection; - const firstUserToken = (await registerUserAndReturnUserInfo(app)).token; - const { testTableName, testTableColumnName, insertedSearchedIds } = await createTestTable(connectionToTestDB); +test.serial( + `${currentTest} with search, with pagination, with sorting and with filtering by id +should return all found rows with search, pagination: page=1, perPage=2 and DESC sorting and with multi filtering`, + async (t) => { + try { + const connectionToTestDB = getTestData(mockFactory).dynamoDBConnection; + const firstUserToken = (await registerUserAndReturnUserInfo(app)).token; + const { testTableName, testTableColumnName, insertedSearchedIds } = await createTestTable(connectionToTestDB); - testTables.push(testTableName); + testTables.push(testTableName); - const createConnectionResponse = await request(app.getHttpServer()) - .post('/connection') - .send(connectionToTestDB) - .set('Cookie', firstUserToken) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - const createConnectionRO = JSON.parse(createConnectionResponse.text); - t.is(createConnectionResponse.status, 201); + const createConnectionResponse = await request(app.getHttpServer()) + .post('/connection') + .send(connectionToTestDB) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + const createConnectionRO = JSON.parse(createConnectionResponse.text); + t.is(createConnectionResponse.status, 201); - const createTableSettingsDTO = mockFactory.generateTableSettings( - createConnectionRO.id, - testTableName, - [], - undefined, - undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, - undefined, - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + createConnectionRO.id, + testTableName, + [], + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + ); - const createTableSettingsResponse = await request(app.getHttpServer()) - .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) - .send(createTableSettingsDTO) - .set('Cookie', firstUserToken) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(createTableSettingsResponse.status, 201); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + undefined, + 3, + QueryOrderingEnum.DESC, + 'id', + ); - const fieldname = 'age'; - const idFieldName = 'id'; - const idFieldValue = 21; - const fieldGtvalue = 14; - // const fieldLtvalue = 95; + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); - const filters = { - // [fieldname]: { gt: fieldGtvalue }, - [idFieldName]: { eq: idFieldValue }, - }; + t.is(createPersonalTableSettingsResponse.status, 200); - const getTableRowsResponse = await request(app.getHttpServer()) - .post( - `/table/rows/find/${createConnectionRO.id}?tableName=${testTableName}&page=1&perPage=3`, - ) - .send({ filters }) - .set('Cookie', firstUserToken) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(getTableRowsResponse.status, 201); + const createTableSettingsResponse = await request(app.getHttpServer()) + .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) + .send(createTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + t.is(createTableSettingsResponse.status, 201); - const getTableRowsRO = JSON.parse(getTableRowsResponse.text); - console.log('🚀 ~ getTableRowsRO:', getTableRowsRO.rows); + const fieldname = 'age'; + const idFieldName = 'id'; + const idFieldValue = 21; + const fieldGtvalue = 14; + // const fieldLtvalue = 95; - t.is(typeof getTableRowsRO, 'object'); - t.is(getTableRowsRO.hasOwnProperty('rows'), true); - t.is(getTableRowsRO.hasOwnProperty('primaryColumns'), true); - t.is(getTableRowsRO.hasOwnProperty('pagination'), true); - t.is(getTableRowsRO.rows.length, 1); - t.is(Object.keys(getTableRowsRO.rows[0]).length, 11); + const filters = { + // [fieldname]: { gt: fieldGtvalue }, + [idFieldName]: { eq: idFieldValue }, + }; - const findRowId = 21; + const getTableRowsResponse = await request(app.getHttpServer()) + .post(`/table/rows/find/${createConnectionRO.id}?tableName=${testTableName}&page=1&perPage=3`) + .send({ filters }) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + t.is(getTableRowsResponse.status, 201); - t.is(getTableRowsRO.rows[0].id, findRowId); - t.is(getTableRowsRO.rows[0][testTableColumnName], testSearchedUserName); + const getTableRowsRO = JSON.parse(getTableRowsResponse.text); + console.log('🚀 ~ getTableRowsRO:', getTableRowsRO.rows); - t.is(getTableRowsRO.pagination.currentPage, 1); - t.is(getTableRowsRO.pagination.perPage, 3); + t.is(typeof getTableRowsRO, 'object'); + t.is(getTableRowsRO.hasOwnProperty('rows'), true); + t.is(getTableRowsRO.hasOwnProperty('primaryColumns'), true); + t.is(getTableRowsRO.hasOwnProperty('pagination'), true); + t.is(getTableRowsRO.rows.length, 1); + t.is(Object.keys(getTableRowsRO.rows[0]).length, 11); - t.is(typeof getTableRowsRO.primaryColumns, 'object'); - t.is(getTableRowsRO.primaryColumns[0].hasOwnProperty('column_name'), true); - t.is(getTableRowsRO.primaryColumns[0].hasOwnProperty('data_type'), true); - } catch (e) { - console.error(e); - throw e; - } -}); + const findRowId = 21; + + t.is(getTableRowsRO.rows[0].id, findRowId); + t.is(getTableRowsRO.rows[0][testTableColumnName], testSearchedUserName); + + t.is(getTableRowsRO.pagination.currentPage, 1); + t.is(getTableRowsRO.pagination.perPage, 3); + + t.is(typeof getTableRowsRO.primaryColumns, 'object'); + t.is(getTableRowsRO.primaryColumns[0].hasOwnProperty('column_name'), true); + t.is(getTableRowsRO.primaryColumns[0].hasOwnProperty('data_type'), true); + } catch (e) { + console.error(e); + throw e; + } + }, +); test.serial(`${currentTest} should throw an exception when connection id is not passed in request`, async (t) => { try { @@ -1639,16 +1874,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1698,16 +1946,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1762,16 +2023,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1828,16 +2102,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3566,16 +3853,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3637,16 +3937,29 @@ test.skip(`${currentTest} should import csv file with table data`, async (t) => [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-elasticsearch-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-elasticsearch-e2e.test.ts index 1c508ebae..715de0ac8 100644 --- a/backend/test/ava-tests/saas-tests/table-elasticsearch-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-elasticsearch-e2e.test.ts @@ -250,16 +250,29 @@ test.serial(`${currentTest} should return rows of selected table with search and [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -323,16 +336,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['age'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -397,16 +423,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['age'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -474,16 +513,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -552,16 +604,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -630,16 +695,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -702,16 +780,29 @@ should return all found rows with sorting AGE by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -774,16 +865,29 @@ should return all found rows with sorting age by DESC and with pagination page=1 [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -844,16 +948,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -914,16 +1031,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -987,16 +1117,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1065,16 +1208,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1139,16 +1295,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1219,16 +1388,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1296,16 +1478,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1381,16 +1576,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1469,16 +1677,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1555,16 +1776,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1614,16 +1848,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1678,16 +1925,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1744,16 +2004,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3537,16 +3810,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3606,16 +3892,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-filters-e2e-test.ts b/backend/test/ava-tests/saas-tests/table-filters-e2e-test.ts index 3ea8e2043..3af1ef772 100644 --- a/backend/test/ava-tests/saas-tests/table-filters-e2e-test.ts +++ b/backend/test/ava-tests/saas-tests/table-filters-e2e-test.ts @@ -568,16 +568,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-ibmdb2-agent-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-ibmdb2-agent-e2e.test.ts index f04a67b95..31ca6fb50 100644 --- a/backend/test/ava-tests/saas-tests/table-ibmdb2-agent-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-ibmdb2-agent-e2e.test.ts @@ -253,16 +253,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['ID'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -320,16 +333,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['ID'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -388,16 +414,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['ID'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -459,16 +498,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -532,16 +584,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -605,16 +670,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -672,16 +750,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -738,16 +829,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -803,16 +907,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -868,16 +985,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -934,16 +1064,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1004,16 +1147,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1072,16 +1228,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1143,16 +1312,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1212,16 +1394,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1288,16 +1483,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1365,16 +1573,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1438,16 +1659,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1511,16 +1745,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1564,16 +1811,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1622,16 +1882,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1682,16 +1955,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3068,16 +3354,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3131,16 +3430,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-ibmdb2-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-ibmdb2-e2e.test.ts index 889b708ba..3668afe73 100644 --- a/backend/test/ava-tests/saas-tests/table-ibmdb2-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-ibmdb2-e2e.test.ts @@ -249,16 +249,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['ID'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -322,16 +335,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['ID'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -396,16 +422,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['ID'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -473,16 +512,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -552,16 +604,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -631,16 +696,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -704,16 +782,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -776,16 +867,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -847,16 +951,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -918,16 +1035,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -990,16 +1120,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1066,16 +1209,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1140,16 +1296,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1217,16 +1386,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1292,16 +1474,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1374,16 +1569,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1457,16 +1665,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1536,16 +1757,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1615,16 +1849,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1674,16 +1921,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1738,16 +1998,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1804,16 +2077,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3511,16 +3797,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3580,16 +3879,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'ID', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'ID', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-mongodb-agent-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-mongodb-agent-e2e.test.ts index c8141c19f..8253c0586 100644 --- a/backend/test/ava-tests/saas-tests/table-mongodb-agent-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-mongodb-agent-e2e.test.ts @@ -245,16 +245,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['_id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -311,16 +324,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['_id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -379,16 +405,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['_id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -450,16 +489,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -522,16 +574,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -594,16 +659,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -660,16 +738,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -730,16 +821,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -799,16 +903,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -868,16 +985,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -938,16 +1068,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1012,16 +1155,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1081,16 +1237,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1155,16 +1324,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1226,16 +1408,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1305,16 +1500,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1387,16 +1595,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1467,16 +1688,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1520,16 +1754,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1578,16 +1825,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1638,16 +1898,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3140,16 +3413,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3203,16 +3489,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-mongodb-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-mongodb-e2e.test.ts index 3fda77b3b..b5e703812 100644 --- a/backend/test/ava-tests/saas-tests/table-mongodb-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-mongodb-e2e.test.ts @@ -249,16 +249,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['_id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -321,16 +334,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['_id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -395,16 +421,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['_id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -472,16 +511,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -550,16 +602,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -628,16 +693,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -700,16 +778,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -776,16 +867,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -851,16 +955,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -926,16 +1043,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1002,16 +1132,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1082,16 +1225,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1157,16 +1313,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1237,16 +1406,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1314,16 +1496,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1399,16 +1594,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1487,16 +1695,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1573,16 +1794,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1632,16 +1866,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1696,16 +1943,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1762,16 +2022,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3558,16 +3831,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3627,16 +3913,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - '_id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + '_id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-mssql-agent-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-mssql-agent-e2e.test.ts index 93cc854df..78dffb1a0 100644 --- a/backend/test/ava-tests/saas-tests/table-mssql-agent-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-mssql-agent-e2e.test.ts @@ -292,16 +292,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -358,16 +371,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -426,16 +452,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -497,16 +536,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -569,16 +621,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -640,16 +705,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -706,16 +784,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -772,16 +863,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -837,16 +941,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -902,16 +1019,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -968,16 +1098,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1038,16 +1181,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1106,16 +1262,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1177,16 +1346,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1246,16 +1428,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1322,16 +1517,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1399,16 +1607,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1472,16 +1693,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1545,16 +1779,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1598,16 +1845,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1656,16 +1916,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1716,16 +1989,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3226,16 +3512,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-mssql-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-mssql-e2e.test.ts index 894cca698..a84bfc12d 100644 --- a/backend/test/ava-tests/saas-tests/table-mssql-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-mssql-e2e.test.ts @@ -253,16 +253,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -325,16 +338,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -399,16 +425,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -476,16 +515,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -554,16 +606,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -632,16 +697,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -704,16 +782,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -776,16 +867,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -847,16 +951,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -918,16 +1035,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -990,16 +1120,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1066,16 +1209,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1140,16 +1296,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1217,16 +1386,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1292,16 +1474,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1374,16 +1569,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1457,16 +1665,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1536,16 +1757,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1615,16 +1849,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1674,16 +1921,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1738,16 +1998,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1804,16 +2077,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3514,16 +3800,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3583,16 +3882,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-mssql-schema-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-mssql-schema-e2e.test.ts index 1338c7ddc..a070498d2 100644 --- a/backend/test/ava-tests/saas-tests/table-mssql-schema-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-mssql-schema-e2e.test.ts @@ -245,16 +245,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -317,16 +330,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -391,16 +417,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -468,16 +507,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -546,16 +598,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -624,16 +689,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -696,16 +774,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -768,16 +859,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -839,16 +943,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -910,16 +1027,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -982,16 +1112,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1058,16 +1201,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1132,16 +1288,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1209,16 +1378,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1284,16 +1466,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1366,16 +1561,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1449,16 +1657,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1528,16 +1749,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1607,16 +1841,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1666,16 +1913,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1730,16 +1990,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1796,16 +2069,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-mysql-agent-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-mysql-agent-e2e.test.ts index 6399dcdaf..cc46dc3f7 100644 --- a/backend/test/ava-tests/saas-tests/table-mysql-agent-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-mysql-agent-e2e.test.ts @@ -288,16 +288,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -354,16 +367,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -422,16 +448,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -493,16 +532,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -565,16 +617,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -636,16 +701,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -702,16 +780,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -768,16 +859,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -833,16 +937,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -898,16 +1015,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -964,16 +1094,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1034,16 +1177,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1102,16 +1258,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1173,16 +1342,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1242,16 +1424,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1318,16 +1513,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1395,16 +1603,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1468,16 +1689,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1541,16 +1775,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1594,16 +1841,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1652,16 +1912,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1712,16 +1985,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3228,16 +3514,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-mysql-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-mysql-e2e.test.ts index e05e15bbc..30e5f9b9e 100644 --- a/backend/test/ava-tests/saas-tests/table-mysql-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-mysql-e2e.test.ts @@ -251,16 +251,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -323,16 +336,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -397,16 +423,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -474,16 +513,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -552,16 +604,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -630,16 +695,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -702,16 +780,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -774,16 +865,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -845,16 +949,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -916,16 +1033,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -988,16 +1118,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1064,16 +1207,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1138,16 +1294,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1215,16 +1384,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1290,16 +1472,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1372,16 +1567,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1455,16 +1663,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1534,16 +1755,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1613,16 +1847,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1672,16 +1919,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1736,16 +1996,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1802,16 +2075,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3513,16 +3799,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3582,16 +3881,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-oracle-agent-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-oracle-agent-e2e.test.ts index c1cca7aa0..ec5b5ece1 100644 --- a/backend/test/ava-tests/saas-tests/table-oracle-agent-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-oracle-agent-e2e.test.ts @@ -288,16 +288,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -354,16 +367,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -422,16 +448,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -493,16 +532,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -565,16 +617,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -636,16 +701,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -702,16 +780,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -768,16 +859,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -833,16 +937,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -898,16 +1015,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -964,16 +1094,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1034,16 +1177,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1102,16 +1258,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1173,16 +1342,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1242,16 +1424,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1318,16 +1513,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1395,16 +1603,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1468,16 +1689,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1541,16 +1775,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1594,16 +1841,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1652,16 +1912,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1712,16 +1985,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3228,16 +3514,29 @@ test.skip(`${currentTest} should import csv file with table data`, async (t) => [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts index c270ad711..6c7a0ef5f 100644 --- a/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts @@ -253,16 +253,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -327,16 +340,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -401,16 +427,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -478,16 +517,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -556,16 +608,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -633,16 +698,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -705,16 +783,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -777,16 +868,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -848,16 +952,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -919,16 +1036,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -991,16 +1121,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1067,16 +1210,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1141,16 +1297,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1218,16 +1387,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1293,16 +1475,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1375,16 +1570,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const firstFieldName = 'created_at'; const secondFieldName = 'updated_at'; const firstFieldValue = '2011-11-03'; @@ -1453,16 +1661,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1536,16 +1757,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1615,16 +1849,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1694,16 +1941,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1753,16 +2013,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1817,16 +2090,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1883,16 +2169,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3732,16 +4031,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3801,16 +4113,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-oracledb-schema-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-oracledb-schema-e2e.test.ts index 83d6ebd83..ba48fc2b4 100644 --- a/backend/test/ava-tests/saas-tests/table-oracledb-schema-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-oracledb-schema-e2e.test.ts @@ -248,16 +248,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -320,16 +333,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -394,16 +420,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -471,16 +510,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -549,16 +601,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -626,16 +691,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -698,16 +776,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -770,16 +861,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -841,16 +945,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -912,16 +1029,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -984,16 +1114,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1060,16 +1203,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1134,16 +1290,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1211,16 +1380,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1286,16 +1468,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1368,16 +1563,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1451,16 +1659,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1530,16 +1751,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1609,16 +1843,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1668,16 +1915,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1732,16 +1992,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1798,16 +2071,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-postgres-agent-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-postgres-agent-e2e.test.ts index c3d867504..5c18d59f7 100644 --- a/backend/test/ava-tests/saas-tests/table-postgres-agent-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-postgres-agent-e2e.test.ts @@ -288,16 +288,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -354,16 +367,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -422,16 +448,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -493,16 +532,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -565,16 +617,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -636,16 +701,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -702,16 +780,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -768,16 +859,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -833,16 +937,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -898,16 +1015,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -964,16 +1094,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1034,16 +1177,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1102,16 +1258,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1173,16 +1342,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1242,16 +1424,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1318,16 +1513,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1395,16 +1603,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1468,16 +1689,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1541,16 +1775,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1594,16 +1841,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1652,16 +1912,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1712,16 +1985,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3227,16 +3513,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts index 761928670..d5758d3a9 100644 --- a/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts @@ -300,16 +300,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -372,16 +385,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -446,16 +472,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -523,16 +562,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -542,7 +594,6 @@ should return all found rows with pagination page=1 perPage=2`, t.is(createTableSettingsResponse.status, 201); const createTableSettingsRO = JSON.parse(createTableSettingsResponse.text); - console.log('🚀 ~ createTableSettingsRO:', createTableSettingsRO); const getTableRowsResponse = await request(app.getHttpServer()) .get( @@ -606,16 +657,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -682,16 +746,29 @@ should return all found rows with sorting ids by DESC`, async (t) => { [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -756,16 +833,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -828,16 +918,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -899,16 +1002,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -970,16 +1086,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1042,16 +1171,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1118,16 +1260,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1192,16 +1347,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1269,16 +1437,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1344,16 +1525,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1426,16 +1620,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1512,16 +1719,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1595,16 +1815,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1674,16 +1907,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1753,16 +1999,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1812,16 +2071,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1876,16 +2148,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1941,16 +2226,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3907,10 +4205,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3919,6 +4213,23 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i false, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + undefined, + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3963,16 +4274,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -4032,16 +4356,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -4139,10 +4476,6 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -4151,6 +4484,23 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, true, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + undefined, + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-postgres-encrypted-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-postgres-encrypted-e2e.test.ts index d99c79659..276927bc0 100644 --- a/backend/test/ava-tests/saas-tests/table-postgres-encrypted-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-postgres-encrypted-e2e.test.ts @@ -289,16 +289,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -364,16 +377,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -441,16 +467,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -521,16 +560,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -602,16 +654,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -683,16 +748,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -758,16 +836,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -833,16 +924,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -907,16 +1011,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -981,16 +1098,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1056,16 +1186,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1135,16 +1278,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1212,16 +1368,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1292,16 +1461,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1370,16 +1552,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1455,16 +1650,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1541,16 +1749,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1623,16 +1844,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1705,16 +1939,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1768,16 +2015,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1835,16 +2095,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1904,16 +2177,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-postgres-schema-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-postgres-schema-e2e.test.ts index 61f888209..8ee7faa61 100644 --- a/backend/test/ava-tests/saas-tests/table-postgres-schema-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-postgres-schema-e2e.test.ts @@ -246,16 +246,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -318,16 +331,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -392,16 +418,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -469,16 +508,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -547,16 +599,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -625,16 +690,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -697,16 +775,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -769,16 +860,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -840,16 +944,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -911,16 +1028,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -983,16 +1113,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1059,16 +1202,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1133,16 +1289,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1210,16 +1379,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1285,16 +1467,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1367,16 +1562,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1450,16 +1658,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1529,16 +1750,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1608,16 +1842,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1667,16 +1914,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1731,16 +1991,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1797,16 +2070,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-redis-agent-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-redis-agent-e2e.test.ts index 4ec455435..d66ab0f98 100644 --- a/backend/test/ava-tests/saas-tests/table-redis-agent-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-redis-agent-e2e.test.ts @@ -242,16 +242,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['key'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -310,16 +323,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['key'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -380,16 +406,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['key'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -453,16 +492,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -528,16 +580,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -602,16 +667,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -670,16 +748,29 @@ should return all found rows with sorting age by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -736,16 +827,29 @@ should return all found rows with sorting ages by DESC and with pagination page= [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -807,16 +911,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -872,16 +989,29 @@ test.skip(`${currentTest} should return all found rows with sorting ages by DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -943,16 +1073,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1019,16 +1162,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1091,16 +1247,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1167,16 +1336,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1240,16 +1422,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1321,16 +1516,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1405,16 +1613,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1487,16 +1708,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1542,16 +1776,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1602,16 +1849,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1664,16 +1924,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3236,16 +3509,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3301,16 +3587,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-redis-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-redis-e2e.test.ts index 3ce589eb0..7d44acb45 100644 --- a/backend/test/ava-tests/saas-tests/table-redis-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-redis-e2e.test.ts @@ -248,16 +248,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['key'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -322,16 +335,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['key'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -396,16 +422,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['key'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -473,16 +512,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -553,16 +605,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -631,16 +696,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -703,16 +781,29 @@ should return all found rows with sorting age by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -773,16 +864,29 @@ should return all found rows with sorting ages by DESC and with pagination page= [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -848,16 +952,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -917,16 +1034,29 @@ test.skip(`${currentTest} should return all found rows with sorting ages by DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -994,16 +1124,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1076,16 +1219,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1152,16 +1308,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1232,16 +1401,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1309,16 +1491,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1394,16 +1589,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1482,16 +1690,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1569,16 +1790,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1628,16 +1862,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1692,16 +1939,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1758,16 +2018,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3559,16 +3832,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3628,16 +3914,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-settings-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-settings-e2e.test.ts index 94eacd996..1d9e0050a 100644 --- a/backend/test/ava-tests/saas-tests/table-settings-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-settings-e2e.test.ts @@ -166,10 +166,6 @@ test.serial(`${currentTest} should return connection settings object`, async (t) ['title'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, undefined, @@ -232,10 +228,6 @@ test.serial(`${currentTest} should return created table settings`, async (t) => ['title'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, undefined, @@ -295,10 +287,6 @@ test.serial(`${currentTest} should throw exception when tableName is missing`, a ['title'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, undefined, @@ -340,10 +328,6 @@ test.serial(`${currentTest} should throw exception when connectionId is missing` ['title'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, undefined, @@ -385,10 +369,6 @@ test.serial(`${currentTest} should throw exception when search_fields is not an 'title', undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, ); @@ -428,10 +408,6 @@ test.serial(`${currentTest} should throw exception when excluded_fields is not a ['title'], 'type', undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, ); @@ -470,10 +446,6 @@ test.serial(`${currentTest} should throw exception when list_fields is not an ar 'connection', ['title'], undefined, - 'type', - 3, - QueryOrderingEnum.DESC, - 'port', undefined, undefined, undefined, @@ -513,10 +485,6 @@ test.serial(`${currentTest} should throw exception when readonly_fields is not a 'connection', ['title'], undefined, - undefined, - 3, - QueryOrderingEnum.DESC, - 'port', 'type', undefined, undefined, @@ -557,10 +525,6 @@ test.serial(`${currentTest} should throw exception when sortable_by is not an ar ['title'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, 'type', undefined, ); @@ -602,10 +566,6 @@ test.serial( ['testField'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, ); @@ -648,10 +608,6 @@ test.serial( ['type'], ['testField'], undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, ); @@ -691,10 +647,6 @@ test.serial(`${currentTest} should throw exception when there are no such field 'connection', ['type'], undefined, - ['testField'], - 3, - QueryOrderingEnum.DESC, - 'port', undefined, undefined, undefined, @@ -736,10 +688,6 @@ test.serial( 'connection', ['type'], undefined, - undefined, - 3, - QueryOrderingEnum.DESC, - 'port', ['testField'], undefined, undefined, @@ -784,10 +732,6 @@ test.serial( ['type'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, ['testField'], undefined, ); diff --git a/backend/test/mock.factory.ts b/backend/test/mock.factory.ts index 941250dc3..edfaf738d 100644 --- a/backend/test/mock.factory.ts +++ b/backend/test/mock.factory.ts @@ -12,6 +12,7 @@ import { ConnectionTypeTestEnum } from '../src/enums/connection-type.enum.js'; import { CreateConnectionDto } from '../src/entities/connection/application/dto/create-connection.dto.js'; import { ConnectionTypesEnum } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/enums/connection-types-enum.js'; import { CreateTableActionDTO } from '../src/entities/table-actions/table-actions-module/dto/create-table-action.dto.js'; +import { CreatePersonalTableSettingsDto } from '../src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.js'; export class MockFactory { generateCognitoUserName() { return 'a876284a-e902-11ea-adc1-0242ac120002'; @@ -522,37 +523,37 @@ export class MockFactory { }; } -// { -// id: 'e82ed355-94fd-46e5-b732-c0e8f01ccc96', -// table_name: 'capitulus_xiphias_rU6K_delectatio', -// display_name: 'test display name', -// search_fields: [ 'voluptas_adulatio' ], -// excluded_fields: [], -// identification_fields: [], -// identity_column: null, -// readonly_fields: [], -// sensitive_fields: null, -// sortable_by: [], -// autocomplete_columns: [], -// columns_view: null, -// connection_id: 'k7N6nja2', -// can_add: true, -// can_delete: true, -// can_update: true, -// icon: null, -// allow_csv_export: true, -// allow_csv_import: true -// } + // { + // id: 'e82ed355-94fd-46e5-b732-c0e8f01ccc96', + // table_name: 'capitulus_xiphias_rU6K_delectatio', + // display_name: 'test display name', + // search_fields: [ 'voluptas_adulatio' ], + // excluded_fields: [], + // identification_fields: [], + // identity_column: null, + // readonly_fields: [], + // sensitive_fields: null, + // sortable_by: [], + // autocomplete_columns: [], + // columns_view: null, + // connection_id: 'k7N6nja2', + // can_add: true, + // can_delete: true, + // can_update: true, + // icon: null, + // allow_csv_export: true, + // allow_csv_import: true + // } generateTableSettings( connectionId: string, tableName: string, searchedFields: Array, excludedFields: Array, - listFields: Array, - listPerPage = 3, - ordering: QueryOrderingEnum, - orderingField: string, + // listFields: Array, + // listPerPage = 3, + // ordering: QueryOrderingEnum, + // orderingField: string, readonlyFields: Array, sortableBy: Array, autocompleteColumns: Array, @@ -579,15 +580,33 @@ export class MockFactory { /*eslint-enable*/ } + generatePersonalTableSettingsDto( + list_fields: Array, + list_per_page = 3, + ordering: QueryOrderingEnum, + ordering_field: string, + columns_view? : Array, + original_names: boolean = true, + ): CreatePersonalTableSettingsDto { + return { + columns_view, + list_fields, + list_per_page, + ordering, + ordering_field, + original_names, + }; + } + generateTableSettingsWithoutTypes( connectionId: any, tableName: any, searchedFields: any, excludedFields: any, - listFields: any, - listPerPage: any, - ordering: any, - orderingField: any, + // listFields: any, + // listPerPage: any, + // ordering: any, + // orderingField: any, readonlyFields: any, sortebleBy: any, autocompleteColumns: any, @@ -599,10 +618,6 @@ export class MockFactory { display_name: 'test display name', search_fields: searchedFields, excluded_fields: excludedFields, - list_fields: listFields, - list_per_page: listPerPage ? listPerPage : 3, - ordering: ordering, - ordering_field: orderingField, readonly_fields: readonlyFields, sortable_by: sortebleBy, autocomplete_columns: autocompleteColumns, From 72b8410f5a60fd31a8abf3fe73e92e01b0fa2380 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Wed, 19 Nov 2025 10:02:58 +0000 Subject: [PATCH 07/14] Refactor table settings tests to remove redundant parameters - Removed unnecessary parameters from various table settings test cases across multiple test files. - Simplified the test data generation by eliminating unused columns and ordering parameters. - Ensured that the tests still validate the expected behavior without the removed parameters. --- .../dto/create-personal-table-settings.dto.ts | 8 +- ...update-personal-table-settings.use.case.ts | 13 +- .../non-saas-table-mysql-e2e.test.ts | 228 ++++++++-- .../non-saas-table-oracledb-e2e.test.ts | 400 ++++++++++++++--- ...non-saas-table-oracledb-schema-e2e.test.ts | 398 ++++++++++++++--- ...-saas-table-postgres-encrypted-e2e.test.ts | 398 ++++++++++++++--- ...non-saas-table-postgres-schema-e2e.test.ts | 398 ++++++++++++++--- .../non-saas-table-redis-e2e.test.ts | 417 +++++++++++++++--- .../non-saas-table-settings-e2e.test.ts | 269 +++++++++-- ...on-saas-user-admin-permissions-e2e.test.ts | 227 ++++++---- ...as-user-group-edit-permissions-e2e.test.ts | 40 -- ...onnection-readonly-permissions-e2e.test.ts | 40 -- ...er-with-table-only-permissions-e2e.test.ts | 40 -- .../saas-tests/table-oracledb-e2e.test.ts | 3 + .../user-admin-permissions-e2e.test.ts | 40 -- .../user-group-edit-permissions-e2e.test.ts | 40 -- ...onnection-readonly-permissions-e2e.test.ts | 40 -- ...er-with-table-only-permissions-e2e.test.ts | 40 -- 18 files changed, 2291 insertions(+), 748 deletions(-) diff --git a/backend/src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.ts b/backend/src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.ts index 1181acd86..83a4551fd 100644 --- a/backend/src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.ts +++ b/backend/src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; import { QueryOrderingEnum } from '../../../../enums/query-ordering.enum.js'; -import { IsEnum, IsOptional } from 'class-validator'; +import { IsBoolean, IsEnum, IsOptional } from 'class-validator'; export class CreatePersonalTableSettingsDto { @ApiProperty({ enumName: 'QueryOrderingEnum', enum: QueryOrderingEnum, description: 'The ordering direction' }) @@ -9,17 +9,23 @@ export class CreatePersonalTableSettingsDto { ordering: QueryOrderingEnum; @ApiProperty({ type: String, description: 'The ordering field' }) + @IsOptional() ordering_field: string; @ApiProperty({ type: Number, description: 'The number of items per page' }) + @IsOptional() list_per_page: number; @ApiProperty({ isArray: true, type: String, description: 'The columns view' }) + @IsOptional() columns_view: Array; @ApiProperty({ type: [String], description: 'The order of columns' }) + @IsOptional() list_fields: Array; @ApiProperty({ type: Boolean, description: 'Whether to use original column names' }) + @IsOptional() + @IsBoolean() original_names: boolean; } diff --git a/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts b/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts index 0296ad381..0c96e4ede 100644 --- a/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts +++ b/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts @@ -59,7 +59,7 @@ export class CreateUpdatePersonalTableSettingsUseCase connection: ConnectionEntity, tableName: string, ): Promise { - const { columns_view, list_fields, list_per_page, ordering, ordering_field, original_names } = settingsData; + const { columns_view, list_fields, list_per_page, ordering, ordering_field } = settingsData; const dao = getDataAccessObject(connection); const tableStructure = await dao.getTableStructure(tableName, null); const tableColumnNames = tableStructure.map((col) => col.column_name); @@ -98,17 +98,6 @@ export class CreateUpdatePersonalTableSettingsUseCase } } - if (original_names !== null && original_names !== undefined) { - if (typeof original_names !== 'object' || Array.isArray(original_names)) { - errors.push('original_names must be an object'); - } else { - const invalidKeys = Object.keys(original_names).filter((key) => !tableColumnNames.includes(key)); - if (invalidKeys.length > 0) { - errors.push(`Invalid columns in original_names: ${invalidKeys.join(', ')}`); - } - } - } - if (errors.length > 0) { throw new BadRequestException(`Validation failed: ${errors.join('; ')}`); } diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-mysql-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-mysql-e2e.test.ts index 4e9f4bfec..a5f58c00e 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-mysql-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-mysql-e2e.test.ts @@ -1114,16 +1114,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1190,16 +1203,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1264,16 +1290,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1341,16 +1380,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1416,16 +1468,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1498,16 +1563,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1581,16 +1659,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1660,16 +1751,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1739,16 +1843,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1798,16 +1915,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1862,16 +1992,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1928,16 +2071,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-e2e.test.ts index 057a83c81..26d5eea22 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-e2e.test.ts @@ -250,16 +250,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -322,16 +335,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -396,16 +422,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -473,16 +512,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -551,16 +603,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -628,16 +693,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -700,16 +778,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -772,16 +863,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -843,16 +947,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -914,16 +1031,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -986,16 +1116,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1062,16 +1205,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1136,16 +1292,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1213,16 +1382,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1288,16 +1470,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1370,16 +1565,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1453,16 +1661,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1532,16 +1753,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1611,16 +1845,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1670,16 +1917,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1711,7 +1971,7 @@ test.serial(`${currentTest} should throw an exception when connection id passed } }); -test.serial(`${currentTest} should throw an exception when table name passed in request is incorrect`, async (t) => { +test.only(`${currentTest} should throw an exception when table name passed in request is incorrect`, async (t) => { try { const connectionToTestDB = getTestData(mockFactory).connectionToOracleDB; const firstUserToken = (await registerUserAndReturnUserInfo(app)).token; @@ -1734,16 +1994,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1800,16 +2073,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-schema-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-schema-e2e.test.ts index 404930b6d..df2e96511 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-schema-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-schema-e2e.test.ts @@ -250,16 +250,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -322,16 +335,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -396,16 +422,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -473,16 +512,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -551,16 +603,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -628,16 +693,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -700,16 +778,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -772,16 +863,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -843,16 +947,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -914,16 +1031,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -986,16 +1116,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1062,16 +1205,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1136,16 +1292,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1213,16 +1382,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1288,16 +1470,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1370,16 +1565,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1453,16 +1661,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1532,16 +1753,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1611,16 +1845,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1670,16 +1917,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1734,16 +1994,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1800,16 +2073,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-encrypted-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-encrypted-e2e.test.ts index 21e6d07f4..af3a2b589 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-encrypted-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-encrypted-e2e.test.ts @@ -291,16 +291,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -366,16 +379,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -443,16 +469,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -523,16 +562,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -604,16 +656,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -685,16 +750,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -760,16 +838,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -835,16 +926,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -909,16 +1013,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -983,16 +1100,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1058,16 +1188,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1137,16 +1280,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1214,16 +1370,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1294,16 +1463,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1372,16 +1554,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1457,16 +1652,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1543,16 +1751,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1625,16 +1846,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1707,16 +1941,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1770,16 +2017,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1837,16 +2097,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1906,16 +2179,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-schema-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-schema-e2e.test.ts index 3d0b565da..ce5f0c3a2 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-schema-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-schema-e2e.test.ts @@ -248,16 +248,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -320,16 +333,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -394,16 +420,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -471,16 +510,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -549,16 +601,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -627,16 +692,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -699,16 +777,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -771,16 +862,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -842,16 +946,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -913,16 +1030,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -985,16 +1115,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1061,16 +1204,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1135,16 +1291,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1212,16 +1381,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1287,16 +1469,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1369,16 +1564,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1452,16 +1660,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1531,16 +1752,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1610,16 +1844,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1669,16 +1916,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1733,16 +1993,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1799,16 +2072,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-redis-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-redis-e2e.test.ts index 947405bd5..18fba71fa 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-redis-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-redis-e2e.test.ts @@ -250,16 +250,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['key'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -324,16 +337,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['key'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -398,16 +424,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['key'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -475,16 +514,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -555,16 +607,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -633,16 +698,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -705,16 +783,29 @@ should return all found rows with sorting age by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -775,16 +866,29 @@ should return all found rows with sorting ages by DESC and with pagination page= [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -850,16 +954,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -919,16 +1036,29 @@ test.skip(`${currentTest} should return all found rows with sorting ages by DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -996,16 +1126,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1078,16 +1221,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1154,16 +1310,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1234,16 +1403,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1311,16 +1493,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1396,16 +1591,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1484,16 +1692,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1571,16 +1792,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1630,16 +1864,29 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1694,16 +1941,29 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1760,16 +2020,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'age', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'age', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3561,16 +3834,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3630,16 +3916,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'key', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'key', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-settings-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-settings-e2e.test.ts index c84b3c46d..b56ca9fc5 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-settings-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-settings-e2e.test.ts @@ -168,16 +168,29 @@ test.serial(`${currentTest} should return connection settings object`, async (t) ['title'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'port', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: tableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) .send(createTableSettingsDTO) @@ -233,17 +246,31 @@ test.serial(`${currentTest} should return created table settings`, async (t) => 'connection', ['title'], undefined, + undefined, - 3, - QueryOrderingEnum.DESC, - 'port', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'port', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=connection`) .send(createTableSettingsDTO) @@ -297,16 +324,28 @@ test.serial(`${currentTest} should throw exception when tableName is missing`, a ['title'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'port', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); const tableName = ''; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -342,16 +381,29 @@ test.serial(`${currentTest} should throw exception when connectionId is missing` ['title'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'port', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const tableName = faker.lorem.words(1); const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -387,14 +439,27 @@ test.serial(`${currentTest} should throw exception when search_fields is not an 'title', undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'port', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -430,14 +495,27 @@ test.serial(`${currentTest} should throw exception when excluded_fields is not a ['title'], 'type', undefined, - 3, - QueryOrderingEnum.DESC, - 'port', undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'port', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -472,15 +550,28 @@ test.serial(`${currentTest} should throw exception when list_fields is not an ar 'connection', ['title'], undefined, - 'type', - 3, - QueryOrderingEnum.DESC, - 'port', undefined, undefined, undefined, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + ['type'], + 3, + QueryOrderingEnum.DESC, + 'port', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -515,15 +606,28 @@ test.serial(`${currentTest} should throw exception when readonly_fields is not a 'connection', ['title'], undefined, + 'type', + undefined, + undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, 3, QueryOrderingEnum.DESC, 'port', - 'type', - undefined, - undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -558,15 +662,28 @@ test.serial(`${currentTest} should throw exception when sortable_by is not an ar 'connection', ['title'], undefined, + undefined, + 'type', + undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, 3, QueryOrderingEnum.DESC, 'port', - undefined, - 'type', - undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -603,15 +720,29 @@ test.serial( 'connection', ['testField'], undefined, + undefined, - 3, - QueryOrderingEnum.DESC, - 'port', undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'port', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -650,14 +781,27 @@ test.serial( ['type'], ['testField'], undefined, - 3, - QueryOrderingEnum.DESC, - 'port', undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'port', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -693,15 +837,28 @@ test.serial(`${currentTest} should throw exception when there are no such field 'connection', ['type'], undefined, + undefined, + undefined, + undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( ['testField'], 3, QueryOrderingEnum.DESC, 'port', - undefined, - undefined, - undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -738,15 +895,28 @@ test.serial( 'connection', ['type'], undefined, + ['testField'], + undefined, + undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, 3, QueryOrderingEnum.DESC, 'port', - ['testField'], - undefined, - undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -785,15 +955,28 @@ test.serial( 'connection', ['type'], undefined, + undefined, + ['testField'], + undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, 3, QueryOrderingEnum.DESC, 'port', - undefined, - ['testField'], - undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${connectionId}`) + .query({ tableName: 'connection' }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', token) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-user-admin-permissions-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-user-admin-permissions-e2e.test.ts index 39eafe9a7..c47d6a051 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-user-admin-permissions-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-user-admin-permissions-e2e.test.ts @@ -3105,10 +3105,7 @@ test.serial(`${currentTest} should return table settings when it was created`, a testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', + ['updated_at'], ['created_at'], undefined, @@ -3116,6 +3113,23 @@ test.serial(`${currentTest} should return table settings when it was created`, a undefined, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + [testData.firstTableInfo.testTableColumnName], + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${testData.connections.firstId}`) + .query({ tableName: testData.firstTableInfo.testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', testData.users.adminUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${testData.connections.firstId}&tableName=${testData.firstTableInfo.testTableName}`) .send(createTableSettingsDTO) @@ -3159,10 +3173,6 @@ test.serial( testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3170,6 +3180,23 @@ test.serial( undefined, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + [testData.firstTableInfo.testTableColumnName], + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${testData.connections.firstId}`) + .query({ tableName: testData.firstTableInfo.testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', testData.users.adminUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post( `/settings?connectionId=${testData.connections.firstId}&tableName=${testData.firstTableInfo.testTableName}`, @@ -3208,10 +3235,6 @@ test.serial(`${currentTest} should return created table settings`, async (t) => testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3219,6 +3242,23 @@ test.serial(`${currentTest} should return created table settings`, async (t) => undefined, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + [testData.firstTableInfo.testTableColumnName], + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${testData.connections.firstId}`) + .query({ tableName: testData.firstTableInfo.testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', testData.users.adminUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${testData.connections.firstId}&tableName=${testData.firstTableInfo.testTableName}`) .send(createTableSettingsDTO) @@ -3255,10 +3295,6 @@ test.serial( testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3266,6 +3302,23 @@ test.serial( undefined, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + [testData.firstTableInfo.testTableColumnName], + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${testData.connections.firstId}`) + .query({ tableName: testData.firstTableInfo.testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', testData.users.adminUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post( `/settings?connectionId=${testData.connections.secondId}&tableName=${testData.firstTableInfo.testTableName}`, @@ -3296,10 +3349,6 @@ test.serial(`${currentTest} should return updated table settings`, async (t) => testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3307,6 +3356,23 @@ test.serial(`${currentTest} should return updated table settings`, async (t) => undefined, ); + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( + [testData.firstTableInfo.testTableColumnName], + 3, + QueryOrderingEnum.DESC, + 'id', + ); + + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${testData.connections.firstId}`) + .query({ tableName: testData.firstTableInfo.testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', testData.users.adminUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${testData.connections.firstId}&tableName=${testData.firstTableInfo.testTableName}`) .send(createTableSettingsDTO) @@ -3320,10 +3386,6 @@ test.serial(`${currentTest} should return updated table settings`, async (t) => testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.ASC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3356,71 +3418,60 @@ test.serial(`${currentTest} should return updated table settings`, async (t) => } }); -test.serial( - `${currentTest} should throw an exception when you try update settings in connection where you do not have permission`, - async (t) => { - try { - const testData = await createConnectionsAndInviteNewUserInAdminGroupOfFirstConnection(app); +test.serial(`${currentTest} should throw an exception when you try update settings in connection where you do not have permission`, async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInAdminGroupOfFirstConnection(app); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.secondId, - testData.secondTableInfo.testTableName, - ['id'], - [testData.secondTableInfo.testTableSecondColumnName], - [testData.secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', - ['updated_at'], - ['created_at'], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.secondId, + testData.secondTableInfo.testTableName, + ['id'], + [testData.secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); - const createTableSettingsResponse = await request(app.getHttpServer()) - .post( - `/settings?connectionId=${testData.connections.secondId}&tableName=${testData.secondTableInfo.testTableName}`, - ) - .send(createTableSettingsDTO) - .set('Cookie', testData.users.adminUserToken) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); + const createTableSettingsResponse = await request(app.getHttpServer()) + .post( + `/settings?connectionId=${testData.connections.secondId}&tableName=${testData.secondTableInfo.testTableName}`, + ) + .send(createTableSettingsDTO) + .set('Cookie', testData.users.adminUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); - t.is(createTableSettingsResponse.status, 201); + t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.secondTableInfo.testTableName, - ['id'], - [testData.secondTableInfo.testTableSecondColumnName], - [testData.secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.ASC, - 'id', - ['updated_at'], - ['created_at'], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.secondTableInfo.testTableName, + ['id'], + [testData.secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); - const updateTableSettingsResponse = await request(app.getHttpServer()) - .put( - `/settings?connectionId=${testData.connections.secondId}&tableName=${testData.secondTableInfo.testTableName}`, - ) - .send(updateTableSettingsDTO) - .set('Cookie', testData.users.simpleUserToken) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(updateTableSettingsResponse.status, 403); - t.is(JSON.parse(updateTableSettingsResponse.text).message, Messages.DONT_HAVE_PERMISSIONS); - } catch (error) { - console.error(error); - throw error; - } - }, -); + const updateTableSettingsResponse = await request(app.getHttpServer()) + .put( + `/settings?connectionId=${testData.connections.secondId}&tableName=${testData.secondTableInfo.testTableName}`, + ) + .send(updateTableSettingsDTO) + .set('Cookie', testData.users.simpleUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + t.is(updateTableSettingsResponse.status, 403); + t.is(JSON.parse(updateTableSettingsResponse.text).message, Messages.DONT_HAVE_PERMISSIONS); + } catch (error) { + console.error(error); + throw error; + } +}); currentTest = 'DELETE /settings/'; @@ -3433,10 +3484,6 @@ test.serial(`${currentTest} should return array without deleted table settings`, testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3487,10 +3534,6 @@ test.serial( testData.secondTableInfo.testTableName, ['id'], [testData.secondTableInfo.testTableSecondColumnName], - [testData.secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-user-group-edit-permissions-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-user-group-edit-permissions-e2e.test.ts index 1bbc1a56e..381f2a020 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-user-group-edit-permissions-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-user-group-edit-permissions-e2e.test.ts @@ -2341,10 +2341,6 @@ test.serial(`${currentTest} 'should return table settings when it was created`, firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2401,10 +2397,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2454,10 +2446,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a 'users', ['id'], ['email'], - ['name'], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2497,10 +2485,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2542,10 +2526,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2566,10 +2546,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2608,10 +2584,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2632,10 +2604,6 @@ test.serial( firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2675,10 +2643,6 @@ test.serial(`${currentTest} should return array without deleted table settings`, firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2725,10 +2689,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-user-table-different-group-connection-readonly-permissions-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-user-table-different-group-connection-readonly-permissions-e2e.test.ts index 7841f25cd..08020f693 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-user-table-different-group-connection-readonly-permissions-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-user-table-different-group-connection-readonly-permissions-e2e.test.ts @@ -2314,10 +2314,6 @@ test.serial(`${currentTest} 'should should return created table settings`, async firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2366,10 +2362,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2421,10 +2413,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a 'users', ['id'], ['email'], - ['name'], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2466,10 +2454,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2513,10 +2497,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2537,10 +2517,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2581,10 +2557,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2605,10 +2577,6 @@ test.serial( firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2650,10 +2618,6 @@ test.serial(`${currentTest} should return array without deleted table settings`, firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2702,10 +2666,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-user-with-table-only-permissions-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-user-with-table-only-permissions-e2e.test.ts index 5d13dc824..72a015eb4 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-user-with-table-only-permissions-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-user-with-table-only-permissions-e2e.test.ts @@ -2234,10 +2234,6 @@ test.serial(`${currentTest} 'should should throw exception ${Messages.DONT_HAVE_ firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2286,10 +2282,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2340,10 +2332,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a 'users', ['id'], ['email'], - ['name'], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2384,10 +2372,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2430,10 +2414,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2454,10 +2434,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2497,10 +2473,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2521,10 +2493,6 @@ test.serial( firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2565,10 +2533,6 @@ test.serial(`${currentTest} should return array without deleted table settings`, firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2616,10 +2580,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, diff --git a/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts index 6c7a0ef5f..37dd59da0 100644 --- a/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts @@ -274,6 +274,9 @@ test.serial(`${currentTest} should return rows of selected table with search and .set('Content-Type', 'application/json') .set('Accept', 'application/json'); + const createPersonalTableSettingsRO = JSON.parse(createPersonalTableSettingsResponse.text); + console.log('🚀 ~ createPersonalTableSettingsRO:', createPersonalTableSettingsRO); + t.is(createPersonalTableSettingsResponse.status, 200); const createTableSettingsResponse = await request(app.getHttpServer()) diff --git a/backend/test/ava-tests/saas-tests/user-admin-permissions-e2e.test.ts b/backend/test/ava-tests/saas-tests/user-admin-permissions-e2e.test.ts index 1e129e83c..e4ffe83a6 100644 --- a/backend/test/ava-tests/saas-tests/user-admin-permissions-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/user-admin-permissions-e2e.test.ts @@ -3102,10 +3102,6 @@ test.serial(`${currentTest} should return table settings when it was created`, a testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3156,10 +3152,6 @@ test.serial( testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3205,10 +3197,6 @@ test.serial(`${currentTest} should return created table settings`, async (t) => testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3252,10 +3240,6 @@ test.serial( testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3293,10 +3277,6 @@ test.serial(`${currentTest} should return updated table settings`, async (t) => testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3317,10 +3297,6 @@ test.serial(`${currentTest} should return updated table settings`, async (t) => testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.ASC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3363,10 +3339,6 @@ test.serial( testData.secondTableInfo.testTableName, ['id'], [testData.secondTableInfo.testTableSecondColumnName], - [testData.secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3390,10 +3362,6 @@ test.serial( testData.secondTableInfo.testTableName, ['id'], [testData.secondTableInfo.testTableSecondColumnName], - [testData.secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.ASC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3429,10 +3397,6 @@ test.serial(`${currentTest} should return array without deleted table settings`, testData.firstTableInfo.testTableName, ['id'], [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -3483,10 +3447,6 @@ test.serial( testData.secondTableInfo.testTableName, ['id'], [testData.secondTableInfo.testTableSecondColumnName], - [testData.secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, diff --git a/backend/test/ava-tests/saas-tests/user-group-edit-permissions-e2e.test.ts b/backend/test/ava-tests/saas-tests/user-group-edit-permissions-e2e.test.ts index 77ebdcdf2..25ff9b6db 100644 --- a/backend/test/ava-tests/saas-tests/user-group-edit-permissions-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/user-group-edit-permissions-e2e.test.ts @@ -2358,10 +2358,6 @@ test.serial(`${currentTest} 'should return table settings when it was created`, firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2418,10 +2414,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2471,10 +2463,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a 'users', ['id'], ['email'], - ['name'], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2514,10 +2502,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2559,10 +2543,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2583,10 +2563,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2625,10 +2601,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2649,10 +2621,6 @@ test.serial( firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2692,10 +2660,6 @@ test.serial(`${currentTest} should return array without deleted table settings`, firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2742,10 +2706,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, diff --git a/backend/test/ava-tests/saas-tests/user-table-different-group-connection-readonly-permissions-e2e.test.ts b/backend/test/ava-tests/saas-tests/user-table-different-group-connection-readonly-permissions-e2e.test.ts index aecb66da6..5ba3b9fe3 100644 --- a/backend/test/ava-tests/saas-tests/user-table-different-group-connection-readonly-permissions-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/user-table-different-group-connection-readonly-permissions-e2e.test.ts @@ -2367,10 +2367,6 @@ test.serial(`${currentTest} 'should should return created table settings`, async firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2419,10 +2415,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2474,10 +2466,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a 'users', ['id'], ['email'], - ['name'], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2519,10 +2507,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2566,10 +2550,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2590,10 +2570,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2634,10 +2610,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2658,10 +2630,6 @@ test.serial( firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2703,10 +2671,6 @@ test.serial(`${currentTest} should return array without deleted table settings`, firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2755,10 +2719,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, diff --git a/backend/test/ava-tests/saas-tests/user-with-table-only-permissions-e2e.test.ts b/backend/test/ava-tests/saas-tests/user-with-table-only-permissions-e2e.test.ts index 73c7b84f2..16ccef0b6 100644 --- a/backend/test/ava-tests/saas-tests/user-with-table-only-permissions-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/user-with-table-only-permissions-e2e.test.ts @@ -2234,10 +2234,6 @@ test.serial(`${currentTest} 'should should throw exception ${Messages.DONT_HAVE_ firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2286,10 +2282,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2340,10 +2332,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a 'users', ['id'], ['email'], - ['name'], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2384,10 +2372,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2430,10 +2414,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2454,10 +2434,6 @@ test.serial(`${currentTest} should throw an exception do not have permission`, a firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2497,10 +2473,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2521,10 +2493,6 @@ test.serial( firstTableInfo.testTableName, [firstTableInfo.testTableSecondColumnName], ['id'], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - 'created_at', ['updated_at'], ['created_at'], undefined, @@ -2565,10 +2533,6 @@ test.serial(`${currentTest} should return array without deleted table settings`, firstTableInfo.testTableName, ['id'], [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, @@ -2616,10 +2580,6 @@ test.serial( secondTableInfo.testTableName, ['id'], [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - 'id', ['updated_at'], ['created_at'], undefined, From 8f859d59ca7cc3692d1e0e2bed95bca2154a18c8 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Wed, 19 Nov 2025 13:53:45 +0000 Subject: [PATCH 08/14] fix: add master password header to personal table settings requests --- ...-saas-table-postgres-encrypted-e2e.test.ts | 49 ++++++++----------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-encrypted-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-encrypted-e2e.test.ts index af3a2b589..ac197d32c 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-encrypted-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-postgres-encrypted-e2e.test.ts @@ -307,6 +307,7 @@ test.serial(`${currentTest} should return rows of selected table with search and const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -395,6 +396,7 @@ test.serial(`${currentTest} should return page of all rows with pagination page= const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -485,6 +487,7 @@ test.serial(`${currentTest} should return page of all rows with pagination page= const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -578,6 +581,7 @@ should return all found rows with pagination page=1 perPage=2`, const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -672,6 +676,7 @@ should return all found rows with pagination page=1 perPage=3`, const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -766,6 +771,7 @@ should return all found rows with sorting ids by DESC`, const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -854,6 +860,7 @@ should return all found rows with sorting ids by ASC`, const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -942,6 +949,7 @@ should return all found rows with sorting ports by DESC and with pagination page const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1029,6 +1037,7 @@ test.serial( const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1116,6 +1125,7 @@ test.serial( const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1204,6 +1214,7 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1296,6 +1307,7 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1386,6 +1398,7 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1479,6 +1492,7 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1570,6 +1584,7 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1668,6 +1683,7 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1767,6 +1783,7 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1862,6 +1879,7 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1954,16 +1972,6 @@ test.serial(`${currentTest} should throw an exception when connection id is not 'id', ); - const createPersonalTableSettingsResponse = await request(app.getHttpServer()) - .put(`/settings/personal/${createConnectionRO.id}`) - .query({ tableName: testTableName }) - .send(createPersonalTableSettingsDTO) - .set('Cookie', firstUserToken) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - t.is(createPersonalTableSettingsResponse.status, 200); - const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -2030,25 +2038,6 @@ test.serial(`${currentTest} should throw an exception when connection id passed 'id', ); - const createPersonalTableSettingsResponse = await request(app.getHttpServer()) - .put(`/settings/personal/${createConnectionRO.id}`) - .query({ tableName: testTableName }) - .send(createPersonalTableSettingsDTO) - .set('Cookie', firstUserToken) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - t.is(createPersonalTableSettingsResponse.status, 200); - - const createTableSettingsResponse = await request(app.getHttpServer()) - .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) - .send(createTableSettingsDTO) - .set('Cookie', firstUserToken) - .set('masterpwd', masterPwd) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(createTableSettingsResponse.status, 201); - const fieldname = 'id'; const fieldGtvalue = '25'; const fieldLtvalue = '40'; @@ -2113,6 +2102,7 @@ test.serial(`${currentTest} should throw an exception when table name passed in const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -2195,6 +2185,7 @@ test.serial( const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') From 1f8baf894c095ccd399c364a2f1c9d221f84151c Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Thu, 20 Nov 2025 13:04:13 +0000 Subject: [PATCH 09/14] refactor: update GetTableRowsUseCase to use builtDAOsTableSettings and clean up tests by removing unused assertions --- .../use-cases/get-table-rows.use.case.ts | 14 +- .../non-saas-postgres-with-binary-e2e.test.ts | 3 +- .../non-saas-table-settings-e2e.test.ts | 210 ------------------ .../table-postgres-encrypted-e2e.test.ts | 22 ++ .../saas-tests/table-settings-e2e.test.ts | 128 ----------- 5 files changed, 31 insertions(+), 346 deletions(-) diff --git a/backend/src/entities/table/use-cases/get-table-rows.use.case.ts b/backend/src/entities/table/use-cases/get-table-rows.use.case.ts index 5f08c1b15..910072e71 100644 --- a/backend/src/entities/table/use-cases/get-table-rows.use.case.ts +++ b/backend/src/entities/table/use-cases/get-table-rows.use.case.ts @@ -148,11 +148,11 @@ export class GetTableRowsUseCase extends AbstractUseCase isBinary(field.data_type)) .map((field) => field.column_name); if (connection.type === 'mongodb' || connection.type === 'agent_mongodb') { - tableSettings.search_fields.push('_id'); + builtDAOsTableSettings.search_fields.push('_id'); } } @@ -228,15 +228,15 @@ export class GetTableRowsUseCase extends AbstractUseCase 0 ? tableSettings.sortable_by : [], + sortable_by: builtDAOsTableSettings?.sortable_by?.length > 0 ? builtDAOsTableSettings.sortable_by : [], ordering_field: personalTableSettings.ordering_field ? personalTableSettings.ordering_field : undefined, ordering: personalTableSettings.ordering ? personalTableSettings.ordering : undefined, - columns_view: tableSettings.columns_view ? tableSettings.columns_view : undefined, + columns_view: builtDAOsTableSettings.columns_view ? builtDAOsTableSettings.columns_view : undefined, structure: formedTableStructure, foreignKeys: tableForeignKeys, configured: configured, widgets: tableWidgets, - identity_column: tableSettings.identity_column ? tableSettings.identity_column : null, + identity_column: builtDAOsTableSettings.identity_column ? builtDAOsTableSettings.identity_column : null, table_permissions: userTablePermissions, list_fields: listFields, action_events: actionEventsDtos, @@ -249,9 +249,9 @@ export class GetTableRowsUseCase extends AbstractUseCase 0 ? tableSettings.sortable_by : [], + sortable_by: builtDAOsTableSettings?.sortable_by?.length > 0 ? builtDAOsTableSettings.sortable_by : [], ordering: personalTableSettings.ordering ? personalTableSettings.ordering : undefined, - identity_column: tableSettings.identity_column ? tableSettings.identity_column : null, + identity_column: builtDAOsTableSettings.identity_column ? builtDAOsTableSettings.identity_column : null, list_fields: personalTableSettings?.list_fields?.length > 0 ? personalTableSettings.list_fields : [], allow_csv_export: allowCsvExport, allow_csv_import: allowCsvImport, diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-postgres-with-binary-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-postgres-with-binary-e2e.test.ts index 75883a96a..e5085fa2e 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-postgres-with-binary-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-postgres-with-binary-e2e.test.ts @@ -122,8 +122,9 @@ test.serial(`${currentTest} should return list of tables in connection`, async ( .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') .set('Accept', 'application/json'); - t.is(getTableRowsResponse.status, 200); + const getTableRowsWithSearchRO = JSON.parse(getTableRowsWithSearchResponse.text); + t.is(getTableRowsResponse.status, 200); t.is(getTableRowsWithSearchRO.rows.length, 1); t.is(getTableRowsWithSearchRO.rows[0][testTableColumnName], getTableRowsRO.rows[0][testTableColumnName]); diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-settings-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-settings-e2e.test.ts index b56ca9fc5..a9cfccd22 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-settings-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-settings-e2e.test.ts @@ -211,10 +211,6 @@ test.serial(`${currentTest} should return connection settings object`, async (t) t.is(findSettingsRO.display_name, createTableSettingsDTO.display_name); t.deepEqual(findSettingsRO.search_fields, ['title']); t.deepEqual(findSettingsRO.excluded_fields, []); - t.deepEqual(findSettingsRO.list_fields, []); - t.is(findSettingsRO.list_per_page, 3); - t.is(findSettingsRO.ordering, 'DESC'); - t.is(findSettingsRO.ordering_field, 'port'); t.deepEqual(findSettingsRO.readonly_fields, []); t.deepEqual(findSettingsRO.sortable_by, []); t.deepEqual(findSettingsRO.autocomplete_columns, []); @@ -291,10 +287,6 @@ test.serial(`${currentTest} should return created table settings`, async (t) => t.is(findSettingsRO.display_name, createTableSettingsDTO.display_name); t.deepEqual(findSettingsRO.search_fields, ['title']); t.deepEqual(findSettingsRO.excluded_fields, []); - t.deepEqual(findSettingsRO.list_fields, []); - t.is(findSettingsRO.list_per_page, 3); - t.is(findSettingsRO.ordering, 'DESC'); - t.is(findSettingsRO.ordering_field, 'port'); t.deepEqual(findSettingsRO.readonly_fields, []); t.deepEqual(findSettingsRO.sortable_by, []); t.deepEqual(findSettingsRO.autocomplete_columns, []); @@ -387,23 +379,6 @@ test.serial(`${currentTest} should throw exception when connectionId is missing` undefined, ); - const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( - undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - ); - - const createPersonalTableSettingsResponse = await request(app.getHttpServer()) - .put(`/settings/personal/${connectionId}`) - .query({ tableName: 'connection' }) - .send(createPersonalTableSettingsDTO) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - t.is(createPersonalTableSettingsResponse.status, 200); - const tableName = faker.lorem.words(1); const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) @@ -531,118 +506,6 @@ test.serial(`${currentTest} should throw exception when excluded_fields is not a } }); -test.serial(`${currentTest} should throw exception when list_fields is not an array`, async (t) => { - try { - const newConnection = getTestData(mockFactory).newConnectionToTestDB; - const { token } = await registerUserAndReturnUserInfo(app); - - const createdConnection = await request(app.getHttpServer()) - .post('/connection') - .send(newConnection) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - const connectionId = JSON.parse(createdConnection.text).id; - - const createTableSettingsDTO = mockFactory.generateTableSettingsWithoutTypes( - connectionId, - 'connection', - ['title'], - undefined, - undefined, - undefined, - undefined, - ); - - const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( - ['type'], - 3, - QueryOrderingEnum.DESC, - 'port', - ); - - const createPersonalTableSettingsResponse = await request(app.getHttpServer()) - .put(`/settings/personal/${connectionId}`) - .query({ tableName: 'connection' }) - .send(createPersonalTableSettingsDTO) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - t.is(createPersonalTableSettingsResponse.status, 200); - - const tableName = 'connection'; - const createTableSettingsResponse = await request(app.getHttpServer()) - .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) - .send(createTableSettingsDTO) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(createTableSettingsResponse.status, 400); - const createTableSettingsRO = JSON.parse(createTableSettingsResponse.text); - t.is(createTableSettingsRO.message, 'The field "list_fields" must be an array'); - } catch (e) { - console.error(e); - } -}); - -test.serial(`${currentTest} should throw exception when readonly_fields is not an array`, async (t) => { - try { - const newConnection = getTestData(mockFactory).newConnectionToTestDB; - const { token } = await registerUserAndReturnUserInfo(app); - - const createdConnection = await request(app.getHttpServer()) - .post('/connection') - .send(newConnection) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - const connectionId = JSON.parse(createdConnection.text).id; - - const createTableSettingsDTO = mockFactory.generateTableSettingsWithoutTypes( - connectionId, - 'connection', - ['title'], - undefined, - 'type', - undefined, - undefined, - ); - - const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( - undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - ); - - const createPersonalTableSettingsResponse = await request(app.getHttpServer()) - .put(`/settings/personal/${connectionId}`) - .query({ tableName: 'connection' }) - .send(createPersonalTableSettingsDTO) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - t.is(createPersonalTableSettingsResponse.status, 200); - - const tableName = 'connection'; - const createTableSettingsResponse = await request(app.getHttpServer()) - .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) - .send(createTableSettingsDTO) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(createTableSettingsResponse.status, 400); - const createTableSettingsRO = JSON.parse(createTableSettingsResponse.text); - t.is(createTableSettingsRO.message, 'The field "readonly_fields" must be an array'); - } catch (e) { - console.error(e); - } -}); - test.serial(`${currentTest} should throw exception when sortable_by is not an array`, async (t) => { try { const newConnection = getTestData(mockFactory).newConnectionToTestDB; @@ -818,62 +681,6 @@ test.serial( }, ); -test.serial(`${currentTest} should throw exception when there are no such field in the table for list`, async (t) => { - try { - const newConnection = getTestData(mockFactory).newConnectionToTestDB; - const { token } = await registerUserAndReturnUserInfo(app); - - const createdConnection = await request(app.getHttpServer()) - .post('/connection') - .send(newConnection) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - const connectionId = JSON.parse(createdConnection.text).id; - - const createTableSettingsDTO = mockFactory.generateTableSettingsWithoutTypes( - connectionId, - 'connection', - ['type'], - undefined, - undefined, - undefined, - undefined, - ); - - const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( - ['testField'], - 3, - QueryOrderingEnum.DESC, - 'port', - ); - - const createPersonalTableSettingsResponse = await request(app.getHttpServer()) - .put(`/settings/personal/${connectionId}`) - .query({ tableName: 'connection' }) - .send(createPersonalTableSettingsDTO) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - t.is(createPersonalTableSettingsResponse.status, 200); - - const tableName = 'connection'; - const createTableSettingsResponse = await request(app.getHttpServer()) - .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) - .send(createTableSettingsDTO) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(createTableSettingsResponse.status, 400); - const createTableSettingsRO = JSON.parse(createTableSettingsResponse.text); - t.is(createTableSettingsRO.message, 'There are no such fields: testField - in the table "connection"'); - } catch (e) { - console.error(e); - } -}); - test.serial( `${currentTest} should throw exception when there are no such field in the table for read only`, async (t) => { @@ -900,23 +707,6 @@ test.serial( undefined, ); - const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( - undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - ); - - const createPersonalTableSettingsResponse = await request(app.getHttpServer()) - .put(`/settings/personal/${connectionId}`) - .query({ tableName: 'connection' }) - .send(createPersonalTableSettingsDTO) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - t.is(createPersonalTableSettingsResponse.status, 200); - const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) diff --git a/backend/test/ava-tests/saas-tests/table-postgres-encrypted-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-postgres-encrypted-e2e.test.ts index 276927bc0..b036150ff 100644 --- a/backend/test/ava-tests/saas-tests/table-postgres-encrypted-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-postgres-encrypted-e2e.test.ts @@ -305,6 +305,7 @@ test.serial(`${currentTest} should return rows of selected table with search and const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -393,6 +394,7 @@ test.serial(`${currentTest} should return page of all rows with pagination page= const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -483,6 +485,7 @@ test.serial(`${currentTest} should return page of all rows with pagination page= const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -576,6 +579,7 @@ should return all found rows with pagination page=1 perPage=2`, const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -670,6 +674,7 @@ should return all found rows with pagination page=1 perPage=3`, const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -764,6 +769,7 @@ should return all found rows with sorting ids by DESC`, const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -852,6 +858,7 @@ should return all found rows with sorting ids by ASC`, const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -940,6 +947,7 @@ should return all found rows with sorting ports by DESC and with pagination page const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1027,6 +1035,7 @@ test.serial( const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1114,6 +1123,7 @@ test.serial( const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1202,6 +1212,7 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1294,6 +1305,7 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1384,6 +1396,7 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1477,6 +1490,7 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1568,6 +1582,7 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1666,6 +1681,7 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1765,6 +1781,7 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1860,6 +1877,7 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -1955,6 +1973,7 @@ test.serial(`${currentTest} should throw an exception when connection id is not const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -2031,6 +2050,7 @@ test.serial(`${currentTest} should throw an exception when connection id passed const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -2111,6 +2131,7 @@ test.serial(`${currentTest} should throw an exception when table name passed in const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') @@ -2193,6 +2214,7 @@ test.serial( const createPersonalTableSettingsResponse = await request(app.getHttpServer()) .put(`/settings/personal/${createConnectionRO.id}`) .query({ tableName: testTableName }) + .set('masterpwd', masterPwd) .send(createPersonalTableSettingsDTO) .set('Cookie', firstUserToken) .set('Content-Type', 'application/json') diff --git a/backend/test/ava-tests/saas-tests/table-settings-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-settings-e2e.test.ts index 1d9e0050a..4bcf73fb6 100644 --- a/backend/test/ava-tests/saas-tests/table-settings-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-settings-e2e.test.ts @@ -192,10 +192,6 @@ test.serial(`${currentTest} should return connection settings object`, async (t) t.is(findSettingsRO.display_name, createTableSettingsDTO.display_name); t.deepEqual(findSettingsRO.search_fields, ['title']); t.deepEqual(findSettingsRO.excluded_fields, []); - t.deepEqual(findSettingsRO.list_fields, []); - t.is(findSettingsRO.list_per_page, 3); - t.is(findSettingsRO.ordering, 'DESC'); - t.is(findSettingsRO.ordering_field, 'port'); t.deepEqual(findSettingsRO.readonly_fields, []); t.deepEqual(findSettingsRO.sortable_by, []); t.deepEqual(findSettingsRO.autocomplete_columns, []); @@ -254,10 +250,6 @@ test.serial(`${currentTest} should return created table settings`, async (t) => t.is(findSettingsRO.display_name, createTableSettingsDTO.display_name); t.deepEqual(findSettingsRO.search_fields, ['title']); t.deepEqual(findSettingsRO.excluded_fields, []); - t.deepEqual(findSettingsRO.list_fields, []); - t.is(findSettingsRO.list_per_page, 3); - t.is(findSettingsRO.ordering, 'DESC'); - t.is(findSettingsRO.ordering_field, 'port'); t.deepEqual(findSettingsRO.readonly_fields, []); t.deepEqual(findSettingsRO.sortable_by, []); t.deepEqual(findSettingsRO.autocomplete_columns, []); @@ -427,45 +419,6 @@ test.serial(`${currentTest} should throw exception when excluded_fields is not a } }); -test.serial(`${currentTest} should throw exception when list_fields is not an array`, async (t) => { - try { - const newConnection = getTestData(mockFactory).newConnectionToTestDB; - const { token } = await registerUserAndReturnUserInfo(app); - - const createdConnection = await request(app.getHttpServer()) - .post('/connection') - .send(newConnection) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - const connectionId = JSON.parse(createdConnection.text).id; - - const createTableSettingsDTO = mockFactory.generateTableSettingsWithoutTypes( - connectionId, - 'connection', - ['title'], - undefined, - undefined, - undefined, - undefined, - ); - - const tableName = 'connection'; - const createTableSettingsResponse = await request(app.getHttpServer()) - .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) - .send(createTableSettingsDTO) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(createTableSettingsResponse.status, 400); - const createTableSettingsRO = JSON.parse(createTableSettingsResponse.text); - t.is(createTableSettingsRO.message, 'The field "list_fields" must be an array'); - } catch (e) { - console.error(e); - } -}); - test.serial(`${currentTest} should throw exception when readonly_fields is not an array`, async (t) => { try { const newConnection = getTestData(mockFactory).newConnectionToTestDB; @@ -628,45 +581,6 @@ test.serial( }, ); -test.serial(`${currentTest} should throw exception when there are no such field in the table for list`, async (t) => { - try { - const newConnection = getTestData(mockFactory).newConnectionToTestDB; - const { token } = await registerUserAndReturnUserInfo(app); - - const createdConnection = await request(app.getHttpServer()) - .post('/connection') - .send(newConnection) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - const connectionId = JSON.parse(createdConnection.text).id; - - const createTableSettingsDTO = mockFactory.generateTableSettingsWithoutTypes( - connectionId, - 'connection', - ['type'], - undefined, - undefined, - undefined, - undefined, - ); - - const tableName = 'connection'; - const createTableSettingsResponse = await request(app.getHttpServer()) - .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) - .send(createTableSettingsDTO) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(createTableSettingsResponse.status, 400); - const createTableSettingsRO = JSON.parse(createTableSettingsResponse.text); - t.is(createTableSettingsRO.message, 'There are no such fields: testField - in the table "connection"'); - } catch (e) { - console.error(e); - } -}); - test.serial( `${currentTest} should throw exception when there are no such field in the table for read only`, async (t) => { @@ -709,45 +623,3 @@ test.serial( } }, ); - -test.serial( - `${currentTest} should throw exception when there are no such field in the table for sorting`, - async (t) => { - try { - const newConnection = getTestData(mockFactory).newConnectionToTestDB; - const { token } = await registerUserAndReturnUserInfo(app); - - const createdConnection = await request(app.getHttpServer()) - .post('/connection') - .send(newConnection) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - const connectionId = JSON.parse(createdConnection.text).id; - - const createTableSettingsDTO = mockFactory.generateTableSettingsWithoutTypes( - connectionId, - 'connection', - ['type'], - undefined, - undefined, - ['testField'], - undefined, - ); - - const tableName = 'connection'; - const createTableSettingsResponse = await request(app.getHttpServer()) - .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) - .send(createTableSettingsDTO) - .set('Cookie', token) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - t.is(createTableSettingsResponse.status, 400); - const createTableSettingsRO = JSON.parse(createTableSettingsResponse.text); - t.is(createTableSettingsRO.message, 'There are no such fields: testField - in the table "connection"'); - } catch (e) { - console.error(e); - } - }, -); From 25bee3a9f20e0384cc79f7ea229dfe2cc110a0e6 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Fri, 21 Nov 2025 13:36:07 +0000 Subject: [PATCH 10/14] fix: update expected row IDs in table row tests for consistency --- backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts | 2 +- backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts index 37dd59da0..8950b46b3 100644 --- a/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-oracledb-e2e.test.ts @@ -1621,7 +1621,7 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC t.is(Object.keys(getTableRowsRO.rows[1]).length, 5); t.is(getTableRowsRO.rows[0][testTableColumnName], testSearchedUserName); - t.is(getTableRowsRO.rows[0].id, 1); + t.is(getTableRowsRO.rows[0].id, 38); t.is(getTableRowsRO.rows[1][testTableColumnName], testSearchedUserName); t.is(getTableRowsRO.rows[1].id, 22); diff --git a/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts index d5758d3a9..b3e9f9956 100644 --- a/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts @@ -754,7 +754,7 @@ should return all found rows with sorting ids by DESC`, async (t) => { const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, - 42, + 20, QueryOrderingEnum.DESC, 'id', ); From d69844033d650eec0302f3ff8e439bc631119c96 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Mon, 24 Nov 2025 12:32:37 +0000 Subject: [PATCH 11/14] test: update test cases to use serial execution and fix assertions --- .../non-saas-table-oracledb-e2e.test.ts | 12 +----------- .../ava-tests/saas-tests/table-postgres-e2e.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-e2e.test.ts index 26d5eea22..88fd89beb 100644 --- a/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-e2e.test.ts +++ b/backend/test/ava-tests/non-saas-tests/non-saas-table-oracledb-e2e.test.ts @@ -1971,7 +1971,7 @@ test.serial(`${currentTest} should throw an exception when connection id passed } }); -test.only(`${currentTest} should throw an exception when table name passed in request is incorrect`, async (t) => { +test.serial(`${currentTest} should throw an exception when table name passed in request is incorrect`, async (t) => { try { const connectionToTestDB = getTestData(mockFactory).connectionToOracleDB; const firstUserToken = (await registerUserAndReturnUserInfo(app)).token; @@ -2007,16 +2007,6 @@ test.only(`${currentTest} should throw an exception when table name passed in re 'id', ); - const createPersonalTableSettingsResponse = await request(app.getHttpServer()) - .put(`/settings/personal/${createConnectionRO.id}`) - .query({ tableName: testTableName }) - .send(createPersonalTableSettingsDTO) - .set('Cookie', firstUserToken) - .set('Content-Type', 'application/json') - .set('Accept', 'application/json'); - - t.is(createPersonalTableSettingsResponse.status, 200); - const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) diff --git a/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts index b3e9f9956..9ac9d741e 100644 --- a/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-postgres-e2e.test.ts @@ -722,7 +722,7 @@ should return all found rows with pagination page=1 perPage=3`, }, ); -test.only(`${currentTest} without search and without pagination and with sorting +test.serial(`${currentTest} without search and without pagination and with sorting should return all found rows with sorting ids by DESC`, async (t) => { try { const connectionToTestDB = getTestData(mockFactory).connectionToPostgres; @@ -796,7 +796,7 @@ should return all found rows with sorting ids by DESC`, async (t) => { t.is(Object.keys(getTableRowsRO.rows[1]).length, 5); t.is(getTableRowsRO.rows[0].id, 42); t.is(getTableRowsRO.rows[1].id, 41); - t.is(getTableRowsRO.rows[41].id, 1); + t.is(getTableRowsRO.rows[19].id, 23); t.is(typeof getTableRowsRO.primaryColumns, 'object'); t.is(getTableRowsRO.primaryColumns[0].hasOwnProperty('column_name'), true); From 69cb6f37e3f0b4b006381f0fa3ecf25a603bfb43 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Fri, 5 Dec 2025 15:11:21 +0000 Subject: [PATCH 12/14] Refactor ClickHouse E2E tests to include personal table settings updates and improve CSV file handling in DynamoDB tests --- .../table-clickhouse-agent-e2e.test.ts | 418 ++++++++++++++---- .../saas-tests/table-clickhouse-e2e.test.ts | 418 ++++++++++++++---- .../saas-tests/table-dynamodb-e2e.test.ts | 19 +- 3 files changed, 688 insertions(+), 167 deletions(-) diff --git a/backend/test/ava-tests/saas-tests/table-clickhouse-agent-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-clickhouse-agent-e2e.test.ts index b15cb087e..5a4247e37 100644 --- a/backend/test/ava-tests/saas-tests/table-clickhouse-agent-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-clickhouse-agent-e2e.test.ts @@ -262,16 +262,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -333,16 +346,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -406,16 +432,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -483,16 +522,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -560,16 +612,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -637,16 +702,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -708,16 +786,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -779,16 +870,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -849,16 +953,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -919,16 +1036,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -990,16 +1120,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1065,16 +1208,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1138,16 +1294,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1214,16 +1383,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1288,16 +1470,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1369,16 +1564,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1454,16 +1662,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1536,16 +1757,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1614,16 +1848,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1692,16 +1939,29 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1750,10 +2010,6 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -1813,10 +2069,6 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -1877,10 +2129,6 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3566,10 +3814,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3619,16 +3863,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3681,16 +3938,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3781,10 +4051,6 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, diff --git a/backend/test/ava-tests/saas-tests/table-clickhouse-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-clickhouse-e2e.test.ts index 6d79a818e..5b8e57ec1 100644 --- a/backend/test/ava-tests/saas-tests/table-clickhouse-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-clickhouse-e2e.test.ts @@ -251,16 +251,29 @@ test.serial(`${currentTest} should return rows of selected table with search and ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -323,16 +336,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -397,16 +423,29 @@ test.serial(`${currentTest} should return page of all rows with pagination page= ['id'], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -475,16 +514,29 @@ should return all found rows with pagination page=1 perPage=2`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -553,16 +605,29 @@ should return all found rows with pagination page=1 perPage=3`, [testTableColumnName], undefined, undefined, - 3, undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, undefined, undefined, ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -631,16 +696,29 @@ should return all found rows with sorting ids by DESC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -703,16 +781,29 @@ should return all found rows with sorting ids by ASC`, [testTableColumnName], undefined, undefined, - 42, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 42, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -775,16 +866,29 @@ should return all found rows with sorting ports by DESC and with pagination page [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -846,16 +950,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -917,16 +1034,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -989,16 +1119,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1065,16 +1208,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1139,16 +1295,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1216,16 +1385,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and ASC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.ASC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.ASC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1291,16 +1473,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1373,16 +1568,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1459,16 +1667,29 @@ should return all found rows with search, pagination: page=1, perPage=10 and DES [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1542,16 +1763,29 @@ should return all found rows with search, pagination: page=2, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1621,16 +1855,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1700,10 +1947,6 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -1759,10 +2002,6 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -1823,10 +2062,6 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -1888,16 +2123,29 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3693,10 +3941,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3749,16 +3993,29 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3814,16 +4071,29 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) = [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -3917,10 +4187,6 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, diff --git a/backend/test/ava-tests/saas-tests/table-dynamodb-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-dynamodb-e2e.test.ts index 58be837dc..efaac9294 100644 --- a/backend/test/ava-tests/saas-tests/table-dynamodb-e2e.test.ts +++ b/backend/test/ava-tests/saas-tests/table-dynamodb-e2e.test.ts @@ -21,6 +21,7 @@ import { TestUtils } from '../../utils/test.utils.js'; import { ValidationException } from '../../../src/exceptions/custom-exceptions/validation-exception.js'; import { ValidationError } from 'class-validator'; import fs from 'fs'; +import os from 'os'; import path from 'path'; import { fileURLToPath } from 'url'; import { join } from 'path'; @@ -3809,12 +3810,8 @@ test.serial(`${currentTest} should return csv file with table data`, async (t) = } t.is(getTableCsvResponse.status, 201); const fileName = `${testTableName}.csv`; - const downloadedFilePatch = join(__dirname, 'response-files', fileName); + const downloadedFilePatch = join(os.tmpdir(), fileName); - const dir = join(__dirname, 'response-files'); - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir); - } // eslint-disable-next-line security/detect-non-literal-fs-filename fs.writeFileSync(downloadedFilePatch, getTableCsvResponse.body); @@ -3897,12 +3894,8 @@ with search and pagination: page=1, perPage=2 and DESC sorting`, } t.is(getTableCsvResponse.status, 201); const fileName = `${testTableName}.csv`; - const downloadedFilePatch = join(__dirname, 'response-files', fileName); + const downloadedFilePatch = join(os.tmpdir(), fileName); - const dir = join(__dirname, 'response-files'); - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir); - } // eslint-disable-next-line security/detect-non-literal-fs-filename fs.writeFileSync(downloadedFilePatch, getTableCsvResponse.body); @@ -3981,12 +3974,8 @@ test.skip(`${currentTest} should import csv file with table data`, async (t) => } t.is(getTableCsvResponse.status, 201); const fileName = `${testTableName}.csv`; - const downloadedFilePatch = join(__dirname, 'response-files', fileName); + const downloadedFilePatch = join(os.tmpdir(), fileName); - const dir = join(__dirname, 'response-files'); - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir); - } // eslint-disable-next-line security/detect-non-literal-fs-filename fs.writeFileSync(downloadedFilePatch, getTableCsvResponse.body); // eslint-disable-next-line security/detect-non-literal-fs-filename From 1903482044cb4a4d188a18847b66223c56f5eb8f Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Wed, 17 Dec 2025 15:15:22 +0000 Subject: [PATCH 13/14] fix: update import path for QueryOrderingEnum in table-settings.ds.builder.ts --- .../data-structures-builders/table-settings.ds.builder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-code/src/helpers/data-structures-builders/table-settings.ds.builder.ts b/shared-code/src/helpers/data-structures-builders/table-settings.ds.builder.ts index e037f975e..876feb0b7 100644 --- a/shared-code/src/helpers/data-structures-builders/table-settings.ds.builder.ts +++ b/shared-code/src/helpers/data-structures-builders/table-settings.ds.builder.ts @@ -1,5 +1,5 @@ import { TableSettingsDS } from '../../data-access-layer/shared/data-structures/table-settings.ds.js'; -import { QueryOrderingEnum } from '../../data-access-layer/shared/enums/query-ordering.enum.js'; +import { QueryOrderingEnum } from '../../shared/enums/query-ordering.enum.js'; type CommonTableSettingsInput = { table_name: string; From 3937265192781e6a7c2ce503c9773c881c4b7251 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Mon, 5 Jan 2026 10:12:42 +0000 Subject: [PATCH 14/14] refactor: reorganize imports and add new modules for S3 widget and personal table settings --- backend/src/app.module.ts | 2 + backend/src/entities/ai/ai.service.ts | 143 ++++++---------- .../use-cases/get-s3-file-url.use.case.ts | 153 ++++++------------ .../shared-jobs/shared-jobs.service.ts | 2 +- 4 files changed, 103 insertions(+), 197 deletions(-) diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index e3f2f7449..b61b65130 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -86,6 +86,8 @@ import { PersonalTableSettingsModule } from './entities/table-settings/personal- TableCategoriesModule, UserSecretModule, SignInAuditModule, + PersonalTableSettingsModule, + S3WidgetModule, ], controllers: [AppController], providers: [ diff --git a/backend/src/entities/ai/ai.service.ts b/backend/src/entities/ai/ai.service.ts index dd172015c..c6465bf7f 100644 --- a/backend/src/entities/ai/ai.service.ts +++ b/backend/src/entities/ai/ai.service.ts @@ -1,18 +1,14 @@ -import { Injectable } from "@nestjs/common"; -import { QueryOrderingEnum } from "../../enums/query-ordering.enum.js"; -import { WidgetTypeEnum } from "../../enums/widget-type.enum.js"; -import { checkFieldAutoincrement } from "../../helpers/check-field-autoincrement.js"; -import { TableSettingsEntity } from "../table-settings/table-settings.entity.js"; -import { TableWidgetEntity } from "../widget/table-widget.entity.js"; -import { TableInformation } from "./ai-data-entities/types/ai-module-types.js"; -import { AmazonBedrockAiProvider } from "./amazon-bedrock/amazon-bedrock.ai.provider.js"; +import { Injectable } from '@nestjs/common'; +import { WidgetTypeEnum } from '../../enums/widget-type.enum.js'; +import { checkFieldAutoincrement } from '../../helpers/check-field-autoincrement.js'; +import { TableWidgetEntity } from '../widget/table-widget.entity.js'; +import { TableInformation } from './ai-data-entities/types/ai-module-types.js'; +import { AmazonBedrockAiProvider } from './amazon-bedrock/amazon-bedrock.ai.provider.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; interface AIGeneratedTableSettings { table_name: string; display_name: string; - list_fields: string[]; - ordering_field: string | null; - ordering: "ASC" | "DESC"; search_fields: string[]; readonly_fields: string[]; columns_view: string[]; @@ -42,47 +38,39 @@ export class AiService { } private buildPrompt(tablesInformation: Array): string { - const widgetTypes = Object.values(WidgetTypeEnum).join(", "); + const widgetTypes = Object.values(WidgetTypeEnum).join(', '); const tablesDescription = tablesInformation .map((table) => { const columns = table.structure .map( (col) => - ` - ${col.column_name}: ${col.data_type}${col.allow_null ? " (nullable)" : ""}${checkFieldAutoincrement(col.column_default, col.extra) ? " (auto_increment)" : ""}`, + ` - ${col.column_name}: ${col.data_type}${col.allow_null ? ' (nullable)' : ''}${checkFieldAutoincrement(col.column_default, col.extra) ? ' (auto_increment)' : ''}`, ) - .join("\n"); - const primaryKeys = table.primaryColumns - .map((pk) => pk.column_name) - .join(", "); + .join('\n'); + const primaryKeys = table.primaryColumns.map((pk) => pk.column_name).join(', '); const foreignKeys = table.foreignKeys - .map( - (fk) => - ` - ${fk.column_name} -> ${fk.referenced_table_name}.${fk.referenced_column_name}`, - ) - .join("\n"); + .map((fk) => ` - ${fk.column_name} -> ${fk.referenced_table_name}.${fk.referenced_column_name}`) + .join('\n'); return ` Table: ${table.table_name} - Primary Keys: ${primaryKeys || "none"} + Primary Keys: ${primaryKeys || 'none'} Columns: ${columns} Foreign Keys: -${foreignKeys || " none"}`; +${foreignKeys || ' none'}`; }) - .join("\n\n"); + .join('\n\n'); return `You are a database administration assistant. Analyze the following database tables and generate optimal settings for displaying and managing them in a web admin panel. For each table, provide: 1. display_name: A human-readable name for the table -2. list_fields: Columns to display in the table list view (most important columns first, max 5-7 columns) -3. ordering_field: The best column to sort by default (usually created_at, id, or a timestamp) -4. ordering: ASC or DESC -5. search_fields: Columns that should be searchable -6. readonly_fields: Columns that should not be editable (like auto_increment, timestamps) -7. columns_view: All columns in preferred display order -8. widgets: For each column, suggest the best widget type from: ${widgetTypes} +2. search_fields: Columns that should be searchable (text fields like name, email, title) +3. readonly_fields: Columns that should not be editable (like auto_increment, timestamps) +4. columns_view: All columns in preferred display order +5. widgets: For each column, suggest the best widget type from: ${widgetTypes} Available widget types and when to use them: - Password: for password fields @@ -118,9 +106,6 @@ Respond ONLY with valid JSON in this exact format (no markdown, no explanations) { "table_name": "table_name", "display_name": "Human Readable Name", - "list_fields": ["col1", "col2"], - "ordering_field": "created_at", - "ordering": "DESC", "search_fields": ["name", "email"], "readonly_fields": ["id", "created_at"], "columns_view": ["id", "name", "email", "created_at"], @@ -139,12 +124,12 @@ Respond ONLY with valid JSON in this exact format (no markdown, no explanations) private parseAIResponse(aiResponse: string): AIResponse { let cleanedResponse = aiResponse.trim(); - if (cleanedResponse.startsWith("```json")) { + if (cleanedResponse.startsWith('```json')) { cleanedResponse = cleanedResponse.slice(7); - } else if (cleanedResponse.startsWith("```")) { + } else if (cleanedResponse.startsWith('```')) { cleanedResponse = cleanedResponse.slice(3); } - if (cleanedResponse.endsWith("```")) { + if (cleanedResponse.endsWith('```')) { cleanedResponse = cleanedResponse.slice(0, -3); } cleanedResponse = cleanedResponse.trim(); @@ -161,36 +146,15 @@ Respond ONLY with valid JSON in this exact format (no markdown, no explanations) tablesInformation: Array, ): Array { return aiResponse.tables.map((tableSettings) => { - const tableInfo = tablesInformation.find( - (t) => t.table_name === tableSettings.table_name, - ); - const validColumnNames = - tableInfo?.structure.map((col) => col.column_name) || []; + const tableInfo = tablesInformation.find((t) => t.table_name === tableSettings.table_name); + const validColumnNames = tableInfo?.structure.map((col) => col.column_name) || []; const settings = new TableSettingsEntity(); settings.table_name = tableSettings.table_name; settings.display_name = tableSettings.display_name; - settings.list_fields = this.filterValidColumns( - tableSettings.list_fields, - validColumnNames, - ); - settings.ordering_field = tableSettings.ordering_field; - settings.ordering = - tableSettings.ordering === "DESC" - ? QueryOrderingEnum.DESC - : QueryOrderingEnum.ASC; - settings.search_fields = this.filterValidColumns( - tableSettings.search_fields, - validColumnNames, - ); - settings.readonly_fields = this.filterValidColumns( - tableSettings.readonly_fields, - validColumnNames, - ); - settings.columns_view = this.filterValidColumns( - tableSettings.columns_view, - validColumnNames, - ); + settings.search_fields = this.filterValidColumns(tableSettings.search_fields, validColumnNames); + settings.readonly_fields = this.filterValidColumns(tableSettings.readonly_fields, validColumnNames); + settings.columns_view = this.filterValidColumns(tableSettings.columns_view, validColumnNames); settings.table_widgets = tableSettings.widgets .filter((w) => validColumnNames.includes(w.field_name)) .map((widgetData) => { @@ -206,38 +170,35 @@ Respond ONLY with valid JSON in this exact format (no markdown, no explanations) }); } - private filterValidColumns( - columns: string[], - validColumnNames: string[], - ): string[] { + private filterValidColumns(columns: string[], validColumnNames: string[]): string[] { return columns?.filter((col) => validColumnNames.includes(col)) || []; } private mapWidgetType(widgetType: string): WidgetTypeEnum | undefined { const widgetTypeMap = new Map([ - ["Password", WidgetTypeEnum.Password], - ["Boolean", WidgetTypeEnum.Boolean], - ["Date", WidgetTypeEnum.Date], - ["Time", WidgetTypeEnum.Time], - ["DateTime", WidgetTypeEnum.DateTime], - ["JSON", WidgetTypeEnum.JSON], - ["Textarea", WidgetTypeEnum.Textarea], - ["String", WidgetTypeEnum.String], - ["Readonly", WidgetTypeEnum.Readonly], - ["Number", WidgetTypeEnum.Number], - ["Select", WidgetTypeEnum.Select], - ["UUID", WidgetTypeEnum.UUID], - ["Enum", WidgetTypeEnum.Enum], - ["Foreign_key", WidgetTypeEnum.Foreign_key], - ["File", WidgetTypeEnum.File], - ["Image", WidgetTypeEnum.Image], - ["URL", WidgetTypeEnum.URL], - ["Code", WidgetTypeEnum.Code], - ["Phone", WidgetTypeEnum.Phone], - ["Country", WidgetTypeEnum.Country], - ["Color", WidgetTypeEnum.Color], - ["Range", WidgetTypeEnum.Range], - ["Timezone", WidgetTypeEnum.Timezone], + ['Password', WidgetTypeEnum.Password], + ['Boolean', WidgetTypeEnum.Boolean], + ['Date', WidgetTypeEnum.Date], + ['Time', WidgetTypeEnum.Time], + ['DateTime', WidgetTypeEnum.DateTime], + ['JSON', WidgetTypeEnum.JSON], + ['Textarea', WidgetTypeEnum.Textarea], + ['String', WidgetTypeEnum.String], + ['Readonly', WidgetTypeEnum.Readonly], + ['Number', WidgetTypeEnum.Number], + ['Select', WidgetTypeEnum.Select], + ['UUID', WidgetTypeEnum.UUID], + ['Enum', WidgetTypeEnum.Enum], + ['Foreign_key', WidgetTypeEnum.Foreign_key], + ['File', WidgetTypeEnum.File], + ['Image', WidgetTypeEnum.Image], + ['URL', WidgetTypeEnum.URL], + ['Code', WidgetTypeEnum.Code], + ['Phone', WidgetTypeEnum.Phone], + ['Country', WidgetTypeEnum.Country], + ['Color', WidgetTypeEnum.Color], + ['Range', WidgetTypeEnum.Range], + ['Timezone', WidgetTypeEnum.Timezone], ]); return widgetTypeMap.get(widgetType); } diff --git a/backend/src/entities/s3-widget/use-cases/get-s3-file-url.use.case.ts b/backend/src/entities/s3-widget/use-cases/get-s3-file-url.use.case.ts index ce097e846..b9471ec25 100644 --- a/backend/src/entities/s3-widget/use-cases/get-s3-file-url.use.case.ts +++ b/backend/src/entities/s3-widget/use-cases/get-s3-file-url.use.case.ts @@ -1,27 +1,22 @@ -import { HttpStatus, Inject, Injectable } from "@nestjs/common"; -import { HttpException } from "@nestjs/common/exceptions/http.exception.js"; -import { getDataAccessObject } from "@rocketadmin/shared-code/dist/src/data-access-layer/shared/create-data-access-object.js"; -import JSON5 from "json5"; -import AbstractUseCase from "../../../common/abstract-use.case.js"; -import { IGlobalDatabaseContext } from "../../../common/application/global-database-context.interface.js"; -import { BaseType } from "../../../common/data-injection.tokens.js"; -import { WidgetTypeEnum } from "../../../enums/index.js"; -import { Messages } from "../../../exceptions/text/messages.js"; -import { Encryptor } from "../../../helpers/encryption/encryptor.js"; -import { isConnectionTypeAgent } from "../../../helpers/index.js"; -import { - S3FileUrlResponseDs, - S3GetFileUrlDs, -} from "../application/data-structures/s3-operation.ds.js"; -import { S3WidgetParams } from "../application/data-structures/s3-widget-params.ds.js"; -import { S3HelperService } from "../s3-helper.service.js"; -import { IGetS3FileUrl } from "./s3-use-cases.interface.js"; +import { HttpStatus, Inject, Injectable } from '@nestjs/common'; +import { HttpException } from '@nestjs/common/exceptions/http.exception.js'; +import { getDataAccessObject } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/create-data-access-object.js'; +import JSON5 from 'json5'; +import AbstractUseCase from '../../../common/abstract-use.case.js'; +import { IGlobalDatabaseContext } from '../../../common/application/global-database-context.interface.js'; +import { BaseType } from '../../../common/data-injection.tokens.js'; +import { WidgetTypeEnum } from '../../../enums/index.js'; +import { Messages } from '../../../exceptions/text/messages.js'; +import { Encryptor } from '../../../helpers/encryption/encryptor.js'; +import { isConnectionTypeAgent } from '../../../helpers/index.js'; +import { S3FileUrlResponseDs, S3GetFileUrlDs } from '../application/data-structures/s3-operation.ds.js'; +import { S3WidgetParams } from '../application/data-structures/s3-widget-params.ds.js'; +import { S3HelperService } from '../s3-helper.service.js'; +import { IGetS3FileUrl } from './s3-use-cases.interface.js'; +import { buildDAOsTableSettingsDs } from '@rocketadmin/shared-code/dist/src/helpers/data-structures-builders/table-settings.ds.builder.js'; @Injectable() -export class GetS3FileUrlUseCase - extends AbstractUseCase - implements IGetS3FileUrl -{ +export class GetS3FileUrlUseCase extends AbstractUseCase implements IGetS3FileUrl { constructor( @Inject(BaseType.GLOBAL_DB_CONTEXT) protected _dbContext: IGlobalDatabaseContext, @@ -30,110 +25,70 @@ export class GetS3FileUrlUseCase super(); } - protected async implementation( - inputData: S3GetFileUrlDs, - ): Promise { - const { - connectionId, - tableName, - fieldName, - rowPrimaryKey, - userId, - masterPwd, - } = inputData; + protected async implementation(inputData: S3GetFileUrlDs): Promise { + const { connectionId, tableName, fieldName, rowPrimaryKey, userId, masterPwd } = inputData; - const user = - await this._dbContext.userRepository.findOneUserByIdWithCompany(userId); + const user = await this._dbContext.userRepository.findOneUserByIdWithCompany(userId); if (!user || !user.company) { - throw new HttpException( - { message: Messages.USER_NOT_FOUND_OR_NOT_IN_COMPANY }, - HttpStatus.NOT_FOUND, - ); + throw new HttpException({ message: Messages.USER_NOT_FOUND_OR_NOT_IN_COMPANY }, HttpStatus.NOT_FOUND); } - const connection = - await this._dbContext.connectionRepository.findAndDecryptConnection( - connectionId, - masterPwd, - ); + const connection = await this._dbContext.connectionRepository.findAndDecryptConnection(connectionId, masterPwd); if (!connection) { - throw new HttpException( - { message: Messages.CONNECTION_NOT_FOUND }, - HttpStatus.BAD_REQUEST, - ); + throw new HttpException({ message: Messages.CONNECTION_NOT_FOUND }, HttpStatus.BAD_REQUEST); } - const foundTableWidgets = - await this._dbContext.tableWidgetsRepository.findTableWidgets( - connectionId, - tableName, - ); + const foundTableWidgets = await this._dbContext.tableWidgetsRepository.findTableWidgets(connectionId, tableName); const widget = foundTableWidgets.find((w) => w.field_name === fieldName); if (!widget || widget.widget_type !== WidgetTypeEnum.S3) { - throw new HttpException( - { message: "S3 widget not configured for this field" }, - HttpStatus.BAD_REQUEST, - ); + throw new HttpException({ message: 'S3 widget not configured for this field' }, HttpStatus.BAD_REQUEST); } const params: S3WidgetParams = - typeof widget.widget_params === "string" - ? JSON5.parse(widget.widget_params) - : widget.widget_params; + typeof widget.widget_params === 'string' ? JSON5.parse(widget.widget_params) : widget.widget_params; // Fetch the row from database to get the actual file key const dao = getDataAccessObject(connection); let userEmail: string; if (isConnectionTypeAgent(connection.type)) { - userEmail = - await this._dbContext.userRepository.getUserEmailOrReturnNull(userId); + userEmail = await this._dbContext.userRepository.getUserEmailOrReturnNull(userId); } - const tableSettings = - await this._dbContext.tableSettingsRepository.findTableSettingsPure( - connectionId, - tableName, - ); + const tableSettings = await this._dbContext.tableSettingsRepository.findTableSettingsPure(connectionId, tableName); + const personalTableSettings = await this._dbContext.personalTableSettingsRepository.findUserTableSettings( + userId, + connectionId, + tableName, + ); const rowData = await dao.getRowByPrimaryKey( tableName, rowPrimaryKey, - tableSettings, + buildDAOsTableSettingsDs(tableSettings, personalTableSettings), userEmail, ); if (!rowData) { - throw new HttpException( - { message: Messages.ROW_PRIMARY_KEY_NOT_FOUND }, - HttpStatus.NOT_FOUND, - ); + throw new HttpException({ message: Messages.ROW_PRIMARY_KEY_NOT_FOUND }, HttpStatus.NOT_FOUND); } const fileKey = rowData[fieldName] as string; if (!fileKey) { - throw new HttpException( - { message: "File key not found in row" }, - HttpStatus.NOT_FOUND, - ); + throw new HttpException({ message: 'File key not found in row' }, HttpStatus.NOT_FOUND); } - const accessKeySecret = - await this._dbContext.userSecretRepository.findSecretBySlugAndCompanyId( - params.aws_access_key_id_secret_name, - user.company.id, - ); + const accessKeySecret = await this._dbContext.userSecretRepository.findSecretBySlugAndCompanyId( + params.aws_access_key_id_secret_name, + user.company.id, + ); - const secretKeySecret = - await this._dbContext.userSecretRepository.findSecretBySlugAndCompanyId( - params.aws_secret_access_key_secret_name, - user.company.id, - ); + const secretKeySecret = await this._dbContext.userSecretRepository.findSecretBySlugAndCompanyId( + params.aws_secret_access_key_secret_name, + user.company.id, + ); if (!accessKeySecret || !secretKeySecret) { - throw new HttpException( - { message: "AWS credentials secrets not found" }, - HttpStatus.NOT_FOUND, - ); + throw new HttpException({ message: 'AWS credentials secrets not found' }, HttpStatus.NOT_FOUND); } let accessKeyId = Encryptor.decryptData(accessKeySecret.encryptedValue); @@ -143,25 +98,13 @@ export class GetS3FileUrlUseCase accessKeyId = Encryptor.decryptDataMasterPwd(accessKeyId, masterPwd); } if (secretKeySecret.masterEncryption && masterPwd) { - secretAccessKey = Encryptor.decryptDataMasterPwd( - secretAccessKey, - masterPwd, - ); + secretAccessKey = Encryptor.decryptDataMasterPwd(secretAccessKey, masterPwd); } - const client = this.s3Helper.createS3Client( - accessKeyId, - secretAccessKey, - params.region || "us-east-1", - ); + const client = this.s3Helper.createS3Client(accessKeyId, secretAccessKey, params.region || 'us-east-1'); const expiresIn = 3600; - const url = await this.s3Helper.getSignedGetUrl( - client, - params.bucket, - fileKey, - expiresIn, - ); + const url = await this.s3Helper.getSignedGetUrl(client, params.bucket, fileKey, expiresIn); return { url, key: fileKey, expiresIn }; } diff --git a/backend/src/entities/shared-jobs/shared-jobs.service.ts b/backend/src/entities/shared-jobs/shared-jobs.service.ts index 830d09e17..2d4ab3196 100644 --- a/backend/src/entities/shared-jobs/shared-jobs.service.ts +++ b/backend/src/entities/shared-jobs/shared-jobs.service.ts @@ -13,10 +13,10 @@ import { isTest } from '../../helpers/app/is-test.js'; import { ValidationHelper } from '../../helpers/validators/validation-helper.js'; import { AiService } from '../ai/ai.service.js'; import { ConnectionEntity } from '../connection/connection.entity.js'; -import { TableSettingsEntity } from '../table-settings/table-settings.entity.js'; import { buildEmptyTableSettings } from '../table-settings/common-table-settings/utils/build-empty-table-settings.js'; import { buildNewTableSettingsEntity } from '../table-settings/common-table-settings/utils/build-new-table-settings-entity.js'; import { TableWidgetEntity } from '../widget/table-widget.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; @Injectable() export class SharedJobsService {