Skip to content

Commit

Permalink
feat(api): add topic e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
tatarco committed Dec 9, 2024
1 parent 35d7783 commit 5505702
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions apps/api/src/app/shared/helpers/e2e/sdk/e2e-sdk.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/topics/topics.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
return await this.deleteTopicUseCase.execute(
await this.deleteTopicUseCase.execute(
DeleteTopicCommand.create({
environmentId: user.environmentId,
topicKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TopicSubscriberDto> {
const topicSubscriber = await this.topicSubscribersRepository.findOneByTopicKeyAndExternalSubscriberId(
command.environmentId,
command.organizationId,
Expand All @@ -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,
Expand Down
40 changes: 18 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5505702

Please sign in to comment.