Skip to content

Commit 33b75e1

Browse files
authored
fix(audit-dto): support for invocation id (#1424)
1 parent 5118d0c commit 33b75e1

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

src/dto/audit.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const AuditDto = {
2626
* fullAuditRef: string,
2727
* isLive: boolean,
2828
* siteId: string
29+
* invocationId: string
2930
* }} JSON object.
3031
*/
3132
toJSON: (audit) => ({
@@ -36,6 +37,7 @@ export const AuditDto = {
3637
isLive: audit.getIsLive(),
3738
isError: audit.getIsError(),
3839
siteId: audit.getSiteId(),
40+
invocationId: audit.getInvocationId(),
3941
}),
4042

4143
/**
@@ -48,6 +50,7 @@ export const AuditDto = {
4850
* fullAuditRef: string,
4951
* isLive: boolean,
5052
* siteId: string
53+
* invocationId: string
5154
* }} JSON object.
5255
*/
5356
toAbbreviatedJSON: (audit) => {
@@ -68,6 +71,7 @@ export const AuditDto = {
6871
isLive: audit.getIsLive(),
6972
isError: audit.getIsError(),
7073
siteId: audit.getSiteId(),
74+
invocationId: audit.getInvocationId(),
7175
};
7276
},
7377
};

test/controllers/audits.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ describe('Audits Controller', () => {
5454
isError: false,
5555
isLive: true,
5656
fullAuditRef: 'https://lh-metrics.com/audit/123',
57+
invocationId: 'some-invocation-id1',
5758
auditResult: {
5859
scores: {
5960
performance: 0.5,
@@ -70,6 +71,7 @@ describe('Audits Controller', () => {
7071
isError: false,
7172
isLive: true,
7273
fullAuditRef: 'https://lh-metrics.com/audit/234',
74+
invocationId: 'some-invocation-id2',
7375
auditResult: {
7476
scores: {
7577
performance: 0.5,
@@ -86,6 +88,7 @@ describe('Audits Controller', () => {
8688
isError: false,
8789
isLive: true,
8890
fullAuditRef: 'https://lh-metrics.com/audit/345',
91+
invocationId: 'some-invocation-id3',
8992
auditResult: {
9093
scores: {
9194
'first-contentful-paint': 0.5,

test/controllers/sites.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ describe('Sites Controller', () => {
178178
getIsError: sandbox.stub().returns(false),
179179
getIsLive: sandbox.stub().returns(true),
180180
getSiteId: sandbox.stub().returns(SITE_IDS[0]),
181+
getInvocationId: sandbox.stub().returns('some-invocation-id'),
181182
}),
182183
},
183184
KeyEvent: {
@@ -555,6 +556,7 @@ describe('Sites Controller', () => {
555556
getIsError: () => false,
556557
getIsLive: () => true,
557558
getSiteId: () => SITE_IDS[0],
559+
getInvocationId: () => 'some-invocation-id',
558560
};
559561
sites.forEach((site) => {
560562
// eslint-disable-next-line no-param-reassign

test/dto/audit.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('Audit DTO', () => {
4848
getIsLive: () => true,
4949
getIsError: () => false,
5050
getSiteId: () => 'site-id',
51+
getInvocationId: () => 'some-invocation',
5152
};
5253

5354
const auditJson = AuditDto.toAbbreviatedJSON(audit);
@@ -60,6 +61,7 @@ describe('Audit DTO', () => {
6061
isLive: true,
6162
isError: false,
6263
siteId: 'site-id',
64+
invocationId: 'some-invocation',
6365
});
6466
});
6567
});

test/index.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('Index Tests', () => {
4848
'best-practices': 0.6,
4949
},
5050
}),
51+
getInvocationId: () => 'some-invocation',
5152
};
5253

5354
const scrapeJobConfiguration = {

0 commit comments

Comments
 (0)