36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { identityApp } from './helpers/identity-app';
|
|
|
|
describe('Application OpenAPI', () => {
|
|
it('exports all application controllers and accepts a documented login', async () => {
|
|
const fixture = await identityApp(true);
|
|
try {
|
|
const { body: doc } = await fixture
|
|
.api()
|
|
.get('/api/docs-json')
|
|
.expect(200);
|
|
expect(Object.keys(doc.paths).length).toBeGreaterThan(30);
|
|
expect(
|
|
doc.paths['/api/v1/auth/login'].post.requestBody.content[
|
|
'application/json'
|
|
].schema.required,
|
|
).toEqual(
|
|
expect.arrayContaining(['organizationId', 'email', 'password']),
|
|
);
|
|
const login = await fixture.login();
|
|
await fixture
|
|
.api()
|
|
.get('/api/v1/auth/me')
|
|
.set('Authorization', `Bearer ${login.body.accessToken}`)
|
|
.expect(200);
|
|
for (const path of Object.values(doc.paths) as Record<string, any>[]) {
|
|
for (const operation of Object.values(path)) {
|
|
expect(operation.security).toBeDefined();
|
|
expect(operation.responses.default).toBeDefined();
|
|
}
|
|
}
|
|
} finally {
|
|
await fixture.close();
|
|
}
|
|
}, 60000);
|
|
});
|