mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
test: app should not crash on requests to /
Regression test for 396ad181d0
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
2c081b8dbf
commit
81d47b57d6
1 changed files with 58 additions and 0 deletions
58
test/app.e2e-spec.ts
Normal file
58
test/app.e2e-spec.ts
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
import { getConfigToken } from '@nestjs/config';
|
||||||
|
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({
|
||||||
|
domain: 'localhost',
|
||||||
|
port: 3333,
|
||||||
|
loglevel: 'debug',
|
||||||
|
})
|
||||||
|
.overrideProvider(getConfigToken('mediaConfig'))
|
||||||
|
.useValue({
|
||||||
|
backend: {
|
||||||
|
use: BackendType.FILESYSTEM,
|
||||||
|
filesystem: {
|
||||||
|
uploadPath:
|
||||||
|
'test_uploads' + Math.floor(Math.random() * 100000).toString(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.overrideProvider(getConfigToken('databaseConfig'))
|
||||||
|
.useValue({
|
||||||
|
storage: ':memory:',
|
||||||
|
dialect: 'sqlite',
|
||||||
|
})
|
||||||
|
.overrideProvider(getConfigToken('authConfig'))
|
||||||
|
.useValue({
|
||||||
|
session: {
|
||||||
|
secret: 'secret',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.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();
|
||||||
|
await app.init();
|
||||||
|
await request(app.getHttpServer()).get('/').expect(404);
|
||||||
|
await app.close();
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue