Merge pull request #13559 from backstage/rugvip/jest29
cli: switch to Jest 29
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Updated fallback versions of dependencies in all templates.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Switched the Jest transform for YAML files to use a custom one available at `@backstage/cli/config/jestYamlTransform.js`.
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
'@backstage/cli': minor
|
||||
---
|
||||
|
||||
**BREAKING**: Bumped `jest`, `jest-runtime`, and `jest-environment-jsdom` to v29. This is up from v27, so check out both the [v28](https://jestjs.io/docs/28.x/upgrading-to-jest28) and [v29](https://jestjs.io/docs/upgrading-to-jest29) (later [here](https://jestjs.io/docs/29.x/upgrading-to-jest29)) migration guides.
|
||||
|
||||
Particular changes that where encountered in the main Backstage repo are:
|
||||
|
||||
- The updated snapshot format.
|
||||
- `jest.useFakeTimers('legacy')` is now `jest.useFakeTimers({ legacyFakeTimers: true })`.
|
||||
- Error objects collected by `withLogCollector` from `@backstage/test-utils` are now objects with a `detail` property rather than a string.
|
||||
@@ -276,7 +276,7 @@ Usage: backstage-cli [--config=<pathToConfigFile>] [TestPathPattern]
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
-v, --version
|
||||
--version
|
||||
--all
|
||||
--automock
|
||||
-b, --bail
|
||||
@@ -289,7 +289,6 @@ Options:
|
||||
--clearMocks
|
||||
--collectCoverage
|
||||
--collectCoverageFrom
|
||||
--collectCoverageOnlyFrom
|
||||
--color
|
||||
--colors
|
||||
-c, --config
|
||||
@@ -312,6 +311,7 @@ Options:
|
||||
--globalTeardown
|
||||
--globals
|
||||
--haste
|
||||
--ignoreProjects
|
||||
--init
|
||||
--injectGlobals
|
||||
--json
|
||||
@@ -348,6 +348,7 @@ Options:
|
||||
--selectProjects
|
||||
--setupFiles
|
||||
--setupFilesAfterEnv
|
||||
--shard
|
||||
--showConfig
|
||||
--silent
|
||||
--skipFilter
|
||||
@@ -365,8 +366,6 @@ Options:
|
||||
--testRunner
|
||||
--testSequencer
|
||||
--testTimeout
|
||||
--testURL
|
||||
--timers
|
||||
--transform
|
||||
--transformIgnorePatterns
|
||||
--unmockedModulePathPatterns
|
||||
@@ -433,7 +432,7 @@ Usage: backstage-cli [--config=<pathToConfigFile>] [TestPathPattern]
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
-v, --version
|
||||
--version
|
||||
--all
|
||||
--automock
|
||||
-b, --bail
|
||||
@@ -446,7 +445,6 @@ Options:
|
||||
--clearMocks
|
||||
--collectCoverage
|
||||
--collectCoverageFrom
|
||||
--collectCoverageOnlyFrom
|
||||
--color
|
||||
--colors
|
||||
-c, --config
|
||||
@@ -469,6 +467,7 @@ Options:
|
||||
--globalTeardown
|
||||
--globals
|
||||
--haste
|
||||
--ignoreProjects
|
||||
--init
|
||||
--injectGlobals
|
||||
--json
|
||||
@@ -505,6 +504,7 @@ Options:
|
||||
--selectProjects
|
||||
--setupFiles
|
||||
--setupFilesAfterEnv
|
||||
--shard
|
||||
--showConfig
|
||||
--silent
|
||||
--skipFilter
|
||||
@@ -522,8 +522,6 @@ Options:
|
||||
--testRunner
|
||||
--testSequencer
|
||||
--testTimeout
|
||||
--testURL
|
||||
--timers
|
||||
--transform
|
||||
--transformIgnorePatterns
|
||||
--unmockedModulePathPatterns
|
||||
|
||||
@@ -27,7 +27,6 @@ const envOptions = {
|
||||
|
||||
const transformIgnorePattern = [
|
||||
'@material-ui',
|
||||
'@rjsf',
|
||||
'ajv',
|
||||
'core-js',
|
||||
'jest-.*',
|
||||
@@ -189,13 +188,13 @@ async function getProjectConfig(targetPath, displayName) {
|
||||
],
|
||||
'\\.(bmp|gif|jpg|jpeg|png|frag|xml|svg|eot|woff|woff2|ttf)$':
|
||||
require.resolve('./jestFileTransform.js'),
|
||||
'\\.(yaml)$': require.resolve('jest-transform-yaml'),
|
||||
'\\.(yaml)$': require.resolve('./jestYamlTransform'),
|
||||
},
|
||||
|
||||
// A bit more opinionated
|
||||
testMatch: ['**/*.test.{js,jsx,ts,tsx,mjs,cjs}'],
|
||||
|
||||
moduleLoader: envOptions.nextTests
|
||||
runtime: envOptions.nextTests
|
||||
? require.resolve('./jestCachingModuleLoader')
|
||||
: undefined,
|
||||
|
||||
@@ -210,16 +209,16 @@ async function getProjectConfig(targetPath, displayName) {
|
||||
|
||||
const config = Object.assign(options, ...pkgJsonConfigs);
|
||||
|
||||
// The config name is a cache key that lets us share the jest cache across projects.
|
||||
// If no explicit name was configured, generated one based on the configuration.
|
||||
if (!config.name) {
|
||||
// The config id is a cache key that lets us share the jest cache across projects.
|
||||
// If no explicit id was configured, generated one based on the configuration.
|
||||
if (!config.id) {
|
||||
const configHash = crypto
|
||||
.createHash('md5')
|
||||
.update(version)
|
||||
.update(Buffer.alloc(1))
|
||||
.update(JSON.stringify(config.transform))
|
||||
.digest('hex');
|
||||
config.name = `backstage_cli_${configHash}`;
|
||||
config.id = `backstage_cli_${configHash}`;
|
||||
}
|
||||
|
||||
return config;
|
||||
|
||||
@@ -21,7 +21,8 @@ module.exports = {
|
||||
const assetFilename = JSON.stringify(path.basename(filename));
|
||||
|
||||
if (filename.match(/\.icon\.svg$/)) {
|
||||
return `const React = require('react');
|
||||
return {
|
||||
code: `const React = require('react');
|
||||
const SvgIcon = require('@material-ui/core/SvgIcon').default;
|
||||
module.exports = {
|
||||
__esModule: true,
|
||||
@@ -34,9 +35,10 @@ module.exports = {
|
||||
children: ${assetFilename}
|
||||
})
|
||||
})
|
||||
};`;
|
||||
};`,
|
||||
};
|
||||
}
|
||||
|
||||
return `module.exports = ${assetFilename};`;
|
||||
return { code: `module.exports = ${assetFilename};` };
|
||||
},
|
||||
};
|
||||
|
||||
@@ -64,10 +64,10 @@ function createTransformer(config) {
|
||||
}
|
||||
// We only return the `map` result if source maps are enabled, as they
|
||||
// have a negative impact on the coverage accuracy.
|
||||
return code;
|
||||
return { code };
|
||||
}
|
||||
|
||||
return source;
|
||||
return { code: source };
|
||||
};
|
||||
|
||||
// TODO: contribute something like this to @sucrase/jest-plugin
|
||||
|
||||
@@ -21,7 +21,7 @@ function createTransformer(config) {
|
||||
const swcTransformer = createSwcTransformer(config);
|
||||
const process = (source, filePath, jestOptions) => {
|
||||
if (filePath.endsWith('.js') && !ESM_REGEX.test(source)) {
|
||||
return source;
|
||||
return { code: source };
|
||||
}
|
||||
|
||||
return swcTransformer.process(source, filePath, jestOptions);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2022 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const yaml = require('yaml');
|
||||
const crypto = require('crypto');
|
||||
|
||||
function createTransformer(config) {
|
||||
const process = source => {
|
||||
const json = JSON.stringify(yaml.parse(source), null, 2);
|
||||
return { code: `module.exports = ${json}`, map: null };
|
||||
};
|
||||
|
||||
const getCacheKey = sourceText => {
|
||||
return crypto
|
||||
.createHash('md5')
|
||||
.update(sourceText)
|
||||
.update(Buffer.alloc(1))
|
||||
.update(JSON.stringify(config))
|
||||
.update(Buffer.alloc(1))
|
||||
.update('1') // increment whenever the transform logic in this file changes
|
||||
.digest('hex');
|
||||
};
|
||||
|
||||
return { process, getCacheKey };
|
||||
}
|
||||
|
||||
module.exports = { createTransformer };
|
||||
@@ -55,7 +55,7 @@
|
||||
"@swc/core": "^1.2.239",
|
||||
"@swc/helpers": "^0.4.7",
|
||||
"@swc/jest": "^0.2.22",
|
||||
"@types/jest": "^27",
|
||||
"@types/jest": "^29.0.0",
|
||||
"@types/webpack-env": "^1.15.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.9.0",
|
||||
"@typescript-eslint/parser": "^5.9.0",
|
||||
@@ -89,10 +89,10 @@
|
||||
"handlebars": "^4.7.3",
|
||||
"html-webpack-plugin": "^5.3.1",
|
||||
"inquirer": "^8.2.0",
|
||||
"jest": "^27.5.1",
|
||||
"jest": "^29.0.2",
|
||||
"jest-css-modules": "^2.1.0",
|
||||
"jest-runtime": "^27.5.1",
|
||||
"jest-transform-yaml": "^1.0.0",
|
||||
"jest-environment-jsdom": "^29.0.2",
|
||||
"jest-runtime": "^29.0.2",
|
||||
"json-schema": "^0.4.0",
|
||||
"lodash": "^4.17.21",
|
||||
"mini-css-extract-plugin": "^2.4.2",
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
x:
|
||||
y: 'z'
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2022 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import yaml from './yaml-fixture.yaml';
|
||||
|
||||
describe('tests', () => {
|
||||
it('should load yaml', () => {
|
||||
expect(yaml).toEqual({ x: { y: 'z' } });
|
||||
});
|
||||
});
|
||||
@@ -30,18 +30,18 @@
|
||||
"dependencies": {
|
||||
"@backstage/backend-common": "{{versionQuery '@backstage/backend-common'}}",
|
||||
"@backstage/config": "{{versionQuery '@backstage/config'}}",
|
||||
"@types/express": "{{versionQuery '@types/express' '4.17.6'}}",
|
||||
"express": "{{versionQuery 'express' '4.17.1'}}",
|
||||
"@types/express": "{{versionQuery '@types/express' '4.17.13'}}",
|
||||
"express": "{{versionQuery 'express' '4.18.1'}}",
|
||||
"express-promise-router": "{{versionQuery 'express-promise-router' '4.1.0'}}",
|
||||
"winston": "{{versionQuery 'winston' '3.2.1'}}",
|
||||
"winston": "{{versionQuery 'winston' '3.8.1'}}",
|
||||
"node-fetch": "{{versionQuery 'node-fetch' '2.6.7'}}",
|
||||
"yn": "{{versionQuery 'yn' '4.0.0'}}"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "{{versionQuery '@backstage/cli'}}",
|
||||
"@types/supertest": "{{versionQuery '@types/supertest' '2.0.8'}}",
|
||||
"supertest": "{{versionQuery 'supertest' '4.0.2'}}",
|
||||
"msw": "{{versionQuery 'msw' '0.46.0'}}"
|
||||
"@types/supertest": "{{versionQuery '@types/supertest' '2.0.12'}}",
|
||||
"supertest": "{{versionQuery 'supertest' '6.2.4'}}",
|
||||
"msw": "{{versionQuery 'msw' '0.47.0'}}"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
"@testing-library/react": "{{versionQuery '@testing-library/react' '12.1.3'}}",
|
||||
"@testing-library/user-event": "{{versionQuery '@testing-library/user-event' '14.0.0'}}",
|
||||
"@types/node": "{{versionQuery '@types/node' '16.11.26'}}",
|
||||
"msw": "{{versionQuery 'msw' '0.46.0'}}",
|
||||
"msw": "{{versionQuery 'msw' '0.47.0'}}",
|
||||
"cross-fetch": "{{versionQuery 'cross-fetch' '3.1.5'}}"
|
||||
},
|
||||
"files": [
|
||||
|
||||
@@ -118,9 +118,10 @@ describe('ApiProvider', () => {
|
||||
}).toThrow(/^API context is not available/);
|
||||
}).error,
|
||||
).toEqual([
|
||||
expect.stringMatching(
|
||||
/^Error: Uncaught \[Error: API context is not available/,
|
||||
),
|
||||
expect.objectContaining({
|
||||
detail: new Error('API context is not available'),
|
||||
type: 'unhandled exception',
|
||||
}),
|
||||
expect.stringMatching(
|
||||
/^The above error occurred in the <MyHookConsumer> component/,
|
||||
),
|
||||
@@ -133,9 +134,10 @@ describe('ApiProvider', () => {
|
||||
}).toThrow(/^API context is not available/);
|
||||
}).error,
|
||||
).toEqual([
|
||||
expect.stringMatching(
|
||||
/^Error: Uncaught \[Error: API context is not available/,
|
||||
),
|
||||
expect.objectContaining({
|
||||
detail: new Error('API context is not available'),
|
||||
type: 'unhandled exception',
|
||||
}),
|
||||
expect.stringMatching(
|
||||
/^The above error occurred in the <withApis\(Component\)> component/,
|
||||
),
|
||||
@@ -154,9 +156,10 @@ describe('ApiProvider', () => {
|
||||
}).toThrow('No implementation available for apiRef{x}');
|
||||
}).error,
|
||||
).toEqual([
|
||||
expect.stringMatching(
|
||||
/^Error: Uncaught \[Error: No implementation available for apiRef{x}\]/,
|
||||
),
|
||||
expect.objectContaining({
|
||||
detail: new Error('No implementation available for apiRef{x}'),
|
||||
type: 'unhandled exception',
|
||||
}),
|
||||
expect.stringMatching(
|
||||
/^The above error occurred in the <MyHookConsumer> component/,
|
||||
),
|
||||
@@ -173,9 +176,10 @@ describe('ApiProvider', () => {
|
||||
}).toThrow('No implementation available for apiRef{x}');
|
||||
}).error,
|
||||
).toEqual([
|
||||
expect.stringMatching(
|
||||
/^Error: Uncaught \[Error: No implementation available for apiRef{x}\]/,
|
||||
),
|
||||
expect.objectContaining({
|
||||
detail: new Error('No implementation available for apiRef{x}'),
|
||||
type: 'unhandled exception',
|
||||
}),
|
||||
expect.stringMatching(
|
||||
/^The above error occurred in the <withApis\(Component\)> component/,
|
||||
),
|
||||
|
||||
@@ -47,9 +47,11 @@ describe('TabbedLayout', () => {
|
||||
});
|
||||
|
||||
expect(error).toEqual([
|
||||
expect.stringMatching(
|
||||
/Child of TabbedLayout must be an TabbedLayout.Route/,
|
||||
),
|
||||
expect.objectContaining({
|
||||
detail: new Error(
|
||||
'Child of TabbedLayout must be an TabbedLayout.Route',
|
||||
),
|
||||
}),
|
||||
expect.stringMatching(
|
||||
/The above error occurred in the <TabbedLayout> component/,
|
||||
),
|
||||
|
||||
@@ -67,7 +67,9 @@ describe('<ErrorBoundary/>', () => {
|
||||
});
|
||||
|
||||
expect(error).toEqual([
|
||||
expect.stringMatching(/^Error: Uncaught \[Error: Bomb\]/),
|
||||
expect.objectContaining({
|
||||
detail: new Error('Bomb'),
|
||||
}),
|
||||
expect.stringMatching(
|
||||
/^The above error occurred in the <Bomb> component:/,
|
||||
),
|
||||
|
||||
@@ -29,7 +29,7 @@ const validBackstageToken =
|
||||
|
||||
describe('ProxiedSignInIdentity', () => {
|
||||
describe('tokenToExpiry', () => {
|
||||
beforeEach(() => jest.useFakeTimers('modern'));
|
||||
beforeEach(() => jest.useFakeTimers());
|
||||
afterEach(() => jest.useRealTimers());
|
||||
|
||||
it('handles undefined', async () => {
|
||||
@@ -56,7 +56,7 @@ describe('ProxiedSignInIdentity', () => {
|
||||
});
|
||||
|
||||
describe('ProxiedSignInIdentity', () => {
|
||||
beforeEach(() => jest.useFakeTimers('modern'));
|
||||
beforeEach(() => jest.useFakeTimers());
|
||||
afterEach(() => jest.useRealTimers());
|
||||
|
||||
const worker = setupServer();
|
||||
|
||||
@@ -117,7 +117,7 @@ describe('extensions', () => {
|
||||
render(<BrokenComponent />);
|
||||
});
|
||||
screen.getByText('Error in my-plugin');
|
||||
expect(errors[0]).toMatch('Test error');
|
||||
expect(errors[0]).toMatchObject({ detail: new Error('Test error') });
|
||||
});
|
||||
|
||||
it('should wrap extended component with analytics context', async () => {
|
||||
|
||||
@@ -62,7 +62,7 @@ describe('isValidHost', () => {
|
||||
['[::]', true],
|
||||
['[::1]', true],
|
||||
['[1:2:3:4:5:6:7:8]', true],
|
||||
['1.2.3.4.5.6.7.8', true],
|
||||
['1.2.3.4.5.6.7.8', false],
|
||||
['https://example.com', false],
|
||||
['foo:100000', false],
|
||||
['FOO', false],
|
||||
|
||||
@@ -92,9 +92,11 @@ describe('wrapInTestApp', () => {
|
||||
});
|
||||
|
||||
expect(error).toEqual([
|
||||
expect.stringMatching(
|
||||
/^Error: Uncaught \[Error: MockErrorApi received unexpected error, Error: NOPE\]/,
|
||||
),
|
||||
expect.objectContaining({
|
||||
detail: new Error(
|
||||
'MockErrorApi received unexpected error, Error: NOPE',
|
||||
),
|
||||
}),
|
||||
expect.stringMatching(/^The above error occurred in the <A> component:/),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
|
||||
|
||||
-1
@@ -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",
|
||||
},
|
||||
|
||||
+16
-16
@@ -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"
|
||||
|
||||
+3
-3
@@ -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,
|
||||
},
|
||||
],
|
||||
|
||||
+8
-8
@@ -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&owner=mock_owner&repo=updated_mock_repo\\"
|
||||
}"
|
||||
`);
|
||||
"{
|
||||
"parsedQuery": {
|
||||
"versioningStrategy": "semver",
|
||||
"owner": "mock_owner",
|
||||
"repo": "mock_repo"
|
||||
},
|
||||
"queryParams": "versioningStrategy=semver&owner=mock_owner&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",
|
||||
|
||||
+15
-5
@@ -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}'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user