generated from CallePuzzle/svelte-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* añadimos install activate y fetch al service worker * fix fmt * actualización de paquetes * validate refuse refactor * Add test for get-user-notifications * notifications test * fix notification tests * wip test validate refuse * fix estilos de los filtros de notificaciones * nuevo servicio para comprobar si hay nombres repetidos * si hay alguna peña con un nombre parecido, lo mostramos y pedimos confirmación * validate refuse test * escribiendo test con playwright * fix reset button * test for wellcome modal * fix sonar issues * add sonar properties
- Loading branch information
Showing
23 changed files
with
922 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Nombre del proyecto | ||
sonar.projectKey=donde-esta-tu-local | ||
sonar.projectName=donde-esta-tu-local | ||
sonar.projectVersion=1.0 | ||
|
||
# Ruta a la fuente del proyecto | ||
sonar.sources=src | ||
|
||
# Extensiones de archivo a analizar | ||
sonar.inclusions=**/*.svelte,**/*.js,**/*.ts,**/*.html | ||
|
||
# Configuración de TypeScript (si usas TypeScript) | ||
sonar.ts.node.maxSpaceSize=4096 | ||
|
||
# Configuración de la codificación de caracteres | ||
sonar.sourceEncoding=UTF-8 | ||
|
||
# Opcional: Configuración de pruebas | ||
sonar.tests=tests | ||
sonar.test.inclusions=**/*.spec.js,**/*.spec.ts | ||
|
||
# Opcional: Configuración de exclusiones | ||
sonar.exclusions=**/*.test.js,**/*.test.ts |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { describe, it, expect, beforeAll, afterAll } from 'vitest'; | ||
import { getPrismaClient } from '$lib/tests/clientForTest'; | ||
import { GetUserNotifications, type UserNotifications } from './get-user-notifications'; | ||
|
||
const prisma = await getPrismaClient(); | ||
|
||
describe('get user notification fn', () => { | ||
const USER_LOCAL = 'user|local'; | ||
const GANG1 = 'Gang 1'; | ||
let userNotifications: UserNotifications; | ||
|
||
beforeAll(async () => { | ||
// Create a PEDING notification for USER_LOCAL | ||
await prisma.notification.create({ | ||
data: { | ||
title: 'Test notification', | ||
body: 'Test notification body', | ||
status: 'PENDING', | ||
users: { | ||
connect: { | ||
id: USER_LOCAL | ||
} | ||
} | ||
} | ||
}); | ||
// Create a VALIDATED notification for USER_LOCAL | ||
await prisma.notification.create({ | ||
data: { | ||
title: 'Test notification', | ||
body: 'Test notification body', | ||
status: 'VALIDATED', | ||
users: { | ||
connect: { | ||
id: USER_LOCAL | ||
} | ||
} | ||
} | ||
}); | ||
// Create a REFUSED notification for USER_LOCAL | ||
await prisma.notification.create({ | ||
data: { | ||
title: 'Test notification', | ||
body: 'Test notification body', | ||
status: 'REFUSED', | ||
users: { | ||
connect: { | ||
id: USER_LOCAL | ||
} | ||
} | ||
} | ||
}); | ||
|
||
userNotifications = await GetUserNotifications(prisma, USER_LOCAL); | ||
}); | ||
|
||
afterAll(async () => { | ||
// Remove notification from user|local | ||
const notificationsToDelete = await prisma.notification.findMany({ | ||
where: { users: { some: { id: USER_LOCAL } } } | ||
}); | ||
if (notificationsToDelete) { | ||
for (const notificationToDelete of notificationsToDelete) { | ||
await prisma.notification.delete({ | ||
where: { id: notificationToDelete.id } | ||
}); | ||
} | ||
} | ||
await prisma.$disconnect(); | ||
}); | ||
|
||
it('user has gang', async () => { | ||
expect(userNotifications.user).toHaveProperty('gang'); | ||
expect(userNotifications.user?.gang).toHaveProperty('name'); | ||
expect(userNotifications.user?.gang.name).toBe(GANG1); | ||
}); | ||
|
||
it('user has notifications', async () => { | ||
expect(userNotifications).toHaveProperty('notifications'); | ||
expect(userNotifications.notifications).toHaveLength(3); | ||
}); | ||
}); |
16 changes: 6 additions & 10 deletions
16
...ls/notification/get-user-notifications.ts → ...ib/notification/get-user-notifications.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { describe, it, expect, beforeAll, afterAll } from 'vitest'; | ||
import { getPrismaClient } from '$lib/tests/clientForTest'; | ||
import { | ||
NewNotificationForAll, | ||
NewNotificationForAdmins, | ||
NewNotificationForUsers, | ||
type Payload, | ||
type NotificationExtraData | ||
} from './notifications'; | ||
import type { User } from '@prisma/client'; | ||
|
||
const prisma = await getPrismaClient(); | ||
|
||
describe('new notifications', () => { | ||
const USER_LOCAL = 'user|local'; | ||
const USER_ADMIN = 'admin|local'; | ||
const USER_NO_GANG = 'user|no-gang'; | ||
|
||
beforeAll(async () => { | ||
const payload: Payload = { | ||
title: 'Test notification', | ||
body: 'Test notification body' | ||
}; | ||
|
||
const extraData: NotificationExtraData = { | ||
type: 'test-notification', | ||
status: 'PENDING' | ||
}; | ||
const user_admin = (await prisma.user.findUnique({ | ||
where: { id: USER_ADMIN } | ||
})) as User; | ||
const user_no_gang = (await prisma.user.findUnique({ | ||
where: { id: USER_NO_GANG } | ||
})) as User; | ||
|
||
await NewNotificationForAll(payload, extraData, USER_LOCAL, prisma); | ||
await NewNotificationForAdmins(payload, extraData, prisma); | ||
await NewNotificationForUsers(payload, extraData, [user_admin, user_no_gang], prisma); | ||
}); | ||
|
||
afterAll(async () => { | ||
await prisma.notification.deleteMany({ | ||
where: { title: 'Test notification' } | ||
}); | ||
await prisma.$disconnect(); | ||
}); | ||
|
||
it('USER_ADMIN has 3 notifications', async () => { | ||
const userNotifications = await prisma.notification.findMany({ | ||
where: { | ||
title: 'Test notification', | ||
users: { some: { id: USER_ADMIN } } | ||
} | ||
}); | ||
expect(userNotifications.length).toBe(3); | ||
}); | ||
it('USER_NO_GANG has 2 notifications', async () => { | ||
const userNotifications = await prisma.notification.findMany({ | ||
where: { | ||
title: 'Test notification', | ||
users: { some: { id: USER_NO_GANG } } | ||
} | ||
}); | ||
expect(userNotifications.length).toBe(2); | ||
}); | ||
}); |
3 changes: 1 addition & 2 deletions
3
src/lib/utils/notification/notifications.ts → src/lib/notification/notifications.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.