Public Access
feat(admin): add the admin users page and view as
This commit is contained in:
1 parent
46587dfb5c
commit
afe00ceae9
14 files changed
+649
-8
No files matched your search
@@ -0,0 +1,25 @@
|
||||
// @vitest-environment jsdom
|
||||
import {describe, expect, it, vi} from 'vitest';
|
||||
import {refreshSession} from './api.js';
|
||||
import {viewAs} from './admin.js';
|
||||
|
||||
describe('viewAs', () => {
|
||||
it('waits for a running refresh before it sends the refresh cookie', async () => {
|
||||
let finishRefresh;
|
||||
globalThis.fetch = vi.fn((url) => (url.endsWith('/api/auth/refresh')
|
||||
? new Promise((resolve) => {
|
||||
finishRefresh = () => resolve({ok: true, status: 204});
|
||||
})
|
||||
: Promise.resolve({ok: true, status: 204})));
|
||||
|
||||
const refreshing = refreshSession();
|
||||
const switching = viewAs('USER');
|
||||
await Promise.resolve();
|
||||
|
||||
expect(fetch.mock.calls.map(([url]) => url).filter((url) => url.endsWith('/api/auth/view-as'))).toHaveLength(0);
|
||||
|
||||
finishRefresh();
|
||||
await refreshing;
|
||||
await switching;
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user