Skip to content

Commit

Permalink
Accept optional siteID in upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Jym77 committed Nov 20, 2024
1 parent 9187d87 commit aa99920
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .changeset/itchy-pens-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@siteimprove/alfa-test-utils": minor
---

**Added:** `SIP.upload` now accepts an optional `siteID` parameter.

This should be the site ID of your site in the Siteimprove Intelligence Platform. It can be use to group tests by site and generate more accurate metadata and aggregates.
2 changes: 2 additions & 0 deletions docs/review/api/alfa-test-utils.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export namespace SIP {
CantTell: number;
Durations: RuleDurations;
}>;
SiteId?: string;
TestName?: string;
Version: `${number}.${number}.${number}`;
}
Expand All @@ -272,6 +273,7 @@ export namespace SIP {
includeGitInfo?: boolean;
pageTitle?: string | ((page: Page) => string);
pageURL?: string | ((page: Page) => string);
siteID?: string;
testName?: string | ((git: CommitInformation) => string);
userName?: string;
}
Expand Down
15 changes: 10 additions & 5 deletions packages/alfa-test-utils/src/report/sip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ export namespace SIP {
*/
apiKey?: string;

/**
* The site ID in the Siteimprove Intelligence Platform.
*/
siteID?: string;

/**
* The URL of the page, or a function to build it from the audited page.
* Defaults to the URL used to scrape the page.
Expand Down Expand Up @@ -150,11 +155,10 @@ export namespace SIP {
*/
Version: `${number}.${number}.${number}`;

// Ignored for now.
// /**
// * The site ID to which the page belongs in the Siteimprove Intelligence Platform.
// */
// SiteId?: string;
/**
* The site ID to which the page belongs in the Siteimprove Intelligence Platform.
*/
SiteId?: string;

/**
* Information about the latest git commit
Expand Down Expand Up @@ -254,6 +258,7 @@ export namespace SIP {
const result: Payload = {
RequestTimestamp: timestamp,
Version: audit.alfaVersion,
SiteId: options.siteID,
PageUrl,
PageTitle,
TestName,
Expand Down
12 changes: 12 additions & 0 deletions packages/alfa-test-utils/test/report/sip.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ test("S3.axiosConfig() creates an axios config", (t) => {
});
});

test("Metadata.payload() uses site ID if provided", async (t) => {
const actual = await Metadata.payload(
makeAudit(),
{ siteID: "12345" },
timestamp
);
t.notEqual(actual.CommitInformation, undefined);
delete actual.CommitInformation;

t.deepEqual(actual, makePayload({ SiteId: "12345" }));
});

test("Metadata.payload() uses test name if provided", async (t) => {
const actual = await Metadata.payload(
makeAudit(),
Expand Down

0 comments on commit aa99920

Please sign in to comment.