diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index a89a5f801..b61b65130 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -1,46 +1,47 @@ -import { MiddlewareConsumer, Module, NestModule } from "@nestjs/common"; -import { APP_GUARD, APP_INTERCEPTOR } from "@nestjs/core"; -import { ScheduleModule } from "@nestjs/schedule"; -import { ThrottlerGuard, ThrottlerModule } from "@nestjs/throttler"; -import { AppController } from "./app.controller.js"; -import { GlobalDatabaseContext } from "./common/application/global-database-context.js"; -import { BaseType, UseCaseType } from "./common/data-injection.tokens.js"; -import { AIModule } from "./entities/ai/ai.module.js"; -import { ApiKeyModule } from "./entities/api-key/api-key.module.js"; -import { CompanyFaviconModule } from "./entities/company-favicon/company-favicon.module.js"; -import { CompanyInfoModule } from "./entities/company-info/company-info.module.js"; -import { CompanyLogoModule } from "./entities/company-logo/company-logo.module.js"; -import { CompanyTabTitleModule } from "./entities/company-tab-title/company-tab-title.module.js"; -import { ConnectionModule } from "./entities/connection/connection.module.js"; -import { ConnectionPropertiesModule } from "./entities/connection-properties/connection-properties.module.js"; -import { ConversionModule } from "./entities/convention/conversion.module.js"; -import { CronJobsModule } from "./entities/cron-jobs/cron-jobs.module.js"; -import { CustomFieldModule } from "./entities/custom-field/custom-field.module.js"; -import { DemoDataModule } from "./entities/demo-data/demo-deta.module.js"; -import { EmailModule } from "./entities/email/email/email.module.js"; -import { GroupModule } from "./entities/group/group.module.js"; -import { LoggingModule } from "./entities/logging/logging.module.js"; -import { PermissionModule } from "./entities/permission/permission.module.js"; -import { S3WidgetModule } from "./entities/s3-widget/s3-widget.module.js"; -import { SharedJobsModule } from "./entities/shared-jobs/shared-jobs.module.js"; -import { TableModule } from "./entities/table/table.module.js"; -import { TableTriggersModule } from "./entities/table-actions/table-action-rules-module/action-rules.module.js"; -import { TableActionModule } from "./entities/table-actions/table-actions-module/table-action.module.js"; -import { TableCategoriesModule } from "./entities/table-categories/table-categories.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 { UserModule } from "./entities/user/user.module.js"; -import { UserActionModule } from "./entities/user-actions/user-action.module.js"; -import { UserSecretModule } from "./entities/user-secret/user-secret.module.js"; -import { SignInAuditModule } from "./entities/user-sign-in-audit/sign-in-audit.module.js"; -import { TableWidgetModule } from "./entities/widget/table-widget.module.js"; -import { TimeoutInterceptor } from "./interceptors/index.js"; -import { SaaSGatewayModule } from "./microservices/gateways/saas-gateway.ts/saas-gateway.module.js"; -import { SaasModule } from "./microservices/saas-microservice/saas.module.js"; -import { AppLoggerMiddleware } from "./middlewares/logging-middleware/app-logger-middlewate.js"; -import { DatabaseModule } from "./shared/database/database.module.js"; -import { GetHelloUseCase } from "./use-cases-app/get-hello.use.case.js"; +import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common'; +import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core'; +import { ScheduleModule } from '@nestjs/schedule'; +import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler'; +import { AppController } from './app.controller.js'; +import { GlobalDatabaseContext } from './common/application/global-database-context.js'; +import { BaseType, UseCaseType } from './common/data-injection.tokens.js'; +import { AIModule } from './entities/ai/ai.module.js'; +import { ApiKeyModule } from './entities/api-key/api-key.module.js'; +import { CompanyFaviconModule } from './entities/company-favicon/company-favicon.module.js'; +import { CompanyInfoModule } from './entities/company-info/company-info.module.js'; +import { CompanyLogoModule } from './entities/company-logo/company-logo.module.js'; +import { CompanyTabTitleModule } from './entities/company-tab-title/company-tab-title.module.js'; +import { ConnectionModule } from './entities/connection/connection.module.js'; +import { ConnectionPropertiesModule } from './entities/connection-properties/connection-properties.module.js'; +import { ConversionModule } from './entities/convention/conversion.module.js'; +import { CronJobsModule } from './entities/cron-jobs/cron-jobs.module.js'; +import { CustomFieldModule } from './entities/custom-field/custom-field.module.js'; +import { DemoDataModule } from './entities/demo-data/demo-deta.module.js'; +import { EmailModule } from './entities/email/email/email.module.js'; +import { GroupModule } from './entities/group/group.module.js'; +import { LoggingModule } from './entities/logging/logging.module.js'; +import { PermissionModule } from './entities/permission/permission.module.js'; +import { S3WidgetModule } from './entities/s3-widget/s3-widget.module.js'; +import { SharedJobsModule } from './entities/shared-jobs/shared-jobs.module.js'; +import { TableModule } from './entities/table/table.module.js'; +import { TableTriggersModule } from './entities/table-actions/table-action-rules-module/action-rules.module.js'; +import { TableActionModule } from './entities/table-actions/table-actions-module/table-action.module.js'; +import { TableCategoriesModule } from './entities/table-categories/table-categories.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/common-table-settings/table-settings.module.js'; +import { UserModule } from './entities/user/user.module.js'; +import { UserActionModule } from './entities/user-actions/user-action.module.js'; +import { UserSecretModule } from './entities/user-secret/user-secret.module.js'; +import { SignInAuditModule } from './entities/user-sign-in-audit/sign-in-audit.module.js'; +import { TableWidgetModule } from './entities/widget/table-widget.module.js'; +import { TimeoutInterceptor } from './interceptors/index.js'; +import { SaaSGatewayModule } from './microservices/gateways/saas-gateway.ts/saas-gateway.module.js'; +import { SaasModule } from './microservices/saas-microservice/saas.module.js'; +import { AppLoggerMiddleware } from './middlewares/logging-middleware/app-logger-middlewate.js'; +import { DatabaseModule } from './shared/database/database.module.js'; +import { GetHelloUseCase } from './use-cases-app/get-hello.use.case.js'; +import { PersonalTableSettingsModule } from './entities/table-settings/personal-table-settings/personal-table-settings.module.js'; @Module({ imports: [ @@ -85,8 +86,8 @@ import { GetHelloUseCase } from "./use-cases-app/get-hello.use.case.js"; TableCategoriesModule, UserSecretModule, SignInAuditModule, + PersonalTableSettingsModule, S3WidgetModule, - AIModule, ], controllers: [AppController], providers: [ @@ -110,6 +111,6 @@ import { GetHelloUseCase } from "./use-cases-app/get-hello.use.case.js"; }) export class ApplicationModule implements NestModule { configure(consumer: MiddlewareConsumer): void { - consumer.apply(AppLoggerMiddleware).forRoutes("*"); + consumer.apply(AppLoggerMiddleware).forRoutes('*'); } } diff --git a/backend/src/common/application/global-database-context.interface.ts b/backend/src/common/application/global-database-context.interface.ts index dc354ee67..820f3e32c 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'; @@ -54,6 +54,8 @@ import { SecretAccessLogEntity } from '../../entities/secret-access-log/secret-a import { ISecretAccessLogRepository } from '../../entities/secret-access-log/repository/secret-access-log-repository.interface.js'; import { SignInAuditEntity } from '../../entities/user-sign-in-audit/sign-in-audit.entity.js'; import { ISignInAuditRepository } from '../../entities/user-sign-in-audit/repository/sign-in-audit-repository.interface.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; @@ -92,4 +94,5 @@ export interface IGlobalDatabaseContext extends IDatabaseContext { userSecretRepository: Repository & IUserSecretRepository; secretAccessLogRepository: Repository & ISecretAccessLogRepository; signInAuditRepository: Repository & ISignInAuditRepository; + personalTableSettingsRepository: Repository & IPersonalTableSettingsRepository; } diff --git a/backend/src/common/application/global-database-context.ts b/backend/src/common/application/global-database-context.ts index 73d770c61..221ef343d 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'; @@ -99,6 +99,9 @@ import { secretAccessLogRepositoryExtension } from '../../entities/secret-access import { SignInAuditEntity } from '../../entities/user-sign-in-audit/sign-in-audit.entity.js'; import { ISignInAuditRepository } from '../../entities/user-sign-in-audit/repository/sign-in-audit-repository.interface.js'; import { signInAuditCustomRepositoryExtension } from '../../entities/user-sign-in-audit/repository/sign-in-audit-custom-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 { @@ -140,6 +143,7 @@ export class GlobalDatabaseContext implements IGlobalDatabaseContext { private _userSecretRepository: Repository & IUserSecretRepository; private _secretAccessLogRepository: Repository & ISecretAccessLogRepository; private _signInAuditRepository: Repository & ISignInAuditRepository; + private _personalTableSettingsRepository: Repository & IPersonalTableSettingsRepository; public constructor( @Inject(BaseType.DATA_SOURCE) @@ -237,6 +241,9 @@ export class GlobalDatabaseContext implements IGlobalDatabaseContext { this._signInAuditRepository = this.appDataSource .getRepository(SignInAuditEntity) .extend(signInAuditCustomRepositoryExtension); + this._personalTableSettingsRepository = this.appDataSource + .getRepository(PersonalTableSettingsEntity) + .extend(personalTableSettingsCustomRepositoryExtension); } public get userRepository(): Repository & IUserRepository { @@ -283,7 +290,8 @@ export class GlobalDatabaseContext implements IGlobalDatabaseContext { return this._userInvitationRepository; } - public get connectionPropertiesRepository(): Repository & IConnectionPropertiesRepository { + public get connectionPropertiesRepository(): Repository & + IConnectionPropertiesRepository { return this._connectionPropertiesRepository; } @@ -383,6 +391,11 @@ export class GlobalDatabaseContext implements IGlobalDatabaseContext { return this._signInAuditRepository; } + 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 4a133f5d8..0f9c43065 100644 --- a/backend/src/common/data-injection.tokens.ts +++ b/backend/src/common/data-injection.tokens.ts @@ -1,179 +1,183 @@ export enum BaseType { - GLOBAL_DB_CONTEXT = "GLOBAL_DB_CONTEXT", - DATA_SOURCE = "DATA_SOURCE", - NUNJUCKS = "NUNJUCKS", + GLOBAL_DB_CONTEXT = 'GLOBAL_DB_CONTEXT', + DATA_SOURCE = 'DATA_SOURCE', + NUNJUCKS = 'NUNJUCKS', } export enum UseCaseType { - DELETE_USER_ACCOUNT = "DELETE_USER_ACCOUNT", - FIND_USER = "FIND_USER", - USUAL_LOGIN = "USUAL_LOGIN", - LOG_OUT = "LOG_OUT", - CHANGE_USUAL_PASSWORD = "CHANGE_USUAL_PASSWORD", - VERIFY_EMAIL = "VERIFY_EMAIL", - VERIFY_RESET_USER_PASSWORD = "VERIFY_RESET_USER_PASSWORD", - REQUEST_RESET_USER_PASSWORD = "REQUEST_RESET_USER_PASSWORD", - REQUEST_CHANGE_USER_EMAIL = "REQUEST_CHANGE_USER_EMAIL", - VERIFY_EMAIL_CHANGE = "VERIFY_EMAIL_CHANGE", - VERIFY_EMAIL_REQUEST = "VERIFY_EMAIL_REQUEST", - CHANGE_USER_NAME = "CHANGE_USER_NAME", - GENERATE_OTP = "GENERATE_OTP", - VERIFY_OTP = "VERIFY_OTP", - OTP_LOGIN = "OTP_LOGIN", - DISABLE_OTP = "DISABLE_OTP", - SAVE_USER_SESSION_SETTINGS = "SAVE_USER_SESSION_SETTINGS", - GET_USER_SESSION_SETTINGS = "GET_USER_SESSION_SETTINGS", - TOGGLE_TEST_CONNECTIONS_DISPLAY_MODE = "TOGGLE_TEST_CONNECTIONS_DISPLAY_MODE", - - FIND_CONNECTIONS = "FIND_CONNECTIONS", - FIND_USERS_IN_CONNECTION = "FIND_USERS_IN_CONNECTION", - FIND_CONNECTION = "FIND_CONNECTION", - CREATE_CONNECTION = "CREATE_CONNECTION", - UPDATE_CONNECTION = "UPDATE_CONNECTION", - DELETE_CONNECTION = "DELETE_CONNECTION", - DELETE_GROUP_FROM_CONNECTION = "DELETE_GROUP_FROM_CONNECTION", - CREATE_GROUP_IN_CONNECTION = "CREATE_GROUP_IN_CONNECTION", - GET_USER_GROUPS_IN_CONNECTION = "GET_USER_GROUPS_IN_CONNECTION", - GET_PERMISSIONS_FOR_GROUP_IN_CONNECTION = "GET_PERMISSIONS_FOR_GROUP_IN_CONNECTION", - GET_USER_PERMISSIONS_FOR_GROUP_IN_CONNECTION = "GET_USER_PERMISSIONS_FOR_GROUP_IN_CONNECTION", - TEST_CONNECTION_USE_CASE = "TEST_CONNECTION_USE_CASE", - UPDATE_CONNECTION_MASTER_PASSWORD = "UPDATE_CONNECTION_MASTER_PASSWORD", - RESTORE_CONNECTION = "RESTORE_CONNECTION", - VALIDATE_CONNECTION_TOKEN = "VALIDATE_CONNECTION_TOKEN", - REFRESH_CONNECTION_AGENT_TOKEN = "REFRESH_CONNECTION_AGENT_TOKEN", - VALIDATE_CONNECTION_MASTER_PASSWORD = "VALIDATE_CONNECTION_MASTER_PASSWORD", - UNFREEZE_CONNECTION = "UNFREEZE_CONNECTION", - - FIND_ALL_USER_GROUPS = "FIND_ALL_USER_GROUPS", - INVITE_USER_IN_GROUP = "INVITE_USER_IN_GROUP", - FIND_ALL_USERS_IN_GROUP = "FIND_ALL_USERS_IN_GROUP", - REMOVE_USER_FROM_GROUP = "REMOVE_USER_FROM_GROUP", - DELETE_GROUP = "DELETE_GROUP", - UPDATE_GROUP_TITLE = "UPDATE_GROUP_TITLE", - - FIND_CONNECTION_PROPERTIES = "FIND_CONNECTION_PROPERTIES", - CREATE_CONNECTION_PROPERTIES = "CREATE_CONNECTION_PROPERTIES", - UPDATE_CONNECTION_PROPERTIES = "UPDATE_CONNECTION_PROPERTIES", - DELETE_CONNECTION_PROPERTIES = "DELETE_CONNECTION_PROPERTIES", - - GET_CONVERSIONS = "GET_CONVERSIONS", - - GET_CUSTOM_FIELDS = "GET_CUSTOM_FIELDS", - CREATE_CUSTOM_FIELDS = "CREATE_CUSTOM_FIELDS", - UPDATE_CUSTOM_FIELDS = "UPDATE_CUSTOM_FIELDS", - DELETE_CUSTOM_FIELD = "DELETE_CUSTOM_FIELD", - - CREATE_OR_UPDATE_PERMISSIONS = "CREATE_OR_UPDATE_PERMISSIONS", - - FIND_LOGS = "FIND_LOGS", - EXPORT_LOGS_AS_CSV = "EXPORT_LOGS_AS_CSV", - - FIND_TABLE_SETTINGS = "FIND_TABLE_SETTINGS", - CREATE_TABLE_SETTINGS = "CREATE_TABLE_SETTINGS", - UPDATE_TABLE_SETTINGS = "UPDATE_TABLE_SETTINGS", - DELETE_TABLE_SETTINGS = "DELETE_TABLE_SETTINGS", - - GET_HELLO = "GET_HELLO", - - CREATE_USER_ACTION = "CREATE_USER_ACTION", - - CHECK_USER_LOGS_AND_UPDATE_ACTIONS = "CHECK_USER_LOGS_AND_UPDATE_ACTIONS", - CHECK_USER_ACTIONS_AND_MAIL_USERS = "CHECK_USER_ACTIONS_AND_MAIL_USERS", - - FIND_TABLE_WIDGETS = "FIND_TABLE_WIDGETS", - CREATE_UPDATE_DELETE_TABLE_WIDGETS = "CREATE_UPDATE_DELETE_TABLE_WIDGETS", - - FIND_TABLES_IN_CONNECTION = "FIND_TABLES_IN_CONNECTION", - FIND_TABLES_IN_CONNECTION_V2 = "FIND_TABLES_IN_CONNECTION_V2", - GET_ALL_TABLE_ROWS = "GET_ALL_TABLE_ROWS", - GET_TABLE_STRUCTURE = "GET_TABLE_STRUCTURE", - ADD_ROW_IN_TABLE = "ADD_ROW_IN_TABLE", - UPDATE_ROW_IN_TABLE = "UPDATE_ROW_IN_TABLE", - BULK_UPDATE_ROWS_IN_TABLE = "BULK_UPDATE_ROWS_IN_TABLE", - DELETE_ROW_FROM_TABLE = "DELETE_ROW_FROM_TABLE", - DELETE_ROWS_FROM_TABLE = "DELETE_ROWS_FROM_TABLE", - GET_ROW_BY_PRIMARY_KEY = "GET_ROW_BY_PRIMARY_KEY", - EXPORT_CSV_FROM_TABLE = "EXPORT_CSV_FROM_TABLE", - IMPORT_CSV_TO_TABLE = "IMPORT_CSV_TO_TABLE", - - SAAS_COMPANY_REGISTRATION = "SAAS_COMPANY_REGISTRATION", - SAAS_GET_USER_INFO = "SAAS_GET_USER_INFO", - SAAS_USUAL_REGISTER_USER = "SAAS_USUAL_REGISTER_USER", - SAAS_DEMO_USER_REGISTRATION = "SAAS_DEMO_USER_REGISTRATION", - SAAS_LOGIN_USER_WITH_GOOGLE = "SAAS_LOGIN_USER_WITH_GOOGLE", - SAAS_LOGIN_USER_WITH_GITHUB = "SAAS_LOGIN_USER_WITH_GITHUB", - SAAS_SAAS_GET_USERS_INFOS_BY_EMAIL = "SAAS_SAAS_GET_USERS_INFOS_BY_EMAIL", - SAAS_SUSPEND_USERS = "SAAS_SUSPEND_USERS", - SAAS_SUSPEND_USERS_OVER_LIMIT = "SAAS_SUSPEND_USERS_OVER_LIMIT", - SAAS_GET_COMPANY_INFO_BY_USER_ID = "SAAS_GET_COMPANY_INFO_BY_USER_ID", - SAAS_GET_USERS_COUNT_IN_COMPANY = "SAAS_GET_USERS_COUNT_IN_COMPANY", - FREEZE_CONNECTIONS_IN_COMPANY = "FREEZE_CONNECTIONS_IN_COMPANY", - UNFREEZE_CONNECTIONS_IN_COMPANY = "UNFREEZE_CONNECTIONS_IN_COMPANY", - SAAS_REGISTER_USER_WITH_SAML = "SAAS_REGISTER_USER_WITH_SAML", - - INVITE_USER_IN_COMPANY_AND_CONNECTION_GROUP = "INVITE_USER_IN_COMPANY_AND_CONNECTION_GROUP", - VERIFY_INVITE_USER_IN_COMPANY_AND_CONNECTION_GROUP = "VERIFY_INVITE_USER_IN_COMPANY_AND_CONNECTION_GROUP", - CHECK_IS_VERIFICATION_LINK_AVAILABLE = "CHECK_IS_VERIFICATION_LINK_AVAILABLE", - UPDATE_USERS_2FA_STATUS_IN_COMPANY = "UPDATE_USERS_2FA_STATUS_IN_COMPANY", - - GET_USER_COMPANY = "GET_USER_COMPANY", - GET_FULL_USER_COMPANIES_INFO = "GET_FULL_USER_COMPANIES_INFO", - GET_USER_EMAIL_COMPANIES = "GET_USER_EMAIL_COMPANIES", - GET_USERS_IN_COMPANY = "GET_USERS_IN_COMPANY", - GET_COMPANY_NAME = "GET_COMPANY_NAME", - REMOVE_USER_FROM_COMPANY = "REMOVE_USER_FROM_COMPANY", - REVOKE_INVITATION_IN_COMPANY = "REVOKE_INVITATION_IN_COMPANY", - UPDATE_COMPANY_NAME = "UPDATE_COMPANY_NAME", - UPDATE_USERS_COMPANY_ROLES = "UPDATE_USERS_COMPANY_ROLES", - DELETE_COMPANY = "DELETE_COMPANY", - SUSPEND_USERS_IN_COMPANY = "SUSPEND_USERS_IN_COMPANY", - UNSUSPEND_USERS_IN_COMPANY = "UNSUSPEND_USERS_IN_COMPANY", - TOGGLE_TEST_CONNECTIONS_DISPLAY_MODE_IN_COMPANY = "TOGGLE_TEST_CONNECTIONS_DISPLAY_MODE_IN_COMPANY", - UPLOAD_COMPANY_LOGO = "UPLOAD_COMPANY_LOGO", - FIND_COMPANY_LOGO = "FIND_COMPANY_LOGO", - DELETE_COMPANY_LOGO = "DELETE_COMPANY_LOGO", - UPLOAD_COMPANY_FAVICON = "UPLOAD_COMPANY_FAVICON", - FIND_COMPANY_FAVICON = "FIND_COMPANY_FAVICON", - DELETE_COMPANY_FAVICON = "DELETE_COMPANY_FAVICON", - ADD_COMPANY_TAB_TITLE = "ADD_COMPANY_TAB_TITLE", - FIND_COMPANY_TAB_TITLE = "FIND_COMPANY_TAB_TITLE", - DELETE_COMPANY_TAB_TITLE = "DELETE_COMPANY_TAB_TITLE", - GET_COMPANY_WHITE_LABEL_PROPERTIES = "GET_COMPANY_WHITE_LABEL_PROPERTIES", - - CREATE_ACTION_RULES = "CREATE_ACTION_RULES", - FIND_ACTION_RULES_FOR_TABLE = "FIND_ACTION_RULES_FOR_TABLE", - DELETE_ACTION_RULE_IN_TABLE = "DELETE_ACTION_RULE_IN_TABLE", - FIND_ACTION_RULE_BY_ID = "FIND_ACTION_RULE_BY_ID", - UPDATE_ACTION_RULE = "UPDATE_ACTION_RULE", - FIND_ACTION_RULE_CUSTOM_EVENTS = "FIND_ACTION_RULE_CUSTOM_EVENTS", - ACTIVATE_TABLE_ACTIONS_IN_EVENT = "ACTIVATE_TABLE_ACTIONS_IN_EVENT", - - CREATE_API_KEY = "CREATE_API_KEY", - GET_API_KEYS = "GET_API_KEYS", - GET_API_KEY = "GET_API_KEY", - DELETE_API_KEY = "DELETE_API_KEY", - - REQUEST_INFO_FROM_TABLE_WITH_AI_V2 = "REQUEST_INFO_FROM_TABLE_WITH_AI_V2", - REQUEST_AI_SETTINGS_AND_WIDGETS_CREATION = "REQUEST_AI_SETTINGS_AND_WIDGETS_CREATION", - - CREATE_TABLE_FILTERS = "CREATE_TABLE_FILTERS", - FIND_TABLE_FILTERS = "FIND_TABLE_FILTERS", - DELETE_TABLE_FILTERS = "DELETE_TABLE_FILTERS", - FIND_TABLE_FILTER_BY_ID = "FIND_TABLE_FILTER_BY_ID", - DELETE_TABLE_FILTER_BY_ID = "DELETE_TABLE_FILTER_BY_ID", - UPDATE_TABLE_FILTER_BY_ID = "UPDATE_TABLE_FILTER_BY_ID", - - CREATE_UPDATE_TABLE_CATEGORIES = "CREATE_UPDATE_TABLE_CATEGORIES", - FIND_TABLE_CATEGORIES = "FIND_TABLE_CATEGORIES", - - CREATE_SECRET = "CREATE_SECRET", - GET_SECRETS = "GET_SECRETS", - GET_SECRET_BY_SLUG = "GET_SECRET_BY_SLUG", - UPDATE_SECRET = "UPDATE_SECRET", - DELETE_SECRET = "DELETE_SECRET", - GET_SECRET_AUDIT_LOG = "GET_SECRET_AUDIT_LOG", - FIND_SIGN_IN_AUDIT_LOGS = "FIND_SIGN_IN_AUDIT_LOGS", - - GET_S3_FILE_URL = "GET_S3_FILE_URL", - GET_S3_UPLOAD_URL = "GET_S3_UPLOAD_URL", + DELETE_USER_ACCOUNT = 'DELETE_USER_ACCOUNT', + FIND_USER = 'FIND_USER', + USUAL_LOGIN = 'USUAL_LOGIN', + LOG_OUT = 'LOG_OUT', + CHANGE_USUAL_PASSWORD = 'CHANGE_USUAL_PASSWORD', + VERIFY_EMAIL = 'VERIFY_EMAIL', + VERIFY_RESET_USER_PASSWORD = 'VERIFY_RESET_USER_PASSWORD', + REQUEST_RESET_USER_PASSWORD = 'REQUEST_RESET_USER_PASSWORD', + REQUEST_CHANGE_USER_EMAIL = 'REQUEST_CHANGE_USER_EMAIL', + VERIFY_EMAIL_CHANGE = 'VERIFY_EMAIL_CHANGE', + VERIFY_EMAIL_REQUEST = 'VERIFY_EMAIL_REQUEST', + CHANGE_USER_NAME = 'CHANGE_USER_NAME', + GENERATE_OTP = 'GENERATE_OTP', + VERIFY_OTP = 'VERIFY_OTP', + OTP_LOGIN = 'OTP_LOGIN', + DISABLE_OTP = 'DISABLE_OTP', + SAVE_USER_SESSION_SETTINGS = 'SAVE_USER_SESSION_SETTINGS', + GET_USER_SESSION_SETTINGS = 'GET_USER_SESSION_SETTINGS', + TOGGLE_TEST_CONNECTIONS_DISPLAY_MODE = 'TOGGLE_TEST_CONNECTIONS_DISPLAY_MODE', + + FIND_CONNECTIONS = 'FIND_CONNECTIONS', + FIND_USERS_IN_CONNECTION = 'FIND_USERS_IN_CONNECTION', + FIND_CONNECTION = 'FIND_CONNECTION', + CREATE_CONNECTION = 'CREATE_CONNECTION', + UPDATE_CONNECTION = 'UPDATE_CONNECTION', + DELETE_CONNECTION = 'DELETE_CONNECTION', + DELETE_GROUP_FROM_CONNECTION = 'DELETE_GROUP_FROM_CONNECTION', + CREATE_GROUP_IN_CONNECTION = 'CREATE_GROUP_IN_CONNECTION', + GET_USER_GROUPS_IN_CONNECTION = 'GET_USER_GROUPS_IN_CONNECTION', + GET_PERMISSIONS_FOR_GROUP_IN_CONNECTION = 'GET_PERMISSIONS_FOR_GROUP_IN_CONNECTION', + GET_USER_PERMISSIONS_FOR_GROUP_IN_CONNECTION = 'GET_USER_PERMISSIONS_FOR_GROUP_IN_CONNECTION', + TEST_CONNECTION_USE_CASE = 'TEST_CONNECTION_USE_CASE', + UPDATE_CONNECTION_MASTER_PASSWORD = 'UPDATE_CONNECTION_MASTER_PASSWORD', + RESTORE_CONNECTION = 'RESTORE_CONNECTION', + VALIDATE_CONNECTION_TOKEN = 'VALIDATE_CONNECTION_TOKEN', + REFRESH_CONNECTION_AGENT_TOKEN = 'REFRESH_CONNECTION_AGENT_TOKEN', + VALIDATE_CONNECTION_MASTER_PASSWORD = 'VALIDATE_CONNECTION_MASTER_PASSWORD', + UNFREEZE_CONNECTION = 'UNFREEZE_CONNECTION', + + FIND_ALL_USER_GROUPS = 'FIND_ALL_USER_GROUPS', + INVITE_USER_IN_GROUP = 'INVITE_USER_IN_GROUP', + FIND_ALL_USERS_IN_GROUP = 'FIND_ALL_USERS_IN_GROUP', + REMOVE_USER_FROM_GROUP = 'REMOVE_USER_FROM_GROUP', + DELETE_GROUP = 'DELETE_GROUP', + UPDATE_GROUP_TITLE = 'UPDATE_GROUP_TITLE', + + FIND_CONNECTION_PROPERTIES = 'FIND_CONNECTION_PROPERTIES', + CREATE_CONNECTION_PROPERTIES = 'CREATE_CONNECTION_PROPERTIES', + UPDATE_CONNECTION_PROPERTIES = 'UPDATE_CONNECTION_PROPERTIES', + DELETE_CONNECTION_PROPERTIES = 'DELETE_CONNECTION_PROPERTIES', + + GET_CONVERSIONS = 'GET_CONVERSIONS', + + GET_CUSTOM_FIELDS = 'GET_CUSTOM_FIELDS', + CREATE_CUSTOM_FIELDS = 'CREATE_CUSTOM_FIELDS', + UPDATE_CUSTOM_FIELDS = 'UPDATE_CUSTOM_FIELDS', + DELETE_CUSTOM_FIELD = 'DELETE_CUSTOM_FIELD', + + CREATE_OR_UPDATE_PERMISSIONS = 'CREATE_OR_UPDATE_PERMISSIONS', + + FIND_LOGS = 'FIND_LOGS', + EXPORT_LOGS_AS_CSV = 'EXPORT_LOGS_AS_CSV', + + FIND_TABLE_SETTINGS = 'FIND_TABLE_SETTINGS', + CREATE_TABLE_SETTINGS = 'CREATE_TABLE_SETTINGS', + UPDATE_TABLE_SETTINGS = 'UPDATE_TABLE_SETTINGS', + DELETE_TABLE_SETTINGS = 'DELETE_TABLE_SETTINGS', + + FIND_PERSONAL_TABLE_SETTINGS = 'FIND_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', + + CREATE_USER_ACTION = 'CREATE_USER_ACTION', + + CHECK_USER_LOGS_AND_UPDATE_ACTIONS = 'CHECK_USER_LOGS_AND_UPDATE_ACTIONS', + CHECK_USER_ACTIONS_AND_MAIL_USERS = 'CHECK_USER_ACTIONS_AND_MAIL_USERS', + + FIND_TABLE_WIDGETS = 'FIND_TABLE_WIDGETS', + CREATE_UPDATE_DELETE_TABLE_WIDGETS = 'CREATE_UPDATE_DELETE_TABLE_WIDGETS', + + FIND_TABLES_IN_CONNECTION = 'FIND_TABLES_IN_CONNECTION', + FIND_TABLES_IN_CONNECTION_V2 = 'FIND_TABLES_IN_CONNECTION_V2', + GET_ALL_TABLE_ROWS = 'GET_ALL_TABLE_ROWS', + GET_TABLE_STRUCTURE = 'GET_TABLE_STRUCTURE', + ADD_ROW_IN_TABLE = 'ADD_ROW_IN_TABLE', + UPDATE_ROW_IN_TABLE = 'UPDATE_ROW_IN_TABLE', + BULK_UPDATE_ROWS_IN_TABLE = 'BULK_UPDATE_ROWS_IN_TABLE', + DELETE_ROW_FROM_TABLE = 'DELETE_ROW_FROM_TABLE', + DELETE_ROWS_FROM_TABLE = 'DELETE_ROWS_FROM_TABLE', + GET_ROW_BY_PRIMARY_KEY = 'GET_ROW_BY_PRIMARY_KEY', + EXPORT_CSV_FROM_TABLE = 'EXPORT_CSV_FROM_TABLE', + IMPORT_CSV_TO_TABLE = 'IMPORT_CSV_TO_TABLE', + + SAAS_COMPANY_REGISTRATION = 'SAAS_COMPANY_REGISTRATION', + SAAS_GET_USER_INFO = 'SAAS_GET_USER_INFO', + SAAS_USUAL_REGISTER_USER = 'SAAS_USUAL_REGISTER_USER', + SAAS_DEMO_USER_REGISTRATION = 'SAAS_DEMO_USER_REGISTRATION', + SAAS_LOGIN_USER_WITH_GOOGLE = 'SAAS_LOGIN_USER_WITH_GOOGLE', + SAAS_LOGIN_USER_WITH_GITHUB = 'SAAS_LOGIN_USER_WITH_GITHUB', + SAAS_SAAS_GET_USERS_INFOS_BY_EMAIL = 'SAAS_SAAS_GET_USERS_INFOS_BY_EMAIL', + SAAS_SUSPEND_USERS = 'SAAS_SUSPEND_USERS', + SAAS_SUSPEND_USERS_OVER_LIMIT = 'SAAS_SUSPEND_USERS_OVER_LIMIT', + SAAS_GET_COMPANY_INFO_BY_USER_ID = 'SAAS_GET_COMPANY_INFO_BY_USER_ID', + SAAS_GET_USERS_COUNT_IN_COMPANY = 'SAAS_GET_USERS_COUNT_IN_COMPANY', + FREEZE_CONNECTIONS_IN_COMPANY = 'FREEZE_CONNECTIONS_IN_COMPANY', + UNFREEZE_CONNECTIONS_IN_COMPANY = 'UNFREEZE_CONNECTIONS_IN_COMPANY', + SAAS_REGISTER_USER_WITH_SAML = 'SAAS_REGISTER_USER_WITH_SAML', + + INVITE_USER_IN_COMPANY_AND_CONNECTION_GROUP = 'INVITE_USER_IN_COMPANY_AND_CONNECTION_GROUP', + VERIFY_INVITE_USER_IN_COMPANY_AND_CONNECTION_GROUP = 'VERIFY_INVITE_USER_IN_COMPANY_AND_CONNECTION_GROUP', + CHECK_IS_VERIFICATION_LINK_AVAILABLE = 'CHECK_IS_VERIFICATION_LINK_AVAILABLE', + UPDATE_USERS_2FA_STATUS_IN_COMPANY = 'UPDATE_USERS_2FA_STATUS_IN_COMPANY', + + GET_USER_COMPANY = 'GET_USER_COMPANY', + GET_FULL_USER_COMPANIES_INFO = 'GET_FULL_USER_COMPANIES_INFO', + GET_USER_EMAIL_COMPANIES = 'GET_USER_EMAIL_COMPANIES', + GET_USERS_IN_COMPANY = 'GET_USERS_IN_COMPANY', + GET_COMPANY_NAME = 'GET_COMPANY_NAME', + REMOVE_USER_FROM_COMPANY = 'REMOVE_USER_FROM_COMPANY', + REVOKE_INVITATION_IN_COMPANY = 'REVOKE_INVITATION_IN_COMPANY', + UPDATE_COMPANY_NAME = 'UPDATE_COMPANY_NAME', + UPDATE_USERS_COMPANY_ROLES = 'UPDATE_USERS_COMPANY_ROLES', + DELETE_COMPANY = 'DELETE_COMPANY', + SUSPEND_USERS_IN_COMPANY = 'SUSPEND_USERS_IN_COMPANY', + UNSUSPEND_USERS_IN_COMPANY = 'UNSUSPEND_USERS_IN_COMPANY', + TOGGLE_TEST_CONNECTIONS_DISPLAY_MODE_IN_COMPANY = 'TOGGLE_TEST_CONNECTIONS_DISPLAY_MODE_IN_COMPANY', + UPLOAD_COMPANY_LOGO = 'UPLOAD_COMPANY_LOGO', + FIND_COMPANY_LOGO = 'FIND_COMPANY_LOGO', + DELETE_COMPANY_LOGO = 'DELETE_COMPANY_LOGO', + UPLOAD_COMPANY_FAVICON = 'UPLOAD_COMPANY_FAVICON', + FIND_COMPANY_FAVICON = 'FIND_COMPANY_FAVICON', + DELETE_COMPANY_FAVICON = 'DELETE_COMPANY_FAVICON', + ADD_COMPANY_TAB_TITLE = 'ADD_COMPANY_TAB_TITLE', + FIND_COMPANY_TAB_TITLE = 'FIND_COMPANY_TAB_TITLE', + DELETE_COMPANY_TAB_TITLE = 'DELETE_COMPANY_TAB_TITLE', + GET_COMPANY_WHITE_LABEL_PROPERTIES = 'GET_COMPANY_WHITE_LABEL_PROPERTIES', + + CREATE_ACTION_RULES = 'CREATE_ACTION_RULES', + FIND_ACTION_RULES_FOR_TABLE = 'FIND_ACTION_RULES_FOR_TABLE', + DELETE_ACTION_RULE_IN_TABLE = 'DELETE_ACTION_RULE_IN_TABLE', + FIND_ACTION_RULE_BY_ID = 'FIND_ACTION_RULE_BY_ID', + UPDATE_ACTION_RULE = 'UPDATE_ACTION_RULE', + FIND_ACTION_RULE_CUSTOM_EVENTS = 'FIND_ACTION_RULE_CUSTOM_EVENTS', + ACTIVATE_TABLE_ACTIONS_IN_EVENT = 'ACTIVATE_TABLE_ACTIONS_IN_EVENT', + + CREATE_API_KEY = 'CREATE_API_KEY', + GET_API_KEYS = 'GET_API_KEYS', + GET_API_KEY = 'GET_API_KEY', + DELETE_API_KEY = 'DELETE_API_KEY', + + REQUEST_INFO_FROM_TABLE_WITH_AI_V2 = 'REQUEST_INFO_FROM_TABLE_WITH_AI_V2', + REQUEST_AI_SETTINGS_AND_WIDGETS_CREATION = 'REQUEST_AI_SETTINGS_AND_WIDGETS_CREATION', + + CREATE_TABLE_FILTERS = 'CREATE_TABLE_FILTERS', + FIND_TABLE_FILTERS = 'FIND_TABLE_FILTERS', + DELETE_TABLE_FILTERS = 'DELETE_TABLE_FILTERS', + FIND_TABLE_FILTER_BY_ID = 'FIND_TABLE_FILTER_BY_ID', + DELETE_TABLE_FILTER_BY_ID = 'DELETE_TABLE_FILTER_BY_ID', + UPDATE_TABLE_FILTER_BY_ID = 'UPDATE_TABLE_FILTER_BY_ID', + + CREATE_UPDATE_TABLE_CATEGORIES = 'CREATE_UPDATE_TABLE_CATEGORIES', + FIND_TABLE_CATEGORIES = 'FIND_TABLE_CATEGORIES', + + CREATE_SECRET = 'CREATE_SECRET', + GET_SECRETS = 'GET_SECRETS', + GET_SECRET_BY_SLUG = 'GET_SECRET_BY_SLUG', + UPDATE_SECRET = 'UPDATE_SECRET', + DELETE_SECRET = 'DELETE_SECRET', + GET_SECRET_AUDIT_LOG = 'GET_SECRET_AUDIT_LOG', + FIND_SIGN_IN_AUDIT_LOGS = 'FIND_SIGN_IN_AUDIT_LOGS', + + GET_S3_FILE_URL = 'GET_S3_FILE_URL', + GET_S3_UPLOAD_URL = 'GET_S3_UPLOAD_URL', } 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/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..b3cad30f0 100644 --- a/backend/src/entities/connection/connection.entity.ts +++ b/backend/src/entities/connection/connection.entity.ts @@ -19,13 +19,14 @@ 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'; 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/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 bb043d7ba..83ab1f421 100644 --- a/backend/src/entities/demo-data/demo-data.service.ts +++ b/backend/src/entities/demo-data/demo-data.service.ts @@ -3,7 +3,6 @@ import { ConnectionTypesEnum } from '@rocketadmin/shared-code/dist/src/shared/en import { IGlobalDatabaseContext } from '../../common/application/global-database-context.interface.js'; import { BaseType } from '../../common/data-injection.tokens.js'; import { FilterCriteriaEnum } from '../../enums/filter-criteria.enum.js'; -import { QueryOrderingEnum } from '../../enums/query-ordering.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'; @@ -24,8 +23,8 @@ import { buildEmptyActionRule } from '../table-actions/table-action-rules-module 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/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'; @@ -109,15 +108,10 @@ 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'], identification_fields: [], - columns_view: ['space_id', 'title', 'start_time', 'end_time', 'image_url'], identity_column: 'title', can_delete: true, can_update: true, @@ -135,15 +129,10 @@ 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'], identification_fields: [], - columns_view: [], identity_column: 'user_id', can_delete: true, can_update: true, @@ -161,15 +150,10 @@ 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: [], identification_fields: [], - columns_view: null, identity_column: null, can_delete: true, can_update: true, @@ -187,15 +171,10 @@ 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'], identification_fields: [], - columns_view: ['name', 'address', 'city', 'country'], identity_column: 'name', can_delete: true, can_update: true, @@ -213,15 +192,10 @@ 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'], identification_fields: [], - columns_view: ['user_id', 'space_id', 'start_date', 'end_date', 'membership_type'], identity_column: 'user_id', can_delete: true, can_update: true, @@ -239,15 +213,10 @@ 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'], identification_fields: [], - columns_view: [], identity_column: 'name', can_delete: true, can_update: true, @@ -265,15 +234,10 @@ 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: [], identification_fields: [], - columns_view: [], identity_column: '', can_delete: true, can_update: true, @@ -291,15 +255,10 @@ 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'], identification_fields: [], - columns_view: [], identity_column: 'name', can_delete: true, can_update: true, @@ -757,15 +716,10 @@ 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: [], identification_fields: [], - columns_view: ['user_id', 'course_id', 'issued_at', 'certificate_url'], identity_column: 'course_id', can_delete: true, can_update: true, @@ -783,15 +737,10 @@ 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: [], identification_fields: [], - columns_view: null, identity_column: 'user_id', can_delete: true, can_update: true, @@ -809,15 +758,10 @@ 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: [], identification_fields: [], - columns_view: [], identity_column: 'title', can_delete: true, can_update: true, @@ -835,15 +779,10 @@ 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: [], identification_fields: [], - columns_view: [], identity_column: 'title', can_delete: true, can_update: true, @@ -861,15 +800,10 @@ 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: [], identification_fields: [], - columns_view: [], identity_column: 'user_id', can_delete: true, can_update: true, @@ -887,15 +821,10 @@ 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: [], identification_fields: [], - columns_view: null, identity_column: 'title', can_delete: true, can_update: true, @@ -913,15 +842,10 @@ 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: [], identification_fields: [], - columns_view: null, identity_column: 'user_id', can_delete: true, can_update: true, @@ -939,15 +863,10 @@ 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'], identification_fields: [], - columns_view: null, identity_column: 'title', can_delete: true, can_update: true, @@ -965,25 +884,10 @@ 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'], 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/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/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 11f13f420..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/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 { TableWidgetEntity } from '../widget/table-widget.entity.js'; +import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js'; @Injectable() export class SharedJobsService { 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 b84eb84c6..485ee9213 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 af43efe51..c39e1e20a 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/application/data-structures/create-table-settings.ds.ts b/backend/src/entities/table-settings/application/data-structures/create-table-settings.ds.ts index 54cc254af..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 @@ -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'; @@ -8,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 }) @@ -28,20 +24,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/dto/create-table-settings.dto.ts b/backend/src/entities/table-settings/common-table-settings/dto/create-table-settings.dto.ts similarity index 51% 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..8d5d7414b 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,39 +1,17 @@ -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 { 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/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 83% 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..57b5f1de3 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 } 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, @@ -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, @@ -129,17 +123,12 @@ 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, custom_fields: customFields, identification_fields: identification_fields, sensitive_fields: sensitive_fields, - columns_view: columns_view, identity_column: identity_column, masterPwd: masterPwd, userId: userId, @@ -178,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, @@ -205,18 +188,13 @@ 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, 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/table-settings.entity.ts b/backend/src/entities/table-settings/common-table-settings/table-settings.entity.ts similarity index 74% 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..f1f437864 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,9 @@ 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 { 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']) @@ -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/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/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 new file mode 100644 index 000000000..c1d9e97e6 --- /dev/null +++ b/backend/src/entities/table-settings/common-table-settings/use-cases/find-table-settings.use.case.ts @@ -0,0 +1,39 @@ +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'; + +@Injectable() +export class FindTableSettingsUseCase + extends AbstractUseCase + implements IFindTableSettings +{ + constructor( + @Inject(BaseType.GLOBAL_DB_CONTEXT) + protected _dbContext: IGlobalDatabaseContext, + ) { + super(); + } + protected async implementation(inputData: FindTableSettingsDs): Promise { + const { connectionId, tableName, masterPassword } = inputData; + const tableSettings = await this._dbContext.tableSettingsRepository.findTableSettings(connectionId, tableName); + if (!tableSettings) { + return {} as FoundTableSettingsDs; + } + + const foundConnection = await this._dbContext.connectionRepository.findAndDecryptConnection( + connectionId, + masterPassword, + ); + if (!foundConnection) { + throw new NotFoundException(Messages.CONNECTION_NOT_FOUND); + } + + return buildFoundTableSettingsDs(tableSettings); + } +} 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 80% 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..ef6576894 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,20 +1,15 @@ -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 { autocomplete_columns: undefined, - columns_view: undefined, connection_id: connectionId, custom_fields: undefined, display_name: undefined, 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, @@ -39,18 +34,13 @@ export function buildEmptyTableSettingsWithEmptyWidgets( ): CreateTableSettingsDs { return { autocomplete_columns: undefined, - columns_view: undefined, connection_id: connectionId, custom_fields: undefined, display_name: undefined, 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/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 80% 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..7345a9c19 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 { @@ -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/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 76% 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..a8ea49f3f 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( @@ -9,16 +9,11 @@ export function buildNewTableSettingsEntity( const newSettings = new TableSettingsEntity(); const { autocomplete_columns, - columns_view, custom_fields, display_name, excluded_fields, identification_fields, identity_column, - list_fields, - list_per_page, - ordering, - ordering_field, readonly_fields, search_fields, sortable_by, @@ -38,10 +33,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; @@ -49,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/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/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..83a4551fd --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.ts @@ -0,0 +1,31 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { QueryOrderingEnum } from '../../../../enums/query-ordering.enum.js'; +import { IsBoolean, 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' }) + @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/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..5d997b68e --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/dto/found-personal-table-settings.dto.ts @@ -0,0 +1,28 @@ +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({ 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 new file mode 100644 index 000000000..5d8884a45 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.controller.ts @@ -0,0 +1,159 @@ +import { + Body, + Controller, + Delete, + Get, + HttpException, + HttpStatus, + Inject, + Injectable, + Put, + UseGuards, + UseInterceptors, +} from '@nestjs/common'; +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 { + ICreateUpdatePersonalTableSettings, + IDeletePersonalTableSettings, + IFindPersonalTableSettings, +} 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 { 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() +@ApiBearerAuth() +@ApiTags('Personal table settings') +@Injectable() +export class PersonalTableSettingsController { + constructor( + @Inject(UseCaseType.FIND_PERSONAL_TABLE_SETTINGS) + private readonly findPersonalTableSettingsUseCase: IFindPersonalTableSettings, + @Inject(UseCaseType.CREATE_UPDATE_PERSONAL_TABLE_SETTINGS) + private readonly createUpdatePersonalTableSettingsUseCase: ICreateUpdatePersonalTableSettings, + @Inject(UseCaseType.DELETE_PERSONAL_TABLE_SETTINGS) + private readonly deletePersonalTableSettingsUseCase: IDeletePersonalTableSettings, + ) {} + + @ApiOperation({ summary: 'Find user personal table settings' }) + @ApiResponse({ + status: 200, + description: 'Table settings found.', + type: FoundPersonalTableSettingsDto, + }) + @ApiParam({ name: 'connectionId', required: true }) + @ApiQuery({ name: 'tableName', required: true }) + @UseGuards(TableReadGuard) + @Get('/settings/personal/:connectionId') + async findAll( + @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.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 new file mode 100644 index 000000000..18a724ac6 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/personal-table-settings.entity.ts @@ -0,0 +1,53 @@ +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({ type: 'varchar', array: true, default: {} }) + columns_view: Array; + + @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..4ee488227 --- /dev/null +++ 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/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/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..0c96e4ede --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/use-cases/create-update-personal-table-settings.use.case.ts @@ -0,0 +1,105 @@ +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 { 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'; + +@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( + user_id, + connection_id, + table_name, + ); + + 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); + } + + private async validatePersonalTableSettingsData( + settingsData: PersonalTableSettingsData, + connection: ConnectionEntity, + tableName: string, + ): Promise { + 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); + 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 (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/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..d789656f8 --- /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 { 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 + 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( + userId, + connectionId, + tableName, + ); + + if (!foundPersonalTableSettings) { + return {} as FoundPersonalTableSettingsDto; + } + + 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..fb1e6310a --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/use-cases/personal-table-settings.use-cases.interface.ts @@ -0,0 +1,25 @@ +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'; + +export interface IFindPersonalTableSettings { + execute( + inputData: FindPersonalTableSettingsDs, + inTransaction: InTransactionEnum, + ): Promise; +} + +export interface ICreateUpdatePersonalTableSettings { + execute( + inputData: CreatePersonalTableSettingsDs, + inTransaction: InTransactionEnum, + ): Promise; +} + +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 new file mode 100644 index 000000000..f1337b397 --- /dev/null +++ b/backend/src/entities/table-settings/personal-table-settings/utils/build-found-table-settings-dto.ts @@ -0,0 +1,17 @@ +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, + columns_view: personalTableSettings.columns_view, + }; +} 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/src/entities/table-settings/use-cases/find-table-settings.use.case.ts b/backend/src/entities/table-settings/use-cases/find-table-settings.use.case.ts deleted file mode 100644 index 0ac916dec..000000000 --- a/backend/src/entities/table-settings/use-cases/find-table-settings.use.case.ts +++ /dev/null @@ -1,49 +0,0 @@ -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 { 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 - extends AbstractUseCase - implements IFindTableSettings -{ - constructor( - @Inject(BaseType.GLOBAL_DB_CONTEXT) - protected _dbContext: IGlobalDatabaseContext, - ) { - super(); - } - protected async implementation(inputData: FindTableSettingsDs): Promise { - const { connectionId, tableName, masterPassword } = inputData; - const tableSettings = await this._dbContext.tableSettingsRepository.findTableSettings(connectionId, tableName); - if (!tableSettings) { - return {} as FoundTableSettingsDs; - } - - const foundConnection = await this._dbContext.connectionRepository.findAndDecryptConnection( - connectionId, - masterPassword, - ); - 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/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/add-row-in-table.use.case.ts b/backend/src/entities/table/use-cases/add-row-in-table.use.case.ts index de0ac3ca6..aa234953b 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/shared/interfaces/data-access-object-agent.interface.js'; import { IDataAccessObject } from '@rocketadmin/shared-code/dist/src/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'; @@ -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/find-tables-in-connection-v2.use.case.ts b/backend/src/entities/table/use-cases/find-tables-in-connection-v2.use.case.ts index e261abc8f..f15f3558f 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 4230d8c63..9b76f5c48 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-row-by-primary-key.use.case.ts b/backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts index babb27ed0..70315a171 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 { NonAvailableInFreePlanException } from '../../../exceptions/custom-exce import { findAvailableFields } from '../utils/find-available-fields.utils.js'; import { IDataAccessObjectAgent } from '@rocketadmin/shared-code/dist/src/shared/interfaces/data-access-object-agent.interface.js'; import { IDataAccessObject } from '@rocketadmin/shared-code/dist/src/shared/interfaces/data-access-object.interface.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 549a46694..1b2837389 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 @@ -26,7 +26,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'; @@ -41,6 +41,8 @@ import { findAvailableFields } from '../utils/find-available-fields.utils.js'; import { ConnectionTypesEnum } from '@rocketadmin/shared-code/dist/src/shared/enums/connection-types-enum.js'; import { IDataAccessObjectAgent } from '@rocketadmin/shared-code/dist/src/shared/interfaces/data-access-object-agent.interface.js'; import { IDataAccessObject } from '@rocketadmin/shared-code/dist/src/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 { 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 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'); } } @@ -153,7 +160,7 @@ 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)); @@ -221,15 +228,15 @@ export class GetTableRowsUseCase extends AbstractUseCase 0 ? tableSettings.sortable_by : [], - ordering_field: tableSettings.ordering_field ? tableSettings.ordering_field : undefined, - ordering: tableSettings.ordering ? tableSettings.ordering : undefined, - columns_view: tableSettings.columns_view ? tableSettings.columns_view : undefined, + 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: 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, @@ -242,10 +249,10 @@ export class GetTableRowsUseCase extends AbstractUseCase 0 ? tableSettings.sortable_by : [], - ordering: tableSettings.ordering ? tableSettings.ordering : undefined, - identity_column: tableSettings.identity_column ? tableSettings.identity_column : null, - list_fields: tableSettings?.list_fields?.length > 0 ? tableSettings.list_fields : [], + sortable_by: builtDAOsTableSettings?.sortable_by?.length > 0 ? builtDAOsTableSettings.sortable_by : [], + ordering: personalTableSettings.ordering ? personalTableSettings.ordering : undefined, + 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, 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 c870f8f2d..340571733 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 0ff228b9c..4d4660866 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 { hashPasswordsInRowUtil } from '../utils/hash-passwords-in-row.util.js'; 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 { 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/table/utils/find-autocomplete-fields.util.ts b/backend/src/entities/table/utils/find-autocomplete-fields.util.ts index f70adb985..61a808412 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 3b3b54b18..89ed1ee87 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.entity.ts b/backend/src/entities/user/user.entity.ts index f73a96ed9..a829b6f70 100644 --- a/backend/src/entities/user/user.entity.ts +++ b/backend/src/entities/user/user.entity.ts @@ -28,6 +28,7 @@ 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 { SignInAuditEntity } from '../user-sign-in-audit/sign-in-audit.entity.js'; import { SecretAccessLogEntity } from '../secret-access-log/secret-access-log.entity.js'; +import { PersonalTableSettingsEntity } from '../table-settings/personal-table-settings/personal-table-settings.entity.js'; @Entity('user') export class UserEntity { @@ -127,6 +128,9 @@ export class UserEntity { @OneToMany((_) => SecretAccessLogEntity, (secretAccessLog) => secretAccessLog.user) secretAccessLogs: 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/user.module.ts b/backend/src/entities/user/user.module.ts index 7b4fea672..ba76c5d24 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/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/exceptions/text/messages.ts b/backend/src/exceptions/text/messages.ts index 0e75a4c7d..332086ab7 100644 --- a/backend/src/exceptions/text/messages.ts +++ b/backend/src/exceptions/text/messages.ts @@ -376,4 +376,5 @@ export const Messages = { SECRET_MASTER_PASSWORD_INVALID: 'Invalid master password', SECRET_DELETED_SUCCESSFULLY: 'Secret deleted successfully', USER_NOT_FOUND_OR_NOT_IN_COMPANY: 'User not found or not associated with a company', + PERSONAL_TABLE_SETTINGS_NOT_FOUND: 'Personal table settings with this parameters not found', }; diff --git a/backend/src/migrations/1762528788423-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts b/backend/src/migrations/1762528788423-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts new file mode 100644 index 000000000..b1cbab031 --- /dev/null +++ b/backend/src/migrations/1762528788423-AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity.ts @@ -0,0 +1,41 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class AddPersonalTableSettingsEntityRemovePropertiesFromTableSettingsEntity1762528788423 + implements MigrationInterface +{ + 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 '{}', "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"`); + 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-postgres-with-binary-e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-postgres-with-binary-e2e.test.ts index 4ed1c3f00..a98f072c6 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-cassandra.e2e.test.ts b/backend/test/ava-tests/non-saas-tests/non-saas-table-cassandra.e2e.test.ts index 344e66b5b..c31fb7717 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 @@ -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, - '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) @@ -716,16 +794,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) @@ -798,16 +889,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) @@ -879,16 +983,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) @@ -959,16 +1076,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) @@ -1037,16 +1167,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) @@ -1123,16 +1266,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) @@ -1199,16 +1355,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) @@ -1276,16 +1445,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) @@ -1351,16 +1533,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) @@ -1438,16 +1633,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) @@ -1518,16 +1726,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) @@ -1594,16 +1815,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) @@ -1659,16 +1893,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) @@ -3494,10 +3741,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3506,6 +3749,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) @@ -3550,16 +3810,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) @@ -3616,16 +3889,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) @@ -3719,10 +4005,6 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3731,6 +4013,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 715aae67f..f25658df0 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) @@ -3444,16 +3730,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 6fc127ff7..05408b6c3 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) @@ -3557,16 +3830,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 5e898d50d..e52ac5b97 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 e4ff510c2..40c5b2443 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 c978189a0..0dd1e9538 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) @@ -983,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) @@ -1059,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) @@ -1133,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) @@ -1210,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) @@ -1285,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) @@ -1367,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) @@ -1450,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) @@ -1529,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) @@ -1608,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) @@ -1667,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) @@ -1731,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) @@ -1797,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 3980ea9ad..6d410aaf5 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) @@ -1734,14 +1994,17 @@ 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 createTableSettingsResponse = await request(app.getHttpServer()) @@ -1800,16 +2063,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 f5b1b0fa9..5637eed24 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 e6e2f67f0..4bffe7100 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,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +380,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +471,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +565,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +660,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +755,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +844,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +933,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1021,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1109,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1198,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1291,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1382,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1568,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1667,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1767,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1863,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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,14 +1959,17 @@ 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 createTableSettingsResponse = await request(app.getHttpServer()) @@ -1770,24 +2025,18 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - 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('masterpwd', masterPwd) - .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 = 'id'; const fieldGtvalue = '25'; @@ -1837,16 +2086,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +2169,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 75a36fe5c..bb959c921 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 c22f3b05d..f06e529a2 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 @@ -251,16 +251,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) @@ -325,16 +338,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) @@ -399,16 +425,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) @@ -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) @@ -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) @@ -634,16 +699,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) @@ -706,16 +784,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) @@ -776,16 +867,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) @@ -851,16 +955,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) @@ -920,16 +1037,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) @@ -997,16 +1127,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) @@ -1079,16 +1222,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) @@ -1155,16 +1311,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) @@ -1235,16 +1404,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) @@ -1312,16 +1494,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) @@ -1397,16 +1592,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) @@ -1485,16 +1693,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) @@ -1572,16 +1793,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) @@ -1631,16 +1865,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) @@ -1695,16 +1942,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) @@ -1761,16 +2021,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) @@ -3558,16 +3831,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) @@ -3623,16 +3909,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 4a43720c2..76a20e48d 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) @@ -198,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, []); @@ -233,17 +242,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) @@ -264,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, []); @@ -297,16 +316,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,10 +373,6 @@ test.serial(`${currentTest} should throw exception when connectionId is missing` ['title'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, undefined, @@ -387,14 +414,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,99 +470,26 @@ test.serial(`${currentTest} should throw exception when excluded_fields is not a ['title'], 'type', undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - 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 "excluded_fields" must be an array'); - } catch (e) { - console.error(e); - } -}); - -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'], + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, - 'type', 3, QueryOrderingEnum.DESC, 'port', - undefined, - undefined, - undefined, ); - const tableName = 'connection'; - const createTableSettingsResponse = await request(app.getHttpServer()) - .post(`/settings?connectionId=${connectionId}&tableName=${tableName}`) - .send(createTableSettingsDTO) + 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(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, - undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - 'type', - undefined, - undefined, - ); + t.is(createPersonalTableSettingsResponse.status, 200); const tableName = 'connection'; const createTableSettingsResponse = await request(app.getHttpServer()) @@ -533,7 +500,7 @@ test.serial(`${currentTest} should throw exception when readonly_fields is not a .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'); + t.is(createTableSettingsRO.message, 'The field "excluded_fields" must be an array'); } catch (e) { console.error(e); } @@ -558,15 +525,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 +583,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 +644,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}`) @@ -674,49 +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, - ['testField'], - 3, - QueryOrderingEnum.DESC, - 'port', - 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) => { @@ -738,10 +702,6 @@ test.serial( 'connection', ['type'], undefined, - undefined, - 3, - QueryOrderingEnum.DESC, - 'port', ['testField'], undefined, undefined, @@ -785,15 +745,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 734295c0f..70ae5546e 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 @@ -3609,21 +3609,35 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + + ['updated_at'], + ['created_at'], + undefined, + undefined, + 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( @@ -3636,71 +3650,28 @@ test.serial( t.is(createTableSettingsResponse.status, 201); - const getTableSettings = await request(app.getHttpServer()) - .get( - `/settings/?connectionId=${testData.connections.firstId}&tableName=${testData.firstTableInfo.testTableName}`, - ) - .set("Cookie", testData.users.simpleUserToken) - .set("Content-Type", "application/json") - .set("Accept", "application/json"); - const getTableSettingsRO = JSON.parse(getTableSettings.text); - t.is(getTableSettings.status, 200); - t.is(Object.hasOwn(getTableSettingsRO, "id"), true); - t.is(getTableSettingsRO.table_name, createTableSettingsDTO.table_name); - 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([]), - ); - t.is(getTableSettingsRO.connection_id, testData.connections.firstId); - } catch (error) { - console.error(error); - throw error; - } - }, -); + const getTableSettings = await request(app.getHttpServer()) + .get(`/settings/?connectionId=${testData.connections.firstId}&tableName=${testData.firstTableInfo.testTableName}`) + .set('Cookie', testData.users.simpleUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + const getTableSettingsRO = JSON.parse(getTableSettings.text); + t.is(getTableSettings.status, 200); + t.is(getTableSettingsRO.hasOwnProperty('id'), true); + t.is(getTableSettingsRO.table_name, createTableSettingsDTO.table_name); + 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.identification_fields), JSON.stringify([])); + 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([])); + t.is(getTableSettingsRO.connection_id, testData.connections.firstId); + } catch (error) { + console.error(error); + throw error; + } +}); test.serial( `${currentTest} should throw an exception when you try get settings in connection where you do not have permission`, @@ -3711,21 +3682,34 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + 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( @@ -3765,21 +3749,34 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + 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( @@ -3791,59 +3788,22 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const createTableSettingsRO = JSON.parse( - createTableSettingsResponse.text, - ); - t.is(Object.hasOwn(createTableSettingsRO, "id"), true); - t.is(createTableSettingsRO.table_name, createTableSettingsDTO.table_name); - 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([]), - ); - t.is(createTableSettingsRO.connection_id, testData.connections.firstId); - } catch (error) { - console.error(error); - throw error; - } - }, -); + const createTableSettingsRO = JSON.parse(createTableSettingsResponse.text); + t.is(createTableSettingsRO.hasOwnProperty('id'), true); + t.is(createTableSettingsRO.table_name, createTableSettingsDTO.table_name); + 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.identification_fields), JSON.stringify([])); + 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([])); + t.is(createTableSettingsRO.connection_id, testData.connections.firstId); + } catch (error) { + console.error(error); + throw error; + } +}); test.serial( `${currentTest} should throw an exception when you try create settings in connection where you do not have permission`, @@ -3854,21 +3814,34 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + 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( @@ -3902,21 +3875,34 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + 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( @@ -3928,21 +3914,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.ASC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -3957,122 +3939,76 @@ test.serial( ); t.is(updateTableSettingsResponse.status, 200); - t.is(Object.hasOwn(updateTableSettingsRO, "id"), true); - t.is(updateTableSettingsRO.table_name, updateTableSettingsDTO.table_name); - 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([])); - t.is(updateTableSettingsRO.connection_id, testData.connections.firstId); - } catch (error) { - console.error(error); - throw error; - } - }, -); - -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 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); - - 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, - ); + t.is(updateTableSettingsRO.hasOwnProperty('id'), true); + t.is(updateTableSettingsRO.table_name, updateTableSettingsDTO.table_name); + 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.identification_fields)).toBe(JSON.stringify([])); + 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([])); + t.is(updateTableSettingsRO.connection_id, testData.connections.firstId); + } 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; - } - }, -); +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], + ['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'); + + t.is(createTableSettingsResponse.status, 201); + + 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; + } +}); currentTest = "DELETE /settings/"; @@ -4085,21 +4021,17 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -4147,21 +4079,17 @@ test.serial( 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( 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 6a0f21722..d8709c33e 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 @@ -2784,21 +2784,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2810,70 +2806,27 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const getTableSettings = await request(app.getHttpServer()) - .get( - `/settings/?connectionId=${connections.firstId}&tableName=${firstTableInfo.testTableName}`, - ) - .set("Cookie", simpleUserToken) - .set("Content-Type", "application/json") - .set("Accept", "application/json"); - const getTableSettingsRO = JSON.parse(getTableSettings.text); - t.is(getTableSettings.status, 200); - t.is(Object.hasOwn(getTableSettingsRO, "id"), true); - t.is(getTableSettingsRO.table_name, createTableSettingsDTO.table_name); - 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([]), - ); - t.is(getTableSettingsRO.connection_id, connections.firstId); - } catch (e) { - console.error(e); - } - }, -); + const getTableSettings = await request(app.getHttpServer()) + .get(`/settings/?connectionId=${connections.firstId}&tableName=${firstTableInfo.testTableName}`) + .set('Cookie', simpleUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + const getTableSettingsRO = JSON.parse(getTableSettings.text); + t.is(getTableSettings.status, 200); + t.is(getTableSettingsRO.hasOwnProperty('id'), true); + t.is(getTableSettingsRO.table_name, createTableSettingsDTO.table_name); + 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.identification_fields), JSON.stringify([])); + 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([])); + t.is(getTableSettingsRO.connection_id, connections.firstId); + } catch (e) { + console.error(e); + } +}); test.serial( `${currentTest} should throw an exception when you try get settings in connection where you do not have permission`, @@ -2892,21 +2845,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2954,21 +2903,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - "users", - ["id"], - ["email"], - ["name"], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + 'users', + ['id'], + ['email'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3006,21 +2951,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3044,37 +2985,28 @@ test.serial( currentTest = "PUT /settings/"; -test.serial( - `${currentTest} should throw an exception do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should throw an exception do not have permission`, async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3086,21 +3018,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -3122,36 +3050,29 @@ test.serial( ); 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 createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try update settings in connection where you do not have permission`, + async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3163,21 +3084,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -3200,37 +3117,28 @@ test.serial( currentTest = "DELETE /settings/"; -test.serial( - `${currentTest} should return array without deleted table settings`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should return array without deleted table settings`, async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3262,36 +3170,29 @@ test.serial( ); test.serial( - `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, + async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( 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 8757dc121..cb53180ff 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 @@ -2678,21 +2678,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2737,21 +2733,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2800,21 +2792,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - "users", - ["id"], - ["email"], - ["name"], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + 'users', + ['id'], + ['email'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2853,21 +2841,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2892,37 +2876,29 @@ test.serial( currentTest = "PUT /settings/"; -test.serial( - `${currentTest} should throw an exception do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should throw an exception do not have permission`, async (t) => { + try { + const testData = + await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2934,21 +2910,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -2971,36 +2943,30 @@ test.serial( ); 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 createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try update settings in connection where you do not have permission`, + async (t) => { + try { + const testData = + await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3012,21 +2978,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -3050,37 +3012,29 @@ test.serial( currentTest = "DELETE /settings/"; -test.serial( - `${currentTest} should return array without deleted table settings`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should return array without deleted table settings`, async (t) => { + try { + const testData = + await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3113,36 +3067,30 @@ test.serial( ); test.serial( - `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, + async (t) => { + try { + const testData = + await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( 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 77c37b172..4653b3dd4 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 @@ -2656,21 +2656,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2716,21 +2712,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2779,21 +2771,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - "users", - ["id"], - ["email"], - ["name"], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + 'users', + ['id'], + ['email'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2832,21 +2820,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2871,37 +2855,28 @@ test.serial( currentTest = "PUT /settings/"; -test.serial( - `${currentTest} should throw an exception do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should throw an exception do not have permission`, async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2913,21 +2888,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -2950,36 +2921,29 @@ test.serial( ); 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 createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try update settings in connection where you do not have permission`, + async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2991,21 +2955,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -3029,37 +2989,28 @@ test.serial( currentTest = "DELETE /settings/"; -test.serial( - `${currentTest} should return array without deleted table settings`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should return array without deleted table settings`, async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3092,36 +3043,29 @@ test.serial( ); test.serial( - `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, + async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( 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 554364051..d925254aa 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 @@ -98,7 +98,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()) @@ -248,16 +247,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) @@ -316,16 +328,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) @@ -386,16 +411,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 +497,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) @@ -533,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) @@ -607,16 +671,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) @@ -688,16 +765,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) @@ -766,16 +856,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) @@ -843,16 +946,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) @@ -919,16 +1035,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) @@ -993,16 +1122,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) @@ -1075,16 +1217,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) @@ -1147,16 +1302,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) @@ -1220,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) @@ -1291,16 +1472,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) @@ -1374,16 +1568,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) @@ -1450,16 +1657,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) @@ -1522,16 +1742,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) @@ -1583,16 +1816,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) @@ -3207,10 +3453,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3219,6 +3461,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) @@ -3259,16 +3518,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) @@ -3320,16 +3592,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) @@ -3419,10 +3704,6 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3431,6 +3712,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 0649b09e2..2e3d16ebf 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 @@ -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) @@ -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, - '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) @@ -716,16 +794,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) @@ -798,16 +889,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) @@ -879,16 +983,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) @@ -959,16 +1076,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) @@ -1037,16 +1167,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) @@ -1123,16 +1266,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) @@ -1199,16 +1355,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) @@ -1276,16 +1445,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) @@ -1351,16 +1533,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) @@ -1438,16 +1633,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) @@ -1518,16 +1726,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) @@ -1594,16 +1815,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) @@ -1659,16 +1893,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) @@ -3494,10 +3741,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3506,6 +3749,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) @@ -3550,16 +3810,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) @@ -3615,16 +3888,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) @@ -3718,10 +4004,6 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3730,6 +4012,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-clickhouse-agent-e2e.test.ts b/backend/test/ava-tests/saas-tests/table-clickhouse-agent-e2e.test.ts index d2030f2c4..cd3ac3b7b 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 @@ -261,16 +261,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) @@ -332,16 +345,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) @@ -405,16 +431,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) @@ -482,16 +521,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) @@ -559,16 +611,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) @@ -707,16 +785,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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -1137,16 +1293,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) @@ -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) @@ -1368,16 +1563,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) @@ -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) @@ -1535,16 +1756,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) @@ -1613,16 +1847,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) @@ -1691,16 +1938,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) @@ -1749,10 +2009,6 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -1812,10 +2068,6 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -1876,10 +2128,6 @@ test.serial( [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3565,10 +3813,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3618,16 +3862,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) @@ -3680,16 +3937,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) @@ -3780,10 +4050,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 f7509fceb..12aaa7fc5 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 @@ -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) @@ -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=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) @@ -1458,16 +1666,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 +1762,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) @@ -1620,16 +1854,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) @@ -1699,10 +1946,6 @@ test.serial(`${currentTest} should throw an exception when connection id is not [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -1758,10 +2001,6 @@ test.serial(`${currentTest} should throw an exception when connection id passed [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -1822,10 +2061,6 @@ test.serial(`${currentTest} should throw an exception when table name passed in [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -1887,16 +2122,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) @@ -3692,10 +3940,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3748,16 +3992,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) @@ -3813,16 +4070,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) @@ -3916,10 +4186,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 c11898abd..deb8202c1 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 @@ -228,16 +228,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) @@ -297,16 +310,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) @@ -371,16 +397,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) @@ -448,16 +487,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) @@ -526,16 +578,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) @@ -604,16 +669,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) @@ -676,16 +754,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) @@ -752,16 +843,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) @@ -827,16 +931,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) @@ -978,16 +1108,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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -1464,16 +1672,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) @@ -1553,16 +1774,29 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC [], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', undefined, undefined, undefined, undefined, + ); + + const createPersonalTableSettingsDTO = mockFactory.generatePersonalTableSettingsDto( undefined, + 3, + QueryOrderingEnum.DESC, + 'id', ); + const createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -1641,16 +1875,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) @@ -1700,16 +1947,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) @@ -1764,16 +2024,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) @@ -1830,16 +2103,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) @@ -3564,16 +3850,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) @@ -3631,16 +3930,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 bd307efee..1020e0048 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 @@ -251,16 +251,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) @@ -324,16 +337,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) @@ -398,16 +424,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) @@ -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, - '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) @@ -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) @@ -775,16 +866,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) @@ -845,16 +949,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) @@ -915,16 +1032,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) @@ -988,16 +1118,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) @@ -1066,16 +1209,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) @@ -1140,16 +1296,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) @@ -1220,16 +1389,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) @@ -1297,16 +1479,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) @@ -1382,16 +1577,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) @@ -1470,16 +1678,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) @@ -1556,16 +1777,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) @@ -1615,16 +1849,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) @@ -1679,16 +1926,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) @@ -1745,16 +2005,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) @@ -3534,16 +3807,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) @@ -3599,16 +3885,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 ba08a3adc..0a862096a 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 ab2a118c3..8a63c9c15 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) @@ -3064,16 +3350,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) @@ -3123,16 +3422,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 2731d630f..e3ffb0f7c 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) @@ -3507,16 +3793,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) @@ -3572,16 +3871,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 82e06d843..19849739b 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 @@ -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) @@ -312,16 +325,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) @@ -380,16 +406,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) @@ -451,16 +490,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) @@ -523,16 +575,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) @@ -595,16 +660,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) @@ -661,16 +739,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) @@ -731,16 +822,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) @@ -800,16 +904,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) @@ -869,16 +986,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) @@ -939,16 +1069,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) @@ -1013,16 +1156,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) @@ -1082,16 +1238,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) @@ -1156,16 +1325,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) @@ -1227,16 +1409,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) @@ -1306,16 +1501,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) @@ -1388,16 +1596,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) @@ -1468,16 +1689,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) @@ -1521,16 +1755,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) @@ -1579,16 +1826,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) @@ -1639,16 +1899,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) @@ -3137,16 +3410,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) @@ -3196,16 +3482,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 77c91744a..966ca115d 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 @@ -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) @@ -629,16 +694,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) @@ -701,16 +779,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) @@ -852,16 +956,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) @@ -927,16 +1044,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) @@ -1003,16 +1133,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) @@ -1083,16 +1226,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) @@ -1158,16 +1314,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) @@ -1238,16 +1407,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) @@ -1315,16 +1497,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) @@ -1400,16 +1595,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) @@ -1488,16 +1696,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) @@ -1574,16 +1795,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) @@ -1633,16 +1867,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) @@ -1697,16 +1944,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) @@ -1763,16 +2023,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) @@ -3555,16 +3828,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) @@ -3620,16 +3906,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 e2f6053f4..2046f7130 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) @@ -3222,16 +3508,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 678b7ff6b..0d9a9c662 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 @@ -254,16 +254,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) @@ -326,16 +339,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) @@ -400,16 +426,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) @@ -477,16 +516,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, - '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=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) @@ -1458,16 +1666,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) @@ -1537,16 +1758,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) @@ -1616,16 +1850,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) @@ -1675,16 +1922,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) @@ -1739,16 +1999,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) @@ -1805,16 +2078,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) @@ -3576,16 +3875,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 4bc89f404..564064ac8 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 c55928683..d2f132b9d 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) @@ -3224,16 +3510,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 3a995f999..2a5bd0578 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 @@ -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) @@ -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=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) @@ -1456,16 +1664,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) @@ -1535,16 +1756,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) @@ -1614,16 +1848,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) @@ -1673,16 +1920,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) @@ -1737,16 +1997,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) @@ -1803,16 +2076,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) @@ -3510,16 +3796,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) @@ -3575,16 +3874,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 78d2fd7b4..a59e0b0a4 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) @@ -3224,16 +3510,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 709830773..201acbde7 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 @@ -254,16 +254,32 @@ 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'); + + const createPersonalTableSettingsRO = JSON.parse(createPersonalTableSettingsResponse.text); + console.log('🚀 ~ createPersonalTableSettingsRO:', createPersonalTableSettingsRO); + + t.is(createPersonalTableSettingsResponse.status, 200); + const createTableSettingsResponse = await request(app.getHttpServer()) .post(`/settings?connectionId=${createConnectionRO.id}&tableName=${testTableName}`) .send(createTableSettingsDTO) @@ -328,16 +344,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) @@ -402,16 +431,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) @@ -479,16 +521,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) @@ -557,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) @@ -634,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) @@ -706,16 +787,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 +872,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 +956,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 +1040,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 +1125,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 +1214,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 +1301,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 +1391,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 +1479,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 +1574,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'; @@ -1411,7 +1622,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); @@ -1454,16 +1665,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) @@ -1537,16 +1761,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) @@ -1616,16 +1853,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) @@ -1695,16 +1945,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) @@ -1754,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) @@ -1818,16 +2094,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) @@ -1884,16 +2173,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) @@ -3729,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) @@ -3794,16 +4109,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 c7a23d6af..bccdcd870 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 44a5cb384..2fb0c4da0 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) @@ -3223,16 +3509,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 3bd83e406..131d9cd19 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 @@ -301,16 +301,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) @@ -373,16 +386,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 +473,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) @@ -524,16 +563,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,6 +594,8 @@ 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); + const getTableRowsResponse = await request(app.getHttpServer()) .get( `/table/rows/${createConnectionRO.id}?tableName=${testTableName}&search=${testSearchedUserName}&page=1&perPage=2`, @@ -549,9 +603,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(Object.hasOwn(getTableRowsRO, 'rows'), true); t.is(Object.hasOwn(getTableRowsRO, 'primaryColumns'), true); @@ -602,16 +658,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) @@ -654,77 +723,90 @@ 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.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); - 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, + 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, + 20, + QueryOrderingEnum.DESC, + 'id', + ); - 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 createPersonalTableSettingsResponse = await request(app.getHttpServer()) + .put(`/settings/personal/${createConnectionRO.id}`) + .query({ tableName: testTableName }) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); - t.is(typeof getTableRowsRO, 'object'); - t.is(Object.hasOwn(getTableRowsRO, 'rows'), true); - t.is(Object.hasOwn(getTableRowsRO, 'primaryColumns'), true); - t.is(Object.hasOwn(getTableRowsRO, '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); + t.is(createPersonalTableSettingsResponse.status, 200); - t.is(typeof getTableRowsRO.primaryColumns, 'object'); - t.is(Object.hasOwn(getTableRowsRO.primaryColumns[0], 'column_name'), true); - t.is(Object.hasOwn(getTableRowsRO.primaryColumns[0], 'data_type'), true); - } catch (e) { - console.error(e); - throw e; - } - }, -); + 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'); + + 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); + 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[19].id, 23); + + 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 @@ -752,16 +834,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) @@ -824,16 +919,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) @@ -895,16 +1003,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) @@ -966,16 +1087,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) @@ -1038,16 +1172,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) @@ -1114,16 +1261,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) @@ -1188,16 +1348,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) @@ -1265,16 +1438,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) @@ -1340,16 +1526,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) @@ -1422,16 +1621,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) @@ -1508,16 +1720,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) @@ -1591,16 +1816,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) @@ -1670,16 +1908,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) @@ -1749,16 +2000,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) @@ -1808,16 +2072,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) @@ -1872,16 +2149,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) @@ -1937,16 +2227,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) @@ -3899,10 +4202,6 @@ test.serial(`${currentTest} should throw exception when csv export is disabled i [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -3911,6 +4210,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) @@ -3955,16 +4271,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) @@ -4020,16 +4349,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) @@ -4123,10 +4465,6 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`, [testTableColumnName], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'id', - undefined, undefined, undefined, undefined, @@ -4135,6 +4473,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 3fcb981ff..923f94d96 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,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +378,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +469,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +563,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +658,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +753,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +842,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +931,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1019,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1107,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1196,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1289,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1380,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1566,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1665,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1765,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1861,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +1957,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +2034,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +2115,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 +2198,30 @@ 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 }) + .set('masterpwd', masterPwd) + .send(createPersonalTableSettingsDTO) + .set('Cookie', firstUserToken) + .set('Content-Type', 'application/json') + .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 d8670d3d0..a48a30550 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 ab97fa8cd..a41a3a647 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 @@ -243,16 +243,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) @@ -311,16 +324,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) @@ -381,16 +407,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) @@ -454,16 +493,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) @@ -529,16 +581,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, - '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) @@ -671,16 +749,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) @@ -737,16 +828,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) @@ -808,16 +912,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) @@ -873,16 +990,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) @@ -944,16 +1074,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) @@ -1020,16 +1163,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) @@ -1092,16 +1248,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) @@ -1168,16 +1337,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) @@ -1241,16 +1423,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) @@ -1322,16 +1517,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) @@ -1406,16 +1614,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) @@ -1488,16 +1709,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) @@ -1543,16 +1777,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) @@ -1603,16 +1850,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) @@ -1665,16 +1925,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) @@ -3233,16 +3506,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) @@ -3294,16 +3580,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 d34a4e811..57b27a079 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 @@ -249,16 +249,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) @@ -323,16 +336,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) @@ -397,16 +423,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) @@ -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) @@ -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, - '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) @@ -704,16 +782,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 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) @@ -849,16 +953,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) @@ -918,16 +1035,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) @@ -995,16 +1125,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) @@ -1077,16 +1220,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) @@ -1153,16 +1309,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) @@ -1233,16 +1402,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) @@ -1310,16 +1492,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) @@ -1395,16 +1590,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) @@ -1483,16 +1691,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) @@ -1570,16 +1791,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) @@ -1629,16 +1863,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) @@ -1693,16 +1940,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) @@ -1759,16 +2019,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) @@ -3556,16 +3829,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) @@ -3621,16 +3907,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 fbcbf9f27..772d37176 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, @@ -196,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, []); @@ -232,10 +224,6 @@ test.serial(`${currentTest} should return created table settings`, async (t) => ['title'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, undefined, @@ -262,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, []); @@ -295,10 +279,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 +320,6 @@ test.serial(`${currentTest} should throw exception when connectionId is missing` ['title'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, undefined, @@ -385,10 +361,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 +400,6 @@ test.serial(`${currentTest} should throw exception when excluded_fields is not a ['title'], 'type', undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, ); @@ -451,49 +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, - 'type', - 3, - QueryOrderingEnum.DESC, - 'port', - 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; @@ -513,10 +438,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 +478,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 +519,6 @@ test.serial( ['testField'], undefined, undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, ); @@ -648,10 +561,6 @@ test.serial( ['type'], ['testField'], undefined, - 3, - QueryOrderingEnum.DESC, - 'port', - undefined, undefined, undefined, ); @@ -672,49 +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, - ['testField'], - 3, - QueryOrderingEnum.DESC, - 'port', - 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) => { @@ -736,10 +602,6 @@ test.serial( 'connection', ['type'], undefined, - undefined, - 3, - QueryOrderingEnum.DESC, - 'port', ['testField'], undefined, undefined, @@ -761,49 +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, - 3, - QueryOrderingEnum.DESC, - 'port', - 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); - } - }, -); 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, {}); +}); 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 e37754eab..bceadd356 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 @@ -3608,21 +3608,17 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3635,71 +3631,28 @@ test.serial( t.is(createTableSettingsResponse.status, 201); - const getTableSettings = await request(app.getHttpServer()) - .get( - `/settings/?connectionId=${testData.connections.firstId}&tableName=${testData.firstTableInfo.testTableName}`, - ) - .set("Cookie", testData.users.simpleUserToken) - .set("Content-Type", "application/json") - .set("Accept", "application/json"); - const getTableSettingsRO = JSON.parse(getTableSettings.text); - t.is(getTableSettings.status, 200); - t.is(Object.hasOwn(getTableSettingsRO, "id"), true); - t.is(getTableSettingsRO.table_name, createTableSettingsDTO.table_name); - 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([]), - ); - t.is(getTableSettingsRO.connection_id, testData.connections.firstId); - } catch (error) { - console.error(error); - throw error; - } - }, -); + const getTableSettings = await request(app.getHttpServer()) + .get(`/settings/?connectionId=${testData.connections.firstId}&tableName=${testData.firstTableInfo.testTableName}`) + .set('Cookie', testData.users.simpleUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + const getTableSettingsRO = JSON.parse(getTableSettings.text); + t.is(getTableSettings.status, 200); + t.is(getTableSettingsRO.hasOwnProperty('id'), true); + t.is(getTableSettingsRO.table_name, createTableSettingsDTO.table_name); + 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.identification_fields), JSON.stringify([])); + 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([])); + t.is(getTableSettingsRO.connection_id, testData.connections.firstId); + } catch (error) { + console.error(error); + throw error; + } +}); test.serial( `${currentTest} should throw an exception when you try get settings in connection where you do not have permission`, @@ -3710,21 +3663,17 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3764,21 +3713,17 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3790,59 +3735,22 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const createTableSettingsRO = JSON.parse( - createTableSettingsResponse.text, - ); - t.is(Object.hasOwn(createTableSettingsRO, "id"), true); - t.is(createTableSettingsRO.table_name, createTableSettingsDTO.table_name); - 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([]), - ); - t.is(createTableSettingsRO.connection_id, testData.connections.firstId); - } catch (error) { - console.error(error); - throw error; - } - }, -); + const createTableSettingsRO = JSON.parse(createTableSettingsResponse.text); + t.is(createTableSettingsRO.hasOwnProperty('id'), true); + t.is(createTableSettingsRO.table_name, createTableSettingsDTO.table_name); + 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.identification_fields), JSON.stringify([])); + 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([])); + t.is(createTableSettingsRO.connection_id, testData.connections.firstId); + } catch (error) { + console.error(error); + throw error; + } +}); test.serial( `${currentTest} should throw an exception when you try create settings in connection where you do not have permission`, @@ -3853,21 +3761,17 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3901,21 +3805,17 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3927,21 +3827,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.ASC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -3956,50 +3852,20 @@ test.serial( ); t.is(updateTableSettingsResponse.status, 200); - t.is(Object.hasOwn(updateTableSettingsRO, "id"), true); - t.is(updateTableSettingsRO.table_name, updateTableSettingsDTO.table_name); - 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([])); - t.is(updateTableSettingsRO.connection_id, testData.connections.firstId); - } catch (error) { - console.error(error); - throw error; - } - }, -); + t.is(updateTableSettingsRO.hasOwnProperty('id'), true); + t.is(updateTableSettingsRO.table_name, updateTableSettingsDTO.table_name); + 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.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([])); + t.is(updateTableSettingsRO.connection_id, testData.connections.firstId); + } catch (error) { + console.error(error); + throw error; + } +}); test.serial( `${currentTest} should throw an exception when you try update settings in connection where you do not have permission`, @@ -4010,21 +3876,17 @@ test.serial( 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( @@ -4037,21 +3899,17 @@ test.serial( 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( @@ -4084,21 +3942,17 @@ test.serial( app, ); - const createTableSettingsDTO = mockFactory.generateTableSettings( - testData.connections.firstId, - testData.firstTableInfo.testTableName, - ["id"], - [testData.firstTableInfo.testTableSecondColumnName], - [testData.firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + testData.connections.firstId, + testData.firstTableInfo.testTableName, + ['id'], + [testData.firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -4146,21 +4000,17 @@ test.serial( 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( 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 d68cd7953..4e2a02e9c 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 @@ -2783,21 +2783,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2809,70 +2805,27 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const getTableSettings = await request(app.getHttpServer()) - .get( - `/settings/?connectionId=${connections.firstId}&tableName=${firstTableInfo.testTableName}`, - ) - .set("Cookie", simpleUserToken) - .set("Content-Type", "application/json") - .set("Accept", "application/json"); - const getTableSettingsRO = JSON.parse(getTableSettings.text); - t.is(getTableSettings.status, 200); - t.is(Object.hasOwn(getTableSettingsRO, "id"), true); - t.is(getTableSettingsRO.table_name, createTableSettingsDTO.table_name); - 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([]), - ); - t.is(getTableSettingsRO.connection_id, connections.firstId); - } catch (e) { - console.error(e); - } - }, -); + const getTableSettings = await request(app.getHttpServer()) + .get(`/settings/?connectionId=${connections.firstId}&tableName=${firstTableInfo.testTableName}`) + .set('Cookie', simpleUserToken) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json'); + const getTableSettingsRO = JSON.parse(getTableSettings.text); + t.is(getTableSettings.status, 200); + t.is(getTableSettingsRO.hasOwnProperty('id'), true); + t.is(getTableSettingsRO.table_name, createTableSettingsDTO.table_name); + 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.identification_fields), JSON.stringify([])); + 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([])); + t.is(getTableSettingsRO.connection_id, connections.firstId); + } catch (e) { + console.error(e); + } +}); test.serial( `${currentTest} should throw an exception when you try get settings in connection where you do not have permission`, @@ -2891,21 +2844,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2953,21 +2902,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - "users", - ["id"], - ["email"], - ["name"], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + 'users', + ['id'], + ['email'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3005,21 +2950,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3043,37 +2984,28 @@ test.serial( currentTest = "PUT /settings/"; -test.serial( - `${currentTest} should throw an exception do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should throw an exception do not have permission`, async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3085,21 +3017,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -3121,36 +3049,29 @@ test.serial( ); 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 createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try update settings in connection where you do not have permission`, + async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3162,21 +3083,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -3199,37 +3116,28 @@ test.serial( currentTest = "DELETE /settings/"; -test.serial( - `${currentTest} should return array without deleted table settings`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should return array without deleted table settings`, async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3261,36 +3169,29 @@ test.serial( ); test.serial( - `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, + async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithGroupPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( 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 99435ca16..1540aa9fa 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 @@ -2728,21 +2728,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2787,21 +2783,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2850,21 +2842,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - "users", - ["id"], - ["email"], - ["name"], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + 'users', + ['id'], + ['email'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2903,21 +2891,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2942,37 +2926,29 @@ test.serial( currentTest = "PUT /settings/"; -test.serial( - `${currentTest} should throw an exception do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should throw an exception do not have permission`, async (t) => { + try { + const testData = + await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2984,21 +2960,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -3021,36 +2993,30 @@ test.serial( ); 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 createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try update settings in connection where you do not have permission`, + async (t) => { + try { + const testData = + await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3062,21 +3028,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -3100,37 +3062,29 @@ test.serial( currentTest = "DELETE /settings/"; -test.serial( - `${currentTest} should return array without deleted table settings`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should return array without deleted table settings`, async (t) => { + try { + const testData = + await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3163,36 +3117,30 @@ test.serial( ); test.serial( - `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, + async (t) => { + try { + const testData = + await createConnectionsAndInviteNewUserInNewGroupWithTableDifferentConnectionGroupReadOnlyPermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( 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 6b05559f2..8e4b54ae3 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 @@ -2645,21 +2645,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2705,21 +2701,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2768,21 +2760,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - "users", - ["id"], - ["email"], - ["name"], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + 'users', + ['id'], + ['email'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2821,21 +2809,17 @@ test.serial( users: { adminUserToken, simpleUserToken }, } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2860,37 +2844,28 @@ test.serial( currentTest = "PUT /settings/"; -test.serial( - `${currentTest} should throw an exception do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should throw an exception do not have permission`, async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2902,21 +2877,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -2939,36 +2910,29 @@ test.serial( ); 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 createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try update settings in connection where you do not have permission`, + async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -2980,21 +2944,17 @@ test.serial( .set("Accept", "application/json"); t.is(createTableSettingsResponse.status, 201); - const updateTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - [firstTableInfo.testTableSecondColumnName], - ["id"], - [firstTableInfo.testTableColumnName], - 50, - QueryOrderingEnum.ASC, - "created_at", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + const updateTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + [firstTableInfo.testTableSecondColumnName], + ['id'], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const updateTableSettingsResponse = await request(app.getHttpServer()) .put( @@ -3018,37 +2978,28 @@ test.serial( currentTest = "DELETE /settings/"; -test.serial( - `${currentTest} should return array without deleted table settings`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.firstId, - firstTableInfo.testTableName, - ["id"], - [firstTableInfo.testTableSecondColumnName], - [firstTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); +test.serial(`${currentTest} should return array without deleted table settings`, async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.firstId, + firstTableInfo.testTableName, + ['id'], + [firstTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( @@ -3081,36 +3032,29 @@ test.serial( ); test.serial( - `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, - async (t) => { - try { - const testData = - await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions( - app, - ); - const { - connections, - firstTableInfo, - groups, - permissions, - secondTableInfo, - users: { adminUserToken, simpleUserToken }, - } = testData; - const createTableSettingsDTO = mockFactory.generateTableSettings( - connections.secondId, - secondTableInfo.testTableName, - ["id"], - [secondTableInfo.testTableSecondColumnName], - [secondTableInfo.testTableColumnName], - 3, - QueryOrderingEnum.DESC, - "id", - ["updated_at"], - ["created_at"], - undefined, - undefined, - undefined, - ); + `${currentTest} should throw an exception when you try delete settings in connection where you do not have permission`, + async (t) => { + try { + const testData = await createConnectionsAndInviteNewUserInNewGroupWithOnlyTablePermissions(app); + const { + connections, + firstTableInfo, + groups, + permissions, + secondTableInfo, + users: { adminUserToken, simpleUserToken }, + } = testData; + const createTableSettingsDTO = mockFactory.generateTableSettings( + connections.secondId, + secondTableInfo.testTableName, + ['id'], + [secondTableInfo.testTableSecondColumnName], + ['updated_at'], + ['created_at'], + undefined, + undefined, + undefined, + ); const createTableSettingsResponse = await request(app.getHttpServer()) .post( diff --git a/backend/test/mock.factory.ts b/backend/test/mock.factory.ts index d0f6b5588..41336a2b2 100644 --- a/backend/test/mock.factory.ts +++ b/backend/test/mock.factory.ts @@ -17,6 +17,7 @@ class CreateGroupDto { isMain?: boolean; users?: Array; } +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'; @@ -548,15 +549,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 + // } + 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, @@ -572,10 +595,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, @@ -587,15 +606,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, @@ -607,10 +644,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, 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 229023661..6fab07d7c 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 '../../../shared/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..876feb0b7 --- /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 '../../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, + }; +}