@verdaccio/ui-components 4.0.0-next-8.2 → 4.0.0-next-8.4
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/.babelrc +9 -1
- package/CHANGELOG.md +4 -269
- package/build/AppTest/AppRoute.js +18 -27
- package/build/AppTest/pages/Front/Home.js +2 -8
- package/build/AppTest/pages/Front/index.js +1 -13
- package/build/AppTest/pages/Version/Version.js +15 -19
- package/build/AppTest/pages/Version/index.js +1 -13
- package/build/Theme/ResetStyles.js +10 -16
- package/build/Theme/StyleBaseline.js +6 -13
- package/build/Theme/ThemeProvider.js +25 -33
- package/build/Theme/colors.js +1 -7
- package/build/Theme/index.js +5 -44
- package/build/Theme/theme.js +26 -32
- package/build/components/ActionBar/ActionBar.js +26 -33
- package/build/components/ActionBar/ActionBarAction.js +59 -59
- package/build/components/ActionBar/index.js +1 -13
- package/build/components/Author/Author.js +17 -23
- package/build/components/Author/index.js +1 -13
- package/build/components/Author/styles.js +5 -12
- package/build/components/CopyClipboard/CopyToClipBoard.js +40 -40
- package/build/components/CopyClipboard/index.js +2 -20
- package/build/components/CopyClipboard/utils.js +1 -8
- package/build/components/Dependencies/Dependencies.js +27 -34
- package/build/components/Dependencies/DependencyBlock.js +29 -35
- package/build/components/Dependencies/index.js +1 -13
- package/build/components/Dependencies/types.js +1 -5
- package/build/components/Dependencies/utits.js +1 -7
- package/build/components/Deprecated/Deprecated.js +10 -16
- package/build/components/Deprecated/index.js +1 -13
- package/build/components/Developers/DeveloperType.js +1 -7
- package/build/components/Developers/Developers.js +29 -37
- package/build/components/Developers/Title.js +26 -29
- package/build/components/Developers/get-unique-developer-values.js +1 -7
- package/build/components/Developers/index.js +2 -20
- package/build/components/Distribution/Dist.js +29 -32
- package/build/components/Distribution/index.js +1 -13
- package/build/components/Distribution/styles.js +7 -14
- package/build/components/Engines/Engines.js +53 -54
- package/build/components/Engines/index.js +1 -13
- package/build/components/Engines/styles.js +5 -12
- package/build/components/ErrorBoundary/ErrorBoundary.js +5 -14
- package/build/components/ErrorBoundary/index.js +1 -13
- package/build/components/Forbidden/Forbidden.js +33 -35
- package/build/components/Forbidden/index.js +1 -13
- package/build/components/FundButton/FundButton.js +42 -41
- package/build/components/FundButton/index.js +1 -13
- package/build/components/HeaderInfoDialog/HeaderInfoDialog.js +39 -41
- package/build/components/HeaderInfoDialog/index.js +1 -13
- package/build/components/Heading/Heading.js +12 -17
- package/build/components/Heading/index.js +1 -13
- package/build/components/Help/Help.js +23 -31
- package/build/components/Help/index.js +1 -13
- package/build/components/Help/styles.js +3 -10
- package/build/components/Icons/DevsIcons/CommonJS.js +4 -11
- package/build/components/Icons/DevsIcons/ES6Module.js +4 -11
- package/build/components/Icons/DevsIcons/Git.js +4 -11
- package/build/components/Icons/DevsIcons/NodeJS.js +4 -11
- package/build/components/Icons/DevsIcons/TypeScript.js +4 -11
- package/build/components/Icons/DevsIcons/index.js +5 -40
- package/build/components/Icons/Earth.js +13 -19
- package/build/components/Icons/FileBinary.js +6 -12
- package/build/components/Icons/Law.js +6 -12
- package/build/components/Icons/License.js +7 -13
- package/build/components/Icons/License.js.map +1 -1
- package/build/components/Icons/Managers/Npm.js +4 -11
- package/build/components/Icons/Managers/Pnpm.js +4 -11
- package/build/components/Icons/Managers/Yarn.js +4 -11
- package/build/components/Icons/Managers/index.js +3 -26
- package/build/components/Icons/SvgIcon.js +27 -23
- package/build/components/Icons/Time.js +8 -14
- package/build/components/Icons/Version.js +6 -12
- package/build/components/Icons/index.js +8 -79
- package/build/components/Install/Install.js +32 -39
- package/build/components/Install/InstallListItem.js +47 -52
- package/build/components/Install/index.js +1 -13
- package/build/components/Keywords/KeywordListItems.js +11 -17
- package/build/components/Keywords/Keywords.js +20 -25
- package/build/components/Keywords/index.js +1 -13
- package/build/components/Label/Label.js +17 -18
- package/build/components/Label/index.js +1 -13
- package/build/components/Link/Link.js +16 -22
- package/build/components/Link/index.js +1 -13
- package/build/components/LinkExternal/LinkExternal.js +15 -19
- package/build/components/LinkExternal/index.js +1 -13
- package/build/components/Loading/Loading.js +8 -15
- package/build/components/Loading/Spinner/Spinner.js +41 -35
- package/build/components/Loading/Spinner/index.js +1 -13
- package/build/components/Loading/index.js +1 -13
- package/build/components/Loading/styles.js +15 -19
- package/build/components/LoginDialog/LoginDialog.js +72 -68
- package/build/components/LoginDialog/LoginDialogCloseButton.js +28 -31
- package/build/components/LoginDialog/LoginDialogForm.js +46 -45
- package/build/components/LoginDialog/LoginDialogFormError.js +34 -36
- package/build/components/LoginDialog/LoginDialogHeader.js +42 -42
- package/build/components/LoginDialog/index.js +1 -13
- package/build/components/Logo/Logo.js +44 -47
- package/build/components/Logo/index.js +1 -13
- package/build/components/MenuItem/MenuItem.js +7 -16
- package/build/components/MenuItem/index.js +1 -13
- package/build/components/NoItems/NoItems.js +16 -17
- package/build/components/NoItems/index.js +1 -13
- package/build/components/NotFound/NotFound.js +31 -35
- package/build/components/NotFound/index.js +1 -13
- package/build/components/Package/Package.js +105 -100
- package/build/components/Package/index.js +1 -20
- package/build/components/Package/styles.js +78 -73
- package/build/components/PackageList/PackageList.js +56 -57
- package/build/components/PackageList/index.js +1 -13
- package/build/components/Person/Person.js +22 -28
- package/build/components/Person/PersonTooltip.js +17 -21
- package/build/components/Person/index.js +1 -13
- package/build/components/Person/utils.js +6 -14
- package/build/components/RawViewer/RawViewer.js +27 -33
- package/build/components/RawViewer/index.js +1 -13
- package/build/components/Readme/Readme.js +21 -27
- package/build/components/Readme/Readme.js.map +1 -1
- package/build/components/Readme/Readme.spec.js +10 -13
- package/build/components/Readme/Readme.spec.js.map +1 -1
- package/build/components/Readme/index.js +1 -13
- package/build/components/Readme/types.js +1 -5
- package/build/components/Readme/utils.js +8 -16
- package/build/components/RegistryInfoDialog/RegistryInfoDialog.js +18 -24
- package/build/components/RegistryInfoDialog/index.js +1 -13
- package/build/components/RegistryInfoDialog/styles.js +34 -32
- package/build/components/RegistryInfoDialog/types.js +1 -5
- package/build/components/Repository/Repository.js +36 -41
- package/build/components/Repository/index.js +1 -13
- package/build/components/Search/AutoComplete/AutoComplete.js +22 -31
- package/build/components/Search/AutoComplete/index.js +1 -13
- package/build/components/Search/AutoComplete/styles.js +2 -9
- package/build/components/Search/Search.js +71 -69
- package/build/components/Search/SearchItem.js +87 -79
- package/build/components/Search/index.js +1 -13
- package/build/components/Search/styles.js +7 -14
- package/build/components/Search/utils.js +3 -9
- package/build/components/SettingsMenu/SettingsMenu.js +56 -57
- package/build/components/SettingsMenu/index.js +1 -13
- package/build/components/SideBarTitle/SideBarTitle.js +56 -54
- package/build/components/SideBarTitle/index.js +1 -13
- package/build/components/SideBarTitle/utils.js +6 -15
- package/build/components/TextField/TextField.js +22 -21
- package/build/components/TextField/index.js +1 -13
- package/build/components/UpLinks/UpLinks.js +32 -38
- package/build/components/UpLinks/UplinkLink.js +12 -18
- package/build/components/UpLinks/index.js +1 -13
- package/build/components/UpLinks/styles.js +28 -29
- package/build/components/Versions/HistoryList.js +56 -60
- package/build/components/Versions/TagList.js +29 -33
- package/build/components/Versions/Versions.js +44 -52
- package/build/components/Versions/index.js +1 -13
- package/build/components/Versions/styles.js +26 -27
- package/build/components/Versions/types.js +1 -5
- package/build/hooks/index.js +2 -20
- package/build/hooks/useLocalStorage.js +7 -12
- package/build/hooks/useOnClickOutside.js +4 -9
- package/build/index.js +63 -530
- package/build/layouts/Version/Version.js +9 -16
- package/build/layouts/Version/index.js +1 -13
- package/build/providers/AppConfigurationProvider/AppConfigurationProvider.js +24 -31
- package/build/providers/AppConfigurationProvider/index.js +1 -20
- package/build/providers/PersistenceSettingProvider/PersistenceSettingProvider.js +15 -24
- package/build/providers/PersistenceSettingProvider/index.js +1 -20
- package/build/providers/TranslatorProvider/TranslatorProvider.js +24 -30
- package/build/providers/TranslatorProvider/TranslatorProvider.spec.js +19 -22
- package/build/providers/TranslatorProvider/index.js +1 -26
- package/build/providers/VersionProvider/VersionProvider.js +27 -29
- package/build/providers/VersionProvider/index.js +1 -20
- package/build/providers/index.js +3 -38
- package/build/sections/Detail/ContainerContent.js +20 -28
- package/build/sections/Detail/Detail.js +22 -30
- package/build/sections/Detail/ReadmeSection.js +8 -14
- package/build/sections/Detail/Tabs.js +20 -26
- package/build/sections/Detail/index.js +1 -13
- package/build/sections/Footer/Footer.js +73 -70
- package/build/sections/Footer/index.js +1 -13
- package/build/sections/Footer/styles.js +62 -57
- package/build/sections/Header/Header.js +34 -42
- package/build/sections/Header/HeaderGreetings.js +12 -18
- package/build/sections/Header/HeaderLeft.js +25 -29
- package/build/sections/Header/HeaderMenu.js +23 -29
- package/build/sections/Header/HeaderRight.js +41 -49
- package/build/sections/Header/HeaderSettingsDialog.js +60 -58
- package/build/sections/Header/HeaderToolTip.js +13 -17
- package/build/sections/Header/HeaderToolTipIcon.js +23 -31
- package/build/sections/Header/LanguageSwitch.js +51 -54
- package/build/sections/Header/RegistryInfoContent/RegistryInfoContent.js +75 -80
- package/build/sections/Header/RegistryInfoContent/index.js +1 -13
- package/build/sections/Header/RegistryInfoContent/styles.js +12 -16
- package/build/sections/Header/index.js +1 -13
- package/build/sections/Header/styles.js +32 -36
- package/build/sections/Home/Home.js +14 -19
- package/build/sections/Home/index.js +1 -13
- package/build/sections/SideBar/Sidebar.js +45 -52
- package/build/sections/SideBar/index.js +1 -13
- package/build/sections/index.js +2 -20
- package/build/src/Theme/index.d.ts +1 -1
- package/build/src/components/SideBarTitle/SideBarTitle.d.ts +1 -1
- package/build/src/components/SideBarTitle/SideBarTitle.stories.d.ts +1 -0
- package/build/store/api.js +28 -29
- package/build/store/index.js +3 -51
- package/build/store/models/configuration.js +20 -22
- package/build/store/models/download.js +26 -27
- package/build/store/models/index.js +13 -19
- package/build/store/models/login.js +60 -63
- package/build/store/models/manifest.js +57 -58
- package/build/store/models/packages.js +29 -27
- package/build/store/models/routes.js +1 -7
- package/build/store/models/search.js +62 -61
- package/build/store/models/utils.js +1 -7
- package/build/store/storage.js +4 -11
- package/build/store/store.js +6 -13
- package/build/test/i18n-config.js +4 -11
- package/build/test/test-react-testing-library.js +32 -50
- package/build/types/index.js +1 -5
- package/build/types/packageMeta.js +1 -5
- package/build/utils/__partials__/packageMeta.js +1 -7
- package/build/utils/cli-utils.js +12 -32
- package/build/utils/index.js +8 -74
- package/build/utils/loadable.js +6 -14
- package/build/utils/routes.js +1 -7
- package/build/utils/token.js +11 -18
- package/build/utils/url.js +12 -22
- package/build/utils/utils.js +32 -46
- package/package.json +11 -9
- package/src/AppTest/AppRoute.test.tsx +5 -4
- package/src/Theme/index.ts +1 -1
- package/src/components/Author/Author.test.tsx +2 -1
- package/src/components/CopyClipboard/CopyToClipBoard.test.tsx +2 -1
- package/src/components/Dependencies/Dependencies.test.tsx +7 -0
- package/src/components/Dependencies/DependencyBlock.test.tsx +3 -2
- package/src/components/Engines/Engines.test.tsx +3 -2
- package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +2 -1
- package/src/components/Forbidden/Forbidden.test.tsx +3 -2
- package/src/components/HeaderInfoDialog/HeaderInfoDialog.test.tsx +2 -1
- package/src/components/LoginDialog/LoginDialog.test.tsx +8 -7
- package/src/components/NotFound/Notfound.test.tsx +3 -2
- package/src/components/PackageList/Packagelist.test.tsx +2 -1
- package/src/components/Search/Search.test.tsx +9 -8
- package/src/components/SideBarTitle/SideBarTitle.stories.tsx +17 -4
- package/src/components/SideBarTitle/SideBarTitle.tsx +5 -3
- package/src/components/Versions/Versions.test.tsx +8 -8
- package/src/providers/TranslatorProvider/TranslatorProvider.spec.tsx +2 -1
- package/src/providers/VersionProvider/VersionProvider.tsx +5 -2
- package/src/sections/Home/Home.test.tsx +7 -3
- package/src/sections/SideBar/Sidebar.test.tsx +8 -7
- package/src/sections/SideBar/Sidebar.tsx +11 -7
- package/src/store/api.test.ts +8 -6
- package/src/store/models/login.test.ts +24 -20
- package/src/test/test-react-testing-library.tsx +3 -5
- package/src/utils/cli-utils.test.ts +10 -9
- package/src/utils/token.test.ts +5 -3
- package/tsconfig.build.json +1 -1
- package/vitest/api/glob-sidebar.json +12520 -0
- package/vitest/api/got-sidebar.json +23346 -0
- package/vitest/api/home-packages.json +40 -0
- package/vitest/api/jquery-readme.js +3 -0
- package/vitest/api/jquery-sidebar.json +5908 -0
- package/vitest/api/search-verdaccio.json +1192 -0
- package/vitest/api/storybook-readme.js +3 -0
- package/vitest/api/storybook-sidebar.json +53782 -0
- package/vitest/api/storybook-v.json +53782 -0
- package/vitest/identity.js +29 -0
- package/vitest/react-markdown.tsx +7 -0
- package/vitest/server-handlers.ts +82 -0
- package/vitest/server.ts +6 -0
- package/vitest/setup-env.ts +33 -0
- package/vitest/setup.ts +40 -0
- package/vitest/unit/components/__mocks__/token.ts +33 -0
- package/vitest/unit/empty-string.ts +1 -0
- package/vitest/unit/empty.ts +1 -0
- package/vitest/vitestSerializer.ts +31 -0
- package/vitest.config.mjs +39 -0
- package/build/__mocks__/react-markdown.js +0 -18
- package/build/__mocks__/remark-plugin.js +0 -8
- package/build/src/__mocks__/react-markdown.d.ts +0 -4
- package/build/src/__mocks__/remark-plugin.d.ts +0 -1
- package/src/__mocks__/react-markdown.tsx +0 -8
- package/src/__mocks__/remark-plugin.ts +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
let Reflect;
|
|
3
|
+
let idObj;
|
|
4
|
+
|
|
5
|
+
function checkIsNodeV6OrAbove() {
|
|
6
|
+
if (typeof process === 'undefined') {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return parseInt(process.versions.node.split('.')[0], 10) >= 6;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (!checkIsNodeV6OrAbove()) {
|
|
14
|
+
Reflect = require('harmony-reflect');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
idObj = new Proxy(
|
|
18
|
+
{},
|
|
19
|
+
{
|
|
20
|
+
get: function getter(target, key) {
|
|
21
|
+
if (key === '__esModule') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return key;
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
module.exports = idObj;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { rest } from 'msw';
|
|
3
|
+
|
|
4
|
+
const packagesPayload = require('./api/home-packages.json');
|
|
5
|
+
|
|
6
|
+
export const handlers = [
|
|
7
|
+
rest.get('http://localhost:9000/-/verdaccio/data/packages', (req, res, ctx) => {
|
|
8
|
+
return res(ctx.json(Array(400).fill(packagesPayload)));
|
|
9
|
+
}),
|
|
10
|
+
|
|
11
|
+
rest.get('http://localhost:9000/-/verdaccio/data/sidebar/storybook', (req, res, ctx) => {
|
|
12
|
+
const { v } = req.params;
|
|
13
|
+
if (v) {
|
|
14
|
+
return res(ctx.json(require('./api/storybook-v.json')));
|
|
15
|
+
} else {
|
|
16
|
+
return res(ctx.json(require('./api/storybook-sidebar.json')));
|
|
17
|
+
}
|
|
18
|
+
}),
|
|
19
|
+
|
|
20
|
+
rest.get('http://localhost:9000/-/verdaccio/data/search/*', (req, res, ctx) => {
|
|
21
|
+
return res(ctx.json(require('./api/search-verdaccio.json')));
|
|
22
|
+
}),
|
|
23
|
+
|
|
24
|
+
rest.get('http://localhost:9000/-/verdaccio/data/package/readme/storybook', (req, res, ctx) => {
|
|
25
|
+
return res(ctx.text(require('./api/storybook-readme')()));
|
|
26
|
+
}),
|
|
27
|
+
|
|
28
|
+
rest.get('http://localhost:9000/-/verdaccio/data/sidebar/jquery', (req, res, ctx) => {
|
|
29
|
+
return res(ctx.json(require('./api/jquery-sidebar.json')));
|
|
30
|
+
}),
|
|
31
|
+
rest.get('http://localhost:9000/-/verdaccio/data/sidebar/JSONStream', (req, res, ctx) => {
|
|
32
|
+
return res(ctx.status(401)); // unauthorized
|
|
33
|
+
}),
|
|
34
|
+
rest.get('http://localhost:9000/-/verdaccio/data/sidebar/semver', (req, res, ctx) => {
|
|
35
|
+
return res(ctx.status(500)); // internal server error
|
|
36
|
+
}),
|
|
37
|
+
rest.get('http://localhost:9000/-/verdaccio/data/sidebar/kleur', (req, res, ctx) => {
|
|
38
|
+
return res(ctx.status(404)); // not found
|
|
39
|
+
}),
|
|
40
|
+
rest.get('http://localhost:9000/-/verdaccio/data/sidebar/glob', (req, res, ctx) => {
|
|
41
|
+
return res(ctx.json(require('./api/glob-sidebar.json')));
|
|
42
|
+
}),
|
|
43
|
+
rest.get('http://localhost:9000/-/verdaccio/data/package/readme/glob', (req, res, ctx) => {
|
|
44
|
+
return res(ctx.text('foo glob'));
|
|
45
|
+
}),
|
|
46
|
+
rest.get('http://localhost:9000/-/verdaccio/data/sidebar/got', (req, res, ctx) => {
|
|
47
|
+
return res(ctx.json(require('./api/got-sidebar.json')));
|
|
48
|
+
}),
|
|
49
|
+
rest.get('http://localhost:9000/-/verdaccio/data/package/readme/got', (req, res, ctx) => {
|
|
50
|
+
return res(ctx.text('foo got'));
|
|
51
|
+
}),
|
|
52
|
+
rest.get('http://localhost:9000/-/verdaccio/data/package/readme/jquery', (req, res, ctx) => {
|
|
53
|
+
return res(ctx.text(require('./api/jquery-readme')()));
|
|
54
|
+
}),
|
|
55
|
+
rest.get('http://localhost:9000/verdaccio/-/verdaccio-1.0.0.tgz', (req, res, ctx) => {
|
|
56
|
+
const fileContent = fs.readFileSync('./api/verdaccio-1.0.0.tgz');
|
|
57
|
+
return res(
|
|
58
|
+
ctx.status(200),
|
|
59
|
+
ctx.set('Content-Type', 'application/octet-stream'),
|
|
60
|
+
ctx.body(fileContent)
|
|
61
|
+
);
|
|
62
|
+
}),
|
|
63
|
+
|
|
64
|
+
rest.post<{ username: string; password: string }, { token: string; username: string }>(
|
|
65
|
+
'http://localhost:9000/-/verdaccio/sec/login',
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
async (req, res, ctx) => {
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
const body = await req.json();
|
|
70
|
+
if (body.username === 'fail') {
|
|
71
|
+
return ctx.status(401);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return res(
|
|
75
|
+
ctx.json({
|
|
76
|
+
username: body.username,
|
|
77
|
+
token: 'valid token',
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
];
|
package/vitest/server.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
|
+
import 'whatwg-fetch';
|
|
3
|
+
|
|
4
|
+
import { server } from './server';
|
|
5
|
+
|
|
6
|
+
// Configure the test environment URL
|
|
7
|
+
Object.defineProperty(window, 'location', {
|
|
8
|
+
writable: true,
|
|
9
|
+
value: new URL('http://localhost:9000/'),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
beforeAll(() => {
|
|
13
|
+
// Enable debug logging
|
|
14
|
+
// server.events.on('request:start', (req) => {
|
|
15
|
+
// console.log('Request started:', req.url.href);
|
|
16
|
+
// });
|
|
17
|
+
// server.events.on('request:match', (req) => {
|
|
18
|
+
// console.log('Request matched:', req.url.href);
|
|
19
|
+
// });
|
|
20
|
+
// server.events.on('request:unhandled', (req) => {
|
|
21
|
+
// console.warn('Unhandled request:', req.url.href);
|
|
22
|
+
// });
|
|
23
|
+
// server.events.on('request:end', (req) => {
|
|
24
|
+
// console.log('Request completed:', req.url.href);
|
|
25
|
+
// });
|
|
26
|
+
server.listen({
|
|
27
|
+
onUnhandledRequest: 'warn',
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
afterEach(() => server.resetHandlers());
|
|
31
|
+
afterAll(() => {
|
|
32
|
+
server.close();
|
|
33
|
+
});
|
package/vitest/setup.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup configuration for Jest
|
|
3
|
+
* This file includes global settings for the JEST environment.
|
|
4
|
+
*/
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
import 'mutationobserver-shim';
|
|
7
|
+
import { vi } from 'vitest';
|
|
8
|
+
import { Headers, Request, Response, fetch } from 'whatwg-fetch';
|
|
9
|
+
|
|
10
|
+
// Override the global fetch and related APIs
|
|
11
|
+
global.fetch = fetch;
|
|
12
|
+
global.Headers = Headers;
|
|
13
|
+
global.Request = Request;
|
|
14
|
+
global.Response = Response;
|
|
15
|
+
|
|
16
|
+
// @ts-ignore : Property '__VERDACCIO_BASENAME_UI_OPTIONS' does not exist on type 'Global'.
|
|
17
|
+
global.__VERDACCIO_BASENAME_UI_OPTIONS = {
|
|
18
|
+
base: 'http://localhost:9000/',
|
|
19
|
+
protocol: 'http',
|
|
20
|
+
host: 'localhost',
|
|
21
|
+
primaryColor: '#4b5e40',
|
|
22
|
+
url_prefix: '',
|
|
23
|
+
darkMode: false,
|
|
24
|
+
language: 'en-US',
|
|
25
|
+
uri: 'http://localhost:9000/',
|
|
26
|
+
pkgManagers: ['pnpm', 'yarn', 'npm'],
|
|
27
|
+
title: 'Verdaccio Dev UI',
|
|
28
|
+
scope: '',
|
|
29
|
+
version: 'v1.0.0',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// mocking few DOM methods
|
|
33
|
+
// @ts-ignore : Property 'document' does not exist on type 'Global'.
|
|
34
|
+
if (global.document) {
|
|
35
|
+
// @ts-ignore : Type 'Mock<{ selectNodeContents: () => void; }, []>' is not assignable to type '() => Range'.
|
|
36
|
+
document.createRange = vi.fn((): void => ({
|
|
37
|
+
selectNodeContents: (): void => {},
|
|
38
|
+
}));
|
|
39
|
+
document.execCommand = vi.fn();
|
|
40
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Utility
|
|
3
|
+
*/
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
|
|
6
|
+
function encodeBase64(string: string) {
|
|
7
|
+
return Buffer.from(string).toString('base64');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function generateTokenWithTimeRange(amount = 0) {
|
|
11
|
+
const payload = {
|
|
12
|
+
username: 'verdaccio',
|
|
13
|
+
exp: Number.parseInt(String(dayjs(new Date()).add(amount, 'hour').valueOf() / 1000), 10),
|
|
14
|
+
};
|
|
15
|
+
return `xxxxxx.${encodeBase64(JSON.stringify(payload))}.xxxxxx`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function generateTokenWithExpirationAsString() {
|
|
19
|
+
const payload = { username: 'verdaccio', exp: 'I am not a number' };
|
|
20
|
+
return `xxxxxx.${encodeBase64(JSON.stringify(payload))}.xxxxxx`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function generateInvalidToken() {
|
|
24
|
+
const payload = `invalidtoken`;
|
|
25
|
+
return `xxxxxx.${encodeBase64(payload)}.xxxxxx`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function generateTokenWithOutExpiration() {
|
|
29
|
+
const payload = {
|
|
30
|
+
username: 'verdaccio',
|
|
31
|
+
};
|
|
32
|
+
return `xxxxxx.${encodeBase64(JSON.stringify(payload))}.xxxxxx`;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default 'empty string module';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SnapshotSerializer } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const serializer: SnapshotSerializer = {
|
|
4
|
+
serialize(val, config, indentation, depth, refs, printer) {
|
|
5
|
+
for (const className of [...val.classList]) {
|
|
6
|
+
if (className.startsWith('css-')) {
|
|
7
|
+
const hashEnd = className.indexOf('-', 4);
|
|
8
|
+
if (hashEnd >= 0) {
|
|
9
|
+
val.classList.replace(className, 'makeStyles' + className.substring(hashEnd));
|
|
10
|
+
} else {
|
|
11
|
+
val.classList.remove(className);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (!val.classList.length) {
|
|
16
|
+
val.removeAttribute('class');
|
|
17
|
+
}
|
|
18
|
+
return printer(val, config, indentation, depth, refs);
|
|
19
|
+
},
|
|
20
|
+
test(val) {
|
|
21
|
+
return val instanceof Element && [...val.classList].some((name) => name.startsWith('css-'));
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An object snapshot serializer that removes dynamic CSS classes (generated by makeStyle) from DOM elements.
|
|
27
|
+
*
|
|
28
|
+
* `css-hash-suffix` is transformed into `makeStyles-suffix`
|
|
29
|
+
* `css-hash` is removed
|
|
30
|
+
*/
|
|
31
|
+
export default serializer;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import react from '@vitejs/plugin-react';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { defineConfig } from 'vitest/config';
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
test: {
|
|
7
|
+
environment: 'jsdom',
|
|
8
|
+
globals: true,
|
|
9
|
+
setupFiles: ['./vitest/setup.ts', './vitest/setup-env.ts'],
|
|
10
|
+
exclude: ['node_modules', './build/'],
|
|
11
|
+
snapshotFormat: {
|
|
12
|
+
escapeString: true,
|
|
13
|
+
printBasicPrototype: true,
|
|
14
|
+
},
|
|
15
|
+
snapshotSerializers: ['./vitest/vitestSerializer.ts'],
|
|
16
|
+
alias: {
|
|
17
|
+
// https://github.com/vitest-dev/vitest/issues/5664#issuecomment-2093986338
|
|
18
|
+
'@emotion/react': path.resolve('node_modules/@emotion/react/dist/emotion-react.cjs.mjs'),
|
|
19
|
+
'\\.(s?css)$': './vitest/identity.js',
|
|
20
|
+
'\\.(png)$': './vitest/identity.js',
|
|
21
|
+
'\\.(svg)$': './vitest/unit/empty.ts',
|
|
22
|
+
'\\.(jpg)$': './vitest/unit/empty.ts',
|
|
23
|
+
'\\.(md)$': './vitest/unit/empty-string.ts',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
plugins: [
|
|
27
|
+
react({
|
|
28
|
+
babel: {
|
|
29
|
+
plugins: ['@emotion'],
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
resolve: {
|
|
34
|
+
alias: {
|
|
35
|
+
'verdaccio-ui/components': path.resolve(__dirname, './src/components'),
|
|
36
|
+
'verdaccio-ui/utils': path.resolve(__dirname, './src/utils'),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = _default;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
// eslint-disable
|
|
10
|
-
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
function _default({
|
|
13
|
-
children
|
|
14
|
-
}) {
|
|
15
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
16
|
-
}
|
|
17
|
-
// eslint-enable
|
|
18
|
-
//# sourceMappingURL=react-markdown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function (): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function () {}
|