Skip to content

Commit 22a3712

Browse files
committed
cleanup and add tests
1 parent 17d9ff7 commit 22a3712

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

testing/e2e/src/global/global.setup.spec.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,33 @@ import { expect, test } from '../helpers/fixtures';
55

66
test.describe.serial(() => {
77
test.describe.serial('setup', () => {
8-
test('initial setup', async ({ request }) => {
8+
test('should initially not be setup', async ({ request }) => {
99
const response = await request.get('/api/v1/setup');
1010
expect(response.status()).toBe(200);
1111
await expect(response.json()).resolves.toMatchObject({ isSetup: false });
1212
});
13-
test('successful setup', async ({ setupPage }) => {
13+
test('should successfully setup', async ({ setupPage }) => {
1414
await setupPage.fillSetupForm(initAppOptions);
15-
await setupPage.expect.toHaveURL('/auth/login');
15+
await setupPage.expect.toHaveURL('/dashboard');
1616
});
17-
test('setup state after initialization', async ({ request }) => {
17+
test('should be setup after initialization', async ({ request }) => {
1818
const response = await request.get('/api/v1/setup');
1919
expect(response.status()).toBe(200);
2020
await expect(response.json()).resolves.toMatchObject({ isSetup: true });
2121
});
22-
test('redirect to login page if setup', async ({ page }) => {
22+
test('should redirect to login page if setup', async ({ page }) => {
2323
await page.goto('/setup');
2424
await expect(page).toHaveURL('/auth/login');
2525
});
26+
test('should block any further setup requests', async ({ request }) => {
27+
const response = await request.post('/api/v1/setup', {
28+
data: initAppOptions
29+
});
30+
expect(response.status()).toBe(403);
31+
});
2632
});
2733
test.describe.serial('auth', () => {
28-
test('login', async ({ request }) => {
34+
test('should login with the admin credentials', async ({ request }) => {
2935
const { password, username } = initAppOptions.admin;
3036
const response = await request.post('/api/v1/auth/login', {
3137
data: { password, username } satisfies $LoginCredentials
@@ -36,7 +42,6 @@ test.describe.serial(() => {
3642
process.env.ADMIN_ACCESS_TOKEN = accessToken;
3743
process.env.ADMIN_USERNAME = username;
3844
process.env.ADMIN_PASSWORD = password;
39-
process.env.GLOBAL_SETUP_COMPLETE = '1';
4045
});
4146
});
4247
});

0 commit comments

Comments
 (0)