Skip to content

Commit 3ba5457

Browse files
fix
1 parent fbc208d commit 3ba5457

5 files changed

Lines changed: 34 additions & 21 deletions

File tree

tests/component-tests/events-tests/event-subscription.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import { randomUUID } from "node:crypto";
55
import { logger } from "tests/helpers/pino-logger";
66
import { createValidRequestHeaders } from "tests/constants/request-headers";
77
import getRestApiGatewayBaseUrl from "tests/helpers/aws-gateway-helper";
8-
import { SUPPLIER_LETTERS } from "tests/constants/api-constants";
8+
import { SUPPLIER_LETTERS, envName } from "tests/constants/api-constants";
99
import {
1010
pollSupplierAllocatorLogForResolvedSpec,
1111
pollUpsertLetterLogForError,
1212
} from "tests/helpers/aws-cloudwatch-helper";
13+
import { supplierDataSetup } from "tests/helpers/suppliers-setup-helper";
1314

1415
let baseUrl: string;
1516

@@ -18,7 +19,7 @@ test.beforeAll(async () => {
1819
});
1920

2021
test.describe("Event Subscription SNS Tests", () => {
21-
test("Verify that the publish event to nhs-main-supapi-eventsub topic inserts data into db", async ({
22+
test(`Verify that the publish event to nhs-${envName}-supapi-eventsub topic inserts data into db`, async ({
2223
request,
2324
}) => {
2425
const domainId = randomUUID();
@@ -43,6 +44,9 @@ test.describe("Event Subscription SNS Tests", () => {
4344
throw new Error("supplierId was not found in supplier allocator log");
4445
}
4546

47+
// check if supplier exists in suppliers table
48+
await supplierDataSetup(supplierId);
49+
4650
const headers = createValidRequestHeaders(supplierId);
4751
let statusCode = 0;
4852
let letterStatus: string | undefined;

tests/config/global-setup.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { logger } from "tests/helpers/pino-logger";
2-
import {
3-
checkSupplierExists,
4-
createSupplierEntry,
5-
createTestData,
6-
} from "../helpers/generate-fetch-test-data";
2+
import { supplierDataSetup } from "tests/helpers/suppliers-setup-helper";
3+
import { createTestData } from "../helpers/generate-fetch-test-data";
74
import { SUPPLIERID } from "../constants/api-constants";
85

96
async function globalSetup() {
@@ -16,17 +13,7 @@ async function globalSetup() {
1613
await createTestData(SUPPLIERID, 10);
1714

1815
// check supplier exists
19-
const supplier = await checkSupplierExists(SUPPLIERID);
20-
if (supplier) {
21-
logger.info(`Supplier with ID ${SUPPLIERID} already exists.`);
22-
logger.info("");
23-
logger.info("*** GLOBAL SETUP COMPLETE ***");
24-
logger.info("");
25-
return;
26-
}
27-
28-
logger.info(`Creating supplier entry with ID: ${SUPPLIERID}`);
29-
await createSupplierEntry(SUPPLIERID);
16+
await supplierDataSetup(SUPPLIERID);
3017

3118
logger.info("");
3219
logger.info("*** GLOBAL SETUP COMPLETE ***");

tests/config/main.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ const localConfig: PlaywrightTestConfig = {
1010
reporter: getReporters("api-test"),
1111
projects: [
1212
{
13-
name: "component-tests",
14-
testDir: path.resolve(__dirname, "../component-tests"),
13+
name: "apiGateway-tests",
14+
testDir: path.resolve(__dirname, "../component-tests/apiGateway-tests"),
1515
testMatch: "**/*.spec.ts",
1616
},
17+
{
18+
name: "events-tests",
19+
testDir: path.resolve(__dirname, "../component-tests/events-tests"),
20+
testMatch: "**/*.spec.ts",
21+
dependencies: ["apiGateway-tests"],
22+
},
1723
],
1824
};
1925

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { logger } from "tests/helpers/pino-logger";
2+
import {
3+
checkSupplierExists,
4+
createSupplierEntry,
5+
} from "./generate-fetch-test-data";
6+
7+
export async function supplierDataSetup(supplierId: string) {
8+
const supplier = await checkSupplierExists(supplierId);
9+
if (supplier) {
10+
logger.info(`Supplier with ID ${supplierId} already exists.`);
11+
return;
12+
}
13+
14+
logger.info(`Creating supplier entry with ID: ${supplierId}`);
15+
await createSupplierEntry(supplierId);
16+
}

tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"clean": "rimraf $(pwd)/target",
4444
"lint": "eslint .",
4545
"lint:fix": "eslint . --fix",
46-
"test:component": "playwright test --config=config/main.config.ts --max-failures=10 --project=component-tests",
46+
"test:component": "playwright test --config=config/main.config.ts --max-failures=10",
4747
"test:pact": "./pact-tests/run-pact-tests.sh",
4848
"test:performance": "playwright test --config=config/performance/performance.config.ts --max-failures=10 --project=performance",
4949
"test:sandbox": "playwright test --config=config/sandbox.config.ts --max-failures=10 --project=sandbox",

0 commit comments

Comments
 (0)