Merge pull request #13559 from backstage/rugvip/jest29

cli: switch to Jest 29
This commit is contained in:
Patrik Oldsberg
2022-09-20 18:48:50 +02:00
committed by GitHub
53 changed files with 1332 additions and 796 deletions
+4
View File
@@ -15,3 +15,7 @@
*/
import '@testing-library/jest-dom';
Object.defineProperty(global, 'TextDecoder', {
value: require('util').TextDecoder,
});
@@ -44,7 +44,7 @@ jest.mock('@google-cloud/firestore', () => ({
Firestore: jest.fn().mockImplementation(() => firestoreMock),
}));
jest.useFakeTimers('legacy');
jest.useFakeTimers({ legacyFakeTimers: true });
describe('FirestoreKeyStore', () => {
const key = {
@@ -18,7 +18,7 @@ import { getDurationFromDates } from './getDurationFromDates';
describe('getDurationFromDates', () => {
beforeAll(() => {
jest.useFakeTimers('modern');
jest.useFakeTimers();
jest.setSystemTime(new Date('2021-10-15T09:45:25.0000000Z'));
});
@@ -153,7 +153,7 @@ describe('GitlabDiscoveryProcessor', () => {
setupRequestMockHandlers(server);
beforeAll(() => {
jest.useFakeTimers('modern');
jest.useFakeTimers();
jest.setSystemTime(new Date(SERVER_TIME));
});
@@ -87,7 +87,6 @@ describe('<PreparePullRequestForm />', () => {
<TextField
{...asInputRef(register('main', { required: true }))}
name="main"
required
/>
{formState.errors.main && (
<FormHelperText error>
@@ -52,7 +52,7 @@ describe('GitReleaseClient', () => {
"getRepository": [Function],
"getTag": [Function],
"getUser": [Function],
"githubAuthApi": Object {
"githubAuthApi": {
"getAccessToken": [MockFunction],
},
"host": "github.com",
@@ -22,7 +22,7 @@ describe('gitReleaseManagerApiRef', () => {
expect(result).toMatchInlineSnapshot(`
ApiRefImpl {
"config": Object {
"config": {
"id": "plugin.git-release-manager.service",
},
}
@@ -19,19 +19,19 @@ import * as constants from './constants';
describe('constants', () => {
it('should match snapshot', () => {
expect(constants).toMatchInlineSnapshot(`
Object {
"DISABLE_CACHE": Object {
"headers": Object {
{
"DISABLE_CACHE": {
"headers": {
"If-None-Match": "",
},
},
"SEMVER_PARTS": Object {
"SEMVER_PARTS": {
"major": "major",
"minor": "minor",
"patch": "patch",
},
"TAG_OBJECT_MESSAGE": "Tag generated by your friendly neighborhood Backstage Release Manager",
"VERSIONING_STRATEGIES": Object {
"VERSIONING_STRATEGIES": {
"calver": "calver",
"semver": "semver",
},
@@ -72,37 +72,37 @@ describe('useCreateReleaseCandidate', () => {
expect(result.current.responseSteps).toHaveLength(7);
expect(result.current).toMatchInlineSnapshot(`
Object {
{
"progress": 100,
"responseSteps": Array [
Object {
"responseSteps": [
{
"link": "https://latestCommit.html_url",
"message": "Fetched latest commit from \\"mock_defaultBranch\\"",
"secondaryMessage": "with message \\"latestCommit.commit.message\\"",
"message": "Fetched latest commit from "mock_defaultBranch"",
"secondaryMessage": "with message "latestCommit.commit.message"",
},
Object {
{
"message": "Created Release Branch",
"secondaryMessage": "with ref \\"mock_createRef_ref\\"",
"secondaryMessage": "with ref "mock_createRef_ref"",
},
Object {
{
"message": "Created Tag Object",
"secondaryMessage": "with sha \\"mock_tag_object_sha\\"",
"secondaryMessage": "with sha "mock_tag_object_sha"",
},
Object {
{
"message": "Cut Tag Reference",
"secondaryMessage": "with ref \\"mock_createRef_ref\\"",
"secondaryMessage": "with ref "mock_createRef_ref"",
},
Object {
{
"link": "https://mock_compareCommits_html_url",
"message": "Fetched commit comparison",
"secondaryMessage": "rc/2020.01.01_1...rc/2020.01.01_1",
},
Object {
{
"link": "https://mock_createRelease_html_url",
"message": "Created Release Candidate \\"mock_createRelease_name\\"",
"secondaryMessage": "with tag \\"rc-2020.01.01_1\\"",
"message": "Created Release Candidate "mock_createRelease_name"",
"secondaryMessage": "with tag "rc-2020.01.01_1"",
},
Object {
{
"icon": "success",
"message": "Success callback successfully called 🚀",
},
@@ -75,91 +75,91 @@ describe('patch', () => {
expect(result.error).toEqual(undefined);
expect(result.current.responseSteps).toHaveLength(19);
expect(result.current).toMatchInlineSnapshot(`
Object {
{
"progress": 100,
"responseSteps": Array [
Object {
"responseSteps": [
{
"message": <PatchDryRunMessage
message="Fetched latest commit from \\"rc/2020.01.01_1\\""
message="Fetched latest commit from "rc/2020.01.01_1""
/>,
},
Object {
{
"message": <PatchDryRunMessage
message="Created temporary patch dry run branch \\"rc/2020.01.01_1-backstage-grm-patch-dry-run\\""
message="Created temporary patch dry run branch "rc/2020.01.01_1-backstage-grm-patch-dry-run""
/>,
},
Object {
{
"message": <PatchDryRunMessage
message="Fetched release branch \\"rc/1.2.3\\""
message="Fetched release branch "rc/1.2.3""
/>,
},
Object {
{
"message": <PatchDryRunMessage
message="Created temporary commit"
/>,
},
Object {
{
"message": <PatchDryRunMessage
message="Forced branch \\"rc/2020.01.01_1-backstage-grm-patch-dry-run\\" to temporary commit \\"mock_commit_sha\\""
message="Forced branch "rc/2020.01.01_1-backstage-grm-patch-dry-run" to temporary commit "mock_commit_sha""
/>,
},
Object {
{
"message": <PatchDryRunMessage
message="Merged temporary commit into \\"rc/2020.01.01_1-backstage-grm-patch-dry-run\\""
message="Merged temporary commit into "rc/2020.01.01_1-backstage-grm-patch-dry-run""
/>,
},
Object {
{
"message": <PatchDryRunMessage
message="Cherry-picked patch commit to \\"mock_branch_commit_sha\\""
message="Cherry-picked patch commit to "mock_branch_commit_sha""
/>,
},
Object {
{
"message": <PatchDryRunMessage
message="Updated reference \\"mock_update_ref_ref\\""
message="Updated reference "mock_update_ref_ref""
/>,
},
Object {
{
"message": <PatchDryRunMessage
message="Deleted temporary patch prep branch \\"rc/2020.01.01_1-backstage-grm-patch-dry-run\\""
message="Deleted temporary patch prep branch "rc/2020.01.01_1-backstage-grm-patch-dry-run""
/>,
},
Object {
{
"link": "https://mock_branch_links_html",
"message": "Fetched release branch \\"rc/1.2.3\\"",
"message": "Fetched release branch "rc/1.2.3"",
},
Object {
{
"message": "Created temporary commit",
"secondaryMessage": "with message \\"mock_commit_message\\"",
"secondaryMessage": "with message "mock_commit_message"",
},
Object {
"message": "Forced branch \\"rc/2020.01.01_1\\" to temporary commit \\"mock_commit_sha\\"",
{
"message": "Forced branch "rc/2020.01.01_1" to temporary commit "mock_commit_sha"",
},
Object {
{
"link": "https://mock_merge_html_url",
"message": "Merged temporary commit into \\"rc/2020.01.01_1\\"",
"secondaryMessage": "with message \\"mock_merge_commit_message\\"",
"message": "Merged temporary commit into "rc/2020.01.01_1"",
"secondaryMessage": "with message "mock_merge_commit_message"",
},
Object {
"message": "Cherry-picked patch commit to \\"mock_branch_commit_sha\\"",
"secondaryMessage": "with message \\"mock_commit_message\\"",
{
"message": "Cherry-picked patch commit to "mock_branch_commit_sha"",
"secondaryMessage": "with message "mock_commit_message"",
},
Object {
"message": "Updated reference \\"mock_update_ref_ref\\"",
{
"message": "Updated reference "mock_update_ref_ref"",
},
Object {
{
"message": "Created new tag object",
"secondaryMessage": "with name \\"mock_tag_object_tag\\"",
"secondaryMessage": "with name "mock_tag_object_tag"",
},
Object {
"message": "Created new reference \\"mock_createRef_ref\\"",
"secondaryMessage": "for tag object \\"mock_tag_object_tag\\"",
{
"message": "Created new reference "mock_createRef_ref"",
"secondaryMessage": "for tag object "mock_tag_object_tag"",
},
Object {
{
"link": "https://mock_update_release_html_url",
"message": "Updated release \\"mock_update_release_name\\"",
"message": "Updated release "mock_update_release_name"",
"secondaryMessage": "with tag mock_update_release_tag_name",
},
Object {
{
"icon": "success",
"message": "Success callback successfully called 🚀",
},
@@ -72,27 +72,27 @@ describe('usePromoteRc', () => {
expect(result.current.responseSteps).toHaveLength(5);
expect(result.current).toMatchInlineSnapshot(`
Object {
{
"progress": 100,
"responseSteps": Array [
Object {
"responseSteps": [
{
"message": "Fetched most recent commit from release branch",
"secondaryMessage": "with sha \\"latestCommit.sha\\"",
"secondaryMessage": "with sha "latestCommit.sha"",
},
Object {
{
"message": "Created Tag Object",
"secondaryMessage": "with sha \\"mock_tag_object_sha\\"",
"secondaryMessage": "with sha "mock_tag_object_sha"",
},
Object {
{
"message": "Create Tag Reference",
"secondaryMessage": "with ref \\"mock_createRef_ref\\"",
"secondaryMessage": "with ref "mock_createRef_ref"",
},
Object {
{
"link": "https://mock_update_release_html_url",
"message": "Promoted \\"mock_update_release_name\\"",
"secondaryMessage": "from \\"rc-2020.01.01_1\\" to \\"mock_update_release_tag_name\\"",
"message": "Promoted "mock_update_release_name"",
"secondaryMessage": "from "rc-2020.01.01_1" to "mock_update_release_tag_name"",
},
Object {
{
"icon": "success",
"message": "Success callback successfully called 🚀",
},
@@ -71,7 +71,7 @@ describe('Owner', () => {
await waitFor(() => screen.getAllByTestId(TEST_IDS.form.owner.empty));
expect(getAllByTestId(TEST_IDS.form.owner.empty)).toMatchInlineSnapshot(`
Array [
[
<p
class="MuiFormHelperText-root Mui-required"
data-testid="grm--form--owner--empty"
@@ -65,7 +65,7 @@ describe('Repo', () => {
await waitFor(() => screen.getAllByTestId(TEST_IDS.form.repo.empty));
expect(getAllByTestId(TEST_IDS.form.repo.empty)).toMatchInlineSnapshot(`
Array [
[
<p
class="MuiFormHelperText-root Mui-required"
data-testid="grm--form--repo--empty"
@@ -51,10 +51,10 @@ describe('Repo', () => {
fireEvent.click(radio2);
expect(mockNavigate.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
[
[
"?versioningStrategy=calver&owner=mock_owner&repo=mock_repo",
Object {
{
"replace": true,
},
],
@@ -96,29 +96,29 @@ describe('getReleaseCommitPairs', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
"releaseCommitPairs": Array [
Object {
{
"releaseCommitPairs": [
{
"baseVersion": "2.0",
"endCommit": Object {
"endCommit": {
"tagName": "version-2.0.0",
"tagSha": "sha-2.0.0",
"tagType": "tag",
},
"startCommit": Object {
"startCommit": {
"tagName": "rc-2.0.0",
"tagSha": "sha-2.0.0",
"tagType": "tag",
},
},
Object {
{
"baseVersion": "3.0",
"endCommit": Object {
"endCommit": {
"tagName": "version-3.0.1",
"tagSha": "sha-3.0.1",
"tagType": "tag",
},
"startCommit": Object {
"startCommit": {
"tagName": "rc-3.0.0",
"tagSha": "sha-3.0.0",
"tagType": "tag",
@@ -33,27 +33,27 @@ describe('getMappedReleases', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
"mappedReleases": Object {
"releases": Object {
"1.0": Object {
{
"mappedReleases": {
"releases": {
"1.0": {
"baseVersion": "1.0",
"candidates": Array [],
"candidates": [],
"createdAt": "2021-01-01T10:11:12Z",
"htmlUrl": "html_url",
"versions": Array [],
"versions": [],
},
"1.1": Object {
"1.1": {
"baseVersion": "1.1",
"candidates": Array [],
"candidates": [],
"createdAt": "2021-01-01T10:11:12Z",
"htmlUrl": "html_url",
"versions": Array [],
"versions": [],
},
},
"unmappableTags": Array [],
"unmatchedReleases": Array [],
"unmatchedTags": Array [],
"unmappableTags": [],
"unmatchedReleases": [],
"unmatchedTags": [],
},
}
`);
@@ -60,23 +60,23 @@ describe('getReleaseStats', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
"releaseStats": Object {
"releases": Object {
"1.0": Object {
{
"releaseStats": {
"releases": {
"1.0": {
"baseVersion": "1.0",
"candidates": Array [
Object {
"candidates": [
{
"tagName": "rc-1.0.0",
"tagSha": "sha",
"tagType": "tag",
},
Object {
{
"tagName": "rc-1.0.1",
"tagSha": "sha",
"tagType": "tag",
},
Object {
{
"tagName": "rc-1.0.2",
"tagSha": "sha",
"tagType": "tag",
@@ -84,18 +84,18 @@ describe('getReleaseStats', () => {
],
"createdAt": "2021-01-01T10:11:12Z",
"htmlUrl": "html_url",
"versions": Array [
Object {
"versions": [
{
"tagName": "version-1.0.2",
"tagSha": "sha",
"tagType": "tag",
},
],
},
"1.1": Object {
"1.1": {
"baseVersion": "1.1",
"candidates": Array [
Object {
"candidates": [
{
"tagName": "rc-1.1.1",
"tagSha": "sha",
"tagType": "tag",
@@ -103,14 +103,14 @@ describe('getReleaseStats', () => {
],
"createdAt": "2021-01-01T10:11:12Z",
"htmlUrl": "html_url",
"versions": Array [],
"versions": [],
},
},
"unmappableTags": Array [
"unmappableTags": [
"rc-123.123.123",
],
"unmatchedReleases": Array [],
"unmatchedTags": Array [
"unmatchedReleases": [],
"unmatchedTags": [
"rc-1/2/3",
],
},
@@ -22,8 +22,8 @@ describe('getSummary', () => {
const result = getSummary({ releaseStats: mockReleaseStats });
expect(result).toMatchInlineSnapshot(`
Object {
"summary": Object {
{
"summary": {
"totalCandidatePatches": 3,
"totalReleases": 2,
"totalVersionPatches": 1,
@@ -43,7 +43,7 @@ describe('getTagDates', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
{
"endDate": undefined,
"startDate": "TAG-START",
}
@@ -65,7 +65,7 @@ describe('getTagDates', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
{
"endDate": undefined,
"startDate": "COMMIT_START",
}
@@ -91,7 +91,7 @@ describe('getTagDates', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
{
"endDate": "TAG-END",
"startDate": "TAG-START",
}
@@ -117,7 +117,7 @@ describe('getTagDates', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
{
"endDate": "COMMIT_END",
"startDate": "COMMIT_START",
}
@@ -160,7 +160,7 @@ describe('getTagDates', () => {
[{ owner, ref: 'OBJECT_SHA_START', repo }],
]);
expect(result).toMatchInlineSnapshot(`
Object {
{
"endDate": "COMMIT_START",
"startDate": "COMMIT_END",
}
@@ -203,7 +203,7 @@ describe('getTagDates', () => {
[{ owner, ref: 'OBJECT_SHA_END', repo }],
]);
expect(result).toMatchInlineSnapshot(`
Object {
{
"endDate": "COMMIT_END",
"startDate": "COMMIT_START",
}
@@ -21,7 +21,7 @@ describe('createResponseStepError', () => {
const result = createResponseStepError(new Error('banana'));
expect(result).toMatchInlineSnapshot(`
Object {
{
"icon": "failure",
"message": "Something went wrong ❌",
"secondaryMessage": "Error message: banana",
@@ -30,10 +30,10 @@ describe('getBumpedTag', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
{
"bumpedTag": "rc-2020.01.01_2",
"error": undefined,
"tagParts": Object {
"tagParts": {
"calver": "2020.01.01",
"patch": 2,
"prefix": "rc",
@@ -50,10 +50,10 @@ describe('getBumpedTag', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
{
"bumpedTag": "rc-2020.01.01_2",
"error": undefined,
"tagParts": Object {
"tagParts": {
"calver": "2020.01.01",
"patch": 2,
"prefix": "rc",
@@ -72,10 +72,10 @@ describe('getBumpedTag', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
{
"bumpedTag": "rc-1.2.4",
"error": undefined,
"tagParts": Object {
"tagParts": {
"major": 1,
"minor": 2,
"patch": 4,
@@ -93,10 +93,10 @@ describe('getBumpedTag', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
{
"bumpedTag": "rc-1.3.0",
"error": undefined,
"tagParts": Object {
"tagParts": {
"major": 1,
"minor": 3,
"patch": 0,
@@ -114,10 +114,10 @@ describe('getBumpedTag', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
{
"bumpedTag": "rc-2.0.0",
"error": undefined,
"tagParts": Object {
"tagParts": {
"major": 2,
"minor": 0,
"patch": 0,
@@ -137,9 +137,9 @@ describe('getBumpedTag', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
"error": Object {
"subtitle": "Expected calver matching \\"/(rc|version)-([0-9]{4}\\\\.[0-9]{2}\\\\.[0-9]{2})_([0-9]+)/\\", found \\"😬\\"",
{
"error": {
"subtitle": "Expected calver matching "/(rc|version)-([0-9]{4}\\.[0-9]{2}\\.[0-9]{2})_([0-9]+)/", found "😬"",
"title": "Invalid tag",
},
}
@@ -43,7 +43,7 @@ describe('getReleaseCandidateGitInfo', () => {
injectedDate: '2021.01.28',
}),
).toMatchInlineSnapshot(`
Object {
{
"rcBranch": "rc/2021.01.28",
"rcReleaseTag": "rc-2021.01.28_0",
"releaseName": "Version 2021.01.28",
@@ -61,7 +61,7 @@ describe('getReleaseCandidateGitInfo', () => {
semverBumpLevel: 'minor',
}),
).toMatchInlineSnapshot(`
Object {
{
"rcBranch": "rc/1.3.0",
"rcReleaseTag": "rc-1.3.0",
"releaseName": "Version 1.3.0",
@@ -77,7 +77,7 @@ describe('getReleaseCandidateGitInfo', () => {
semverBumpLevel: 'minor',
}),
).toMatchInlineSnapshot(`
Object {
{
"rcBranch": "rc/0.0.1",
"rcReleaseTag": "rc-0.0.1",
"releaseName": "Version 0.0.1",
@@ -26,28 +26,28 @@ describe('getCalverTagParts', () => {
const result = getCalverTagParts(mockReleaseCandidateCalver.tagName);
expect(result).toMatchInlineSnapshot(`
Object {
"tagParts": Object {
"calver": "2020.01.01",
"patch": 1,
"prefix": "rc",
},
}
`);
{
"tagParts": {
"calver": "2020.01.01",
"patch": 1,
"prefix": "rc",
},
}
`);
});
it('should return tagParts for Version tag', () => {
const result = getCalverTagParts(mockReleaseVersionCalver.tagName);
expect(result).toMatchInlineSnapshot(`
Object {
"tagParts": Object {
"calver": "2020.01.01",
"patch": 1,
"prefix": "version",
},
}
`);
{
"tagParts": {
"calver": "2020.01.01",
"patch": 1,
"prefix": "version",
},
}
`);
});
});
@@ -56,9 +56,9 @@ describe('getCalverTagParts', () => {
const result = getCalverTagParts('invalid-2020.01.01_1');
expect(result).toMatchInlineSnapshot(`
Object {
"error": Object {
"subtitle": "Expected calver matching \\"/(rc|version)-([0-9]{4}\\\\.[0-9]{2}\\\\.[0-9]{2})_([0-9]+)/\\", found \\"invalid-2020.01.01_1\\"",
{
"error": {
"subtitle": "Expected calver matching "/(rc|version)-([0-9]{4}\\.[0-9]{2}\\.[0-9]{2})_([0-9]+)/", found "invalid-2020.01.01_1"",
"title": "Invalid tag",
},
}
@@ -69,9 +69,9 @@ describe('getCalverTagParts', () => {
const result = getCalverTagParts('rc-2020.1.01_1');
expect(result).toMatchInlineSnapshot(`
Object {
"error": Object {
"subtitle": "Expected calver matching \\"/(rc|version)-([0-9]{4}\\\\.[0-9]{2}\\\\.[0-9]{2})_([0-9]+)/\\", found \\"rc-2020.1.01_1\\"",
{
"error": {
"subtitle": "Expected calver matching "/(rc|version)-([0-9]{4}\\.[0-9]{2}\\.[0-9]{2})_([0-9]+)/", found "rc-2020.1.01_1"",
"title": "Invalid tag",
},
}
@@ -82,9 +82,9 @@ describe('getCalverTagParts', () => {
const result = getCalverTagParts('rc-2020.01_1');
expect(result).toMatchInlineSnapshot(`
Object {
"error": Object {
"subtitle": "Expected calver matching \\"/(rc|version)-([0-9]{4}\\\\.[0-9]{2}\\\\.[0-9]{2})_([0-9]+)/\\", found \\"rc-2020.01_1\\"",
{
"error": {
"subtitle": "Expected calver matching "/(rc|version)-([0-9]{4}\\.[0-9]{2}\\.[0-9]{2})_([0-9]+)/", found "rc-2020.01_1"",
"title": "Invalid tag",
},
}
@@ -95,9 +95,9 @@ describe('getCalverTagParts', () => {
const result = getCalverTagParts('rc-2020.01.01_a');
expect(result).toMatchInlineSnapshot(`
Object {
"error": Object {
"subtitle": "Expected calver matching \\"/(rc|version)-([0-9]{4}\\\\.[0-9]{2}\\\\.[0-9]{2})_([0-9]+)/\\", found \\"rc-2020.01.01_a\\"",
{
"error": {
"subtitle": "Expected calver matching "/(rc|version)-([0-9]{4}\\.[0-9]{2}\\.[0-9]{2})_([0-9]+)/", found "rc-2020.01.01_a"",
"title": "Invalid tag",
},
}
@@ -28,15 +28,15 @@ describe('getSemverTagParts', () => {
);
expect(semverTagParts).toMatchInlineSnapshot(`
Object {
"tagParts": Object {
"major": 1,
"minor": 2,
"patch": 3,
"prefix": "rc",
},
}
`);
{
"tagParts": {
"major": 1,
"minor": 2,
"patch": 3,
"prefix": "rc",
},
}
`);
});
it('should return tagParts for Version tag', () => {
@@ -45,15 +45,15 @@ describe('getSemverTagParts', () => {
);
expect(semverTagParts).toMatchInlineSnapshot(`
Object {
"tagParts": Object {
"major": 1,
"minor": 2,
"patch": 3,
"prefix": "version",
},
}
`);
{
"tagParts": {
"major": 1,
"minor": 2,
"patch": 3,
"prefix": "version",
},
}
`);
});
});
@@ -62,9 +62,9 @@ describe('getSemverTagParts', () => {
const semverTagParts = getSemverTagParts('invalid-1.2.3');
expect(semverTagParts).toMatchInlineSnapshot(`
Object {
"error": Object {
"subtitle": "Expected semver matching \\"/(rc|version)-([0-9]+)\\\\.([0-9]+)\\\\.([0-9]+)/\\", found \\"invalid-1.2.3\\"",
{
"error": {
"subtitle": "Expected semver matching "/(rc|version)-([0-9]+)\\.([0-9]+)\\.([0-9]+)/", found "invalid-1.2.3"",
"title": "Invalid tag",
},
}
@@ -75,9 +75,9 @@ describe('getSemverTagParts', () => {
const semverTagParts = getSemverTagParts('rc-1.2');
expect(semverTagParts).toMatchInlineSnapshot(`
Object {
"error": Object {
"subtitle": "Expected semver matching \\"/(rc|version)-([0-9]+)\\\\.([0-9]+)\\\\.([0-9]+)/\\", found \\"rc-1.2\\"",
{
"error": {
"subtitle": "Expected semver matching "/(rc|version)-([0-9]+)\\.([0-9]+)\\.([0-9]+)/", found "rc-1.2"",
"title": "Invalid tag",
},
}
@@ -88,9 +88,9 @@ describe('getSemverTagParts', () => {
const semverTagParts = getSemverTagParts('rc-1337.01.01_1');
expect(semverTagParts).toMatchInlineSnapshot(`
Object {
"error": Object {
"subtitle": "Expected semver matching \\"/(rc|version)-([0-9]+)\\\\.([0-9]+)\\\\.([0-9]+)/\\", found calver \\"rc-1337.01.01_1\\"",
{
"error": {
"subtitle": "Expected semver matching "/(rc|version)-([0-9]+)\\.([0-9]+)\\.([0-9]+)/", found calver "rc-1337.01.01_1"",
"title": "Invalid tag",
},
}
@@ -31,7 +31,7 @@ describe('validateTagName', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
{
"tagNameError": undefined,
}
`);
@@ -43,10 +43,10 @@ describe('validateTagName', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
"tagNameError": null,
}
`);
{
"tagNameError": null,
}
`);
});
});
@@ -58,9 +58,9 @@ describe('validateTagName', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
"tagNameError": Object {
"subtitle": "Expected semver matching \\"/(rc|version)-([0-9]+)\\\\.([0-9]+)\\\\.([0-9]+)/\\", found calver \\"rc-2020.01.01_1\\"",
{
"tagNameError": {
"subtitle": "Expected semver matching "/(rc|version)-([0-9]+)\\.([0-9]+)\\.([0-9]+)/", found calver "rc-2020.01.01_1"",
"title": "Invalid tag",
},
}
@@ -74,9 +74,9 @@ describe('validateTagName', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
"tagNameError": Object {
"subtitle": "Expected calver matching \\"/(rc|version)-([0-9]{4}\\\\.[0-9]{2}\\\\.[0-9]{2})_([0-9]+)/\\", found \\"rc-1.2.3\\"",
{
"tagNameError": {
"subtitle": "Expected calver matching "/(rc|version)-([0-9]{4}\\.[0-9]{2}\\.[0-9]{2})_([0-9]+)/", found "rc-1.2.3"",
"title": "Invalid tag",
},
}
@@ -92,9 +92,9 @@ describe('validateTagName', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
"tagNameError": Object {
"subtitle": "Expected semver matching \\"/(rc|version)-([0-9]+)\\\\.([0-9]+)\\\\.([0-9]+)/\\", found \\"this-is-so-invalid\\"",
{
"tagNameError": {
"subtitle": "Expected semver matching "/(rc|version)-([0-9]+)\\.([0-9]+)\\.([0-9]+)/", found "this-is-so-invalid"",
"title": "Invalid tag",
},
}
@@ -108,9 +108,9 @@ describe('validateTagName', () => {
});
expect(result).toMatchInlineSnapshot(`
Object {
"tagNameError": Object {
"subtitle": "Expected calver matching \\"/(rc|version)-([0-9]{4}\\\\.[0-9]{2}\\\\.[0-9]{2})_([0-9]+)/\\", found \\"this-is-so-invalid\\"",
{
"tagNameError": {
"subtitle": "Expected calver matching "/(rc|version)-([0-9]{4}\\.[0-9]{2}\\.[0-9]{2})_([0-9]+)/", found "this-is-so-invalid"",
"title": "Invalid tag",
},
}
@@ -35,31 +35,31 @@ describe('useGetHubBatchInfo', () => {
});
expect(result.current.gitBatchInfo).toMatchInlineSnapshot(`
Object {
{
"loading": false,
"value": Object {
"latestRelease": Object {
"value": {
"latestRelease": {
"htmlUrl": "https://mock_release_html_url",
"id": 1,
"prerelease": false,
"tagName": "rc-2020.01.01_1",
"targetCommitish": "rc/2020.01.01_1",
},
"releaseBranch": Object {
"commit": Object {
"commit": Object {
"tree": Object {
"releaseBranch": {
"commit": {
"commit": {
"tree": {
"sha": "mock_branch_commit_commit_tree_sha",
},
},
"sha": "mock_branch_commit_sha",
},
"links": Object {
"links": {
"html": "https://mock_branch_links_html",
},
"name": "rc/1.2.3",
},
"repository": Object {
"repository": {
"defaultBranch": "mock_defaultBranch",
"name": "mock_repo",
"pushPermissions": true,
@@ -86,12 +86,12 @@ describe('useGetHubBatchInfo', () => {
});
expect(result.current.gitBatchInfo).toMatchInlineSnapshot(`
Object {
{
"loading": false,
"value": Object {
"value": {
"latestRelease": null,
"releaseBranch": null,
"repository": Object {
"repository": {
"defaultBranch": "mock_defaultBranch",
"name": "mock_repo",
"pushPermissions": true,
@@ -50,14 +50,14 @@ describe('useQueryHandler', () => {
const result = getByTestId(TEST_ID).innerHTML;
expect(result).toMatchInlineSnapshot(`
"{
\\"parsedQuery\\": {
\\"versioningStrategy\\": \\"semver\\",
\\"owner\\": \\"mock_owner\\",
\\"repo\\": \\"mock_repo\\"
},
\\"queryParams\\": \\"versioningStrategy=semver&amp;owner=mock_owner&amp;repo=updated_mock_repo\\"
}"
`);
"{
"parsedQuery": {
"versioningStrategy": "semver",
"owner": "mock_owner",
"repo": "mock_repo"
},
"queryParams": "versioningStrategy=semver&amp;owner=mock_owner&amp;repo=updated_mock_repo"
}"
`);
});
});
@@ -23,11 +23,11 @@ describe('useResponseSteps', () => {
const { result } = renderHook(() => useResponseSteps());
expect(result.current).toMatchInlineSnapshot(`
Object {
{
"abortIfError": [Function],
"addStepToResponseSteps": [Function],
"asyncCatcher": [Function],
"responseSteps": Array [],
"responseSteps": [],
}
`);
});
@@ -36,7 +36,7 @@ describe('useResponseSteps', () => {
it('should add responseSteps to state', async () => {
const { result } = renderHook(() => useResponseSteps());
expect(result.current.responseSteps).toMatchInlineSnapshot(`Array []`);
expect(result.current.responseSteps).toMatchInlineSnapshot(`[]`);
act(() => {
result.current.addStepToResponseSteps({
@@ -45,12 +45,12 @@ describe('useResponseSteps', () => {
});
expect(result.current.responseSteps).toMatchInlineSnapshot(`
Array [
Object {
"message": "totally added a messaage ✌🏼",
},
]
`);
[
{
"message": "totally added a messaage ✌🏼",
},
]
`);
});
});
@@ -58,7 +58,7 @@ describe('useResponseSteps', () => {
it('should catch Errors and add as failure step, then throw', async () => {
const { result } = renderHook(() => useResponseSteps());
expect(result.current.responseSteps).toMatchInlineSnapshot(`Array []`);
expect(result.current.responseSteps).toMatchInlineSnapshot(`[]`);
await act(async () => {
await new Promise((_, reject) => reject(new Error(':(')))
@@ -69,8 +69,8 @@ describe('useResponseSteps', () => {
});
expect(result.current.responseSteps).toMatchInlineSnapshot(`
Array [
Object {
[
{
"icon": "failure",
"message": <b>
Something went wrong
@@ -91,7 +91,7 @@ describe('useResponseSteps', () => {
it('should catch unknown Errors and add as failure step, then throw', async () => {
const { result } = renderHook(() => useResponseSteps());
expect(result.current.responseSteps).toMatchInlineSnapshot(`Array []`);
expect(result.current.responseSteps).toMatchInlineSnapshot(`[]`);
await act(async () => {
await new Promise((_, reject) => reject())
@@ -102,8 +102,8 @@ describe('useResponseSteps', () => {
});
expect(result.current.responseSteps).toMatchInlineSnapshot(`
Array [
Object {
[
{
"icon": "failure",
"message": <b>
Something went wrong
@@ -126,13 +126,13 @@ describe('useResponseSteps', () => {
it('should do nothing if not Error', async () => {
const { result } = renderHook(() => useResponseSteps());
expect(result.current.responseSteps).toMatchInlineSnapshot(`Array []`);
expect(result.current.responseSteps).toMatchInlineSnapshot(`[]`);
act(() => {
result.current.abortIfError(undefined);
});
expect(result.current.responseSteps).toMatchInlineSnapshot(`Array []`);
expect(result.current.responseSteps).toMatchInlineSnapshot(`[]`);
});
});
});
@@ -19,7 +19,7 @@ import * as plugin from './plugin';
describe('git-release-manager', () => {
it('should export plugin & friends', () => {
expect(Object.keys(plugin)).toMatchInlineSnapshot(`
Array [
[
"gitReleaseManagerApiRef",
"constants",
"helpers",
@@ -46,6 +46,10 @@ describe('AzureIdentityKubernetesAuthTranslator tests', () => {
url: 'mycluster.privatelink.westeurope.azmk8s.io',
};
afterEach(() => {
jest.useRealTimers();
});
it('should decorate cluster with Azure token', async () => {
const authTranslator = new AzureIdentityKubernetesAuthTranslator(
logger,
@@ -70,6 +74,8 @@ describe('AzureIdentityKubernetesAuthTranslator tests', () => {
});
it('should issue new token 15 minutes befory expiry', async () => {
jest.useFakeTimers();
const authTranslator = new AzureIdentityKubernetesAuthTranslator(
logger,
new StaticTokenCredential(16 * 60 * 1000), // token expires in 16min
@@ -78,13 +84,15 @@ describe('AzureIdentityKubernetesAuthTranslator tests', () => {
const response = await authTranslator.decorateClusterDetailsWithAuth(cd);
expect(response.serviceAccountToken).toEqual('MY_TOKEN_1');
jest.useFakeTimers().setSystemTime(Date.now() + 2 * 60 * 1000); // advance time by 2mins
jest.setSystemTime(Date.now() + 2 * 60 * 1000); // advance time by 2mins
const response2 = await authTranslator.decorateClusterDetailsWithAuth(cd);
expect(response2.serviceAccountToken).toEqual('MY_TOKEN_2');
});
it('should re-use existing token if there is afailure', async () => {
jest.useFakeTimers();
const authTranslator = new AzureIdentityKubernetesAuthTranslator(
logger,
new StaticTokenCredential(16 * 60 * 1000), // new tokens expires in 16min
@@ -93,12 +101,12 @@ describe('AzureIdentityKubernetesAuthTranslator tests', () => {
const response = await authTranslator.decorateClusterDetailsWithAuth(cd);
expect(response.serviceAccountToken).toEqual('MY_TOKEN_1');
jest.useFakeTimers().setSystemTime(Date.now() + 2 * 60 * 1000); // advance time by 2min
jest.setSystemTime(Date.now() + 2 * 60 * 1000); // advance time by 2min
const response2 = await authTranslator.decorateClusterDetailsWithAuth(cd);
expect(response2.serviceAccountToken).toEqual('MY_TOKEN_2');
jest.useFakeTimers().setSystemTime(Date.now() + 2 * 60 * 1000); // advance time by 2min
jest.setSystemTime(Date.now() + 2 * 60 * 1000); // advance time by 2min
const response3 = await authTranslator.decorateClusterDetailsWithAuth(cd);
expect(response3.serviceAccountToken).toEqual('MY_TOKEN_2');
@@ -108,6 +116,8 @@ describe('AzureIdentityKubernetesAuthTranslator tests', () => {
});
it('should throw if existing token expired and failed to fetch a new one', async () => {
jest.useFakeTimers();
const authTranslator = new AzureIdentityKubernetesAuthTranslator(
logger,
new StaticTokenCredential(16 * 60 * 1000), // new tokens expires in 16min
@@ -116,12 +126,12 @@ describe('AzureIdentityKubernetesAuthTranslator tests', () => {
const response = await authTranslator.decorateClusterDetailsWithAuth(cd);
expect(response.serviceAccountToken).toEqual('MY_TOKEN_1');
jest.useFakeTimers().setSystemTime(Date.now() + 2 * 60 * 1000); // advance time by 2min
jest.setSystemTime(Date.now() + 2 * 60 * 1000); // advance time by 2min
const response2 = await authTranslator.decorateClusterDetailsWithAuth(cd);
expect(response2.serviceAccountToken).toEqual('MY_TOKEN_2');
jest.useFakeTimers().setSystemTime(Date.now() + 17 * 60 * 1000); // advance time by 17min
jest.setSystemTime(Date.now() + 17 * 60 * 1000); // advance time by 17min
await expect(
authTranslator.decorateClusterDetailsWithAuth(cd),
@@ -124,8 +124,8 @@ describe('RadarComponent', () => {
);
}).toThrow();
}).error[0],
).toMatch(
/^Error: Uncaught \[Error: No implementation available for apiRef{core.error}\]/,
);
).toMatchObject({
detail: new Error('No implementation available for apiRef{core.error}'),
});
});
});