feat: check permissions in realtime code and frontend

Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Philip Molares 2023-03-26 14:51:18 +02:00 committed by Tilman Vatteroth
parent 24f1b2a361
commit c2f41118b6
27 changed files with 287 additions and 66 deletions

View file

@ -7,15 +7,22 @@ import * as useApplicationStateModule from '../hooks/common/use-application-stat
import type { ApplicationState } from '../redux/application-state'
jest.mock('../hooks/common/use-application-state')
export const mockNoteOwnership = (ownUsername: string, noteOwner: string) => {
export const mockNoteOwnership = (
ownUsername: string,
noteOwner: string,
additionalState?: Partial<ApplicationState>
) => {
jest.spyOn(useApplicationStateModule, 'useApplicationState').mockImplementation((fn) => {
return fn({
...additionalState,
noteDetails: {
...additionalState?.noteDetails,
permissions: {
owner: noteOwner
}
},
user: {
...additionalState?.user,
username: ownUsername
}
} as ApplicationState)