Skip to content

Commit 820f495

Browse files
committed
CCM-14205 - Refactored test imports
1 parent 8db51f0 commit 820f495

21 files changed

Lines changed: 56 additions & 96 deletions

eslint.config.mjs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export default defineConfig([
200200
},
201201
},
202202
{
203-
files: ["**/utils/**", "tests/test-team/**", "lambdas/**/src/**"],
203+
files: ["**/utils/**", "tests/test-team/**", "tests/performance/helpers/**", "lambdas/**/src/**"],
204204
rules: {
205205
"import-x/prefer-default-export": 0,
206206
},
@@ -214,21 +214,14 @@ export default defineConfig([
214214
},
215215
},
216216
{
217-
// Files inside helpers/ are loaded transitively by globalSetup/globalTeardown which run
218-
// outside Jest's module system, so moduleNameMapper does not apply — relative imports only
219-
files: ["tests/integration/helpers/**", "tests/performance/helpers/**", "tests/test-support/helpers/**"],
220-
rules: {
221-
"no-relative-import-paths/no-relative-import-paths": 0,
222-
},
223-
},
224-
{
225-
// globalSetup/globalTeardown run outside Jest's module system so moduleNameMapper
226-
// does not apply — relative imports are the only way to reach local helpers
217+
// helpers/ files use relative imports between each other; test files import
218+
// directly from local helpers using relative paths
227219
files: [
228-
"tests/integration/jest.global-setup.ts",
229-
"tests/integration/jest.global-teardown.ts",
230-
"tests/performance/jest.global-setup.ts",
231-
"tests/performance/jest.global-teardown.ts",
220+
"tests/integration/helpers/**",
221+
"tests/integration/*.test.ts",
222+
"tests/performance/helpers/**",
223+
"tests/performance/*.test.ts",
224+
"tests/test-support/helpers/**",
232225
],
233226
rules: {
234227
"no-relative-import-paths/no-relative-import-paths": 0,

tests/integration/dlq-redrive.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
import { GetQueueAttributesCommand, SQSClient } from "@aws-sdk/client-sqs";
2+
import { CloudWatchLogsClient } from "@aws-sdk/client-cloudwatch-logs";
23
import type {
34
MessageStatusData,
45
StatusPublishEvent,
56
} from "@nhs-notify-client-callbacks/models";
67
import {
7-
awaitSignedCallbacksFromWebhookLogGroup,
88
buildInboundEventQueueUrl,
99
buildLambdaLogGroupName,
1010
buildMockClientDlqQueueUrl,
11-
computeExpectedSignature,
1211
createCloudWatchLogsClient,
13-
createMessageStatusPublishEvent,
1412
createSqsClient,
15-
ensureInboundQueueIsEmpty,
1613
getDeploymentDetails,
14+
} from "@nhs-notify-client-callbacks/test-support/helpers";
15+
import { awaitSignedCallbacksFromWebhookLogGroup } from "./helpers/cloudwatch";
16+
import { createMessageStatusPublishEvent } from "./helpers/event-factories";
17+
import sendEventToDlqAndRedrive from "./helpers/redrive";
18+
import { computeExpectedSignature } from "./helpers/signature";
19+
import {
20+
ensureInboundQueueIsEmpty,
1721
purgeQueues,
18-
sendEventToDlqAndRedrive,
1922
sendSqsEvent,
20-
} from "helpers";
21-
import { CloudWatchLogsClient } from "@aws-sdk/client-cloudwatch-logs";
23+
} from "./helpers/sqs";
2224

2325
describe("DLQ Redrive", () => {
2426
let sqsClient: SQSClient;

tests/integration/event-bus-to-webhook.test.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
import { DeleteMessageCommand, SQSClient } from "@aws-sdk/client-sqs";
2+
import { CloudWatchLogsClient } from "@aws-sdk/client-cloudwatch-logs";
23
import {
34
type ChannelStatusData,
45
type MessageStatusData,
56
type StatusPublishEvent,
67
} from "@nhs-notify-client-callbacks/models";
78
import {
8-
awaitQueueMessage,
9-
awaitQueueMessageByMessageId,
109
buildInboundEventDlqQueueUrl,
1110
buildInboundEventQueueUrl,
1211
buildLambdaLogGroupName,
1312
buildMockClientDlqQueueUrl,
14-
computeExpectedSignature,
15-
createChannelStatusPublishEvent,
1613
createCloudWatchLogsClient,
17-
createMessageStatusPublishEvent,
1814
createSqsClient,
19-
ensureInboundQueueIsEmpty,
2015
getDeploymentDetails,
21-
processChannelStatusEvent,
22-
processMessageStatusEvent,
16+
} from "@nhs-notify-client-callbacks/test-support/helpers";
17+
import { computeExpectedSignature } from "./helpers/signature";
18+
import {
19+
createChannelStatusPublishEvent,
20+
createMessageStatusPublishEvent,
21+
} from "./helpers/event-factories";
22+
import {
23+
awaitQueueMessage,
24+
awaitQueueMessageByMessageId,
25+
ensureInboundQueueIsEmpty,
2326
purgeQueues,
2427
sendSqsEvent,
25-
} from "helpers";
26-
import { CloudWatchLogsClient } from "@aws-sdk/client-cloudwatch-logs";
28+
} from "./helpers/sqs";
29+
import {
30+
processChannelStatusEvent,
31+
processMessageStatusEvent,
32+
} from "./helpers/status-events";
2733

2834
describe("SQS to Webhook Integration", () => {
2935
let sqsClient: SQSClient;

tests/integration/helpers/clients.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/integration/helpers/deployment.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/integration/helpers/index.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/integration/helpers/sqs.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ import {
1111
import { logger } from "@nhs-notify-client-callbacks/logger";
1212
import { waitUntil } from "async-wait-until";
1313

14-
export {
15-
buildInboundEventDlqQueueUrl,
16-
buildInboundEventQueueUrl,
17-
buildMockClientDlqQueueUrl,
18-
} from "@nhs-notify-client-callbacks/test-support/helpers/sqs";
19-
2014
const QUEUE_WAIT_TIMEOUT_MS = 60_000;
2115
const POLL_INTERVAL_MS = 500;
2216
const SQS_MAX_NUMBER_OF_MESSAGES = 1;

tests/integration/infrastructure-exists.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
buildSubscriptionConfigBucketName,
55
createS3Client,
66
getDeploymentDetails,
7-
} from "helpers";
7+
} from "@nhs-notify-client-callbacks/test-support/helpers";
88

99
describe("Infrastructure exists", () => {
1010
let s3Client: S3Client;

tests/integration/jest.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ export default {
99
...(nodeJestConfig.coveragePathIgnorePatterns ?? []),
1010
"/helpers/",
1111
],
12-
moduleNameMapper: {
13-
"^helpers$": "<rootDir>/helpers/index",
14-
},
1512
setupFilesAfterEnv: [
1613
...(nodeJestConfig.setupFilesAfterEnv ?? []),
1714
"<rootDir>/jest.setup.ts",

tests/integration/jest.global-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
buildSubscriptionConfigBucketName,
44
createS3Client,
55
getDeploymentDetails,
6-
} from "./helpers";
6+
} from "@nhs-notify-client-callbacks/test-support/helpers";
77

88
const mockClientSubscriptionKey = "client_subscriptions/mock-client.json";
99

0 commit comments

Comments
 (0)