Skip to content

Commit

Permalink
Bump sdk-bundles-api version (#475)
Browse files Browse the repository at this point in the history
The `DetailedTestCaseResult` type was modified in a non-backwards
compatible commit on `meticulous-sdk`, so, to maintain compatibility with older versions of
`report-diffs-action`, we add in the old type here.
  • Loading branch information
dbook13 authored Jul 16, 2024
2 parents bd953a6 + ea0a0e7 commit ddba1ad
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 32 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"devDependencies": {
"@alwaysmeticulous/api": "^2.137.0",
"@alwaysmeticulous/sdk-bundles-api": "^2.137.0",
"@alwaysmeticulous/sdk-bundles-api": "^2.141.0",
"@parcel/packager-ts": "^2.12.0",
"@parcel/transformer-typescript-types": "^2.12.0",
"@types/jest": "^27.0.3",
Expand Down
44 changes: 41 additions & 3 deletions src/actions/main/utils/results-reporter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { getOctokit } from "@actions/github";
import { Project } from "@alwaysmeticulous/api";
import {
Project,
ScreenshotDiffResult,
TestCaseResult,
} from "@alwaysmeticulous/api";
import { METICULOUS_LOGGER_NAME } from "@alwaysmeticulous/common";
import {
DetailedTestCaseResult,
ExecuteTestRunResult,
RunningTestRunExecution,
} from "@alwaysmeticulous/sdk-bundles-api";
Expand All @@ -20,6 +25,29 @@ export interface EnrichedProject extends Project {
isGitHubIntegrationActive?: boolean;
}

interface OldDetailedTestCaseResult extends TestCaseResult {
screenshotDiffResultsByBaseReplayId: Record<string, ScreenshotDiffResult[]>;
totalNumberOfScreenshots: number;
}

const isOldDetailedTestCaseResult = (
result: DetailedTestCaseResult | OldDetailedTestCaseResult
): result is OldDetailedTestCaseResult => {
return (
(result as OldDetailedTestCaseResult)
.screenshotDiffResultsByBaseReplayId !== undefined
);
};

/**
* v2.140.0 of `@alwaysmeticulous/sdk-bundles-api` changed the type of DetailedTestCaseResult to include a
* `screenshotDiffDataByBaseReplayId` field instead of a `screenshotDiffResultsByBaseReplayId` field.
* To stay backwards compatible, we need to support both types.
*/
type VersionedDetailedTestCaseResult =
| DetailedTestCaseResult
| OldDetailedTestCaseResult;

/**
* Posts/updates Github comments and Github commit statuses to keep the user updated on progress/results.
*/
Expand Down Expand Up @@ -88,8 +116,18 @@ export class ResultsReporter {

async testRunFinished(results: ExecuteTestRunResult) {
const { testRun, testCaseResults } = results;
const screenshotDiffResults = testCaseResults.flatMap((testCase) =>
Object.values(testCase.screenshotDiffResultsByBaseReplayId).flat()
const screenshotDiffResults = testCaseResults.flatMap(
(testCase: VersionedDetailedTestCaseResult) => {
if (isOldDetailedTestCaseResult(testCase)) {
return Object.values(
testCase.screenshotDiffResultsByBaseReplayId
).flat();
} else {
return Object.values(
testCase.screenshotDiffDataByBaseReplayId
).flatMap((data) => data.results);
}
}
);
const screensWithDifferences = screenshotDiffResults.filter(
(result) => result.outcome === "diff"
Expand Down
36 changes: 8 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@
resolved "https://registry.yarnpkg.com/@alwaysmeticulous/sdk-bundles-api/-/sdk-bundles-api-2.137.0.tgz#e565b46f783239319d1b40e3b7250d05445ac4c3"
integrity sha512-S//KhYbPXRGz8RzIDWBmur3CeWi7y7QfKviF+qnEWSU554whjndiDXXjdJGF6baUZOHKsDQjW2Xw6aUL4hMqwA==

"@alwaysmeticulous/sdk-bundles-api@^2.141.0":
version "2.141.0"
resolved "https://registry.yarnpkg.com/@alwaysmeticulous/sdk-bundles-api/-/sdk-bundles-api-2.141.0.tgz#594f1c0e10149fe756a19a4b7e6664e41f5d13d8"
integrity sha512-Is13yYgKiK1Z/+Y2brk1ZhYz0srIj8P5kDnJpDpbgPyl/wn0hzjzh2iI9Zcghuz2ZiWR4C9I0r/Nr0GKBkdN/w==

"@alwaysmeticulous/sentry@^2.137.0":
version "2.137.0"
resolved "https://registry.yarnpkg.com/@alwaysmeticulous/sentry/-/sentry-2.137.0.tgz#072170853f7324a9d5cbe48b0afe3342099aaa8d"
Expand Down Expand Up @@ -5593,16 +5598,7 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -5647,14 +5643,7 @@ string.prototype.trimstart@^1.0.7:
define-properties "^1.2.0"
es-abstract "^1.22.1"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -6164,16 +6153,7 @@ word-wrap@~1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.4.tgz#cb4b50ec9aca570abd1f52f33cd45b6c61739a9f"
integrity sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down

0 comments on commit ddba1ad

Please sign in to comment.