auth0-lock 14.3.0 → 15.0.1

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 (54) hide show
  1. package/.github/workflows/codeql.yml +1 -1
  2. package/.github/workflows/npm-release.yml +1 -1
  3. package/.github/workflows/snyk.yml +1 -1
  4. package/.github/workflows/test.yml +2 -2
  5. package/.husky/pre-commit +4 -0
  6. package/.version +1 -1
  7. package/CHANGELOG.md +28 -0
  8. package/README.md +1 -1
  9. package/lib/__tests__/auth_button.js +21 -6
  10. package/lib/__tests__/connection/database/login_pane.js +12 -5
  11. package/lib/__tests__/connection/database/reset_password.js +15 -12
  12. package/lib/__tests__/connection/enterprise/hrd_pane.js +16 -6
  13. package/lib/__tests__/connection/enterprise/hrd_screen.js +27 -18
  14. package/lib/__tests__/connection/passwordless/ask_vcode.js +15 -7
  15. package/lib/__tests__/core/sso/last_login_screen.js +91 -40
  16. package/lib/__tests__/engine/classic/mfa_login_screen.js +9 -3
  17. package/lib/__tests__/engine/classic/sign_up_pane.js +16 -6
  18. package/lib/__tests__/engine/classic/sign_up_screen.js +0 -1
  19. package/lib/__tests__/field/captcha/arkose.js +7 -0
  20. package/lib/__tests__/field/captcha/auth0_v2.js +6 -0
  21. package/lib/__tests__/field/captcha/friendlyCaptcha.js +6 -0
  22. package/lib/__tests__/field/captcha/hcaptcha.js +6 -0
  23. package/lib/__tests__/field/captcha/recaptcha_enterprise.js +6 -0
  24. package/lib/__tests__/field/captcha/recaptchav2.js +6 -0
  25. package/lib/__tests__/field/captcha/third_party_captcha.js +97 -64
  26. package/lib/__tests__/field/captcha.js +76 -143
  27. package/lib/__tests__/field/custom_input.js +7 -5
  28. package/lib/__tests__/field/email_pane.js +27 -11
  29. package/lib/__tests__/field/login_pane.js +6 -3
  30. package/lib/__tests__/field/mfa_code_pane.js +13 -6
  31. package/lib/__tests__/field/option_selection_pane.js +17 -7
  32. package/lib/__tests__/field/password_pane.js +8 -10
  33. package/lib/__tests__/field/phone_number_pane.js +7 -5
  34. package/lib/__tests__/field/social_buttons_pane.js +12 -9
  35. package/lib/__tests__/field/username_pane.js +33 -14
  36. package/lib/__tests__/field/vcode_pane.js +9 -5
  37. package/lib/__tests__/setup-tests.js +1 -7
  38. package/lib/__tests__/testUtils.js +27 -42
  39. package/lib/__tests__/ui/box/global_message.js +75 -42
  40. package/lib/__tests__/ui/input/email_input.js +4 -4
  41. package/lib/__tests__/ui/input/password/password_strength.js +8 -7
  42. package/lib/__tests__/ui/input/password_input.js +18 -14
  43. package/lib/avatar/gravatar_provider.js +1 -2
  44. package/lib/connection/database/index.js +1 -2
  45. package/lib/core/index.js +1 -2
  46. package/lib/core/web_api/helper.js +1 -1
  47. package/lib/field/email.js +1 -2
  48. package/lib/field/index.js +4 -5
  49. package/lib/field/mfa_code.js +1 -3
  50. package/lib/field/username.js +2 -4
  51. package/lib/i18n.js +1 -1
  52. package/lib/lock.js +1 -1
  53. package/lib/passwordless.js +1 -1
  54. package/package.json +13 -10
@@ -37,7 +37,7 @@ jobs:
37
37
  run: exit 0 # Skip unnecessary test runs for dependabot and merge queues. Artifically flag as successful, as this is a required check for branch protection.
38
38
 
39
39
  - name: Checkout
40
- uses: actions/checkout@v6
40
+ uses: actions/checkout@v7
41
41
 
42
42
  - name: Initialize CodeQL
43
43
  uses: github/codeql-action/init@v4
@@ -30,7 +30,7 @@ jobs:
30
30
 
31
31
  steps:
32
32
  # Checkout the code
33
- - uses: actions/checkout@v6
33
+ - uses: actions/checkout@v7
34
34
  with:
35
35
  fetch-depth: 0
36
36
 
@@ -29,7 +29,7 @@ jobs:
29
29
  - if: github.actor == 'dependabot[bot]' || github.event_name == 'merge_group'
30
30
  run: exit 0 # Skip unnecessary test runs for dependabot and merge queues. Artifically flag as successful, as this is a required check for branch protection.
31
31
 
32
- - uses: actions/checkout@v6
32
+ - uses: actions/checkout@v7
33
33
  with:
34
34
  ref: ${{ github.event.pull_request.head.sha || github.ref }}
35
35
 
@@ -25,7 +25,7 @@ jobs:
25
25
 
26
26
  steps:
27
27
  - name: Checkout code
28
- uses: actions/checkout@v6
28
+ uses: actions/checkout@v7
29
29
  with:
30
30
  ref: ${{ github.event.pull_request.head.sha || github.ref }}
31
31
 
@@ -56,4 +56,4 @@ jobs:
56
56
  run: npm run test:e2e
57
57
 
58
58
  - name: Upload coverage
59
- uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # pin@5.5.3
59
+ uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # pin@7.0.0
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ ./node_modules/.bin/lint-staged
package/.version CHANGED
@@ -1 +1 @@
1
- v14.3.0
1
+ v15.0.1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Change Log
2
2
 
3
+ ## [v15.0.1](https://github.com/auth0/lock/tree/v15.0.1) (2026-06-30)
4
+ [Full Changelog](https://github.com/auth0/lock/compare/v15.0.0...v15.0.1)
5
+
6
+ **Added**
7
+ - fix: add react19 support [\#2818](https://github.com/auth0/lock/pull/2818) ([jd3vi1](https://github.com/jd3vi1))
8
+
9
+ ## [v15.0.0](https://github.com/auth0/lock/tree/v15.0.0) (2026-06-05)
10
+ [Full Changelog](https://github.com/auth0/lock/compare/v14.3.0...v15.0.0)
11
+
12
+ ### Highlights
13
+
14
+ This release upgrades `auth0-js` to [v10.0.0](https://github.com/auth0/auth0.js/releases/tag/v10.0.0), which resolves [CVE-2026-42280](https://www.cve.org/CVERecord?id=CVE-2026-42280) — a security vulnerability in token validation for browser-based applications.
15
+
16
+ **⚠️ Breaking Changes**
17
+
18
+ - feat!: upgrade auth0-js from v9 to v10 [\#2810](https://github.com/auth0/lock/pull/2810) ([cschetan77](https://github.com/cschetan77))
19
+
20
+ **HS256 is no longer supported.** Applications configured with HS256 as the JWT Signature Algorithm will see `parseHash()` return an `invalid_token` error. HS256 requires the client secret to be present in the browser to verify tokens, which is a security vulnerability. Applications using RS256 are not affected.
21
+
22
+ **Migration:** Switch to RS256 before upgrading:
23
+ > Auth0 Dashboard → Applications → [Your App] → Settings → Advanced Settings → OAuth → JsonWebToken Signature Algorithm → **RS256**
24
+
25
+ **Changed**
26
+
27
+ - fix(deps): remove `trim` dependency [\#2783](https://github.com/auth0/lock/pull/2783) ([gameroman](https://github.com/gameroman))
28
+
29
+ The third-party `trim` package has been removed. All string trimming now uses the native `String.prototype.trim()` method, which has been available in all supported browsers and Node.js versions for many years. This removes one dependency from the shipped package with no change in behaviour.
30
+
3
31
  ## [v14.3.0](https://github.com/auth0/lock/tree/v14.3.0) (2026-04-06)
4
32
  [Full Changelog](https://github.com/auth0/lock/compare/v14.2.5...v14.3.0)
5
33
 
package/README.md CHANGED
@@ -31,7 +31,7 @@ From CDN
31
31
 
32
32
  ```html
33
33
  <!-- Latest patch release (recommended for production) -->
34
- <script src="https://cdn.auth0.com/js/lock/14.3.0/lock.min.js"></script>
34
+ <script src="https://cdn.auth0.com/js/lock/15.0.1/lock.min.js"></script>
35
35
  ```
36
36
 
37
37
  ### Configure Auth0
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _react = _interopRequireDefault(require("react"));
4
- var _enzyme = require("enzyme");
4
+ var _react2 = require("@testing-library/react");
5
+ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
5
6
  var _testUtils = require("testUtils");
6
7
  var _auth_button = _interopRequireDefault(require("ui/button/auth_button"));
7
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
10
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
11
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
12
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
8
13
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
9
14
  describe('AuthButton', function () {
10
15
  var defaultProps = {
@@ -22,9 +27,19 @@ describe('AuthButton', function () {
22
27
  foregroundColor: "foregroundColor"
23
28
  }))).toMatchSnapshot();
24
29
  });
25
- it('should trigger onClick when clicked', function () {
26
- var wrapper = (0, _enzyme.mount)(/*#__PURE__*/_react.default.createElement(_auth_button.default, defaultProps));
27
- wrapper.find('a').simulate('click');
28
- expect(defaultProps.onClick.mock.calls.length).toBe(1);
29
- });
30
+ it('should trigger onClick when clicked', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
31
+ var _render, container;
32
+ return _regenerator().w(function (_context) {
33
+ while (1) switch (_context.n) {
34
+ case 0:
35
+ _render = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_auth_button.default, defaultProps)), container = _render.container;
36
+ _context.n = 1;
37
+ return _userEvent.default.click(container.querySelector('a'));
38
+ case 1:
39
+ expect(defaultProps.onClick.mock.calls.length).toBe(1);
40
+ case 2:
41
+ return _context.a(2);
42
+ }
43
+ }, _callee);
44
+ })));
30
45
  });
@@ -19,7 +19,14 @@ describe('LoginPane', function () {
19
19
  var defaultProps = {
20
20
  emailInputPlaceholder: '',
21
21
  forgotPasswordAction: '',
22
- i18n: {},
22
+ i18n: {
23
+ str: function str() {
24
+ return '';
25
+ },
26
+ html: function html() {
27
+ return null;
28
+ }
29
+ },
23
30
  passwordInputPlaceholder: '',
24
31
  showForgotPasswordLink: true,
25
32
  showPassword: true,
@@ -33,7 +40,7 @@ describe('LoginPane', function () {
33
40
  return _regenerator().w(function (_context) {
34
41
  while (1) switch (_context.n) {
35
42
  case 0:
36
- (0, _testUtils.expectShallowComponent)(/*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
43
+ (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
37
44
  case 1:
38
45
  return _context.a(2);
39
46
  }
@@ -45,7 +52,7 @@ describe('LoginPane', function () {
45
52
  return true;
46
53
  }
47
54
  });
48
- (0, _testUtils.expectShallowComponent)(/*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
55
+ (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
49
56
  });
50
57
  it('hides the captcha for SSO connections', function () {
51
58
  require('core/index').captcha.mockReturnValue({
@@ -54,7 +61,7 @@ describe('LoginPane', function () {
54
61
  }
55
62
  });
56
63
  require('engine/classic').isSSOEnabled.mockReturnValue(true);
57
- (0, _testUtils.expectShallowComponent)(/*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
64
+ (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
58
65
  });
59
66
  it('shows the captcha for SSO (ADFS) connections', function () {
60
67
  require('core/index').captcha.mockReturnValue({
@@ -64,6 +71,6 @@ describe('LoginPane', function () {
64
71
  });
65
72
  require('engine/classic').isSSOEnabled.mockReturnValue(true);
66
73
  require('connection/enterprise').isHRDDomain.mockReturnValue(true);
67
- (0, _testUtils.expectShallowComponent)(/*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
74
+ (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
68
75
  });
69
76
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _react = _interopRequireDefault(require("react"));
4
+ var _react2 = require("@testing-library/react");
4
5
  var _testUtils = require("testUtils");
5
6
  var _immutable = _interopRequireDefault(require("immutable"));
6
7
  var _field = require("../../../field");
@@ -104,13 +105,14 @@ describe('ResetPasswordScreen', function () {
104
105
  });
105
106
  var store = require('store/index');
106
107
  var Component = getComponent();
107
-
108
- // Set a field on Lock to set the username field, then check it was set as the email
109
108
  var l = (0, _field.setField)(lock, 'username', 'test@test.com');
110
- (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(Component, {
111
- i18n: i18n,
112
- model: l
113
- })).toMatchSnapshot();
109
+ var _render = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, {
110
+ i18n: i18n,
111
+ model: l
112
+ })),
113
+ container = _render.container;
114
+ var props = (0, _testUtils.getMockProps)(container.querySelector('[data-__type="reset_password_pane"]'));
115
+ expect(props.lock).toBe(l);
114
116
  expect(store.swap).toHaveBeenCalledWith('updateEntity', 'lock', 'id', expect.anything(), 'test@test.com', false);
115
117
  });
116
118
  it('sets the email field to a blank value if username is not an email address', function () {
@@ -121,13 +123,14 @@ describe('ResetPasswordScreen', function () {
121
123
  });
122
124
  var store = require('store/index');
123
125
  var Component = getComponent();
124
-
125
- // Set a field on Lock to set the username field, then check it was set as the email
126
126
  var l = (0, _field.setField)(lock, 'username', 'some-username');
127
- (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(Component, {
128
- i18n: i18n,
129
- model: l
130
- })).toMatchSnapshot();
127
+ var _render2 = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, {
128
+ i18n: i18n,
129
+ model: l
130
+ })),
131
+ container = _render2.container;
132
+ var props = (0, _testUtils.getMockProps)(container.querySelector('[data-__type="reset_password_pane"]'));
133
+ expect(props.lock).toBe(l);
131
134
  expect(store.swap).toHaveBeenCalledWith('updateEntity', 'lock', 'id', expect.anything(), '', false);
132
135
  });
133
136
  });
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
3
  var _react = _interopRequireDefault(require("react"));
5
4
  var _testUtils = require("testUtils");
6
5
  var _immutable = _interopRequireDefault(require("immutable"));
7
- var i18n = _interopRequireWildcard(require("../../../i18n"));
8
6
  var _hrd_pane = _interopRequireDefault(require("../../../connection/enterprise/hrd_pane"));
9
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
10
7
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
8
  var lock = _immutable.default.fromJS({
12
9
  id: '__lock-id__'
@@ -16,7 +13,20 @@ describe('HRDPane', function () {
16
13
  var defaultProps = {
17
14
  model: lock,
18
15
  header: /*#__PURE__*/_react.default.createElement("header", null),
19
- i18n: i18n,
16
+ i18n: {
17
+ str: function str() {
18
+ for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
19
+ keys[_key] = arguments[_key];
20
+ }
21
+ return keys.join(',');
22
+ },
23
+ html: function html() {
24
+ for (var _len2 = arguments.length, keys = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
25
+ keys[_key2] = arguments[_key2];
26
+ }
27
+ return keys.join(',');
28
+ }
29
+ },
20
30
  passwordInputPlaceholder: 'password',
21
31
  usernameInputPlaceholder: 'username'
22
32
  };
@@ -24,7 +34,7 @@ describe('HRDPane', function () {
24
34
  jest.resetAllMocks();
25
35
  });
26
36
  it('renders correctly', function () {
27
- (0, _testUtils.expectShallowComponent)(/*#__PURE__*/_react.default.createElement(_hrd_pane.default, defaultProps)).toMatchSnapshot();
37
+ (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(_hrd_pane.default, defaultProps)).toMatchSnapshot();
28
38
  });
29
39
  it('renders the captcha if required', function () {
30
40
  require('core/index').captcha.mockReturnValue({
@@ -32,6 +42,6 @@ describe('HRDPane', function () {
32
42
  return true;
33
43
  }
34
44
  });
35
- (0, _testUtils.expectShallowComponent)(/*#__PURE__*/_react.default.createElement(_hrd_pane.default, defaultProps)).toMatchSnapshot();
45
+ (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(_hrd_pane.default, defaultProps)).toMatchSnapshot();
36
46
  });
37
47
  });
@@ -2,6 +2,7 @@
2
2
 
3
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
4
  var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
5
6
  var _testUtils = require("testUtils");
6
7
  var _immutable = _interopRequireDefault(require("immutable"));
7
8
  var _data_utils = require("../../../utils/data_utils");
@@ -26,6 +27,11 @@ var getComponent = function getComponent() {
26
27
  var screen = new HRDScreen();
27
28
  return screen.render();
28
29
  };
30
+ var renderAndGetProps = function renderAndGetProps(Component, props) {
31
+ var _render = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, props)),
32
+ container = _render.container;
33
+ return (0, _testUtils.getMockProps)(container.querySelector('[data-__type="hrd_pane"]'));
34
+ };
29
35
  describe('HRDScreen Component', function () {
30
36
  var i18nProp;
31
37
  var lock;
@@ -48,32 +54,36 @@ describe('HRDScreen Component', function () {
48
54
  }
49
55
  };
50
56
  });
51
- it('renders correctly when there is an enterprise domain', function () {
57
+ it('passes domain-specific header when enterprise domain is present', function () {
52
58
  var Component = getComponent();
53
- (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(Component, {
59
+ var props = renderAndGetProps(Component, {
54
60
  model: lock,
55
61
  i18n: i18nProp
56
- })).toMatchSnapshot();
62
+ });
63
+ expect(props.header).not.toBeNull();
64
+ expect(props.header.props.children).toContain('domain.com');
57
65
  });
58
- it('renders correctly when there is no enterprise domain', function () {
66
+ it('passes fallback header when there is no enterprise domain', function () {
59
67
  require('connection/enterprise').enterpriseDomain.mockImplementation(function () {
60
68
  return null;
61
69
  });
62
70
  var Component = getComponent();
63
- (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(Component, {
71
+ var props = renderAndGetProps(Component, {
64
72
  model: lock,
65
73
  i18n: i18nProp
66
- })).toMatchSnapshot();
74
+ });
75
+ expect(props.header.props.children).toContain('Login with your corporate credentials.');
67
76
  });
68
- it('renders correctly when enterprise domain is undefined', function () {
77
+ it('passes fallback header when enterprise domain is undefined', function () {
69
78
  require('connection/enterprise').enterpriseDomain.mockImplementation(function () {
70
79
  return undefined;
71
80
  });
72
81
  var Component = getComponent();
73
- (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(Component, {
82
+ var props = renderAndGetProps(Component, {
74
83
  model: lock,
75
84
  i18n: i18nProp
76
- })).toMatchSnapshot();
85
+ });
86
+ expect(props.header.props.children).toContain('Login with your corporate credentials.');
77
87
  });
78
88
  it('does not show "undefined" in message when enterprise domain is undefined', function () {
79
89
  require('connection/enterprise').enterpriseDomain.mockImplementation(function () {
@@ -81,8 +91,6 @@ describe('HRDScreen Component', function () {
81
91
  });
82
92
  var _i18nProp = i18nProp,
83
93
  str = _i18nProp.str;
84
-
85
- // Should use the fallback message without domain placeholder
86
94
  var expectedMessage = str('enterpriseLoginIntructions');
87
95
  expect(expectedMessage).toContain('Login with your corporate credentials.');
88
96
  expect(expectedMessage).not.toContain('undefined');
@@ -93,29 +101,30 @@ describe('HRDScreen Component', function () {
93
101
  });
94
102
  var _i18nProp2 = i18nProp,
95
103
  str = _i18nProp2.str;
96
- // Should use the fallback message without domain placeholder
97
104
  var expectedMessage = str('enterpriseLoginIntructions');
98
105
  expect(expectedMessage).toContain('Login with your corporate credentials.');
99
106
  expect(expectedMessage).not.toContain('undefined');
100
107
  });
101
- it('uses fallback message when enterprise domain is empty string', function () {
108
+ it('passes fallback header when enterprise domain is empty string', function () {
102
109
  require('connection/enterprise').enterpriseDomain.mockImplementation(function () {
103
110
  return '';
104
111
  });
105
112
  var Component = getComponent();
106
- (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(Component, {
113
+ var props = renderAndGetProps(Component, {
107
114
  model: lock,
108
115
  i18n: i18nProp
109
- })).toMatchSnapshot();
116
+ });
117
+ expect(props.header.props.children).toContain('Login with your corporate credentials.');
110
118
  });
111
- it('uses fallback message when enterprise domain is whitespace only', function () {
119
+ it('passes fallback header when enterprise domain is whitespace only', function () {
112
120
  require('connection/enterprise').enterpriseDomain.mockImplementation(function () {
113
121
  return ' ';
114
122
  });
115
123
  var Component = getComponent();
116
- (0, _testUtils.expectComponent)(/*#__PURE__*/_react.default.createElement(Component, {
124
+ var props = renderAndGetProps(Component, {
117
125
  model: lock,
118
126
  i18n: i18nProp
119
- })).toMatchSnapshot();
127
+ });
128
+ expect(props.header.props.children).toContain('Login with your corporate credentials.');
120
129
  });
121
130
  });
@@ -2,11 +2,11 @@
2
2
 
3
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
4
  var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
5
6
  var _testUtils = require("testUtils");
6
7
  var _immutable = _interopRequireDefault(require("immutable"));
7
8
  var _field = require("../../../field");
8
9
  var i18n = _interopRequireWildcard(require("../../../i18n"));
9
- var _testUtils2 = require("../../testUtils");
10
10
  var _data_utils = require("../../../utils/data_utils");
11
11
  var _phone_number = require("../../../field/phone_number");
12
12
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -33,6 +33,11 @@ var getComponent = function getComponent() {
33
33
  var screen = new VCodeScreen();
34
34
  return screen.render();
35
35
  };
36
+ var renderAndGetProps = function renderAndGetProps(Component, props) {
37
+ var _render = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, props)),
38
+ container = _render.container;
39
+ return (0, _testUtils.getMockProps)(container.querySelector('[data-__type="vcode_pane"]'));
40
+ };
36
41
  describe('AskVCode', function () {
37
42
  var lock;
38
43
  var i18nProp;
@@ -55,27 +60,30 @@ describe('AskVCode', function () {
55
60
  }
56
61
  };
57
62
  });
58
- it('renders correctly when logging in with email', function () {
63
+ it('passes email instructions when logging in with email', function () {
59
64
  require('connection/passwordless/index').isEmail.mockImplementation(function () {
60
65
  return true;
61
66
  });
62
67
  var Component = getComponent();
63
68
  var l = (0, _field.setField)(lock, 'email', 'test@user.com');
64
- (0, _testUtils2.expectComponent)(/*#__PURE__*/_react.default.createElement(Component, {
69
+ var props = renderAndGetProps(Component, {
65
70
  model: l,
66
71
  i18n: i18nProp
67
- })).toMatchSnapshot();
72
+ });
73
+ expect(props.instructions).toContain('An email with the code has been sent to');
74
+ expect(props.instructions).toContain('test@user.com');
68
75
  });
69
- it('renders correctly when logging in with a phone number', function () {
76
+ it('passes SMS instructions when logging in with a phone number', function () {
70
77
  require('connection/passwordless/index').isEmail.mockImplementation(function () {
71
78
  return false;
72
79
  });
73
80
  var Component = getComponent();
74
81
  var l = (0, _phone_number.setPhoneNumber)(lock, '456 789');
75
82
  l = (0, _phone_number.initLocation)(l, 'UK');
76
- (0, _testUtils2.expectComponent)(/*#__PURE__*/_react.default.createElement(Component, {
83
+ var props = renderAndGetProps(Component, {
77
84
  model: l,
78
85
  i18n: i18nProp
79
- })).toMatchSnapshot();
86
+ });
87
+ expect(props.instructions).toContain('An SMS with the code has been sent to');
80
88
  });
81
89
  });