@verdaccio/ui-theme 6.0.0-6-next.10 → 6.0.0-6-next.11

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.
Files changed (107) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/jest/api/packages.json +42 -0
  3. package/jest/jest.config.js +2 -2
  4. package/jest/server-handlers.ts +9 -0
  5. package/jest/server.ts +6 -0
  6. package/jest/setup-env.ts +15 -0
  7. package/jest/setup.ts +2 -7
  8. package/package.json +21 -8
  9. package/src/App/App.test.tsx +75 -49
  10. package/src/App/App.tsx +6 -39
  11. package/src/App/AppRoute.tsx +2 -15
  12. package/src/App/Footer/Footer.tsx +32 -19
  13. package/src/App/Footer/__snapshots__/Footer.test.tsx.snap +183 -293
  14. package/src/App/Header/Header.test.tsx +52 -58
  15. package/src/App/Header/Header.tsx +12 -21
  16. package/src/App/Header/HeaderMenu.tsx +3 -3
  17. package/src/App/Header/LanguageSwitch.tsx +13 -74
  18. package/src/App/Header/LoginDialog/LoginDialog.test.tsx +23 -30
  19. package/src/App/Header/LoginDialog/LoginDialog.tsx +27 -43
  20. package/src/App/Header/RegistryInfoContent/RegistryInfoContent.test.tsx +0 -1
  21. package/src/App/Header/Search/Search.test.tsx +23 -9
  22. package/src/App/Header/Search/Search.tsx +18 -60
  23. package/src/App/index.ts +0 -1
  24. package/src/components/ActionBar/ActionBar.test.tsx +15 -8
  25. package/src/components/ActionBar/ActionBarAction.tsx +5 -7
  26. package/src/components/Author/Author.test.tsx +0 -1
  27. package/src/components/AutoComplete/AutoCompleteV2.tsx +1 -1
  28. package/src/components/Icons/index.ts +1 -17
  29. package/src/design-tokens/ThemeContext.ts +1 -1
  30. package/src/i18n/ABOUT_TRANSLATIONS.md +13 -0
  31. package/src/i18n/config.ts +52 -0
  32. package/src/i18n/crowdin/ui.json +170 -0
  33. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/cs-CZ.json +0 -0
  34. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/de-DE.json +0 -0
  35. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/en-US.json +0 -0
  36. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/es-ES.json +0 -0
  37. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/fr-FR.json +0 -0
  38. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/ja-JP.json +0 -0
  39. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/km-KH.json +0 -0
  40. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/pt-BR.json +0 -0
  41. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/ru-RU.json +0 -0
  42. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/tr-TR.json +0 -0
  43. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/uk-UA.json +0 -0
  44. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/zh-CN.json +0 -0
  45. package/{i18n/translations → src/i18n/deprecated_translations_dont_use}/zh-TW.json +0 -0
  46. package/src/i18n/enabledLanguages.ts +35 -0
  47. package/src/index.tsx +11 -10
  48. package/src/pages/Version/DetailContainer/UpLinks/UpLinks.test.tsx +0 -6
  49. package/src/pages/Version/DetailContainer/Versions/Versions.test.tsx +1 -1
  50. package/src/pages/Version/Version.test.tsx +2 -2
  51. package/src/pages/Version/Version.tsx +22 -5
  52. package/src/pages/Version/VersionContextProvider.tsx +14 -44
  53. package/src/pages/home/Home.tsx +10 -27
  54. package/src/pages/home/PackageList/Help/__snapshots__/Help.test.tsx.snap +3 -3
  55. package/src/pages/home/PackageList/Package/Package.test.tsx +6 -3
  56. package/src/pages/home/PackageList/Package/Package.tsx +7 -10
  57. package/src/pages/home/PackageList/PackageList.tsx +17 -16
  58. package/src/pages/home/PackageList/Packagelist.test.tsx +7 -4
  59. package/src/providers/API/api.test.ts +1 -0
  60. package/src/providers/API/api.ts +6 -2
  61. package/src/store/index.ts +1 -0
  62. package/src/store/models/configuration.ts +42 -0
  63. package/src/store/models/download.ts +31 -0
  64. package/src/store/models/index.ts +17 -0
  65. package/src/store/models/login.ts +90 -0
  66. package/src/store/models/manifest.ts +91 -0
  67. package/src/store/models/packages.ts +36 -0
  68. package/src/store/models/search.ts +81 -0
  69. package/src/store/store.ts +15 -0
  70. package/src/utils/login.test.ts +1 -1
  71. package/src/utils/test-react-testing-library.tsx +20 -7
  72. package/static/index.html +1 -1
  73. package/static/main.c57129036f278d0c7acf.js +2 -0
  74. package/static/{main.77e8bdb212b3a2239e58.js.LICENSE.txt → main.c57129036f278d0c7acf.js.LICENSE.txt} +78 -210
  75. package/static/manifest.json +3 -3
  76. package/static/{runtime.77e8bdb212b3a2239e58.js → runtime.c57129036f278d0c7acf.js} +1 -1
  77. package/static/{runtime.77e8bdb212b3a2239e58.js.LICENSE.txt → runtime.c57129036f278d0c7acf.js.LICENSE.txt} +2 -2
  78. package/static/vendors.c57129036f278d0c7acf.js +2 -0
  79. package/static/{vendors.77e8bdb212b3a2239e58.js.LICENSE.txt → vendors.c57129036f278d0c7acf.js.LICENSE.txt} +188 -16
  80. package/tsconfig.json +1 -1
  81. package/types/index.ts +3 -21
  82. package/i18n/config.ts +0 -94
  83. package/src/App/AppContext.ts +0 -18
  84. package/src/App/AppContextProvider.tsx +0 -44
  85. package/src/components/Icons/Austria.tsx +0 -23
  86. package/src/components/Icons/Brazil.tsx +0 -44
  87. package/src/components/Icons/China.tsx +0 -33
  88. package/src/components/Icons/Czech.tsx +0 -21
  89. package/src/components/Icons/France.tsx +0 -27
  90. package/src/components/Icons/Germany.tsx +0 -27
  91. package/src/components/Icons/India.tsx +0 -44
  92. package/src/components/Icons/Japan.tsx +0 -23
  93. package/src/components/Icons/Khmer.tsx +0 -40
  94. package/src/components/Icons/Nicaragua.tsx +0 -66
  95. package/src/components/Icons/Russia.tsx +0 -27
  96. package/src/components/Icons/Spain.tsx +0 -43
  97. package/src/components/Icons/Taiwan.tsx +0 -25
  98. package/src/components/Icons/Turkey.tsx +0 -23
  99. package/src/components/Icons/Ukraine.tsx +0 -30
  100. package/src/components/Icons/Usa.tsx +0 -34
  101. package/src/pages/Version/DetailSidebar/ActionBar/ActionBar.test.tsx +0 -84
  102. package/src/pages/Version/DetailSidebar/ActionBar/__snapshots__/ActionBar.test.tsx.snap +0 -122
  103. package/src/pages/Version/is-package-version-valid.ts +0 -19
  104. package/src/providers/API/APIProvider.tsx +0 -109
  105. package/src/providers/API/index.ts +0 -1
  106. package/static/main.77e8bdb212b3a2239e58.js +0 -2
  107. package/static/vendors.77e8bdb212b3a2239e58.js +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @verdaccio/ui-theme
2
2
 
3
+ ## 6.0.0-6-next.11
4
+
5
+ ### Minor Changes
6
+
7
+ - 5fed1955: feat: integrate rematch for ui state storage
8
+
3
9
  ## 6.0.0-6-next.10
4
10
 
5
11
  ### Major Changes
@@ -0,0 +1,42 @@
1
+ [
2
+ {
3
+ "name": "test",
4
+ "version": "1.0.22",
5
+ "description": "test",
6
+ "main": "src/index.js",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "repository": {
11
+ "type": "http",
12
+ "url": "git+https://github.com/test/test.git"
13
+ },
14
+ "keywords": [],
15
+ "author": {
16
+ "name": "",
17
+ "email": "",
18
+ "url": "",
19
+ "avatar": "data:image/svg+xml;utf8,%3Csvg%20height%3D%22100%22%20viewBox%3D%22-27%2024%20100%20100%22%20width%3D%22100%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%3E%3Cdefs%3E%3Ccircle%20cx%3D%2223%22%20cy%3D%2274%22%20id%3D%22a%22%20r%3D%2250%22%2F%3E%3C%2Fdefs%3E%3Cuse%20fill%3D%22%23F5EEE5%22%20overflow%3D%22visible%22%20xlink%3Ahref%3D%22%23a%22%2F%3E%3CclipPath%20id%3D%22b%22%3E%3Cuse%20overflow%3D%22visible%22%20xlink%3Ahref%3D%22%23a%22%2F%3E%3C%2FclipPath%3E%3Cg%20clip-path%3D%22url(%23b)%22%3E%3Cdefs%3E%3Cpath%20d%3D%22M36%2095.9c0%204%204.7%205.2%207.1%205.8%207.6%202%2022.8%205.9%2022.8%205.9%203.2%201.1%205.7%203.5%207.1%206.6v9.8H-27v-9.8c1.3-3.1%203.9-5.5%207.1-6.6%200%200%2015.2-3.9%2022.8-5.9%202.4-.6%207.1-1.8%207.1-5.8V85h26v10.9z%22%20id%3D%22c%22%2F%3E%3C%2Fdefs%3E%3Cuse%20fill%3D%22%23E6C19C%22%20overflow%3D%22visible%22%20xlink%3Ahref%3D%22%23c%22%2F%3E%3CclipPath%20id%3D%22d%22%3E%3Cuse%20overflow%3D%22visible%22%20xlink%3Ahref%3D%22%23c%22%2F%3E%3C%2FclipPath%3E%3Cpath%20clip-path%3D%22url(%23d)%22%20d%3D%22M23.2%2035h.2c3.3%200%208.2.2%2011.4%202%203.3%201.9%207.3%205.6%208.5%2012.1%202.4%2013.7-2.1%2035.4-6.3%2042.4-4%206.7-9.8%209.2-13.5%209.4H23h-.1c-3.7-.2-9.5-2.7-13.5-9.4-4.2-7-8.7-28.7-6.3-42.4%201.2-6.5%205.2-10.2%208.5-12.1%203.2-1.8%208.1-2%2011.4-2h.2z%22%20fill%3D%22%23D4B08C%22%2F%3E%3C%2Fg%3E%3Cpath%20d%3D%22M22.6%2040c19.1%200%2020.7%2013.8%2020.8%2015.1%201.1%2011.9-3%2028.1-6.8%2033.7-4%205.9-9.8%208.1-13.5%208.3h-.5c-3.8-.3-9.6-2.5-13.6-8.4-3.8-5.6-7.9-21.8-6.8-33.8C2.3%2053.7%203.5%2040%2022.6%2040z%22%20fill%3D%22%23F2CEA5%22%2F%3E%3C%2Fsvg%3E"
20
+ },
21
+ "license": "ISC",
22
+ "dependencies": {
23
+ "lodash": "^4.17.21"
24
+ },
25
+ "readmeFilename": "README.md",
26
+ "bugs": {
27
+ "url": "https://github.com/test/test/issues"
28
+ },
29
+ "homepage": "https://github.com/test/test#readme",
30
+ "_id": "test@1.0.22",
31
+ "_nodeVersion": "14.17.4",
32
+ "_npmVersion": "7.20.5",
33
+ "dist": {
34
+ "integrity": "sha512-2IDD0lLzGUL7YJ+17Oh9VtbOwdKLqBLS+ZFATDXi5R22TL2hZ9LBFE10bzsDovNc4xtgwZAk1/K+5LHTye4ztg==",
35
+ "shasum": "c9152f57636bce762ccb5a83113c42a5831579bc",
36
+ "tarball": "http://localhost:4873/test/-/test-1.0.22.tgz"
37
+ },
38
+ "contributors": [],
39
+ "time": "2021-08-14T20:15:19.336Z",
40
+ "users": {}
41
+ }
42
+ ]
@@ -10,9 +10,9 @@ module.exports = Object.assign({}, config, {
10
10
  '^.+\\.(js|ts|tsx)$': 'babel-jest',
11
11
  },
12
12
  moduleFileExtensions: ['js', 'ts', 'tsx'],
13
- testURL: 'http://localhost',
13
+ testURL: 'http://localhost:9000/',
14
14
  rootDir: '..',
15
- setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
15
+ setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect', '<rootDir>/jest/setup-env.ts'],
16
16
  setupFiles: ['<rootDir>/jest/setup.ts'],
17
17
  transformIgnorePatterns: ['<rootDir>/node_modules/(?!react-syntax-highlighter)'],
18
18
  modulePathIgnorePatterns: [
@@ -0,0 +1,9 @@
1
+ import { rest } from 'msw';
2
+
3
+ const packagesPayload = require('./api/packages.json');
4
+
5
+ export const handlers = [
6
+ rest.get('http://localhost:9000/-/verdaccio/packages', (req, res, ctx) => {
7
+ return res(ctx.json(packagesPayload));
8
+ }),
9
+ ];
package/jest/server.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { setupServer } from 'msw/node';
2
+
3
+ import { handlers } from './server-handlers';
4
+
5
+ const server = setupServer(...handlers);
6
+ export { server };
@@ -0,0 +1,15 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ import 'whatwg-fetch';
3
+ import '@testing-library/jest-dom';
4
+
5
+ import { server } from './server';
6
+
7
+ beforeAll(() => {
8
+ server.listen({
9
+ onUnhandledRequest: 'warn',
10
+ });
11
+ });
12
+ afterEach(() => server.resetHandlers());
13
+ afterAll(() => {
14
+ server.close();
15
+ });
package/jest/setup.ts CHANGED
@@ -2,29 +2,24 @@
2
2
  * Setup configuration for Jest
3
3
  * This file includes global settings for the JEST environment.
4
4
  */
5
- import { GlobalWithFetchMock } from 'jest-fetch-mock';
6
5
  import 'mutationobserver-shim';
7
6
 
8
7
  // @ts-ignore : Property '__VERDACCIO_BASENAME_UI_OPTIONS' does not exist on type 'Global'.
9
8
  global.__VERDACCIO_BASENAME_UI_OPTIONS = {
10
- base: 'http://localhost',
9
+ base: 'http://localhost:9000/',
11
10
  protocol: 'http',
12
11
  host: 'localhost',
13
12
  primaryColor: '#4b5e40',
14
13
  url_prefix: '',
15
14
  darkMode: false,
16
15
  language: 'en-US',
17
- uri: 'http://localhost:4873',
16
+ uri: 'http://localhost:9000/',
18
17
  pkgManagers: ['pnpm', 'yarn', 'npm'],
19
18
  title: 'Verdaccio Dev UI',
20
19
  scope: '',
21
20
  version: 'v1.0.0',
22
21
  };
23
22
 
24
- const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;
25
- customGlobal.fetch = require('jest-fetch-mock');
26
- customGlobal.fetchMock = customGlobal.fetch;
27
-
28
23
  // mocking few DOM methods
29
24
  // @ts-ignore : Property 'document' does not exist on type 'Global'.
30
25
  if (global.document) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/ui-theme",
3
- "version": "6.0.0-6-next.10",
3
+ "version": "6.0.0-6-next.11",
4
4
  "description": "Verdaccio User Interface",
5
5
  "author": {
6
6
  "name": "Verdaccio Contributors",
@@ -17,6 +17,13 @@
17
17
  "npm": ">=6"
18
18
  },
19
19
  "devDependencies": {
20
+ "@types/react": "17.0.19",
21
+ "@types/react-autosuggest": "10.1.5",
22
+ "@types/react-dom": "17.0.9",
23
+ "@types/react-helmet": "6.1.2",
24
+ "@types/redux": "3.6.0",
25
+ "@types/react-router-dom": "5.1.8",
26
+ "@types/react-virtualized": "9.21.13",
20
27
  "@emotion/core": "10.1.1",
21
28
  "@emotion/jest": "11.3.0",
22
29
  "@emotion/styled": "10.0.27",
@@ -24,10 +31,12 @@
24
31
  "@material-ui/core": "4.11.4",
25
32
  "@material-ui/icons": "4.11.2",
26
33
  "@material-ui/styles": "4.11.4",
27
- "@testing-library/dom": "8.2.0",
34
+ "@rematch/core": "2.1.0",
35
+ "@rematch/loading": "2.1.0",
36
+ "@testing-library/dom": "8.5.0",
28
37
  "@testing-library/jest-dom": "5.14.1",
29
- "@testing-library/react": "12.0.0",
30
- "@verdaccio/node-api": "6.0.0-6-next.20",
38
+ "@testing-library/react": "12.1.0",
39
+ "@verdaccio/node-api": "6.0.0-6-next.21",
31
40
  "autosuggest-highlight": "3.1.1",
32
41
  "babel-loader": "8.2.2",
33
42
  "babel-plugin-dynamic-import-node": "2.3.3",
@@ -42,8 +51,9 @@
42
51
  "harmony-reflect": "1.6.2",
43
52
  "history": "4.10.1",
44
53
  "html-webpack-plugin": "5.3.2",
45
- "i18next": "20.6.0",
54
+ "i18next": "20.6.1",
46
55
  "in-publish": "2.0.1",
56
+ "country-flag-icons": "1.4.10",
47
57
  "js-base64": "3.6.1",
48
58
  "js-yaml": "3.14.1",
49
59
  "localstorage-memory": "1.0.3",
@@ -58,13 +68,16 @@
58
68
  "react": "17.0.2",
59
69
  "react-autosuggest": "10.1.0",
60
70
  "react-dom": "17.0.2",
61
- "react-hook-form": "7.14.2",
71
+ "react-hook-form": "7.15.3",
62
72
  "react-hot-loader": "4.13.0",
63
- "react-i18next": "11.11.4",
73
+ "react-i18next": "11.12.0",
64
74
  "react-router": "5.2.1",
65
75
  "react-router-dom": "5.3.0",
66
76
  "react-virtualized": "9.22.3",
77
+ "react-redux": "7.2.1",
78
+ "redux": "4.1.1",
67
79
  "rimraf": "3.0.2",
80
+ "msw": "0.35.0",
68
81
  "standard-version": "9.3.1",
69
82
  "style-loader": "3.2.1",
70
83
  "stylelint": "13.13.1",
@@ -129,7 +142,7 @@
129
142
  "type-check": "tsc --noEmit -p tsconfig.build.json",
130
143
  "start": "babel-node tools/dev.server.js",
131
144
  "test:clean": "jest --clearCache",
132
- "test": "cross-env BABEL_ENV=test cross-env NODE_ENV=test cross-env TZ=UTC jest --config ./jest/jest.config.js --maxWorkers 2 --passWithNoTests",
145
+ "test": "cross-env BABEL_ENV=test cross-env NODE_ENV=test cross-env TZ=UTC jest --config ./jest/jest.config.js --runInBand",
133
146
  "test:update-snapshot": "yarn run test -- -u",
134
147
  "test:size": "bundlesize",
135
148
  "lint": "pnpm lint:js && pnpm lint:css",
@@ -1,10 +1,16 @@
1
1
  import React from 'react';
2
2
 
3
- import storage from 'verdaccio-ui/utils/storage';
4
- import { render, waitFor, fireEvent } from 'verdaccio-ui/utils/test-react-testing-library';
3
+ import {
4
+ renderWithStore,
5
+ act,
6
+ waitFor,
7
+ fireEvent,
8
+ screen,
9
+ } from 'verdaccio-ui/utils/test-react-testing-library';
5
10
 
6
11
  // eslint-disable-next-line jest/no-mocks-import
7
12
  import { generateTokenWithTimeRange } from '../../jest/unit/components/__mocks__/token';
13
+ import { store } from '../store';
8
14
 
9
15
  import App from './App';
10
16
 
@@ -30,68 +36,88 @@ jest.mock('verdaccio-ui/utils/storage', () => {
30
36
  return new LocalStorageMock();
31
37
  });
32
38
 
33
- jest.mock('verdaccio-ui/providers/API/api', () => ({
34
- // eslint-disable-next-line jest/no-mocks-import
35
- request: require('../../jest/unit/components/__mocks__/api').default.request,
36
- }));
39
+ // force the windows to expand to display items
40
+ // https://github.com/bvaughn/react-virtualized/issues/493#issuecomment-640084107
41
+ jest.spyOn(HTMLElement.prototype, 'offsetHeight', 'get').mockReturnValue(600);
42
+ jest.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(600);
37
43
 
38
44
  /* eslint-disable react/jsx-no-bind*/
39
45
  describe('<App />', () => {
40
- // test('should display the Header component ', async () => {
41
- // const { queryByTestId } = render(<App />);
42
- //
43
- // expect(queryByTestId('loading')).toBeTruthy();
44
- //
45
- // // wait for the Header component appearance and return the element
46
- // const headerElement = await waitFor(() => queryByTestId('header'));
47
- // expect(headerElement).toBeTruthy();
48
- // });
49
-
50
- test('handleLogout - logouts the user and clear localstorage', async () => {
51
- storage.setItem('username', 'verdaccio');
52
- storage.setItem('token', generateTokenWithTimeRange(24));
53
-
54
- const { queryByTestId } = render(<App />);
46
+ describe('login - log out', () => {
47
+ test('handleLogout - logouts the user and clear localstorage', async () => {
48
+ const { queryByTestId } = renderWithStore(<App />, store);
49
+ store.dispatch.login.logInUser({
50
+ username: 'verdaccio',
51
+ token: generateTokenWithTimeRange(24),
52
+ });
53
+
54
+ // wait for the Account's circle element component appearance and return the element
55
+ const accountCircleElement = await waitFor(() => queryByTestId('logInDialogIcon'));
56
+ expect(accountCircleElement).toBeTruthy();
57
+
58
+ if (accountCircleElement) {
59
+ fireEvent.click(accountCircleElement);
60
+
61
+ // wait for the Button's logout element component appearance and return the element
62
+ const buttonLogoutElement = await waitFor(() => queryByTestId('logOutDialogIcon'));
63
+ expect(buttonLogoutElement).toBeTruthy();
64
+
65
+ if (buttonLogoutElement) {
66
+ fireEvent.click(buttonLogoutElement);
67
+
68
+ expect(queryByTestId('greetings-label')).toBeFalsy();
69
+ }
70
+ }
71
+ });
55
72
 
56
- // wait for the Account's circle element component appearance and return the element
57
- const accountCircleElement = await waitFor(() => queryByTestId('header--menu-accountcircle'));
58
- expect(accountCircleElement).toBeTruthy();
73
+ test('isUserAlreadyLoggedIn: token already available in storage', async () => {
74
+ const { queryByTestId, queryAllByText } = renderWithStore(<App />, store);
75
+ store.dispatch.login.logInUser({
76
+ username: 'verdaccio',
77
+ token: generateTokenWithTimeRange(24),
78
+ });
59
79
 
60
- if (accountCircleElement) {
61
- fireEvent.click(accountCircleElement);
80
+ // wait for the Account's circle element component appearance and return the element
81
+ const accountCircleElement = await waitFor(() => queryByTestId('logInDialogIcon'));
82
+ expect(accountCircleElement).toBeTruthy();
62
83
 
63
- // wait for the Button's logout element component appearance and return the element
64
- const buttonLogoutElement = await waitFor(() => queryByTestId('header--button-logout'));
65
- expect(buttonLogoutElement).toBeTruthy();
84
+ if (accountCircleElement) {
85
+ fireEvent.click(accountCircleElement);
66
86
 
67
- if (buttonLogoutElement) {
68
- fireEvent.click(buttonLogoutElement);
87
+ // wait for the Greeting's label element component appearance and return the element
88
+ const greetingsLabelElement = await waitFor(() => queryByTestId('greetings-label'));
89
+ expect(greetingsLabelElement).toBeTruthy();
69
90
 
70
- expect(queryByTestId('greetings-label')).toBeFalsy();
91
+ if (greetingsLabelElement) {
92
+ expect(queryAllByText('verdaccio')).toBeTruthy();
93
+ }
71
94
  }
72
- }
95
+ });
73
96
  });
74
97
 
75
- test('isUserAlreadyLoggedIn: token already available in storage', async () => {
76
- storage.setItem('username', 'verdaccio');
77
- storage.setItem('token', generateTokenWithTimeRange(24));
98
+ describe('list packages', () => {
99
+ test('should display the Header component', async () => {
100
+ renderWithStore(<App />, store);
78
101
 
79
- const { queryByTestId, queryAllByText } = render(<App />);
102
+ await waitFor(() => {
103
+ expect(screen.queryByTestId('loading')).toBeTruthy();
104
+ });
80
105
 
81
- // wait for the Account's circle element component appearance and return the element
82
- const accountCircleElement = await waitFor(() => queryByTestId('header--menu-accountcircle'));
83
- expect(accountCircleElement).toBeTruthy();
106
+ // wait for the Header component appearance and return the element
107
+ const headerElement = await waitFor(() => screen.queryByTestId('header'));
108
+ expect(headerElement).toBeTruthy();
109
+ });
84
110
 
85
- if (accountCircleElement) {
86
- fireEvent.click(accountCircleElement);
111
+ test('should display package lists', async () => {
112
+ act(() => {
113
+ renderWithStore(<App />, store);
114
+ });
87
115
 
88
- // wait for the Greeting's label element component appearance and return the element
89
- const greetingsLabelElement = await waitFor(() => queryByTestId('greetings-label'));
90
- expect(greetingsLabelElement).toBeTruthy();
116
+ await waitFor(() => {
117
+ expect(screen.getByTestId('package-item-list')).toBeInTheDocument();
118
+ });
91
119
 
92
- if (greetingsLabelElement) {
93
- expect(queryAllByText('verdaccio')).toBeTruthy();
94
- }
95
- }
120
+ expect(store.getState().packages.response).toHaveLength(1);
121
+ }, 10000);
96
122
  });
97
123
  });
package/src/App/App.tsx CHANGED
@@ -1,7 +1,6 @@
1
1
  /* eslint-disable react/jsx-max-depth */
2
2
  import styled from '@emotion/styled';
3
- import isNil from 'lodash/isNil';
4
- import React, { useState, useEffect, Suspense } from 'react';
3
+ import React, { useEffect, Suspense } from 'react';
5
4
  import { Router } from 'react-router-dom';
6
5
 
7
6
  import Box from 'verdaccio-ui/components/Box';
@@ -9,15 +8,12 @@ import Loading from 'verdaccio-ui/components/Loading';
9
8
  import loadDayJSLocale from 'verdaccio-ui/design-tokens/load-dayjs-locale';
10
9
  import StyleBaseline from 'verdaccio-ui/design-tokens/StyleBaseline';
11
10
  import { Theme } from 'verdaccio-ui/design-tokens/theme';
12
- import { isTokenExpire } from 'verdaccio-ui/utils/login';
13
- import storage from 'verdaccio-ui/utils/storage';
14
11
 
15
- import AppContextProvider from './AppContextProvider';
16
12
  import AppRoute, { history } from './AppRoute';
17
13
  import Footer from './Footer';
18
14
  import Header from './Header';
19
15
 
20
- import '../../i18n/config';
16
+ import '../i18n/config';
21
17
 
22
18
  const StyledBox = styled(Box)<{ theme?: Theme }>(({ theme }) => ({
23
19
  backgroundColor: theme?.palette.background.default,
@@ -32,35 +28,8 @@ const StyledBoxContent = styled(Box)<{ theme?: Theme }>(({ theme }) => ({
32
28
  },
33
29
  }));
34
30
 
35
- /* eslint-disable react/jsx-no-bind */
36
- /* eslint-disable react-hooks/exhaustive-deps */
37
31
  const App: React.FC = () => {
38
- const [user, setUser] = useState<undefined | { username: string | null }>();
39
- /**
40
- * Logout user
41
- * Required by: <Header />
42
- */
43
- const logout = () => {
44
- storage.removeItem('username');
45
- storage.removeItem('token');
46
- setUser(undefined);
47
- };
48
-
49
- const checkUserAlreadyLoggedIn = () => {
50
- // checks for token validity
51
- const token = storage.getItem('token');
52
- const username = storage.getItem('username');
53
-
54
- if (isTokenExpire(token) || isNil(username)) {
55
- logout();
56
- return;
57
- }
58
-
59
- setUser({ username });
60
- };
61
-
62
32
  useEffect(() => {
63
- checkUserAlreadyLoggedIn();
64
33
  loadDayJSLocale();
65
34
  }, []);
66
35
 
@@ -70,12 +39,10 @@ const App: React.FC = () => {
70
39
  <StyledBox display="flex" flexDirection="column" height="100%">
71
40
  <>
72
41
  <Router history={history}>
73
- <AppContextProvider user={user}>
74
- <Header />
75
- <StyledBoxContent flexGrow={1}>
76
- <AppRoute />
77
- </StyledBoxContent>
78
- </AppContextProvider>
42
+ <Header />
43
+ <StyledBoxContent flexGrow={1}>
44
+ <AppRoute />
45
+ </StyledBoxContent>
79
46
  </Router>
80
47
  <Footer />
81
48
  </>
@@ -1,9 +1,7 @@
1
1
  import { createBrowserHistory } from 'history';
2
- import React, { useContext } from 'react';
3
- import { useTranslation } from 'react-i18next';
2
+ import React from 'react';
4
3
  import { Route as ReactRouterDomRoute, Switch, Router } from 'react-router-dom';
5
4
 
6
- import AppContext from './AppContext';
7
5
  import loadable from './utils/loadable';
8
6
 
9
7
  const NotFound = loadable(
@@ -28,22 +26,11 @@ export const history = createBrowserHistory({
28
26
  });
29
27
 
30
28
  const AppRoute: React.FC = () => {
31
- const appContext = useContext(AppContext);
32
- const { t } = useTranslation();
33
-
34
- if (!appContext) {
35
- throw Error(t('app-context-not-correct-used'));
36
- }
37
-
38
- const { user } = appContext;
39
-
40
- const isUserLoggedIn = user?.username;
41
-
42
29
  return (
43
30
  <Router history={history}>
44
31
  <Switch>
45
32
  <ReactRouterDomRoute exact={true} path={Route.ROOT}>
46
- <HomePage isUserLoggedIn={!!isUserLoggedIn} />
33
+ <HomePage />
47
34
  </ReactRouterDomRoute>
48
35
  <ReactRouterDomRoute exact={true} path={Route.PACKAGE}>
49
36
  <VersionContextProvider>
@@ -1,18 +1,11 @@
1
+ /* eslint-disable react/jsx-max-depth */
2
+ /* eslint-disable react/jsx-pascal-case */
1
3
  import styled from '@emotion/styled';
4
+ import FlagsIcon from 'country-flag-icons/react/3x2';
2
5
  import React from 'react';
3
6
  import { useTranslation, Trans } from 'react-i18next';
4
7
 
5
- import {
6
- Austria,
7
- Brazil,
8
- Earth,
9
- Nicaragua,
10
- Spain,
11
- Germany,
12
- India,
13
- China,
14
- Taiwan,
15
- } from 'verdaccio-ui/components/Icons';
8
+ import { Earth } from 'verdaccio-ui/components/Icons';
16
9
  import Logo from 'verdaccio-ui/components/Logo';
17
10
  import { Theme } from 'verdaccio-ui/design-tokens/theme';
18
11
  import { useConfig } from 'verdaccio-ui/providers/config';
@@ -32,14 +25,30 @@ const Footer = () => {
32
25
  <ToolTip>
33
26
  <StyledEarth />
34
27
  <Flags>
35
- <Spain />
36
- <Nicaragua />
37
- <India />
38
- <Brazil />
39
- <China />
40
- <Austria />
41
- <Germany />
42
- <Taiwan />
28
+ <Icon>
29
+ <FlagsIcon.ES />
30
+ </Icon>
31
+ <Icon>
32
+ <FlagsIcon.NI />
33
+ </Icon>
34
+ <Icon>
35
+ <FlagsIcon.IN />
36
+ </Icon>
37
+ <Icon>
38
+ <FlagsIcon.BR />
39
+ </Icon>
40
+ <Icon>
41
+ <FlagsIcon.CN />
42
+ </Icon>
43
+ <Icon>
44
+ <FlagsIcon.AU />
45
+ </Icon>
46
+ <Icon>
47
+ <FlagsIcon.DE />
48
+ </Icon>
49
+ <Icon>
50
+ <FlagsIcon.TW />
51
+ </Icon>
43
52
  </Flags>
44
53
  </ToolTip>
45
54
  </Left>
@@ -87,6 +96,10 @@ const Flags = styled('span')<{ theme?: Theme }>(({ theme }) => ({
87
96
  },
88
97
  }));
89
98
 
99
+ const Icon = styled('div')({
100
+ width: '10px',
101
+ });
102
+
90
103
  const ToolTip = styled('span')({
91
104
  position: 'relative',
92
105
  height: '18px',