cozy-bar 15.0.0 → 15.1.0

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.
@@ -27,7 +27,8 @@ var ButtonCozyHome = function ButtonCozyHome(_ref) {
27
27
  onClick: function onClick() {
28
28
  webviewIntent.call('backToHome');
29
29
  },
30
- className: "coz-nav-apps-btns-home coz-nav-apps-btns-home--is-flagship"
30
+ className: "coz-nav-apps-btns-home coz-nav-apps-btns-home--is-flagship",
31
+ "data-testid": "buttonCozyHome"
31
32
  }, /*#__PURE__*/_react.default.createElement(_IconCozyHome.default, {
32
33
  className: "coz-nav-apps-btns-home-svg",
33
34
  isInvertedTheme: isInvertedTheme
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { shallow } from 'enzyme'
2
+ import { render, fireEvent } from '@testing-library/react'
3
3
  import { ButtonCozyHome } from './ButtonCozyHome'
4
4
  import { isFlagshipApp } from 'cozy-device-helper'
5
5
  import { useWebviewIntent } from 'cozy-intent'
@@ -9,51 +9,39 @@ jest.mock('cozy-intent', () => ({
9
9
  useWebviewIntent: jest.fn(() => ({ call: jest.fn() }))
10
10
  }))
11
11
 
12
- const homeHref = 'foo'
13
- const expectedCall = 'backToHome'
14
-
15
12
  describe('ButtonCozyHome', () => {
16
- it('should render a span with no props', () => {
17
- isFlagshipApp.mockImplementation(() => false)
18
- const render = shallow(<ButtonCozyHome />)
19
- const element = render.getElement()
13
+ it('renders a link with backToHome intent for flagship apps', () => {
14
+ isFlagshipApp.mockReturnValue(true)
20
15
 
21
- expect(element.type).toBe('span')
22
- })
16
+ const mockCall = jest.fn()
17
+ useWebviewIntent.mockImplementation(() => ({ call: mockCall }))
23
18
 
24
- it('should render an anchor with correct href when homeHref', () => {
25
- isFlagshipApp.mockImplementation(() => false)
26
- const render = shallow(<ButtonCozyHome homeHref={homeHref} />)
27
- const element = render.getElement()
19
+ // We need to use a testid because
20
+ // - the a tag has no text to query it (just an icon)
21
+ // - an "a" tag without href is not seen as a link by queryByRole
22
+ const { getByTestId } = render(<ButtonCozyHome />)
23
+ const linkElement = getByTestId('buttonCozyHome')
28
24
 
29
- expect(element.type).toBe('a')
30
- expect(element.props.href).toBe(homeHref)
31
- })
25
+ fireEvent.click(linkElement)
32
26
 
33
- it('should render an anchor when isFlagshipApp', () => {
34
- isFlagshipApp.mockImplementation(() => true)
35
- const render = shallow(<ButtonCozyHome />)
36
- const element = render.getElement()
37
-
38
- expect(element.type).toBe('a')
27
+ expect(mockCall).toHaveBeenCalledWith('backToHome')
39
28
  })
40
29
 
41
- it('should give priority to anchor if both isFlagshipApp and homeHref are present', () => {
42
- isFlagshipApp.mockImplementation(() => true)
43
- const render = shallow(<ButtonCozyHome homeHref={homeHref} />)
44
- const element = render.getElement()
30
+ it('renders a link with homeHref for non-flagship apps with homeHref', () => {
31
+ isFlagshipApp.mockReturnValue(false)
32
+
33
+ const { queryByRole } = render(<ButtonCozyHome homeHref="/home" />)
34
+ const linkElement = queryByRole('link')
45
35
 
46
- expect(element.type).toBe('a')
36
+ expect(linkElement).toHaveAttribute('href', '/home')
47
37
  })
48
38
 
49
- it('should call the correct context method on click', () => {
50
- isFlagshipApp.mockImplementation(() => true)
51
- const mockCall = jest.fn()
52
- useWebviewIntent.mockImplementation(() => ({ call: mockCall }))
53
- const render = shallow(<ButtonCozyHome homeHref={homeHref} />)
39
+ it('renders a span without href for non-flagship apps without homeHref', () => {
40
+ isFlagshipApp.mockReturnValue(false)
54
41
 
55
- render.simulate('click')
42
+ const { queryByRole } = render(<ButtonCozyHome />)
43
+ const linkElement = queryByRole('link')
56
44
 
57
- expect(mockCall).toBeCalledWith(expectedCall)
45
+ expect(linkElement).toBeNull()
58
46
  })
59
47
  })
@@ -27,7 +27,7 @@ var StorageData = function StorageData() {
27
27
 
28
28
  if (!isLoaded) return null; // we used this default quota set in getStorageData, we just reuse it here
29
29
 
30
- var storageData = (0, _instance.makeDiskInfos)(diskUsage.data.attributes.used, diskUsage.data.attributes.quota || Math.max(Math.pow(10, 12), 10 * parseInt(diskUsage.data.attributes.used, 10)));
30
+ var storageData = (0, _instance.makeDiskInfos)(diskUsage.data.used, diskUsage.data.quota || Math.max(Math.pow(10, 12), 10 * parseInt(diskUsage.data.used, 10)));
31
31
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, t('storage_phrase', {
32
32
  diskUsage: storageData.humanDiskUsage,
33
33
  diskQuota: storageData.humanDiskQuota
package/dist/index.js CHANGED
@@ -72,5 +72,5 @@ var _BarProvider = _interopRequireDefault(require("./components/BarProvider"));
72
72
  var _reducers = require("./lib/reducers");
73
73
 
74
74
  /* global __VERSION__ */
75
- var version = "\"15.0.0\"";
75
+ var version = "\"15.1.0\"";
76
76
  exports.version = version;
@@ -17,6 +17,8 @@ var _stack = _interopRequireDefault(require("../stack"));
17
17
 
18
18
  var _lodash = _interopRequireDefault(require("lodash.unionwith"));
19
19
 
20
+ var _cozyFlags = _interopRequireDefault(require("cozy-flags"));
21
+
20
22
  // constants
21
23
  var DELETE_APP = 'DELETE_APP';
22
24
  var RECEIVE_APP = 'RECEIVE_APP';
@@ -107,7 +109,7 @@ exports.setInfos = setInfos;
107
109
  var fetchApps = function fetchApps() {
108
110
  return /*#__PURE__*/function () {
109
111
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(dispatch) {
110
- var rawAppList, apps;
112
+ var rawAppList, excludedApps, apps;
111
113
  return _regenerator.default.wrap(function _callee$(_context) {
112
114
  while (1) {
113
115
  switch (_context.prev = _context.next) {
@@ -121,29 +123,32 @@ var fetchApps = function fetchApps() {
121
123
 
122
124
  case 4:
123
125
  rawAppList = _context.sent;
124
- apps = rawAppList.map(mapApp);
126
+ excludedApps = (0, _cozyFlags.default)('apps.hidden') || [];
127
+ apps = rawAppList.map(mapApp).filter(function (app) {
128
+ return !excludedApps.includes(app);
129
+ });
125
130
 
126
131
  if (rawAppList.length) {
127
- _context.next = 8;
132
+ _context.next = 9;
128
133
  break;
129
134
  }
130
135
 
131
136
  throw new Error('No installed apps found by the bar');
132
137
 
133
- case 8:
134
- _context.next = 10;
138
+ case 9:
139
+ _context.next = 11;
135
140
  return dispatch(setDefaultApp(apps));
136
141
 
137
- case 10:
138
- _context.next = 12;
142
+ case 11:
143
+ _context.next = 13;
139
144
  return dispatch(receiveAppList(apps));
140
145
 
141
- case 12:
142
- _context.next = 18;
146
+ case 13:
147
+ _context.next = 19;
143
148
  break;
144
149
 
145
- case 14:
146
- _context.prev = 14;
150
+ case 15:
151
+ _context.prev = 15;
147
152
  _context.t0 = _context["catch"](0);
148
153
  dispatch({
149
154
  type: FETCH_APPS_FAILURE
@@ -151,12 +156,12 @@ var fetchApps = function fetchApps() {
151
156
 
152
157
  console.warn(_context.t0.message ? _context.t0.message : _context.t0);
153
158
 
154
- case 18:
159
+ case 19:
155
160
  case "end":
156
161
  return _context.stop();
157
162
  }
158
163
  }
159
- }, _callee, null, [[0, 14]]);
164
+ }, _callee, null, [[0, 15]]);
160
165
  }));
161
166
 
162
167
  return function (_x) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-bar",
3
- "version": "15.0.0",
3
+ "version": "15.1.0",
4
4
  "description": "cozy-bar.js library, a small lib provided by cozy-stack to inject the Cozy-bar component into each app",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy Cloud <contact@cozycloud.cc> (https://cozy.io/)",
@@ -50,9 +50,6 @@
50
50
  "cozy-logger": "1.9.1",
51
51
  "cozy-realtime": "^4.0.5",
52
52
  "cozy-ui": "^111.12.0",
53
- "enzyme": "3.10.0",
54
- "enzyme-adapter-react-16": "1.3",
55
- "enzyme-to-json": "3.3.5",
56
53
  "eslint-config-cozy-app": "2.0.0",
57
54
  "identity-obj-proxy": "3.0.0",
58
55
  "jest": "24.9.0",