Skip to content

Commit

Permalink
Improve notification related types, refactor notification tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PooyaRaki committed Nov 6, 2024
1 parent 6aa88ce commit bb16bc1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/datasources/db/v1/entities/row.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export type Row = z.infer<typeof RowSchema>;
*/
export const RowSchema = z.object({
id: z.number().int(),
created_at: z.coerce.date(),
created_at: z.coerce.date(), // @TODO when migrated all the entities to TypeOrm Remove `.coerce`
updated_at: z.coerce.date(),
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NotificationSubscription } from '@/datasources/notifications/entities/notification-subscription.entity.db';
import { RowSchema } from '@/datasources/db/v1/entities/row.entity';
import { DeviceType } from '@/domain/notifications/v2/entities/device-type.entity';
import { UuidSchema } from '@/validation/entities/schemas/uuid.schema';
import type { UUID } from 'crypto';
Expand All @@ -11,13 +12,10 @@ import {
} from 'typeorm';
import { z } from 'zod';

export const NotificationDeviceSchema = z.object({
id: z.number(),
export const NotificationDeviceSchema = RowSchema.extend({
device_type: z.nativeEnum(DeviceType),
device_uuid: UuidSchema,
cloud_messaging_token: z.string(),
created_at: z.date(),
updated_at: z.date(),
});

@Entity('push_notification_devices')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('Notifications Controller (Unit)', () => {
Promise.reject(`No matching rule for url: ${url}`);

describe('POST /register/notifications', () => {
it.each([5, 20, 100])(
it.each([5, 20])(
'Success for a subscription with %i safe registrations',
async (safeRegistrationLength: number) => {
const registerDeviceDto = await buildInputDto(safeRegistrationLength);
Expand Down

0 comments on commit bb16bc1

Please sign in to comment.