cozy-harvest-lib 22.0.7 → 22.0.8

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 CHANGED
@@ -3,6 +3,17 @@
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
+ ## [22.0.8](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@22.0.7...cozy-harvest-lib@22.0.8) (2024-01-23)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * No more disabled submit button on 2nd 2FA ([7bdd26c](https://github.com/cozy/cozy-libs/commit/7bdd26c381f8883ea007fafb5515bb8625da67a1))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [22.0.7](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@22.0.6...cozy-harvest-lib@22.0.7) (2024-01-17)
7
18
 
8
19
 
@@ -69,7 +69,7 @@ export var TwoFAModal = /*#__PURE__*/function (_PureComponent) {
69
69
  var flowState = this.props.flow.getState();
70
70
  this.setState({
71
71
  hasErrored: flowState.twoFARetry,
72
- isJobRunning: flowState.twoFARunning || flowState.konnectorRunning
72
+ isJobRunning: flowState.twoFARunning
73
73
  });
74
74
  }
75
75
  }, {
@@ -1,4 +1,6 @@
1
- import { render, fireEvent } from '@testing-library/react';
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import { render, fireEvent, waitFor } from '@testing-library/react';
2
4
  import React from 'react';
3
5
  import TwoFAModal from './TwoFAModal';
4
6
  import AppLike from '../../test/AppLike';
@@ -91,41 +93,77 @@ describe('TwoFAModal', function () {
91
93
  expect(root.queryByPlaceholderText('')).toBeFalsy();
92
94
  expect(root.getByText("You need to open your provider's app to confirm your authentication. In some cases, you will have to validate two times."));
93
95
  });
94
- it('should work for several two fa requests', function () {
95
- var opts = {
96
- account: {
97
- state: 'TWO_FA_NEEDED.SMS'
98
- },
99
- konnectorSlug: 'boursoma83'
100
- };
101
-
102
- var _setup3 = setup(opts),
103
- root = _setup3.root,
104
- flow = _setup3.flow;
105
-
106
- var input = root.getByPlaceholderText('');
107
- expect(input).toBeTruthy(); // expect(inp.length).toBe(1)
108
- // expect((root)).toBe('')
109
-
110
- expect(root.getByText('This code enables you to finish your connexion.')).toBeTruthy();
111
- expect(root.getByText('code')).toBeTruthy();
112
- fireEvent.change(input, {
113
- target: {
114
- value: 'abcd'
96
+ it('should work for several two fa requests', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
97
+ var opts, _setup3, root, flow, input, button, input2, input3;
98
+
99
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
100
+ while (1) {
101
+ switch (_context.prev = _context.next) {
102
+ case 0:
103
+ opts = {
104
+ account: {
105
+ state: 'TWO_FA_NEEDED.SMS'
106
+ },
107
+ konnectorSlug: 'boursoma83'
108
+ };
109
+ _setup3 = setup(opts), root = _setup3.root, flow = _setup3.flow;
110
+ input = root.getByPlaceholderText('');
111
+ expect(input).toBeTruthy(); // expect(inp.length).toBe(1)
112
+ // expect((root)).toBe('')
113
+
114
+ expect(root.getByText('This code enables you to finish your connexion.')).toBeTruthy();
115
+ expect(root.getByText('code')).toBeTruthy();
116
+ fireEvent.change(input, {
117
+ target: {
118
+ value: 'abcd'
119
+ }
120
+ });
121
+ button = root.getByText('Validate').closest('button');
122
+ expect(button.getAttribute('aria-disabled')).toBe(null);
123
+ fireEvent.click(button); // 2nd 2FA request
124
+
125
+ flow.emit('twoFARequest');
126
+ expect(getInputValue(root)).toBe('');
127
+ expect(root.getByText('The second code received on your mobile phone or by email enables you to finalize your connexion.')).toBeTruthy();
128
+ expect(root.getByText('Second code')).toBeTruthy();
129
+ input2 = root.getByPlaceholderText('');
130
+ fireEvent.change(input2, {
131
+ target: {
132
+ value: 'abcd'
133
+ }
134
+ });
135
+ _context.next = 18;
136
+ return waitFor(function () {
137
+ return expect(root.getByText('Validate').closest('button').getAttribute('aria-disabled')).toBe(null);
138
+ });
139
+
140
+ case 18:
141
+ flow.emit('twoFARequest'); // 3rd 2FA (should not happen, hypothetical case)
142
+
143
+ flow.emit('twoFARequest');
144
+ expect(getInputValue(root)).toBe('');
145
+ input3 = root.getByPlaceholderText('');
146
+ fireEvent.change(input3, {
147
+ target: {
148
+ value: 'abcd'
149
+ }
150
+ });
151
+ _context.next = 25;
152
+ return waitFor(function () {
153
+ return expect(root.getByText('Validate').closest('button').getAttribute('aria-disabled')).toBe(null);
154
+ });
155
+
156
+ case 25:
157
+ // First attempt translations are re-used
158
+ expect(root.getByText('This code enables you to finish your connexion.')).toBeTruthy();
159
+ expect(root.getByText('code (4)')).toBeTruthy();
160
+ flow.emit('twoFARequest');
161
+
162
+ case 28:
163
+ case "end":
164
+ return _context.stop();
165
+ }
115
166
  }
116
- }); // 2nd 2FA request
117
-
118
- flow.emit('twoFARequest');
119
- expect(getInputValue(root)).toBe('');
120
- expect(root.getByText('The second code received on your mobile phone or by email enables you to finalize your connexion.')).toBeTruthy();
121
- expect(root.getByText('Second code')).toBeTruthy();
122
- flow.emit('twoFARequest'); // 3rd 2FA (should not happen, hypothetical case)
123
-
124
- flow.emit('twoFARequest');
125
- expect(getInputValue(root)).toBe(''); // First attempt translations are re-used
126
-
127
- expect(root.getByText('This code enables you to finish your connexion.')).toBeTruthy();
128
- expect(root.getByText('code (4)')).toBeTruthy();
129
- flow.emit('twoFARequest');
130
- });
167
+ }, _callee);
168
+ })));
131
169
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-harvest-lib",
3
- "version": "22.0.7",
3
+ "version": "22.0.8",
4
4
  "description": "Provides logic, modules and components for Cozy's harvest applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -106,5 +106,5 @@
106
106
  "react-router-dom": ">=4.3.1"
107
107
  },
108
108
  "sideEffects": false,
109
- "gitHead": "e96e3f59e027dc5c55614bbe1877b0b7a527b076"
109
+ "gitHead": "7eb1353edacb3d79bed197c198651f8c685c2fdf"
110
110
  }
@@ -47,7 +47,7 @@ export class TwoFAModal extends PureComponent {
47
47
  const flowState = this.props.flow.getState()
48
48
  this.setState({
49
49
  hasErrored: flowState.twoFARetry,
50
- isJobRunning: flowState.twoFARunning || flowState.konnectorRunning
50
+ isJobRunning: flowState.twoFARunning
51
51
  })
52
52
  }
53
53
 
@@ -1,4 +1,4 @@
1
- import { render, fireEvent } from '@testing-library/react'
1
+ import { render, fireEvent, waitFor } from '@testing-library/react'
2
2
  import React from 'react'
3
3
 
4
4
  import TwoFAModal from './TwoFAModal'
@@ -82,7 +82,7 @@ describe('TwoFAModal', () => {
82
82
  )
83
83
  })
84
84
 
85
- it('should work for several two fa requests', () => {
85
+ it('should work for several two fa requests', async () => {
86
86
  const opts = {
87
87
  account: {
88
88
  state: 'TWO_FA_NEEDED.SMS'
@@ -103,6 +103,9 @@ describe('TwoFAModal', () => {
103
103
  expect(root.getByText('code')).toBeTruthy()
104
104
 
105
105
  fireEvent.change(input, { target: { value: 'abcd' } })
106
+ const button = root.getByText('Validate').closest('button')
107
+ expect(button.getAttribute('aria-disabled')).toBe(null)
108
+ fireEvent.click(button)
106
109
 
107
110
  // 2nd 2FA request
108
111
  flow.emit('twoFARequest')
@@ -115,12 +118,32 @@ describe('TwoFAModal', () => {
115
118
  ).toBeTruthy()
116
119
 
117
120
  expect(root.getByText('Second code')).toBeTruthy()
121
+ const input2 = root.getByPlaceholderText('')
122
+ fireEvent.change(input2, { target: { value: 'abcd' } })
123
+ await waitFor(() =>
124
+ expect(
125
+ root
126
+ .getByText('Validate')
127
+ .closest('button')
128
+ .getAttribute('aria-disabled')
129
+ ).toBe(null)
130
+ )
118
131
  flow.emit('twoFARequest')
119
132
 
120
133
  // 3rd 2FA (should not happen, hypothetical case)
121
134
  flow.emit('twoFARequest')
122
135
 
123
136
  expect(getInputValue(root)).toBe('')
137
+ const input3 = root.getByPlaceholderText('')
138
+ fireEvent.change(input3, { target: { value: 'abcd' } })
139
+ await waitFor(() =>
140
+ expect(
141
+ root
142
+ .getByText('Validate')
143
+ .closest('button')
144
+ .getAttribute('aria-disabled')
145
+ ).toBe(null)
146
+ )
124
147
  // First attempt translations are re-used
125
148
  expect(
126
149
  root.getByText('This code enables you to finish your connexion.')