From 550570246ce7405c29123e545b0803954e3ec57c Mon Sep 17 00:00:00 2001 From: GalT <39020298+tatarco@users.noreply.github.com> Date: Mon, 9 Dec 2024 08:39:20 +0100 Subject: [PATCH] feat(api): add topic e2e --- apps/api/package.json | 2 +- .../shared/helpers/e2e/sdk/e2e-sdk.helper.ts | 3 +- apps/api/src/app/topics/topics.controller.ts | 2 +- .../get-topic-subscriber.use-case.ts | 5 +-- pnpm-lock.yaml | 40 +++++++++---------- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/apps/api/package.json b/apps/api/package.json index d5bdfdf262a9..74e14bbc2821 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -58,7 +58,7 @@ "@sentry/tracing": "^7.40.0", "@types/newrelic": "^9.14.0", "@upstash/ratelimit": "^0.4.4", - "@novu/api": "^0.0.1-alpha.65", + "@novu/api": "^0.0.1-alpha.66", "axios": "^1.6.8", "liquidjs": "^10.13.1", "bcrypt": "^5.0.0", diff --git a/apps/api/src/app/shared/helpers/e2e/sdk/e2e-sdk.helper.ts b/apps/api/src/app/shared/helpers/e2e/sdk/e2e-sdk.helper.ts index 9838af9aceb2..b5e1e61b47ac 100644 --- a/apps/api/src/app/shared/helpers/e2e/sdk/e2e-sdk.helper.ts +++ b/apps/api/src/app/shared/helpers/e2e/sdk/e2e-sdk.helper.ts @@ -19,11 +19,10 @@ export function handleSdkError(error: unknown): { error: SDKError; parsedBody: a if (!isSDKError(error)) { throw new Error('Provided error is not an SDKError'); } - expect(error.name).to.equal('SDKError'); expect(error.body).to.be.ok; expect(typeof error.body).to.be.eq('string'); - const errorBody = JSON.parse(error.body); + const errorBody = error.body ? JSON.parse(error.body) : 'No Body'; return { error, parsedBody: errorBody }; } diff --git a/apps/api/src/app/topics/topics.controller.ts b/apps/api/src/app/topics/topics.controller.ts index 1043d5464e06..48173f974884 100644 --- a/apps/api/src/app/topics/topics.controller.ts +++ b/apps/api/src/app/topics/topics.controller.ts @@ -224,7 +224,7 @@ export class TopicsController { @HttpCode(HttpStatus.NO_CONTENT) @ApiOperation({ summary: 'Delete topic', description: 'Delete a topic by its topic key if it has no subscribers' }) async deleteTopic(@UserSession() user: UserSessionData, @Param('topicKey') topicKey: TopicKey): Promise { - return await this.deleteTopicUseCase.execute( + await this.deleteTopicUseCase.execute( DeleteTopicCommand.create({ environmentId: user.environmentId, topicKey, diff --git a/apps/api/src/app/topics/use-cases/get-topic-subscriber/get-topic-subscriber.use-case.ts b/apps/api/src/app/topics/use-cases/get-topic-subscriber/get-topic-subscriber.use-case.ts index 386056e3e4c5..f00e8e4b5014 100644 --- a/apps/api/src/app/topics/use-cases/get-topic-subscriber/get-topic-subscriber.use-case.ts +++ b/apps/api/src/app/topics/use-cases/get-topic-subscriber/get-topic-subscriber.use-case.ts @@ -4,13 +4,12 @@ import { TopicSubscribersEntity, TopicSubscribersRepository } from '@novu/dal'; import { GetTopicSubscriberCommand } from './get-topic-subscriber.command'; import { TopicSubscriberDto } from '../../dtos'; -import { ExternalSubscriberId } from '../../types'; @Injectable() export class GetTopicSubscriberUseCase { constructor(private topicSubscribersRepository: TopicSubscribersRepository) {} - async execute(command: GetTopicSubscriberCommand) { + async execute(command: GetTopicSubscriberCommand): Promise { const topicSubscriber = await this.topicSubscribersRepository.findOneByTopicKeyAndExternalSubscriberId( command.environmentId, command.organizationId, @@ -29,7 +28,7 @@ export class GetTopicSubscriberUseCase { private mapFromEntity(topicSubscriber: TopicSubscribersEntity): TopicSubscriberDto { return { - ...topicSubscriber, + externalSubscriberId: topicSubscriber.externalSubscriberId, topicKey: topicSubscriber.topicKey, _topicId: topicSubscriber._topicId, _organizationId: topicSubscriber._organizationId, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fc6e2f92357b..74ab1c1f6306 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -394,8 +394,8 @@ importers: specifier: 6.2.1 version: 6.2.1(@nestjs/common@10.4.1(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.1(@nestjs/common@10.4.1(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.1)(@nestjs/websockets@10.4.1)(encoding@0.1.13)(reflect-metadata@0.2.2)(rxjs@7.8.1))(reflect-metadata@0.2.2) '@novu/api': - specifier: ^0.0.1-alpha.65 - version: 0.0.1-alpha.65(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(zod@3.23.8) + specifier: ^0.0.1-alpha.66 + version: 0.0.1-alpha.66(zod@3.23.8) '@novu/application-generic': specifier: workspace:* version: link:../../libs/application-generic @@ -10607,11 +10607,9 @@ packages: '@nothing-but/utils@0.12.1': resolution: {integrity: sha512-1qZU1Q5El0IjE7JT/ucvJNzdr2hL3W8Rm27xNf1p6gb3Nw8pGnZmxp6/GEW9h+I1k1cICxXNq25hBwknTQ7yhg==} - '@novu/api@0.0.1-alpha.65': - resolution: {integrity: sha512-YIqaLvpYdwed2u0/8vFk4TDid9TX5WFbAw9TeTrjDWv/d+VdLsxRot4TewgbNuIyL797yhFISSj1J/Wwe2cs1Q==} + '@novu/api@0.0.1-alpha.66': + resolution: {integrity: sha512-MMgU/ibHMFcPzUuvlTUfGvoK87Mb8ZkK4viqmAcfK7k58PnUiSkcsbXlgLfTrelriBJMm3IK256fMp3VtbE+Dg==} peerDependencies: - react: ^18 || ^19 - react-dom: ^18 || ^19 zod: '>= 3' '@novu/ntfr-client@0.0.4': @@ -35748,8 +35746,8 @@ snapshots: dependencies: '@aws-crypto/sha256-browser': 3.0.0 '@aws-crypto/sha256-js': 3.0.0 - '@aws-sdk/client-sso-oidc': 3.575.0 - '@aws-sdk/client-sts': 3.575.0(@aws-sdk/client-sso-oidc@3.575.0) + '@aws-sdk/client-sso-oidc': 3.575.0(@aws-sdk/client-sts@3.575.0) + '@aws-sdk/client-sts': 3.575.0 '@aws-sdk/core': 3.575.0 '@aws-sdk/credential-provider-node': 3.575.0(@aws-sdk/client-sso-oidc@3.575.0)(@aws-sdk/client-sts@3.575.0) '@aws-sdk/middleware-host-header': 3.575.0 @@ -35950,8 +35948,8 @@ snapshots: '@aws-crypto/sha1-browser': 3.0.0 '@aws-crypto/sha256-browser': 3.0.0 '@aws-crypto/sha256-js': 3.0.0 - '@aws-sdk/client-sso-oidc': 3.575.0 - '@aws-sdk/client-sts': 3.575.0(@aws-sdk/client-sso-oidc@3.575.0) + '@aws-sdk/client-sso-oidc': 3.575.0(@aws-sdk/client-sts@3.575.0) + '@aws-sdk/client-sts': 3.575.0 '@aws-sdk/core': 3.575.0 '@aws-sdk/credential-provider-node': 3.575.0(@aws-sdk/client-sso-oidc@3.575.0)(@aws-sdk/client-sts@3.575.0) '@aws-sdk/middleware-bucket-endpoint': 3.575.0 @@ -36177,11 +36175,11 @@ snapshots: - aws-crt optional: true - '@aws-sdk/client-sso-oidc@3.575.0': + '@aws-sdk/client-sso-oidc@3.575.0(@aws-sdk/client-sts@3.575.0)': dependencies: '@aws-crypto/sha256-browser': 3.0.0 '@aws-crypto/sha256-js': 3.0.0 - '@aws-sdk/client-sts': 3.575.0(@aws-sdk/client-sso-oidc@3.575.0) + '@aws-sdk/client-sts': 3.575.0 '@aws-sdk/core': 3.575.0 '@aws-sdk/credential-provider-node': 3.575.0(@aws-sdk/client-sso-oidc@3.575.0)(@aws-sdk/client-sts@3.575.0) '@aws-sdk/middleware-host-header': 3.575.0 @@ -36220,6 +36218,7 @@ snapshots: '@smithy/util-utf8': 3.0.0 tslib: 2.7.0 transitivePeerDependencies: + - '@aws-sdk/client-sts' - aws-crt '@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0)': @@ -36604,11 +36603,11 @@ snapshots: - aws-crt optional: true - '@aws-sdk/client-sts@3.575.0(@aws-sdk/client-sso-oidc@3.575.0)': + '@aws-sdk/client-sts@3.575.0': dependencies: '@aws-crypto/sha256-browser': 3.0.0 '@aws-crypto/sha256-js': 3.0.0 - '@aws-sdk/client-sso-oidc': 3.575.0 + '@aws-sdk/client-sso-oidc': 3.575.0(@aws-sdk/client-sts@3.575.0) '@aws-sdk/core': 3.575.0 '@aws-sdk/credential-provider-node': 3.575.0(@aws-sdk/client-sso-oidc@3.575.0)(@aws-sdk/client-sts@3.575.0) '@aws-sdk/middleware-host-header': 3.575.0 @@ -36647,7 +36646,6 @@ snapshots: '@smithy/util-utf8': 3.0.0 tslib: 2.7.0 transitivePeerDependencies: - - '@aws-sdk/client-sso-oidc' - aws-crt '@aws-sdk/client-sts@3.637.0': @@ -36877,7 +36875,7 @@ snapshots: '@aws-sdk/credential-provider-ini@3.575.0(@aws-sdk/client-sso-oidc@3.575.0)(@aws-sdk/client-sts@3.575.0)': dependencies: - '@aws-sdk/client-sts': 3.575.0(@aws-sdk/client-sso-oidc@3.575.0) + '@aws-sdk/client-sts': 3.575.0 '@aws-sdk/credential-provider-env': 3.575.0 '@aws-sdk/credential-provider-process': 3.575.0 '@aws-sdk/credential-provider-sso': 3.575.0(@aws-sdk/client-sso-oidc@3.575.0) @@ -37188,7 +37186,7 @@ snapshots: '@aws-sdk/credential-provider-web-identity@3.575.0(@aws-sdk/client-sts@3.575.0)': dependencies: - '@aws-sdk/client-sts': 3.575.0(@aws-sdk/client-sso-oidc@3.575.0) + '@aws-sdk/client-sts': 3.575.0 '@aws-sdk/types': 3.575.0 '@smithy/property-provider': 3.1.3 '@smithy/types': 3.3.0 @@ -37709,7 +37707,7 @@ snapshots: '@aws-sdk/token-providers@3.575.0(@aws-sdk/client-sso-oidc@3.575.0)': dependencies: - '@aws-sdk/client-sso-oidc': 3.575.0 + '@aws-sdk/client-sso-oidc': 3.575.0(@aws-sdk/client-sts@3.575.0) '@aws-sdk/types': 3.575.0 '@smithy/property-provider': 3.1.3 '@smithy/shared-ini-file-loader': 3.1.4 @@ -37718,7 +37716,7 @@ snapshots: '@aws-sdk/token-providers@3.614.0(@aws-sdk/client-sso-oidc@3.575.0)': dependencies: - '@aws-sdk/client-sso-oidc': 3.575.0 + '@aws-sdk/client-sso-oidc': 3.575.0(@aws-sdk/client-sts@3.575.0) '@aws-sdk/types': 3.609.0 '@smithy/property-provider': 3.1.3 '@smithy/shared-ini-file-loader': 3.1.4 @@ -46905,10 +46903,8 @@ snapshots: '@nothing-but/utils@0.12.1': {} - '@novu/api@0.0.1-alpha.65(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(zod@3.23.8)': + '@novu/api@0.0.1-alpha.66(zod@3.23.8)': dependencies: - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) zod: 3.23.8 '@novu/ntfr-client@0.0.4':