Skip to content

Commit 6750c40

Browse files
update test utility
1 parent 49efd2a commit 6750c40

5 files changed

Lines changed: 37 additions & 8 deletions

File tree

internal/datastore/src/__test__/letter-repository.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function createLetter(
3030
source: "/data-plane/letter-rendering/pdf",
3131
subject: `client/1/letter-request/${letterId}`,
3232
billingRef: "specification1",
33-
specificationBillingId: "specification1",
33+
specificationBillingId: "billing1",
3434
};
3535
}
3636

scripts/utilities/letter-test-data/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ npm run cli -- create-letter \
1616
--letter-id letter-id \
1717
--group-id group-id \
1818
--specification-id specification-id \
19+
--billing-id billing-id \
1920
--status PENDING
2021
```
2122

@@ -26,6 +27,7 @@ npm run cli -- create-letter-batch \
2627
--awsAccountId 820178564574 \
2728
--group-id group-id \
2829
--specification-id specification-id \
30+
--billing-id billing-id \
2931
--status PENDING \
3032
--count 10
3133
```

scripts/utilities/letter-test-data/src/__test__/helpers/create-letter-helpers.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ describe("Create letter helpers", () => {
2929
const targetFilename = "targetFilename";
3030
const groupId = "groupId";
3131
const specificationId = "specificationId";
32+
const billingId = "billingId";
3233
const status = "PENDING" as LetterStatusType;
3334
const testLetter = "test-letter-standard";
3435

@@ -39,6 +40,7 @@ describe("Create letter helpers", () => {
3940
targetFilename,
4041
groupId,
4142
specificationId,
43+
billingId,
4244
status,
4345
letterRepository: mockedLetterRepository,
4446
testLetter,
@@ -62,7 +64,7 @@ describe("Create letter helpers", () => {
6264
source: "/data-plane/letter-rendering/letter-test-data",
6365
subject: "supplier-api/letter-test-data/letterId",
6466
billingRef: "specificationId",
65-
specificationBillingId: "specificationId",
67+
specificationBillingId: "billingId",
6668
});
6769
});
6870

@@ -82,6 +84,7 @@ describe("Create letter helpers", () => {
8284
const targetFilename = "targetFilename";
8385
const groupId = "groupId";
8486
const specificationId = "specificationId";
87+
const billingId = "billingId";
8588
const status = "PENDING" as LetterStatusType;
8689
const testLetter = "none";
8790

@@ -92,6 +95,7 @@ describe("Create letter helpers", () => {
9295
targetFilename,
9396
groupId,
9497
specificationId,
98+
billingId,
9599
status,
96100
letterRepository: mockedLetterRepository,
97101
testLetter,
@@ -111,7 +115,7 @@ describe("Create letter helpers", () => {
111115
billingRef: "specificationId",
112116
source: "/data-plane/letter-rendering/letter-test-data",
113117
subject: "supplier-api/letter-test-data/letterId",
114-
specificationBillingId: "specificationId",
118+
specificationBillingId: "billingId",
115119
});
116120
});
117121

@@ -123,6 +127,7 @@ describe("Create letter helpers", () => {
123127
letterId: "testLetterId",
124128
supplierId: "testSupplierId",
125129
specificationId: "testSpecId",
130+
billingId: "testBillingId",
126131
groupId: "testGroupId",
127132
status: "PENDING" as LetterStatusType,
128133
url: "s3://bucket/testSupplierId/testLetter.pdf",
@@ -142,7 +147,7 @@ describe("Create letter helpers", () => {
142147
source: "/data-plane/letter-rendering/letter-test-data",
143148
subject: "supplier-api/letter-test-data/testLetterId",
144149
billingRef: "testSpecId",
145-
specificationBillingId: "testSpecId",
150+
specificationBillingId: "testBillingId",
146151
});
147152
});
148153
});

scripts/utilities/letter-test-data/src/cli/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ async function main() {
4444
type: "string",
4545
demandOption: false,
4646
},
47+
"billing-id": {
48+
type: "string",
49+
demandOption: false,
50+
},
4751
"ttl-hours": {
4852
type: "number",
4953
demandOption: false,
@@ -83,6 +87,7 @@ async function main() {
8387
const targetFilename = `${letterId}.pdf`;
8488
const groupId = argv.groupId ?? randomUUID();
8589
const specificationId = argv.specificationId ?? randomUUID();
90+
const billingId = argv.billingId ?? randomUUID();
8691
const { status } = argv;
8792
const { environment } = argv;
8893
const { ttlHours } = argv;
@@ -96,6 +101,7 @@ async function main() {
96101
targetFilename,
97102
groupId,
98103
specificationId,
104+
billingId,
99105
status: status as LetterStatusType,
100106
letterRepository,
101107
testLetter,
@@ -130,6 +136,10 @@ async function main() {
130136
type: "string",
131137
demandOption: false,
132138
},
139+
"billing-id": {
140+
type: "string",
141+
demandOption: false,
142+
},
133143
"ttl-hours": {
134144
type: "number",
135145
demandOption: false,
@@ -174,6 +184,7 @@ async function main() {
174184
const { supplierId } = argv;
175185
const groupId = argv.groupId ?? randomUUID();
176186
const specificationId = argv.specificationId ?? randomUUID();
187+
const billingId = argv.billingId ?? randomUUID();
177188
const { status } = argv;
178189
const { environment } = argv;
179190
const { ttlHours } = argv;
@@ -206,6 +217,7 @@ async function main() {
206217
supplierId,
207218
groupId,
208219
specificationId,
220+
billingId,
209221
status: status as LetterStatusType,
210222
url,
211223
}),

scripts/utilities/letter-test-data/src/helpers/create-letter-helpers.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ export async function createLetter(params: {
1111
supplierId: string;
1212
targetFilename: string;
1313
specificationId: string;
14+
billingId: string;
1415
groupId: string;
1516
status: LetterStatusType;
1617
letterRepository: LetterRepository;
1718
testLetter: string;
1819
}) {
1920
const {
21+
billingId,
2022
bucketName,
2123
groupId,
2224
letterId,
@@ -49,7 +51,7 @@ export async function createLetter(params: {
4951
source: "/data-plane/letter-rendering/letter-test-data",
5052
subject: `supplier-api/letter-test-data/${letterId}`,
5153
billingRef: specificationId,
52-
specificationBillingId: specificationId,
54+
specificationBillingId: billingId,
5355
};
5456

5557
const letterRecord = await letterRepository.putLetter(letter);
@@ -60,12 +62,20 @@ export function createLetterDto(params: {
6062
letterId: string;
6163
supplierId: string;
6264
specificationId: string;
65+
billingId: string;
6366
groupId: string;
6467
status: LetterStatusType;
6568
url: string;
6669
}) {
67-
const { groupId, letterId, specificationId, status, supplierId, url } =
68-
params;
70+
const {
71+
billingId,
72+
groupId,
73+
letterId,
74+
specificationId,
75+
status,
76+
supplierId,
77+
url,
78+
} = params;
6979

7080
const letter: Omit<Letter, "ttl" | "supplierStatus" | "supplierStatusSk"> = {
7181
id: letterId,
@@ -79,7 +89,7 @@ export function createLetterDto(params: {
7989
source: "/data-plane/letter-rendering/letter-test-data",
8090
subject: `supplier-api/letter-test-data/${letterId}`,
8191
billingRef: specificationId,
82-
specificationBillingId: specificationId,
92+
specificationBillingId: billingId,
8393
};
8494

8595
return letter;

0 commit comments

Comments
 (0)