2022-02-11 13:45:31 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
import { getConfigToken } from '@nestjs/config';
|
2022-04-02 17:45:46 -04:00
|
|
|
import { WsAdapter } from '@nestjs/platform-ws';
|
2022-02-11 13:45:31 -05:00
|
|
|
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({
|
2023-02-05 03:31:33 -05:00
|
|
|
baseUrl: 'localhost',
|
2022-02-11 13:45:31 -05:00
|
|
|
port: 3333,
|
|
|
|
})
|
|
|
|
.overrideProvider(getConfigToken('mediaConfig'))
|
|
|
|
.useValue({
|
|
|
|
backend: {
|
|
|
|
use: BackendType.FILESYSTEM,
|
|
|
|
filesystem: {
|
|
|
|
uploadPath:
|
|
|
|
'test_uploads' + Math.floor(Math.random() * 100000).toString(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.overrideProvider(getConfigToken('databaseConfig'))
|
|
|
|
.useValue({
|
2022-04-18 09:21:49 -04:00
|
|
|
database: ':memory:',
|
|
|
|
type: 'sqlite',
|
2022-02-11 13:45:31 -05:00
|
|
|
})
|
|
|
|
.overrideProvider(getConfigToken('authConfig'))
|
|
|
|
.useValue({
|
|
|
|
session: {
|
|
|
|
secret: 'secret',
|
|
|
|
},
|
2024-03-22 21:10:25 -04:00
|
|
|
oidc: [],
|
2022-02-11 13:45:31 -05:00
|
|
|
})
|
|
|
|
.compile();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: This is not really a regression test, as it does not use the
|
2023-10-07 14:35:58 -04:00
|
|
|
* real initialization code in main.ts.
|
|
|
|
* Should be fixed after https://github.com/hedgedoc/hedgedoc/issues/2083
|
|
|
|
* is done.
|
2022-02-11 13:45:31 -05:00
|
|
|
*/
|
|
|
|
const app = moduleRef.createNestApplication();
|
2022-04-02 17:45:46 -04:00
|
|
|
app.useWebSocketAdapter(new WsAdapter(app));
|
2022-02-11 13:45:31 -05:00
|
|
|
await app.init();
|
|
|
|
await request(app.getHttpServer()).get('/').expect(404);
|
|
|
|
await app.close();
|
|
|
|
});
|
|
|
|
});
|