|
1 | 1 | import { faker } from '@faker-js/faker';
|
2 | 2 | import { startCase } from 'lodash';
|
3 | 3 | import { type ID } from '~/common';
|
4 |
| -import { loggedInSession } from '~/common/session'; |
5 |
| -import { AuthenticationService } from '../../src/components/authentication'; |
| 4 | +import { |
| 5 | + AuthenticationService, |
| 6 | + SessionHost, |
| 7 | +} from '../../src/components/authentication'; |
6 | 8 | import { FileService } from '../../src/components/file';
|
7 | 9 | import { type TestApp } from './create-app';
|
8 | 10 | import { fileNode, type RawDirectory } from './fragments';
|
9 | 11 | import { gql } from './gql-tag';
|
10 | 12 |
|
11 | 13 | export async function createRootDirectory(app: TestApp, name?: string) {
|
12 | 14 | name = name ?? startCase(faker.lorem.words());
|
13 |
| - const rawSession = await app |
| 15 | + const session = await app |
14 | 16 | .get(AuthenticationService)
|
15 | 17 | .resumeSession(app.graphql.authToken);
|
16 |
| - const session = loggedInSession(rawSession); |
17 |
| - const id = await app.get(FileService).createRootDirectory({ |
18 |
| - // An attachment point is required, so just use the current user. |
19 |
| - resource: { __typename: 'User', id: session.userId }, |
20 |
| - relation: 'dir', |
21 |
| - name, |
22 |
| - session, |
| 18 | + return await app.get(SessionHost).withSession(session, async () => { |
| 19 | + const id = await app.get(FileService).createRootDirectory({ |
| 20 | + // An attachment point is required, so just use the current user. |
| 21 | + resource: { __typename: 'User', id: session.userId }, |
| 22 | + relation: 'dir', |
| 23 | + name, |
| 24 | + }); |
| 25 | + return await app.get(FileService).getDirectory(id, session); |
23 | 26 | });
|
24 |
| - return await app.get(FileService).getDirectory(id, session); |
25 | 27 | }
|
26 | 28 |
|
27 | 29 | export async function createDirectory(
|
|
0 commit comments