@verdaccio/ui-components 4.0.0-next-8.4 → 4.0.0-next-8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/build/components/CopyClipboard/CopyToClipBoard.js +2 -2
- package/build/components/HeaderInfoDialog/HeaderInfoDialog.js +2 -2
- package/build/components/Heading/Heading.js +2 -2
- package/build/components/Help/Help.js +1 -1
- package/build/components/Icons/SvgIcon.js +2 -2
- package/build/components/Label/Label.js +2 -2
- package/build/components/LinkExternal/LinkExternal.js +2 -2
- package/build/components/NoItems/NoItems.js +2 -2
- package/build/components/Package/styles.js +13 -13
- package/build/components/Readme/Readme.spec.js +4 -2
- package/build/components/Readme/Readme.spec.js.map +1 -1
- package/build/components/Readme/utils.js +1 -1
- package/build/components/Search/Search.js +13 -2
- package/build/components/Search/SearchItem.js +2 -2
- package/build/components/TextField/TextField.js +2 -2
- package/build/components/Versions/HistoryList.js +6 -1
- package/build/components/Versions/__partials__/unsorted-versions.json +37 -0
- package/build/sections/Header/HeaderSettingsDialog.js +2 -2
- package/build/src/AppTest/App.stories.d.ts +9 -8
- package/build/src/components/Author/Author.stories.d.ts +1 -1
- package/build/src/components/Engines/Engines.stories.d.ts +1 -1
- package/build/src/components/Search/Search.d.ts +3 -1
- package/build/src/components/Search/Search.stories.d.ts +6 -8
- package/build/src/sections/Detail/Detail.stories.d.ts +8 -7
- package/build/src/sections/Header/Header.stories.d.ts +6 -5
- package/build/src/sections/Home/Home.stories.d.ts +6 -5
- package/build/src/sections/SideBar/Sidebar.stories.d.ts +7 -7
- package/build/src/store/api.d.ts +3 -0
- package/build/src/utils/token-generate.d.ts +4 -0
- package/build/store/api.js +1 -1
- package/build/store/models/routes.js +1 -1
- package/build/utils/token-generate.js +33 -0
- package/build/utils/url.js +19 -9
- package/package.json +37 -31
- package/src/AppTest/App.stories.tsx +81 -24
- package/src/AppTest/AppRoute.test.tsx +6 -2
- package/src/components/ActionBar/ActionBar.test.tsx +68 -29
- package/src/components/Author/Author.stories.tsx +1 -1
- package/src/components/Engines/Engines.stories.tsx +12 -12
- package/src/components/Help/Help.tsx +1 -1
- package/src/components/Package/Package.test.tsx +9 -0
- package/src/components/Package/styles.ts +1 -2
- package/src/components/Readme/Readme.spec.tsx +2 -2
- package/src/components/Readme/utils.ts +2 -2
- package/src/components/Search/Search.stories.tsx +24 -2
- package/src/components/Search/Search.tsx +7 -3
- package/src/components/Versions/HistoryList.tsx +10 -2
- package/src/components/Versions/Versions.test.tsx +11 -0
- package/src/components/Versions/__partials__/unsorted-versions.json +37 -0
- package/src/layouts/Version/Version.stories.tsx +26 -0
- package/src/sections/Detail/Detail.stories.tsx +52 -21
- package/src/sections/Header/Header.stories.tsx +33 -10
- package/src/sections/Home/Home.stories.tsx +25 -8
- package/src/sections/SideBar/Sidebar.stories.tsx +53 -28
- package/src/store/api.test.ts +4 -2
- package/src/store/api.ts +1 -1
- package/src/store/models/login.test.ts +25 -19
- package/src/utils/token.test.ts +2 -3
- package/src/utils/url.ts +25 -9
- package/tsconfig.build.json +2 -2
- package/tsconfig.json +3 -2
- package/vitest.config.mjs +2 -1
- package/vitest/api/glob-sidebar.json +0 -12520
- package/vitest/api/got-sidebar.json +0 -23346
- package/vitest/api/home-packages.json +0 -40
- package/vitest/api/jquery-readme.js +0 -3
- package/vitest/api/jquery-sidebar.json +0 -5908
- package/vitest/api/search-verdaccio.json +0 -1192
- package/vitest/api/storybook-readme.js +0 -3
- package/vitest/api/storybook-sidebar.json +0 -53782
- package/vitest/api/storybook-v.json +0 -53782
- package/vitest/identity.js +0 -29
- package/vitest/react-markdown.tsx +0 -7
- package/vitest/server-handlers.ts +0 -82
- package/vitest/server.ts +0 -6
- package/vitest/setup-env.ts +0 -33
- package/vitest/setup.ts +0 -40
- package/vitest/unit/empty-string.ts +0 -1
- package/vitest/unit/empty.ts +0 -1
- package/vitest/vitestSerializer.ts +0 -31
- /package/{vitest/unit/components/__mocks__/token.ts → src/utils/token-generate.ts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _styled from "@emotion/styled/base";
|
|
2
2
|
var _excluded = ["children", "value", "index"];
|
|
3
3
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
4
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var
|
|
5
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.
|
|
4
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
5
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
6
6
|
/* eslint-disable verdaccio/jsx-spread */
|
|
7
7
|
|
|
8
8
|
import Box from '@mui/material/Box';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export default
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import AppRoute from './AppRoute';
|
|
3
|
+
declare const meta: Meta<typeof AppRoute>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof AppRoute>;
|
|
6
|
+
export declare const ApplicationStoryBook: Story;
|
|
7
|
+
export declare const ApplicationJquery: Story;
|
|
8
|
+
export declare const ApplicationForbidden: Story;
|
|
9
|
+
export declare const ApplicationNotFound: Story;
|
|
@@ -2,8 +2,8 @@ declare const _default: {
|
|
|
2
2
|
title: string;
|
|
3
3
|
};
|
|
4
4
|
export default _default;
|
|
5
|
+
export declare const EnginesAll: any;
|
|
5
6
|
export declare const EnginesNpmNode: any;
|
|
6
7
|
export declare const EnginesNode: any;
|
|
7
8
|
export declare const EnginesYarn: any;
|
|
8
9
|
export declare const EnginesPnpm: any;
|
|
9
|
-
export declare const EnginesAll: any;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RouteComponentProps } from 'react-router';
|
|
3
|
-
declare const _default: React.ComponentClass<Pick<RouteComponentProps<
|
|
3
|
+
declare const _default: React.ComponentClass<Pick<RouteComponentProps<any, import("react-router").StaticContext, H.LocationState>, never> | (Pick<RouteComponentProps<any, import("react-router").StaticContext, H.LocationState>, never> & {
|
|
4
|
+
wrappedComponentRef?: React.Ref<any> | undefined;
|
|
5
|
+
}), any> & import("react-router").WithRouterStatics<any>;
|
|
4
6
|
export default _default;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export default
|
|
6
|
-
export declare const SearchByQuery:
|
|
7
|
-
render: (args: any) => React.JSX.Element;
|
|
8
|
-
};
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Search from './Search';
|
|
3
|
+
type Story = StoryObj<typeof Search>;
|
|
4
|
+
declare const meta: Meta<typeof Search>;
|
|
5
|
+
export default meta;
|
|
6
|
+
export declare const SearchByQuery: Story;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export default
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Detail from './Detail';
|
|
3
|
+
declare const meta: Meta<typeof Detail>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Detail>;
|
|
6
|
+
export declare const DetailStorybook: Story;
|
|
7
|
+
export declare const DetailJquery: Story;
|
|
8
|
+
export declare const DetailForbidden: Story;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Header from './Header';
|
|
3
|
+
type Story = StoryObj<typeof Header>;
|
|
4
|
+
declare const meta: Meta<typeof Header>;
|
|
5
|
+
export default meta;
|
|
6
|
+
export declare const HeaderAll: Story;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Home from './Home';
|
|
3
|
+
type Story = StoryObj<typeof Home>;
|
|
4
|
+
declare const meta: Meta<typeof Home>;
|
|
5
|
+
export default meta;
|
|
6
|
+
export declare const HomeDefault: Story;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export default
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import DetailSidebar from './Sidebar';
|
|
3
|
+
declare const meta: Meta<typeof DetailSidebar>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof DetailSidebar>;
|
|
6
|
+
export declare const SidebarLatestPackage: Story;
|
|
7
|
+
export declare const SidebarPackageVersion: Story;
|
package/build/src/store/api.d.ts
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function generateTokenWithTimeRange(amount?: number): string;
|
|
2
|
+
export declare function generateTokenWithExpirationAsString(): string;
|
|
3
|
+
export declare function generateInvalidToken(): string;
|
|
4
|
+
export declare function generateTokenWithOutExpiration(): string;
|
package/build/store/api.js
CHANGED
|
@@ -4,7 +4,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
4
4
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
5
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
6
|
import storage from './storage';
|
|
7
|
-
class CustomError extends Error {}
|
|
7
|
+
export class CustomError extends Error {}
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Handles response according to content type
|
|
@@ -8,5 +8,5 @@ export var APIRoute = /*#__PURE__*/function (APIRoute) {
|
|
|
8
8
|
APIRoute["SIDEBAR"] = "/-/verdaccio/data/sidebar/";
|
|
9
9
|
APIRoute["README"] = "/-/verdaccio/data/package/readme/";
|
|
10
10
|
return APIRoute;
|
|
11
|
-
}({});
|
|
11
|
+
}({});
|
|
12
12
|
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Utility
|
|
3
|
+
*/
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
function encodeBase64(string) {
|
|
6
|
+
return Buffer.from(string).toString('base64');
|
|
7
|
+
}
|
|
8
|
+
export function generateTokenWithTimeRange() {
|
|
9
|
+
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
10
|
+
var payload = {
|
|
11
|
+
username: 'verdaccio',
|
|
12
|
+
exp: Number.parseInt(String(dayjs(new Date()).add(amount, 'hour').valueOf() / 1000), 10)
|
|
13
|
+
};
|
|
14
|
+
return "xxxxxx.".concat(encodeBase64(JSON.stringify(payload)), ".xxxxxx");
|
|
15
|
+
}
|
|
16
|
+
export function generateTokenWithExpirationAsString() {
|
|
17
|
+
var payload = {
|
|
18
|
+
username: 'verdaccio',
|
|
19
|
+
exp: 'I am not a number'
|
|
20
|
+
};
|
|
21
|
+
return "xxxxxx.".concat(encodeBase64(JSON.stringify(payload)), ".xxxxxx");
|
|
22
|
+
}
|
|
23
|
+
export function generateInvalidToken() {
|
|
24
|
+
var payload = "invalidtoken";
|
|
25
|
+
return "xxxxxx.".concat(encodeBase64(payload), ".xxxxxx");
|
|
26
|
+
}
|
|
27
|
+
export function generateTokenWithOutExpiration() {
|
|
28
|
+
var payload = {
|
|
29
|
+
username: 'verdaccio'
|
|
30
|
+
};
|
|
31
|
+
return "xxxxxx.".concat(encodeBase64(JSON.stringify(payload)), ".xxxxxx");
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=token-generate.js.map
|
package/build/utils/url.js
CHANGED
|
@@ -41,14 +41,24 @@ export function downloadFile(fileStream, fileName) {
|
|
|
41
41
|
fileLink.href = objectURL;
|
|
42
42
|
fileLink.download = fileName;
|
|
43
43
|
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
// Skip actual download in test environment to avoid JSDOM navigation error
|
|
45
|
+
// Check if we're in a test environment (JSDOM)
|
|
46
|
+
var isTestEnvironment = typeof window !== 'undefined' && window.navigator && window.navigator.userAgent && window.navigator.userAgent.includes('Node.js') || window.navigator.userAgent.includes('jsdom');
|
|
47
|
+
if (!isTestEnvironment) {
|
|
48
|
+
// Without appending to an HTML Element, download dialog does not show up on Firefox
|
|
49
|
+
// https://github.com/verdaccio/ui/issues/119
|
|
50
|
+
document.documentElement.appendChild(fileLink);
|
|
51
|
+
fileLink.click();
|
|
52
|
+
// firefox requires remove the object url
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
URL.revokeObjectURL(objectURL);
|
|
55
|
+
document.documentElement.removeChild(fileLink);
|
|
56
|
+
}, 150);
|
|
57
|
+
} else {
|
|
58
|
+
// In test environment, just clean up without triggering navigation
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
URL.revokeObjectURL(objectURL);
|
|
61
|
+
}, 150);
|
|
62
|
+
}
|
|
53
63
|
}
|
|
54
64
|
//# sourceMappingURL=url.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/ui-components",
|
|
3
|
-
"version": "4.0.0-next-8.
|
|
3
|
+
"version": "4.0.0-next-8.6",
|
|
4
4
|
"description": "theme ui component",
|
|
5
5
|
"author": "Juan Picado <juanpicado19@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,60 +20,66 @@
|
|
|
20
20
|
"@rematch/core": "2.2.0",
|
|
21
21
|
"@rematch/loading": "2.1.2",
|
|
22
22
|
"@rematch/persist": "2.1.2",
|
|
23
|
-
"country-flag-icons": "1.5.
|
|
23
|
+
"country-flag-icons": "1.5.16",
|
|
24
24
|
"dayjs": "1.11.13",
|
|
25
|
-
"dompurify": "3.
|
|
26
|
-
"highlight.js": "11.
|
|
25
|
+
"dompurify": "3.2.3",
|
|
26
|
+
"highlight.js": "11.11.1",
|
|
27
27
|
"history": "4.10.1",
|
|
28
28
|
"i18next": "20.6.1",
|
|
29
29
|
"js-base64": "3.7.7",
|
|
30
30
|
"localstorage-memory": "1.0.3",
|
|
31
31
|
"lodash": "4.17.21",
|
|
32
|
-
"marked": "
|
|
33
|
-
"marked-highlight": "2.1
|
|
32
|
+
"marked": "15.0.6",
|
|
33
|
+
"marked-highlight": "2.2.1",
|
|
34
34
|
"normalize.css": "8.0.1",
|
|
35
|
-
"react": "18.
|
|
36
|
-
"react-dom": "18.
|
|
37
|
-
"react-hook-form": "7.
|
|
35
|
+
"react": "18.3.1",
|
|
36
|
+
"react-dom": "18.3.1",
|
|
37
|
+
"react-hook-form": "7.54.2",
|
|
38
38
|
"react-i18next": "15.0.0",
|
|
39
|
-
"react-markdown": "9.0.
|
|
39
|
+
"react-markdown": "9.0.3",
|
|
40
40
|
"react-redux": "8.1.3",
|
|
41
41
|
"react-router": "5.3.4",
|
|
42
42
|
"react-router-dom": "5.3.4",
|
|
43
|
-
"react-virtualized": "9.22.
|
|
43
|
+
"react-virtualized": "9.22.6",
|
|
44
44
|
"redux": "4.2.1",
|
|
45
|
-
"semver": "7.
|
|
46
|
-
"validator": "13.12.0"
|
|
45
|
+
"semver": "7.7.1",
|
|
46
|
+
"validator": "13.12.0",
|
|
47
|
+
"@verdaccio/ui-i18n": "8.0.0-next-8.11"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@babel/core": "7.
|
|
50
|
+
"@babel/core": "7.26.9",
|
|
50
51
|
"@emotion/babel-plugin": "11.12.0",
|
|
51
|
-
"@storybook/addon-actions": "^6.
|
|
52
|
-
"@storybook/addon-essentials": "^6.
|
|
53
|
-
"@storybook/addon-
|
|
54
|
-
"@storybook/addon-
|
|
55
|
-
"@storybook/
|
|
56
|
-
"@storybook/
|
|
57
|
-
"@storybook/react": "^6.
|
|
52
|
+
"@storybook/addon-actions": "^8.6.3",
|
|
53
|
+
"@storybook/addon-essentials": "^8.6.3",
|
|
54
|
+
"@storybook/addon-mdx-gfm": "^8.6.3",
|
|
55
|
+
"@storybook/addon-interactions": "^8.6.3",
|
|
56
|
+
"@storybook/addon-links": "^8.6.3",
|
|
57
|
+
"@storybook/addon-webpack5-compiler-babel": "3.0.5",
|
|
58
|
+
"@storybook/react": "^8.6.3",
|
|
59
|
+
"@storybook/react-webpack5": "8.6.3",
|
|
58
60
|
"@testing-library/dom": "10.4.0",
|
|
59
|
-
"@testing-library/jest-dom": "6.
|
|
60
|
-
"@testing-library/react": "16.
|
|
61
|
+
"@testing-library/jest-dom": "6.6.3",
|
|
62
|
+
"@testing-library/react": "16.1.0",
|
|
61
63
|
"@types/hast": "^2.0.0",
|
|
62
64
|
"@types/react-router": "^5.1.20",
|
|
63
65
|
"@types/unist": "^2.0.0",
|
|
64
|
-
"@verdaccio/types": "13.0.0-next-8.
|
|
66
|
+
"@verdaccio/types": "13.0.0-next-8.3",
|
|
65
67
|
"@vitejs/plugin-react": "^4.3.4",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
+
"babel-loader": "9.2.1",
|
|
69
|
+
"jsdom": "^25.0.0",
|
|
68
70
|
"mockdate": "3.0.5",
|
|
71
|
+
"msw": "2.7.0",
|
|
72
|
+
"msw-storybook-addon": "^2.0.4",
|
|
69
73
|
"mutationobserver-shim": "0.3.7",
|
|
70
|
-
"
|
|
74
|
+
"storybook": "8.6.3",
|
|
71
75
|
"typescript": "4.9.5",
|
|
72
|
-
"vitest": "
|
|
76
|
+
"vitest": "3.0.4",
|
|
73
77
|
"whatwg-fetch": "3.6.20"
|
|
74
78
|
},
|
|
75
79
|
"msw": {
|
|
76
|
-
"workerDirectory":
|
|
80
|
+
"workerDirectory": [
|
|
81
|
+
"public"
|
|
82
|
+
]
|
|
77
83
|
},
|
|
78
84
|
"scripts": {
|
|
79
85
|
"test": "cross-env TZ=UTC vitest run",
|
|
@@ -84,7 +90,7 @@
|
|
|
84
90
|
"watch": "babel src/ --out-dir build/ --watch --copy-files --no-copy-ignored --extensions \".ts,.tsx\" --source-maps --ignore \"src/**/*.stories.tsx\" --ignore \"src/**/*.test.tsx\" --ignore \"src/**/*.test.ts\"",
|
|
85
91
|
"build": "pnpm run build:js && pnpm run build:types",
|
|
86
92
|
"netlify:ui:deploy": "npx netlify-cli deploy --dir=./packages/ui-components/storybook-static --prod",
|
|
87
|
-
"start": "
|
|
88
|
-
"build-storybook": "build
|
|
93
|
+
"start": "BROWSER=none storybook dev -p 6006",
|
|
94
|
+
"build-storybook": "storybook build"
|
|
89
95
|
}
|
|
90
96
|
}
|
|
@@ -1,32 +1,89 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { HttpResponse, http } from 'msw';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { MemoryRouter } from 'react-router';
|
|
3
5
|
|
|
4
6
|
import AppRoute from './AppRoute';
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
const meta: Meta<typeof AppRoute> = {
|
|
7
9
|
title: 'App/Main',
|
|
10
|
+
component: AppRoute,
|
|
8
11
|
};
|
|
9
12
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
export default meta;
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof AppRoute>;
|
|
16
|
+
|
|
17
|
+
export const ApplicationStoryBook: Story = {
|
|
18
|
+
render: () => (
|
|
19
|
+
<MemoryRouter initialEntries={[`/-/web/detail/storybook`]}>
|
|
20
|
+
<AppRoute />
|
|
21
|
+
</MemoryRouter>
|
|
22
|
+
),
|
|
23
|
+
parameters: {
|
|
24
|
+
msw: {
|
|
25
|
+
handlers: [
|
|
26
|
+
http.get('https://my-registry.org/-/verdaccio/data/sidebar/storybook', () => {
|
|
27
|
+
return HttpResponse.json(require('../../vitest/api/storybook-sidebar.json'));
|
|
28
|
+
}),
|
|
29
|
+
http.get('https://my-registry.org/-/verdaccio/data/package/readme/storybook', () => {
|
|
30
|
+
return HttpResponse.json(require('../../vitest/api/storybook-readme')());
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const ApplicationJquery: Story = {
|
|
38
|
+
render: () => (
|
|
39
|
+
<MemoryRouter initialEntries={[`/-/web/detail/jquery`]}>
|
|
40
|
+
<AppRoute />
|
|
41
|
+
</MemoryRouter>
|
|
42
|
+
),
|
|
43
|
+
parameters: {
|
|
44
|
+
msw: {
|
|
45
|
+
handlers: [
|
|
46
|
+
http.get('https://my-registry.org/-/verdaccio/data/sidebar/jquery', () => {
|
|
47
|
+
return HttpResponse.json(require('../../vitest/api/jquery-sidebar.json'));
|
|
48
|
+
}),
|
|
49
|
+
http.get('https://my-registry.org/-/verdaccio/data/package/readme/jquery', () => {
|
|
50
|
+
return HttpResponse.json(require('../../vitest/api/jquery-readme')());
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const ApplicationForbidden: Story = {
|
|
58
|
+
render: () => (
|
|
59
|
+
<MemoryRouter initialEntries={[`/-/web/detail/JSONStream`]}>
|
|
60
|
+
<AppRoute />
|
|
61
|
+
</MemoryRouter>
|
|
62
|
+
),
|
|
63
|
+
parameters: {
|
|
64
|
+
msw: {
|
|
65
|
+
handlers: [
|
|
66
|
+
http.get('https://my-registry.org/-/verdaccio/data/sidebar/JSONStream', () => {
|
|
67
|
+
return new HttpResponse('unauthorized', { status: 401 });
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const ApplicationNotFound: Story = {
|
|
75
|
+
render: () => (
|
|
76
|
+
<MemoryRouter initialEntries={[`/-/web/detail/kleur`]}>
|
|
77
|
+
<AppRoute />
|
|
78
|
+
</MemoryRouter>
|
|
79
|
+
),
|
|
80
|
+
parameters: {
|
|
81
|
+
msw: {
|
|
82
|
+
handlers: [
|
|
83
|
+
http.get('https://my-registry.org/-/verdaccio/data/sidebar/kleur', () => {
|
|
84
|
+
return new HttpResponse('unauthorized', { status: 404 });
|
|
85
|
+
}),
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
@@ -34,13 +34,17 @@ describe('AppRoute', () => {
|
|
|
34
34
|
|
|
35
35
|
test('renders VersionPage component for PACKAGE path', async () => {
|
|
36
36
|
act(() => appTest('/-/web/detail/jquery'));
|
|
37
|
-
await waitFor(() => screen.getByTestId('readme-tab'))
|
|
37
|
+
await waitFor(() => expect(screen.getByTestId('readme-tab')).toBeInTheDocument(), {
|
|
38
|
+
timeout: 3000,
|
|
39
|
+
});
|
|
38
40
|
expect(screen.getByTestId('sidebar')).toBeInTheDocument();
|
|
39
41
|
});
|
|
40
42
|
|
|
41
43
|
test('renders VersionPage component for PACKAGE VERSION path', async () => {
|
|
42
44
|
act(() => appTest('/-/web/detail/jquery/v/3.6.3'));
|
|
43
|
-
await waitFor(() => screen.getByTestId('readme-tab'))
|
|
45
|
+
await waitFor(() => expect(screen.getByTestId('readme-tab')).toBeInTheDocument(), {
|
|
46
|
+
timeout: 3000,
|
|
47
|
+
});
|
|
44
48
|
expect(screen.getByTestId('sidebar')).toBeInTheDocument();
|
|
45
49
|
});
|
|
46
50
|
|