Skip to content

Commit

Permalink
fix: Move demo admin login test success case to bottom of file to all…
Browse files Browse the repository at this point in the history
…ow enough time for store to populate
  • Loading branch information
00Chaotic committed Apr 9, 2024
1 parent fcdc9b7 commit df66a75
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/lib/middleware/demo-authentication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let stores: IUnleashStores;
beforeAll(async () => {
db = await dbInit('demo_auth_serial');
stores = db.stores;
}, 20000);
});

afterAll(async () => {
await db?.destroy();
Expand All @@ -24,21 +24,6 @@ const getApp = (adminLoginEnabled: boolean) =>
},
});

test('should allow login with admin user if flag enabled', async () => {
const app = await getApp(true);
return (
app.request
.post(`/auth/demo/login`)
.send({ email: 'admin' })
// .expect(200)
.expect((res) => {
expect(res.body).toBe(''); // TODO remove this - debugging
expect(res.body.id).toBe(1);
expect(res.body.username).toBe('admin');
})
);
});

test('should create regular user with flag enabled', async () => {
const app = await getApp(true);
return app.request
Expand All @@ -58,3 +43,15 @@ test('should return 403 for admin user if flag disabled', async () => {
.send({ email: 'admin' })
.expect(403);
});

test('should allow login with admin user if flag enabled', async () => {
const app = await getApp(true);
return app.request
.post(`/auth/demo/login`)
.send({ email: 'admin' })
.expect(200)
.expect((res) => {
expect(res.body.id).toBe(1);
expect(res.body.username).toBe('admin');
});
});

0 comments on commit df66a75

Please sign in to comment.