|
1 | 1 | import type { $LoginCredentials } from '@opendatacapture/schemas/auth'; |
2 | 2 |
|
3 | | -import { groups, initAppOptions } from '../helpers/data'; |
| 3 | +import { groups, initAppOptions, users } from '../helpers/data'; |
4 | 4 | import { expect, test } from '../helpers/fixtures'; |
5 | 5 |
|
| 6 | +import type { TestDataMap } from '../helpers/types'; |
| 7 | + |
6 | 8 | test.describe.serial(() => { |
7 | 9 | test.describe.serial('setup', () => { |
8 | 10 | test('should initially not be setup', async ({ request }) => { |
@@ -48,9 +50,26 @@ test.describe.serial(() => { |
48 | 50 |
|
49 | 51 | test.describe.serial('creating groups', () => { |
50 | 52 | test('creating groups', async ({ request }) => { |
51 | | - for (const key in groups) { |
| 53 | + const createdGroupIds = {} as TestDataMap<string>; |
| 54 | + for (const browser in groups) { |
52 | 55 | const response = await request.post('/api/v1/groups', { |
53 | | - data: groups[key as keyof typeof groups], |
| 56 | + data: groups[browser as keyof typeof groups], |
| 57 | + headers: { |
| 58 | + Authorization: `Bearer ${process.env.ADMIN_ACCESS_TOKEN}` |
| 59 | + } |
| 60 | + }); |
| 61 | + expect(response.status()).toBe(201); |
| 62 | + const data = await response.json(); |
| 63 | + expect(data).toMatchObject({ id: expect.any(String) }); |
| 64 | + createdGroupIds[browser as keyof typeof groups] = data.id; |
| 65 | + } |
| 66 | + |
| 67 | + for (const key in users) { |
| 68 | + const response = await request.post('/api/v1/users', { |
| 69 | + data: { |
| 70 | + ...users[key as keyof typeof groups], |
| 71 | + groupIds: [createdGroupIds[key as keyof typeof users]] |
| 72 | + }, |
54 | 73 | headers: { |
55 | 74 | Authorization: `Bearer ${process.env.ADMIN_ACCESS_TOKEN}` |
56 | 75 | } |
|
0 commit comments