diff --git a/apps/backend/e2e/jest-e2e.json b/apps/backend/e2e/jest-e2e.json index d68ca02..10f9c14 100644 --- a/apps/backend/e2e/jest-e2e.json +++ b/apps/backend/e2e/jest-e2e.json @@ -12,4 +12,7 @@ "!**/vendor/**" ], "coverageReporters": ["json", "lcov"] + + + } diff --git a/apps/backend/e2e/tests/departure.e2e-spec.ts b/apps/backend/e2e/tests/departure.e2e-spec.ts index fcb539d..c196f19 100644 --- a/apps/backend/e2e/tests/departure.e2e-spec.ts +++ b/apps/backend/e2e/tests/departure.e2e-spec.ts @@ -102,7 +102,7 @@ describe("Departure Module (e2e)", () => { ], ]); - it.each(testUrls)(getRequestTestLabel, async (url) => { + test.each(testUrls)(getRequestTestLabel, async (url) => { const response = await request(app.getHttpServer()) .get(url) .expect(200) diff --git a/apps/backend/e2e/tests/import.e2e-spec.ts b/apps/backend/e2e/tests/import.e2e-spec.ts new file mode 100644 index 0000000..9fec073 --- /dev/null +++ b/apps/backend/e2e/tests/import.e2e-spec.ts @@ -0,0 +1,39 @@ +import { INestApplication } from "@nestjs/common"; +import { ConfigModule } from "@nestjs/config"; +import { Test, TestingModule } from "@nestjs/testing"; + +import { configModuleConfig } from "src/config/config-module.config"; +import { StopSyncTrigger } from "src/enums/log.enum"; +import { ImportService } from "src/modules/import/import.service"; +import { LoggerModule } from "src/modules/logger/logger.module"; +import { PrismaModule } from "src/modules/prisma/prisma.module"; + +describe("Import Module (e2e)", () => { + let app: INestApplication; + + beforeAll(async () => { + const moduleFixture: TestingModule = await Test.createTestingModule({ + imports: [ + ConfigModule.forRoot(configModuleConfig), + PrismaModule, + LoggerModule, + ], + providers: [ImportService], + }).compile(); + + app = moduleFixture.createNestApplication(); + await app.init(); + }); + + afterAll(async () => { + await app.close(); + }); + + test( + "Run import", + async () => { + await app.get(ImportService).syncStops(StopSyncTrigger.TEST); + }, + 10 * 60 * 1_000, + ); +}); diff --git a/apps/backend/e2e/tests/platform.e2e-spec.ts b/apps/backend/e2e/tests/platform.e2e-spec.ts index b6a5f28..7132b63 100644 --- a/apps/backend/e2e/tests/platform.e2e-spec.ts +++ b/apps/backend/e2e/tests/platform.e2e-spec.ts @@ -37,7 +37,7 @@ describe("Platform Module (e2e)", () => { await app.close(); }); - it.each( + test.each( generateTestUrls("/platform/all", [ generateParamsArray("metroOnly"), @@ -61,7 +61,7 @@ describe("Platform Module (e2e)", () => { ...generateParamsArray("longitude", 50.08187897724985), ]; - it.each( + test.each( generateTestUrls("/platform/closest", [ [...latLonSearchParams], diff --git a/apps/backend/e2e/tests/status.e2e-spec.ts b/apps/backend/e2e/tests/status.e2e-spec.ts index efa10ae..4b4a6a6 100644 --- a/apps/backend/e2e/tests/status.e2e-spec.ts +++ b/apps/backend/e2e/tests/status.e2e-spec.ts @@ -33,7 +33,7 @@ describe("Status Module (e2e)", () => { await app.close(); }); - it.each(["/status"])(getRequestTestLabel, async (url) => { + test.each(["/status"])(getRequestTestLabel, async (url) => { const response = await request(app.getHttpServer()) .get(url) .expect(200) @@ -44,7 +44,7 @@ describe("Status Module (e2e)", () => { expect(response.body.length).toEqual(3); }); - it.each(["/status/geo-functions"])(getRequestTestLabel, async (url) => { + test.each(["/status/geo-functions"])(getRequestTestLabel, async (url) => { const response = await request(app.getHttpServer()) .get(url) .expect(200) diff --git a/apps/backend/e2e/tests/stop.e2e-spec.ts b/apps/backend/e2e/tests/stop.e2e-spec.ts index 0db79e3..b231d7e 100644 --- a/apps/backend/e2e/tests/stop.e2e-spec.ts +++ b/apps/backend/e2e/tests/stop.e2e-spec.ts @@ -36,7 +36,7 @@ describe("Stop Module (e2e)", () => { await app.close(); }); - it.each( + test.each( generateTestUrls("/stop/all", [ [], diff --git a/apps/backend/package.json b/apps/backend/package.json index bb78aa1..3ee4827 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -15,6 +15,7 @@ "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", + "pretest:e2e": "jest --config ./e2e/jest-e2e.json -t \"Run import\"", "test:e2e": "jest --config ./e2e/jest-e2e.json", "prisma:studio": "dotenv -e .env.local -- prisma studio", "prisma:generate": "prisma generate", diff --git a/apps/backend/src/enums/log.enum.ts b/apps/backend/src/enums/log.enum.ts index 8958642..99fc5dc 100644 --- a/apps/backend/src/enums/log.enum.ts +++ b/apps/backend/src/enums/log.enum.ts @@ -3,6 +3,7 @@ export { LogLevel } from "@prisma/client"; export enum StopSyncTrigger { CRON = "CRON", INIT = "INIT", + TEST = "TEST", // import is triggered by e2e tests } export enum LogMessage {