cozy-harvest-lib 9.23.2 → 9.24.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.
- package/CHANGELOG.md +35 -0
- package/dist/components/OAuthForm.js +4 -1
- package/dist/components/Routes.js +22 -10
- package/dist/components/TriggerManager.spec.js +115 -85
- package/dist/helpers/useKonnectorWithTriggers.js +182 -0
- package/dist/locales/en.json +10 -2
- package/dist/locales/fr.json +10 -2
- package/dist/services/biWebView.js +136 -148
- package/dist/services/biWebView.spec.js +5 -20
- package/dist/types.js +23 -0
- package/package.json +2 -2
- package/src/components/OAuthForm.jsx +6 -2
- package/src/components/Routes.jsx +98 -74
- package/src/components/TriggerManager.spec.jsx +19 -0
- package/src/helpers/useKonnectorWithTriggers.js +75 -0
- package/src/locales/en.json +10 -2
- package/src/locales/fr.json +10 -2
- package/src/services/biWebView.js +53 -47
- package/src/services/biWebView.spec.js +5 -5
- package/src/types.js +22 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [9.24.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.23.4...cozy-harvest-lib@9.24.0) (2022-07-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **cozy-harvest-app:** Add `konnectorSlug` prop in Routes.jsx ([e7e656e](https://github.com/cozy/cozy-libs/commit/e7e656e5527df108dbed86c2c74543adaa928f34))
|
|
12
|
+
* **cozy-harvest-app:** Display a spinner while connector is fetched ([6c6079b](https://github.com/cozy/cozy-libs/commit/6c6079b2d5dc4d1d993bd5c72d48b18dcbba5377))
|
|
13
|
+
* **cozy-harvest-app:** Fetch connector from cozy-stack if undefined ([5433f97](https://github.com/cozy/cozy-libs/commit/5433f97df552262d6de71eb112e59d81b62c0451))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## [9.23.4](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.23.3...cozy-harvest-lib@9.23.4) (2022-07-27)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* Bank words are reserved for banking konnector ([5d91695](https://github.com/cozy/cozy-libs/commit/5d916957a41a172b34acbc9604c875c695443a09))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [9.23.3](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.23.2...cozy-harvest-lib@9.23.3) (2022-07-27)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
* Add ts-check on biWebview ([1920474](https://github.com/cozy/cozy-libs/commit/1920474b85ad342adbd12a363612918db1665bca))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
6
41
|
## [9.23.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.23.1...cozy-harvest-lib@9.23.2) (2022-07-26)
|
|
7
42
|
|
|
8
43
|
|
|
@@ -128,6 +128,8 @@ export var OAuthForm = /*#__PURE__*/function (_PureComponent) {
|
|
|
128
128
|
}, {
|
|
129
129
|
key: "render",
|
|
130
130
|
value: function render() {
|
|
131
|
+
var _konnector$categories;
|
|
132
|
+
|
|
131
133
|
var _this$props2 = this.props,
|
|
132
134
|
konnector = _this$props2.konnector,
|
|
133
135
|
t = _this$props2.t,
|
|
@@ -141,7 +143,8 @@ export var OAuthForm = /*#__PURE__*/function (_PureComponent) {
|
|
|
141
143
|
extraParams = _this$state.extraParams;
|
|
142
144
|
var error = flowState.error;
|
|
143
145
|
var isBusy = showOAuthWindow === true || flowState.running || needExtraParams && !extraParams;
|
|
144
|
-
var
|
|
146
|
+
var isBankingKonnector = (_konnector$categories = konnector.categories) === null || _konnector$categories === void 0 ? void 0 : _konnector$categories.includes('banking');
|
|
147
|
+
var buttonLabel = reconnect ? isBankingKonnector ? 'oauth.banking.reconnect.label' : 'oauth.reconnect.label' : isBankingKonnector ? 'oauth.banking.connect.label' : 'oauth.connect.label';
|
|
145
148
|
return /*#__PURE__*/React.createElement(React.Fragment, null, error && /*#__PURE__*/React.createElement(TriggerErrorInfo, {
|
|
146
149
|
className: "u-mb-1",
|
|
147
150
|
error: error,
|
|
@@ -4,6 +4,7 @@ import { Switch, Route, Redirect } from 'react-router';
|
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
import Dialog from 'cozy-ui/transpiled/react/Dialog';
|
|
6
6
|
import { DialogCloseButton, useCozyDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
|
|
7
|
+
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
7
8
|
import { useVaultUnlockContext, VaultUnlockProvider, VaultUnlockPlaceholder } from 'cozy-keys-lib';
|
|
8
9
|
import KonnectorAccounts from './KonnectorAccounts';
|
|
9
10
|
import AccountModal from './AccountModal';
|
|
@@ -16,6 +17,7 @@ import { MountPointProvider } from './MountPointContext';
|
|
|
16
17
|
import DialogContext from './DialogContext';
|
|
17
18
|
import { DatacardOptions } from './Datacards/DatacardOptionsContext';
|
|
18
19
|
import { ViewerModal } from '../datacards/ViewerModal';
|
|
20
|
+
import { useKonnectorWithTriggers } from '../helpers/useKonnectorWithTriggers';
|
|
19
21
|
/**
|
|
20
22
|
* Dialog will not be centered vertically since we need the modal to "stay in place"
|
|
21
23
|
* when changing tabs. Since tabs content's height is not the same between the data
|
|
@@ -45,6 +47,7 @@ var HarvestDialog = withStyles({
|
|
|
45
47
|
var Routes = function Routes(_ref) {
|
|
46
48
|
var konnectorRoot = _ref.konnectorRoot,
|
|
47
49
|
konnector = _ref.konnector,
|
|
50
|
+
konnectorSlug = _ref.konnectorSlug,
|
|
48
51
|
onDismiss = _ref.onDismiss,
|
|
49
52
|
datacardOptions = _ref.datacardOptions;
|
|
50
53
|
var dialogContext = useCozyDialog({
|
|
@@ -52,6 +55,11 @@ var Routes = function Routes(_ref) {
|
|
|
52
55
|
open: true,
|
|
53
56
|
onClose: onDismiss
|
|
54
57
|
});
|
|
58
|
+
|
|
59
|
+
var _useKonnectorWithTrig = useKonnectorWithTriggers(konnectorSlug, konnector),
|
|
60
|
+
konnectorWithTriggers = _useKonnectorWithTrig.konnectorWithTriggers,
|
|
61
|
+
fetching = _useKonnectorWithTrig.fetching;
|
|
62
|
+
|
|
55
63
|
return /*#__PURE__*/React.createElement(DatacardOptions, {
|
|
56
64
|
options: datacardOptions
|
|
57
65
|
}, /*#__PURE__*/React.createElement(MountPointProvider, {
|
|
@@ -59,11 +67,15 @@ var Routes = function Routes(_ref) {
|
|
|
59
67
|
}, /*#__PURE__*/React.createElement(DialogContext.Provider, {
|
|
60
68
|
value: dialogContext
|
|
61
69
|
}, /*#__PURE__*/React.createElement(HarvestVaultProvider, null, /*#__PURE__*/React.createElement(VaultUnlockProvider, null, /*#__PURE__*/React.createElement(HarvestDialog, _extends({}, dialogContext.dialogProps, {
|
|
62
|
-
"aria-label":
|
|
70
|
+
"aria-label": konnectorWithTriggers.name
|
|
63
71
|
}), /*#__PURE__*/React.createElement(DialogCloseButton, {
|
|
64
72
|
onClick: onDismiss
|
|
65
|
-
}), /*#__PURE__*/React.createElement(
|
|
66
|
-
|
|
73
|
+
}), fetching ? /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
className: "u-pv-2 u-ta-center"
|
|
75
|
+
}, /*#__PURE__*/React.createElement(Spinner, {
|
|
76
|
+
size: "xxlarge"
|
|
77
|
+
})) : /*#__PURE__*/React.createElement(KonnectorAccounts, {
|
|
78
|
+
konnector: konnectorWithTriggers
|
|
67
79
|
}, function (accountsAndTriggers) {
|
|
68
80
|
return /*#__PURE__*/React.createElement(Switch, null, /*#__PURE__*/React.createElement(Route, {
|
|
69
81
|
path: "".concat(konnectorRoot, "/"),
|
|
@@ -71,7 +83,7 @@ var Routes = function Routes(_ref) {
|
|
|
71
83
|
render: function render() {
|
|
72
84
|
return /*#__PURE__*/React.createElement(HarvestModalRoot, {
|
|
73
85
|
accounts: accountsAndTriggers,
|
|
74
|
-
konnector:
|
|
86
|
+
konnector: konnectorWithTriggers
|
|
75
87
|
});
|
|
76
88
|
}
|
|
77
89
|
}), /*#__PURE__*/React.createElement(Route, {
|
|
@@ -80,12 +92,12 @@ var Routes = function Routes(_ref) {
|
|
|
80
92
|
render: function render(_ref2) {
|
|
81
93
|
var match = _ref2.match;
|
|
82
94
|
return /*#__PURE__*/React.createElement(AccountModal, {
|
|
83
|
-
konnector:
|
|
95
|
+
konnector: konnectorWithTriggers,
|
|
84
96
|
accountId: match.params.accountId,
|
|
85
97
|
accountsAndTriggers: accountsAndTriggers,
|
|
86
98
|
onDismiss: onDismiss,
|
|
87
|
-
showNewAccountButton: !
|
|
88
|
-
showAccountSelection: !
|
|
99
|
+
showNewAccountButton: !konnectorWithTriggers.clientSide,
|
|
100
|
+
showAccountSelection: !konnectorWithTriggers.clientSide
|
|
89
101
|
});
|
|
90
102
|
}
|
|
91
103
|
}), /*#__PURE__*/React.createElement(Route, {
|
|
@@ -94,7 +106,7 @@ var Routes = function Routes(_ref) {
|
|
|
94
106
|
render: function render(_ref3) {
|
|
95
107
|
var match = _ref3.match;
|
|
96
108
|
return /*#__PURE__*/React.createElement(EditAccountModal, {
|
|
97
|
-
konnector:
|
|
109
|
+
konnector: konnectorWithTriggers,
|
|
98
110
|
accountId: match.params.accountId,
|
|
99
111
|
accounts: accountsAndTriggers
|
|
100
112
|
});
|
|
@@ -110,7 +122,7 @@ var Routes = function Routes(_ref) {
|
|
|
110
122
|
exact: true,
|
|
111
123
|
render: function render() {
|
|
112
124
|
return /*#__PURE__*/React.createElement(NewAccountModal, {
|
|
113
|
-
konnector:
|
|
125
|
+
konnector: konnectorWithTriggers,
|
|
114
126
|
onDismiss: onDismiss
|
|
115
127
|
});
|
|
116
128
|
}
|
|
@@ -120,7 +132,7 @@ var Routes = function Routes(_ref) {
|
|
|
120
132
|
render: function render(_ref4) {
|
|
121
133
|
var match = _ref4.match;
|
|
122
134
|
return /*#__PURE__*/React.createElement(KonnectorSuccess, {
|
|
123
|
-
konnector:
|
|
135
|
+
konnector: konnectorWithTriggers,
|
|
124
136
|
accountId: match.params.accountId,
|
|
125
137
|
accounts: accountsAndTriggers,
|
|
126
138
|
onDismiss: onDismiss
|
|
@@ -111,6 +111,12 @@ var oAuthKonnector = {
|
|
|
111
111
|
scope: 'test'
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
|
+
var bankingKonnector = {
|
|
115
|
+
oauth: {
|
|
116
|
+
scope: 'test'
|
|
117
|
+
},
|
|
118
|
+
categories: ['banking']
|
|
119
|
+
};
|
|
114
120
|
|
|
115
121
|
var oAuthProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
116
122
|
konnector: oAuthKonnector,
|
|
@@ -156,7 +162,7 @@ describe('TriggerManager', function () {
|
|
|
156
162
|
konnector: oAuthKonnector
|
|
157
163
|
}))));
|
|
158
164
|
_context2.next = 4;
|
|
159
|
-
return expect(root.findByText('
|
|
165
|
+
return expect(root.findByText('Connect')).resolves.toBeDefined();
|
|
160
166
|
|
|
161
167
|
case 4:
|
|
162
168
|
expect(root.queryByLabelText('username')).toBeFalsy();
|
|
@@ -169,6 +175,30 @@ describe('TriggerManager', function () {
|
|
|
169
175
|
}
|
|
170
176
|
}, _callee2);
|
|
171
177
|
})));
|
|
178
|
+
it('should should not show a form but only a button to connect with a banking konnector', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
179
|
+
var root;
|
|
180
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
181
|
+
while (1) {
|
|
182
|
+
switch (_context3.prev = _context3.next) {
|
|
183
|
+
case 0:
|
|
184
|
+
mockVaultClient.getAll.mockResolvedValue([]);
|
|
185
|
+
root = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(TriggerManager, _extends({}, oAuthProps, {
|
|
186
|
+
konnector: bankingKonnector
|
|
187
|
+
}))));
|
|
188
|
+
_context3.next = 4;
|
|
189
|
+
return expect(root.findByText('Add your bank')).resolves.toBeDefined();
|
|
190
|
+
|
|
191
|
+
case 4:
|
|
192
|
+
expect(root.queryByLabelText('username')).toBeFalsy();
|
|
193
|
+
expect(root.queryByLabelText('passphrase')).toBeFalsy();
|
|
194
|
+
|
|
195
|
+
case 6:
|
|
196
|
+
case "end":
|
|
197
|
+
return _context3.stop();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}, _callee3);
|
|
201
|
+
})));
|
|
172
202
|
});
|
|
173
203
|
describe('when given no account', function () {
|
|
174
204
|
describe('when the vault does not contain ciphers', function () {
|
|
@@ -176,33 +206,33 @@ describe('TriggerManager', function () {
|
|
|
176
206
|
mockVaultClient.getAll.mockResolvedValue([]);
|
|
177
207
|
mockVaultClient.getAllDecrypted.mockResolvedValue([]);
|
|
178
208
|
});
|
|
179
|
-
it('should show the new account form', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
209
|
+
it('should show the new account form', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
180
210
|
var _render, findByLabelText, findByTitle;
|
|
181
211
|
|
|
182
|
-
return _regeneratorRuntime.wrap(function
|
|
212
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
183
213
|
while (1) {
|
|
184
|
-
switch (
|
|
214
|
+
switch (_context4.prev = _context4.next) {
|
|
185
215
|
case 0:
|
|
186
216
|
_render = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(TriggerManager, props))), findByLabelText = _render.findByLabelText, findByTitle = _render.findByTitle;
|
|
187
|
-
|
|
217
|
+
_context4.next = 3;
|
|
188
218
|
return expect(findByLabelText('username')).resolves.toBeDefined();
|
|
189
219
|
|
|
190
220
|
case 3:
|
|
191
|
-
|
|
221
|
+
_context4.next = 5;
|
|
192
222
|
return expect(findByLabelText('passphrase')).resolves.toBeDefined();
|
|
193
223
|
|
|
194
224
|
case 5:
|
|
195
|
-
|
|
225
|
+
_context4.next = 7;
|
|
196
226
|
return expect(findByTitle('back', null, {
|
|
197
227
|
timeout: 500
|
|
198
228
|
})).rejects.toThrow();
|
|
199
229
|
|
|
200
230
|
case 7:
|
|
201
231
|
case "end":
|
|
202
|
-
return
|
|
232
|
+
return _context4.stop();
|
|
203
233
|
}
|
|
204
234
|
}
|
|
205
|
-
},
|
|
235
|
+
}, _callee4);
|
|
206
236
|
})));
|
|
207
237
|
});
|
|
208
238
|
describe('when the vaultClient is not part of the context', function () {
|
|
@@ -210,36 +240,36 @@ describe('TriggerManager', function () {
|
|
|
210
240
|
mockVaultClient.getAll.mockResolvedValue([]);
|
|
211
241
|
mockVaultClient.getAllDecrypted.mockResolvedValue([]);
|
|
212
242
|
});
|
|
213
|
-
it('should show the new account form without any warning', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
243
|
+
it('should show the new account form without any warning', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
214
244
|
var _render2, findByLabelText, findByTitle;
|
|
215
245
|
|
|
216
|
-
return _regeneratorRuntime.wrap(function
|
|
246
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
217
247
|
while (1) {
|
|
218
|
-
switch (
|
|
248
|
+
switch (_context5.prev = _context5.next) {
|
|
219
249
|
case 0:
|
|
220
250
|
findKonnectorPolicy.mockReturnValue({
|
|
221
251
|
saveInVault: false
|
|
222
252
|
});
|
|
223
253
|
_render2 = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(TriggerManager, omit(props, 'vaultClient')))), findByLabelText = _render2.findByLabelText, findByTitle = _render2.findByTitle;
|
|
224
|
-
|
|
254
|
+
_context5.next = 4;
|
|
225
255
|
return expect(findByLabelText('username')).resolves.toBeDefined();
|
|
226
256
|
|
|
227
257
|
case 4:
|
|
228
|
-
|
|
258
|
+
_context5.next = 6;
|
|
229
259
|
return expect(findByLabelText('passphrase')).resolves.toBeDefined();
|
|
230
260
|
|
|
231
261
|
case 6:
|
|
232
|
-
|
|
262
|
+
_context5.next = 8;
|
|
233
263
|
return expect(findByTitle('back', null, {
|
|
234
264
|
timeout: 500
|
|
235
265
|
})).rejects.toThrow();
|
|
236
266
|
|
|
237
267
|
case 8:
|
|
238
268
|
case "end":
|
|
239
|
-
return
|
|
269
|
+
return _context5.stop();
|
|
240
270
|
}
|
|
241
271
|
}
|
|
242
|
-
},
|
|
272
|
+
}, _callee5);
|
|
243
273
|
})));
|
|
244
274
|
});
|
|
245
275
|
describe('when the vault contains ciphers', function () {
|
|
@@ -255,27 +285,27 @@ describe('TriggerManager', function () {
|
|
|
255
285
|
}
|
|
256
286
|
}]);
|
|
257
287
|
});
|
|
258
|
-
it('should show the ciphers list', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
288
|
+
it('should show the ciphers list', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
259
289
|
var _render3, findByText, cipherItem;
|
|
260
290
|
|
|
261
|
-
return _regeneratorRuntime.wrap(function
|
|
291
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
262
292
|
while (1) {
|
|
263
|
-
switch (
|
|
293
|
+
switch (_context6.prev = _context6.next) {
|
|
264
294
|
case 0:
|
|
265
295
|
_render3 = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(TriggerManager, props))), findByText = _render3.findByText;
|
|
266
|
-
|
|
296
|
+
_context6.next = 3;
|
|
267
297
|
return findByText('Isabelle');
|
|
268
298
|
|
|
269
299
|
case 3:
|
|
270
|
-
cipherItem =
|
|
300
|
+
cipherItem = _context6.sent;
|
|
271
301
|
expect(cipherItem).toBeDefined();
|
|
272
302
|
|
|
273
303
|
case 5:
|
|
274
304
|
case "end":
|
|
275
|
-
return
|
|
305
|
+
return _context6.stop();
|
|
276
306
|
}
|
|
277
307
|
}
|
|
278
|
-
},
|
|
308
|
+
}, _callee6);
|
|
279
309
|
})));
|
|
280
310
|
describe('when selecting a cipher without password', function () {
|
|
281
311
|
beforeEach(function () {
|
|
@@ -290,31 +320,31 @@ describe('TriggerManager', function () {
|
|
|
290
320
|
}
|
|
291
321
|
}]);
|
|
292
322
|
});
|
|
293
|
-
it('should show the account form with only password field editable', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
323
|
+
it('should show the account form with only password field editable', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
294
324
|
var _render4, findByText, findByLabelText, findByTitle, cipherItem, passwordField, backButton;
|
|
295
325
|
|
|
296
|
-
return _regeneratorRuntime.wrap(function
|
|
326
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
297
327
|
while (1) {
|
|
298
|
-
switch (
|
|
328
|
+
switch (_context7.prev = _context7.next) {
|
|
299
329
|
case 0:
|
|
300
330
|
_render4 = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(TriggerManager, props))), findByText = _render4.findByText, findByLabelText = _render4.findByLabelText, findByTitle = _render4.findByTitle;
|
|
301
|
-
|
|
331
|
+
_context7.next = 3;
|
|
302
332
|
return findByText('Isabelle');
|
|
303
333
|
|
|
304
334
|
case 3:
|
|
305
|
-
cipherItem =
|
|
335
|
+
cipherItem = _context7.sent;
|
|
306
336
|
fireEvent.click(cipherItem);
|
|
307
|
-
|
|
337
|
+
_context7.next = 7;
|
|
308
338
|
return findByLabelText('passphrase');
|
|
309
339
|
|
|
310
340
|
case 7:
|
|
311
|
-
passwordField =
|
|
312
|
-
|
|
341
|
+
passwordField = _context7.sent;
|
|
342
|
+
_context7.next = 10;
|
|
313
343
|
return findByTitle('back');
|
|
314
344
|
|
|
315
345
|
case 10:
|
|
316
|
-
backButton =
|
|
317
|
-
|
|
346
|
+
backButton = _context7.sent;
|
|
347
|
+
_context7.next = 13;
|
|
318
348
|
return expect(findByLabelText('username', null, {
|
|
319
349
|
timeout: 500
|
|
320
350
|
})).rejects.toThrow();
|
|
@@ -323,15 +353,15 @@ describe('TriggerManager', function () {
|
|
|
323
353
|
expect(passwordField).toBeDefined();
|
|
324
354
|
expect(backButton).toBeDefined();
|
|
325
355
|
fireEvent.click(backButton);
|
|
326
|
-
|
|
356
|
+
_context7.next = 18;
|
|
327
357
|
return expect(findByText('Isabelle')).resolves.toBeDefined();
|
|
328
358
|
|
|
329
359
|
case 18:
|
|
330
360
|
case "end":
|
|
331
|
-
return
|
|
361
|
+
return _context7.stop();
|
|
332
362
|
}
|
|
333
363
|
}
|
|
334
|
-
},
|
|
364
|
+
}, _callee7);
|
|
335
365
|
})));
|
|
336
366
|
});
|
|
337
367
|
});
|
|
@@ -342,33 +372,33 @@ describe('TriggerManager', function () {
|
|
|
342
372
|
mockVaultClient.getAll.mockResolvedValue([]);
|
|
343
373
|
mockVaultClient.getAllDecrypted.mockResolvedValue([]);
|
|
344
374
|
});
|
|
345
|
-
it('should show the account form', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
375
|
+
it('should show the account form', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
346
376
|
var _render5, findByLabelText, usernameField, passwordField;
|
|
347
377
|
|
|
348
|
-
return _regeneratorRuntime.wrap(function
|
|
378
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
349
379
|
while (1) {
|
|
350
|
-
switch (
|
|
380
|
+
switch (_context8.prev = _context8.next) {
|
|
351
381
|
case 0:
|
|
352
382
|
_render5 = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(TriggerManager, propsWithAccount))), findByLabelText = _render5.findByLabelText;
|
|
353
|
-
|
|
383
|
+
_context8.next = 3;
|
|
354
384
|
return findByLabelText('username');
|
|
355
385
|
|
|
356
386
|
case 3:
|
|
357
|
-
usernameField =
|
|
358
|
-
|
|
387
|
+
usernameField = _context8.sent;
|
|
388
|
+
_context8.next = 6;
|
|
359
389
|
return findByLabelText('passphrase');
|
|
360
390
|
|
|
361
391
|
case 6:
|
|
362
|
-
passwordField =
|
|
392
|
+
passwordField = _context8.sent;
|
|
363
393
|
expect(usernameField).toBeDefined();
|
|
364
394
|
expect(passwordField).toBeDefined();
|
|
365
395
|
|
|
366
396
|
case 9:
|
|
367
397
|
case "end":
|
|
368
|
-
return
|
|
398
|
+
return _context8.stop();
|
|
369
399
|
}
|
|
370
400
|
}
|
|
371
|
-
},
|
|
401
|
+
}, _callee8);
|
|
372
402
|
})));
|
|
373
403
|
});
|
|
374
404
|
describe('when the vault does not contain ciphers', function () {
|
|
@@ -384,33 +414,33 @@ describe('TriggerManager', function () {
|
|
|
384
414
|
}
|
|
385
415
|
}]);
|
|
386
416
|
});
|
|
387
|
-
it('should show the account form', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
417
|
+
it('should show the account form', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
388
418
|
var _render6, findByLabelText, usernameField, passwordField;
|
|
389
419
|
|
|
390
|
-
return _regeneratorRuntime.wrap(function
|
|
420
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
391
421
|
while (1) {
|
|
392
|
-
switch (
|
|
422
|
+
switch (_context9.prev = _context9.next) {
|
|
393
423
|
case 0:
|
|
394
424
|
_render6 = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(TriggerManager, propsWithAccount))), findByLabelText = _render6.findByLabelText;
|
|
395
|
-
|
|
425
|
+
_context9.next = 3;
|
|
396
426
|
return findByLabelText('username');
|
|
397
427
|
|
|
398
428
|
case 3:
|
|
399
|
-
usernameField =
|
|
400
|
-
|
|
429
|
+
usernameField = _context9.sent;
|
|
430
|
+
_context9.next = 6;
|
|
401
431
|
return findByLabelText('passphrase');
|
|
402
432
|
|
|
403
433
|
case 6:
|
|
404
|
-
passwordField =
|
|
434
|
+
passwordField = _context9.sent;
|
|
405
435
|
expect(usernameField).toBeDefined();
|
|
406
436
|
expect(passwordField).toBeDefined();
|
|
407
437
|
|
|
408
438
|
case 9:
|
|
409
439
|
case "end":
|
|
410
|
-
return
|
|
440
|
+
return _context9.stop();
|
|
411
441
|
}
|
|
412
442
|
}
|
|
413
|
-
},
|
|
443
|
+
}, _callee9);
|
|
414
444
|
})));
|
|
415
445
|
});
|
|
416
446
|
});
|
|
@@ -421,8 +451,8 @@ describe('TriggerManager', function () {
|
|
|
421
451
|
});
|
|
422
452
|
|
|
423
453
|
var setupForm = /*#__PURE__*/function () {
|
|
424
|
-
var
|
|
425
|
-
var
|
|
454
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
455
|
+
var _ref11,
|
|
426
456
|
account,
|
|
427
457
|
flow,
|
|
428
458
|
utils,
|
|
@@ -431,13 +461,13 @@ describe('TriggerManager', function () {
|
|
|
431
461
|
identifierInput,
|
|
432
462
|
passphraseInput,
|
|
433
463
|
submitButton,
|
|
434
|
-
|
|
464
|
+
_args10 = arguments;
|
|
435
465
|
|
|
436
|
-
return _regeneratorRuntime.wrap(function
|
|
466
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
437
467
|
while (1) {
|
|
438
|
-
switch (
|
|
468
|
+
switch (_context10.prev = _context10.next) {
|
|
439
469
|
case 0:
|
|
440
|
-
|
|
470
|
+
_ref11 = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {}, account = _ref11.account;
|
|
441
471
|
flow = new ConnectionFlow(client);
|
|
442
472
|
jest.spyOn(flow, 'handleFormSubmit').mockImplementation(function () {});
|
|
443
473
|
utils = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(TriggerManager, _extends({}, props, {
|
|
@@ -447,24 +477,24 @@ describe('TriggerManager', function () {
|
|
|
447
477
|
// if data-test-id were supported by Field
|
|
448
478
|
// See https://github.com/cozy/cozy-ui/issues/1387
|
|
449
479
|
|
|
450
|
-
|
|
480
|
+
_context10.next = 6;
|
|
451
481
|
return utils.findByLabelText('username');
|
|
452
482
|
|
|
453
483
|
case 6:
|
|
454
|
-
identifierLabel =
|
|
455
|
-
|
|
484
|
+
identifierLabel = _context10.sent;
|
|
485
|
+
_context10.next = 9;
|
|
456
486
|
return utils.findByLabelText('passphrase');
|
|
457
487
|
|
|
458
488
|
case 9:
|
|
459
|
-
passphraseLabel =
|
|
489
|
+
passphraseLabel = _context10.sent;
|
|
460
490
|
identifierInput = identifierLabel.nextElementSibling;
|
|
461
491
|
passphraseInput = passphraseLabel.nextElementSibling instanceof HTMLInputElement ? passphraseLabel.nextElementSibling : passphraseLabel.nextElementSibling.nextElementSibling;
|
|
462
|
-
|
|
492
|
+
_context10.next = 14;
|
|
463
493
|
return utils.findByText('Connect');
|
|
464
494
|
|
|
465
495
|
case 14:
|
|
466
|
-
submitButton =
|
|
467
|
-
return
|
|
496
|
+
submitButton = _context10.sent;
|
|
497
|
+
return _context10.abrupt("return", _objectSpread({
|
|
468
498
|
flow: flow,
|
|
469
499
|
identifierLabel: identifierLabel,
|
|
470
500
|
passphraseLabel: passphraseLabel,
|
|
@@ -475,30 +505,30 @@ describe('TriggerManager', function () {
|
|
|
475
505
|
|
|
476
506
|
case 16:
|
|
477
507
|
case "end":
|
|
478
|
-
return
|
|
508
|
+
return _context10.stop();
|
|
479
509
|
}
|
|
480
510
|
}
|
|
481
|
-
},
|
|
511
|
+
}, _callee10);
|
|
482
512
|
}));
|
|
483
513
|
|
|
484
514
|
return function setupForm() {
|
|
485
|
-
return
|
|
515
|
+
return _ref10.apply(this, arguments);
|
|
486
516
|
};
|
|
487
517
|
}();
|
|
488
518
|
|
|
489
519
|
describe('when no account is passed in props', function () {
|
|
490
|
-
it('should correctly send the form', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
520
|
+
it('should correctly send the form', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
491
521
|
var _yield$setupForm, flow, identifierInput, passphraseInput, submitButton;
|
|
492
522
|
|
|
493
|
-
return _regeneratorRuntime.wrap(function
|
|
523
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
494
524
|
while (1) {
|
|
495
|
-
switch (
|
|
525
|
+
switch (_context11.prev = _context11.next) {
|
|
496
526
|
case 0:
|
|
497
|
-
|
|
527
|
+
_context11.next = 2;
|
|
498
528
|
return setupForm();
|
|
499
529
|
|
|
500
530
|
case 2:
|
|
501
|
-
_yield$setupForm =
|
|
531
|
+
_yield$setupForm = _context11.sent;
|
|
502
532
|
flow = _yield$setupForm.flow;
|
|
503
533
|
identifierInput = _yield$setupForm.identifierInput;
|
|
504
534
|
passphraseInput = _yield$setupForm.passphraseInput;
|
|
@@ -524,19 +554,19 @@ describe('TriggerManager', function () {
|
|
|
524
554
|
|
|
525
555
|
case 11:
|
|
526
556
|
case "end":
|
|
527
|
-
return
|
|
557
|
+
return _context11.stop();
|
|
528
558
|
}
|
|
529
559
|
}
|
|
530
|
-
},
|
|
560
|
+
}, _callee11);
|
|
531
561
|
})));
|
|
532
562
|
});
|
|
533
563
|
describe('when an account is passed in props', function () {
|
|
534
|
-
it('should correctly send the form', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
564
|
+
it('should correctly send the form', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
535
565
|
var account, _yield$setupForm2, flow, identifierInput, passphraseInput, submitButton;
|
|
536
566
|
|
|
537
|
-
return _regeneratorRuntime.wrap(function
|
|
567
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
538
568
|
while (1) {
|
|
539
|
-
switch (
|
|
569
|
+
switch (_context12.prev = _context12.next) {
|
|
540
570
|
case 0:
|
|
541
571
|
account = {
|
|
542
572
|
auth: {
|
|
@@ -544,13 +574,13 @@ describe('TriggerManager', function () {
|
|
|
544
574
|
passphrase: 'my-old-passphrase'
|
|
545
575
|
}
|
|
546
576
|
};
|
|
547
|
-
|
|
577
|
+
_context12.next = 3;
|
|
548
578
|
return setupForm({
|
|
549
579
|
account: account
|
|
550
580
|
});
|
|
551
581
|
|
|
552
582
|
case 3:
|
|
553
|
-
_yield$setupForm2 =
|
|
583
|
+
_yield$setupForm2 = _context12.sent;
|
|
554
584
|
flow = _yield$setupForm2.flow;
|
|
555
585
|
identifierInput = _yield$setupForm2.identifierInput;
|
|
556
586
|
passphraseInput = _yield$setupForm2.passphraseInput;
|
|
@@ -577,10 +607,10 @@ describe('TriggerManager', function () {
|
|
|
577
607
|
|
|
578
608
|
case 12:
|
|
579
609
|
case "end":
|
|
580
|
-
return
|
|
610
|
+
return _context12.stop();
|
|
581
611
|
}
|
|
582
612
|
}
|
|
583
|
-
},
|
|
613
|
+
}, _callee12);
|
|
584
614
|
})));
|
|
585
615
|
});
|
|
586
616
|
});
|