Skip to content

Commit

Permalink
feat(be): import e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krystxf committed Oct 27, 2024
1 parent 7498806 commit 600f2a6
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 6 deletions.
3 changes: 3 additions & 0 deletions apps/backend/e2e/jest-e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
"!**/vendor/**"
],
"coverageReporters": ["json", "lcov"]



}
2 changes: 1 addition & 1 deletion apps/backend/e2e/tests/departure.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
39 changes: 39 additions & 0 deletions apps/backend/e2e/tests/import.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -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,
);
});
4 changes: 2 additions & 2 deletions apps/backend/e2e/tests/platform.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("Platform Module (e2e)", () => {
await app.close();
});

it.each(
test.each(
generateTestUrls("/platform/all", [
generateParamsArray("metroOnly"),

Expand All @@ -61,7 +61,7 @@ describe("Platform Module (e2e)", () => {
...generateParamsArray("longitude", 50.08187897724985),
];

it.each(
test.each(
generateTestUrls("/platform/closest", [
[...latLonSearchParams],

Expand Down
4 changes: 2 additions & 2 deletions apps/backend/e2e/tests/status.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/e2e/tests/stop.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("Stop Module (e2e)", () => {
await app.close();
});

it.each(
test.each(
generateTestUrls("/stop/all", [
[],

Expand Down
1 change: 1 addition & 0 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions apps/backend/src/enums/log.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 600f2a6

Please sign in to comment.