hedgedoc/backend/test/app.e2e-spec.ts
Erik Michelson 7f665fae4b
Some checks are pending
Docker / build-and-push (frontend) (push) Waiting to run
Docker / build-and-push (backend) (push) Waiting to run
Deploy HD2 docs to Netlify / Deploys to netlify (push) Waiting to run
E2E Tests / backend-sqlite (push) Waiting to run
E2E Tests / backend-mariadb (push) Waiting to run
E2E Tests / backend-postgres (push) Waiting to run
E2E Tests / Build test build of frontend (push) Waiting to run
E2E Tests / frontend-cypress (1) (push) Blocked by required conditions
E2E Tests / frontend-cypress (2) (push) Blocked by required conditions
E2E Tests / frontend-cypress (3) (push) Blocked by required conditions
Lint and check format / Lint files and check formatting (push) Waiting to run
REUSE Compliance Check / reuse (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Static Analysis / Njsscan code scanning (push) Waiting to run
Static Analysis / CodeQL analysis (push) Waiting to run
Run tests & build / Test and build with NodeJS 20 (push) Waiting to run
feat(auth): refactor auth, add oidc
Thanks to all HedgeDoc team members for the time discussing,
helping with weird Nest issues, providing feedback
and suggestions!

Co-authored-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2024-09-11 21:29:49 +02:00

60 lines
1.7 KiB
TypeScript

/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { getConfigToken } from '@nestjs/config';
import { WsAdapter } from '@nestjs/platform-ws';
import { Test } from '@nestjs/testing';
import request from 'supertest';
import { AppModule } from '../src/app.module';
import { BackendType } from '../src/media/backends/backend-type.enum';
describe('App', () => {
it('should not crash on requests to /', async () => {
const moduleRef = await Test.createTestingModule({
imports: [AppModule],
})
.overrideProvider(getConfigToken('appConfig'))
.useValue({
baseUrl: 'localhost',
port: 3333,
})
.overrideProvider(getConfigToken('mediaConfig'))
.useValue({
backend: {
use: BackendType.FILESYSTEM,
filesystem: {
uploadPath:
'test_uploads' + Math.floor(Math.random() * 100000).toString(),
},
},
})
.overrideProvider(getConfigToken('databaseConfig'))
.useValue({
database: ':memory:',
type: 'sqlite',
})
.overrideProvider(getConfigToken('authConfig'))
.useValue({
session: {
secret: 'secret',
},
oidc: [],
})
.compile();
/**
* TODO: This is not really a regression test, as it does not use the
* real initialization code in main.ts.
* Should be fixed after https://github.com/hedgedoc/hedgedoc/issues/2083
* is done.
*/
const app = moduleRef.createNestApplication();
app.useWebSocketAdapter(new WsAdapter(app));
await app.init();
await request(app.getHttpServer()).get('/').expect(404);
await app.close();
});
});