2022-08-08 08:21:36 +02:00
|
|
|
import { Page } from '@playwright/test'
|
|
|
|
|
2022-01-28 09:42:31 +01:00
|
|
|
export const refreshUser = async () => {
|
|
|
|
await fetch('/api/auth/session?update')
|
|
|
|
const event = new Event('visibilitychange')
|
|
|
|
document.dispatchEvent(event)
|
|
|
|
}
|
2022-08-08 08:21:36 +02:00
|
|
|
|
2022-09-24 08:58:23 +02:00
|
|
|
export const mockSessionResponsesToOtherUser = async (page: Page) =>
|
2022-08-08 08:21:36 +02:00
|
|
|
page.route('/api/auth/session', (route) => {
|
|
|
|
if (route.request().method() === 'GET') {
|
|
|
|
return route.fulfill({
|
|
|
|
status: 200,
|
2022-09-17 16:37:33 +02:00
|
|
|
body: '{"user":{"id":"otherUserId","name":"James Doe","email":"other-user@email.com","emailVerified":null,"image":"https://avatars.githubusercontent.com/u/16015833?v=4","stripeId":null,"graphNavigation": "TRACKPAD"}}',
|
2022-08-08 08:21:36 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
return route.continue()
|
|
|
|
})
|