Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { ChannelTypeEnum } from '@novu/stateless';
import { UserSession } from '@novu/testing';
import { expect } from 'chai';
import { createHash } from 'crypto';

Check notice on line 7 in apps/api/migrations/encrypt-api-keys/encrypt-api-keys-migration.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/style/useNodejsImportProtocol

A Node.js builtin module should be imported with the node: protocol.

import { encryptApiKeysMigration } from './encrypt-api-keys-migration';

Expand All @@ -30,8 +30,8 @@

for (let i = 0; i < 2; i += 1) {
await environmentRepository.create({
identifier: 'identifier' + i,

Check notice on line 33 in apps/api/migrations/encrypt-api-keys/encrypt-api-keys-migration.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/style/useTemplate

Template literals are preferred over string concatenation.
name: faker.name.jobTitle(),
name: faker.person.jobTitle(),
_organizationId: session.organization._id,
apiKeys: [
{
Expand Down Expand Up @@ -75,7 +75,7 @@
it('should validate migration idempotence', async () => {
await pruneIntegration({ environmentRepository });

const data = {

Check warning on line 78 in apps/api/migrations/encrypt-api-keys/encrypt-api-keys-migration.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/correctness/noUnusedVariables

This variable data is unused.
providerId: 'sendgrid',
channel: ChannelTypeEnum.EMAIL,
active: false,
Expand All @@ -83,8 +83,8 @@

for (let i = 0; i < 2; i += 1) {
await environmentRepository.create({
identifier: 'identifier' + i,

Check notice on line 86 in apps/api/migrations/encrypt-api-keys/encrypt-api-keys-migration.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/style/useTemplate

Template literals are preferred over string concatenation.
name: faker.name.jobTitle(),
name: faker.person.jobTitle(),
_organizationId: session.organization._id,
apiKeys: [
{
Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"zod-to-json-schema": "^3.25.2"
},
"devDependencies": {
"@faker-js/faker": "^6.0.0",
"@faker-js/faker": "^10.5.0",
"@nestjs/cli": "11.0.23",
"@nestjs/schematics": "11.1.0",
"@nestjs/testing": "11.1.27",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,11 @@

it('should update deviceTokens without duplication on channel creation (addChannelToSubscriber)', async () => {
const subscriberId = SubscriberRepository.createObjectId();
const test = await subscriberRepository.create({

Check warning on line 427 in apps/api/src/app/subscribers/unit/update-subscriber-channel.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/correctness/noUnusedVariables

This variable test is unused.
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
email: faker.internet.email(),
phone: faker.phone.phoneNumber(),
phone: faker.phone.number(),
_environmentId: session.environment._id,
_organizationId: session.organization._id,
subscriberId,
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"@clerk/backend": "^3.4.11",
"@clerk/shared": "^4.23.0",
"@clerk/testing": "^2.0.31",
"@faker-js/faker": "^9.5.0",
"@faker-js/faker": "^10.5.0",
"@hookform/devtools": "^4.3.0",
"@novu/dal": "workspace:*",
"@novu/ee-auth": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/tests/utils/environment-service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { faker } from '@faker-js/faker';
import { EnvironmentEntity, EnvironmentRepository, LayoutRepository, NotificationGroupRepository } from '@novu/dal';
import { createHash } from 'crypto';

Check notice on line 3 in apps/dashboard/tests/utils/environment-service.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/style/useNodejsImportProtocol

A Node.js builtin module should be imported with the node: protocol.

export class EnvironmentService {
constructor() {}

Check notice on line 6 in apps/dashboard/tests/utils/environment-service.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/complexity/noUselessConstructor

This constructor is unnecessary.

private async createEnvironment(
organizationId: string,
Expand All @@ -18,7 +18,7 @@

return await environmentRepository.create({
identifier: faker.string.uuid(),
name: name ?? faker.name.jobTitle(),
name: name ?? faker.person.jobTitle(),
_organizationId: organizationId,
...(parentId && { _parentId: parentId }),
apiKeys: [
Expand Down Expand Up @@ -47,7 +47,7 @@

const environment = await this.createEnvironment(organizationId, userId, name, parentId);

let parentGroup;

Check warning on line 50 in apps/dashboard/tests/utils/environment-service.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/suspicious/noImplicitAnyLet

This variable implicitly has the any type.

if (parentId) {
parentGroup = await notificationGroupRepository.findOne({
Expand Down
2 changes: 1 addition & 1 deletion apps/worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"uuid": "^11.1.1"
},
"devDependencies": {
"@faker-js/faker": "^6.0.0",
"@faker-js/faker": "^10.5.0",
"@nestjs/cli": "11.0.23",
"@nestjs/schematics": "11.1.0",
"@nestjs/testing": "11.1.27",
Expand Down
6 changes: 3 additions & 3 deletions apps/worker/src/app/workflow/services/standard.worker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
} from '@novu/testing';
import { expect } from 'chai';
import { formatISO } from 'date-fns';
import { setTimeout } from 'timers/promises';

Check notice on line 39 in apps/worker/src/app/workflow/services/standard.worker.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/style/useNodejsImportProtocol

A Node.js builtin module should be imported with the node: protocol.
import { v4 as uuid } from 'uuid';
import { SharedModule } from '../../shared/shared.module';
import { HandleLastFailedJob, RunJob, RunJobCommand, SetJobAsFailed, WebhookFilterBackoffStrategy } from '../usecases';
Expand All @@ -46,36 +46,36 @@
let standardQueueService: StandardQueueService;
let standardWorker: StandardWorker;

const mockFeatureFlagsService = {
getFlag: async () => false,
} as unknown as FeatureFlagsService;

Check failure on line 51 in apps/worker/src/app/workflow/services/standard.worker.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

plugin

This assertion widens to unknown/any and then asserts a precise type. Parse untrusted input at its boundary.

Check failure on line 51 in apps/worker/src/app/workflow/services/standard.worker.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

plugin

This assertion chain discards type evidence. Keep the original precise type, or parse untrusted input at its boundary before narrowing it.

const mockOrganizationRepository = {
findOne: async () => ({ _id: 'mock-org-id', apiServiceLevel: 'free' }),
} as unknown as CommunityOrganizationRepository;

Check failure on line 55 in apps/worker/src/app/workflow/services/standard.worker.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

plugin

This assertion widens to unknown/any and then asserts a precise type. Parse untrusted input at its boundary.

Check failure on line 55 in apps/worker/src/app/workflow/services/standard.worker.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

plugin

This assertion chain discards type evidence. Keep the original precise type, or parse untrusted input at its boundary before narrowing it.

const mockSqsService = {
getQueueUrl: () => undefined,
getProducer: () => undefined,
getClient: () => ({}) as any,
isConfigured: () => false,
send: async () => {},
sendBulk: async () => {},
} as unknown as SqsService;

Check failure on line 64 in apps/worker/src/app/workflow/services/standard.worker.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

plugin

This assertion widens to unknown/any and then asserts a precise type. Parse untrusted input at its boundary.

Check failure on line 64 in apps/worker/src/app/workflow/services/standard.worker.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

plugin

This assertion chain discards type evidence. Keep the original precise type, or parse untrusted input at its boundary before narrowing it.

const mockLogger = {
setContext: () => {},
debug: () => {},
info: () => {},
warn: () => {},
error: () => {},
} as unknown as PinoLogger;

Check failure on line 72 in apps/worker/src/app/workflow/services/standard.worker.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

plugin

This assertion widens to unknown/any and then asserts a precise type. Parse untrusted input at its boundary.

Check failure on line 72 in apps/worker/src/app/workflow/services/standard.worker.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

plugin

This assertion chain discards type evidence. Keep the original precise type, or parse untrusted input at its boundary before narrowing it.

const mockSchedulerService = {
isConfigured: () => false,
createDelayedFire: async () => {},
deleteSchedule: async () => {},
} as unknown as EventBridgeSchedulerService;

Check failure on line 78 in apps/worker/src/app/workflow/services/standard.worker.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

plugin

This assertion chain discards type evidence. Keep the original precise type, or parse untrusted input at its boundary before narrowing it.

describe('Standard Worker', () => {
let jobRepository: JobRepository;
Expand All @@ -102,13 +102,13 @@
const userService = new UserService();

const card = {
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
};
const userEntity: Partial<UserEntity> = {
lastName: card.lastName,
firstName: card.firstName,
email: `${card.firstName}_${card.lastName}_${faker.datatype.uuid()}@gmail.com`.toLowerCase(),
email: `${card.firstName}_${card.lastName}_${faker.string.uuid()}@gmail.com`.toLowerCase(),
profilePicture: `https://randomuser.me/api/portraits/men/${Math.floor(Math.random() * 60) + 1}.jpg`,
tokens: [],
password: 'asd#Faf4fd',
Expand Down Expand Up @@ -557,7 +557,7 @@
}) as typeof originalClearInterval;

// Force the first post-claim operation of RunJob.execute to fail.
const stepRunRepository = Reflect.get(runJob, 'stepRunRepository') as {

Check failure on line 560 in apps/worker/src/app/workflow/services/standard.worker.spec.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

plugin

Replace `Reflect.get` with typed property access. Parse dynamic input into a named domain type before reading it.
create: (...createArgs: unknown[]) => Promise<unknown>;
};
const originalCreate = stepRunRepository.create;
Expand Down
2 changes: 1 addition & 1 deletion libs/dal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.382.0",
"@aws-sdk/s3-request-presigner": "^3.382.0",
"@faker-js/faker": "^6.0.0",
"@faker-js/faker": "^10.5.0",
"@novu/shared": "workspace:*",
"class-transformer": "0.5.1",
"cross-fetch": "^3.0.4",
Expand Down
2 changes: 1 addition & 1 deletion libs/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"@clerk/backend": "^3.4.11",
"@clerk/shared": "^4.12.2",
"@faker-js/faker": "^6.0.0",
"@faker-js/faker": "^10.5.0",
"@novu/dal": "workspace:*",
"@novu/shared": "workspace:*",
"JSONStream": "^1.3.5",
Expand Down
2 changes: 1 addition & 1 deletion libs/testing/src/environment.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { faker } from '@faker-js/faker';
import { EnvironmentEntity, EnvironmentRepository } from '@novu/dal';
import { IApiRateLimitMaximum } from '@novu/shared';
import { createHash } from 'crypto';

Check notice on line 4 in libs/testing/src/environment.service.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/style/useNodejsImportProtocol

A Node.js builtin module should be imported with the node: protocol.
import { v4 as uuid } from 'uuid';

enum EnvironmentsEnum {
Expand All @@ -23,7 +23,7 @@

return await this.environmentRepository.create({
identifier: uuid(),
name: name ?? faker.name.jobTitle(),
name: name ?? faker.person.jobTitle(),
_organizationId: organizationId,
...(parentId && { _parentId: parentId }),
apiKeys: [
Expand Down
4 changes: 2 additions & 2 deletions libs/testing/src/notification-template.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class NotificationTemplateService {
const data = {
_notificationGroupId: override.noGroupId ? undefined : groups[0]._id,
_environmentId: this.environmentId,
name: override.name ?? faker.name.jobTitle(),
name: override.name ?? faker.person.jobTitle(),
_organizationId: this.organizationId,
_creatorId: this.userId,
active: true,
Expand All @@ -172,7 +172,7 @@ export class NotificationTemplateService {
description: faker.commerce.productDescription().slice(0, 90),
triggers: override.triggers ?? [
{
identifier: `test-event-${faker.datatype.uuid()}`,
identifier: `test-event-${faker.string.uuid()}`,
type: 'event',
variables: [{ name: 'firstName' }, { name: 'lastName' }, { name: 'urlVariable' }],
},
Expand Down
4 changes: 2 additions & 2 deletions libs/testing/src/organization.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export class OrganizationService {
if (options) {
return await this.organizationRepository.create({
logo: faker.image.avatar(),
name: faker.company.companyName(),
name: faker.company.name(),
...options,
});
}

return await this.organizationRepository.create({
logo: faker.image.avatar(),
name: faker.company.companyName(),
name: faker.company.name(),
});
}

Expand Down
6 changes: 3 additions & 3 deletions libs/testing/src/subscribers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export class SubscribersService {
}

return await this.subscriberRepository.create({
lastName: faker.name.lastName(),
firstName: faker.name.firstName(),
lastName: faker.person.lastName(),
firstName: faker.person.firstName(),
email: faker.internet.email(),
phone: faker.phone.phoneNumber(),
phone: faker.phone.number(),
_environmentId: this._environmentId,
_organizationId: this._organizationId,
subscriberId: SubscriberRepository.createObjectId(),
Expand Down
8 changes: 4 additions & 4 deletions libs/testing/src/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class UserService {
async createTestUser(): Promise<UserEntity> {
const user = await this.createUser({
email: this.randomEmail(),
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
password: this.testPassword(),
});

Expand All @@ -34,8 +34,8 @@ export class UserService {

const user = await this.userRepository.create({
email: normalizeEmail(userEntity?.email ?? faker.internet.email()),
firstName: userEntity?.firstName ?? faker.name.firstName(),
lastName: userEntity?.lastName ?? faker.name.lastName(),
firstName: userEntity?.firstName ?? faker.person.firstName(),
lastName: userEntity?.lastName ?? faker.person.lastName(),
password: passwordHash,
profilePicture: `https://randomuser.me/api/portraits/men/${Math.floor(Math.random() * 60) + 1}.jpg`,
tokens: [],
Expand Down
6 changes: 3 additions & 3 deletions libs/testing/src/user.session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@

private async initializeCommunity(options: UserSessionOptions = {}) {
const card = {
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
};

const userService = new UserService();
const userEntity: Partial<UserEntity> = {
lastName: card.lastName,
firstName: card.firstName,
email: `${card.firstName}_${card.lastName}_${faker.datatype.uuid()}@gmail.com`.toLowerCase(),
email: `${card.firstName}_${card.lastName}_${faker.string.uuid()}@gmail.com`.toLowerCase(),
profilePicture: `https://randomuser.me/api/portraits/men/${Math.floor(Math.random() * 60) + 1}.jpg`,
tokens: [],
password: TEST_USER_PASSWORD,
Expand Down Expand Up @@ -307,7 +307,7 @@
parentId
);

let parentGroup;

Check warning on line 310 in libs/testing/src/user.session.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/suspicious/noImplicitAnyLet

This variable implicitly has the any type.
if (parentId) {
parentGroup = await this.notificationGroupRepository.findOne({
_environmentId: parentId,
Expand Down Expand Up @@ -390,7 +390,7 @@
try {
// is not linked
this.organization = await organizationService.createOrganization(orgId);
} catch (e) {

Check warning on line 393 in libs/testing/src/user.session.ts

View workflow job for this annotation

GitHub Actions / Lint changed files

lint/correctness/noUnusedVariables

This variable e is unused.
// is already linked
this.organization = (await organizationService.getOrganization(orgId)) as OrganizationEntity;
}
Expand Down
2 changes: 1 addition & 1 deletion libs/testing/src/workflow-override.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class WorkflowOverrideService {
const tenant = await this.tenantRepository.create({
_organizationId: organizationId,
_environmentId: environmentId,
identifier: faker.datatype.uuid(),
identifier: faker.string.uuid(),
name: 'name_123',
data: { test1: 'test value1', test2: 'test value2' },
});
Expand Down
35 changes: 14 additions & 21 deletions pnpm-lock.yaml

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

Loading