@eeacms/volto-eea-website-policy 2.0.0 → 2.1.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.
package/CHANGELOG.md CHANGED
@@ -4,17 +4,53 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
- ### [2.0.0](https://github.com/eea/volto-eea-website-policy/compare/1.14.1-beta.1...2.0.0) - 22 April 2024
7
+ ### [2.1.1](https://github.com/eea/volto-eea-website-policy/compare/2.1.0...2.1.1) - 30 May 2024
8
+
9
+ #### :house: Internal changes
10
+
11
+ - chore: Fix @plone-collective/volto-authomatic dependencies [alin - [`3c11765`](https://github.com/eea/volto-eea-website-policy/commit/3c117655f254d68b89a9748216b405c93ec18a0e)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`c297b9e`](https://github.com/eea/volto-eea-website-policy/commit/c297b9efe743ad1f95ab662007a2186b5f042f4c)]
16
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b11c055`](https://github.com/eea/volto-eea-website-policy/commit/b11c055d0a41c89a60f70875124994ba52772e48)]
17
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`a77d04e`](https://github.com/eea/volto-eea-website-policy/commit/a77d04e9f1e4d6b8657e09fd1a2bcde66499f77f)]
18
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`12c6e92`](https://github.com/eea/volto-eea-website-policy/commit/12c6e92e4157896bf812dbbd8996c754b491d3ea)]
19
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`0aa866d`](https://github.com/eea/volto-eea-website-policy/commit/0aa866dc6fb5f4226a99a3e192a958af60385185)]
20
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`7517f96`](https://github.com/eea/volto-eea-website-policy/commit/7517f96d82efd6a7ddaa746c81a51997583363f6)]
21
+ ### [2.1.0](https://github.com/eea/volto-eea-website-policy/compare/2.0.0...2.1.0) - 9 May 2024
22
+
23
+ #### :rocket: New Features
24
+
25
+ - feat: integrated EEA Azure AD authentication - refs #258877 [Alexandru Ghica - [`7ff72c1`](https://github.com/eea/volto-eea-website-policy/commit/7ff72c1567524ce73ec72e6a30e91d6d29342510)]
26
+
27
+ #### :hammer_and_wrench: Others
28
+
29
+ - Release 2.1.0 [alin - [`da22af4`](https://github.com/eea/volto-eea-website-policy/commit/da22af436092236d7ef6e8568e3eca4813d517b5)]
30
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`9a5d706`](https://github.com/eea/volto-eea-website-policy/commit/9a5d7064e829622e2627c616c4ca1ce71511dfcb)]
31
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`f8b40e9`](https://github.com/eea/volto-eea-website-policy/commit/f8b40e961138efc4090d0ab45a5689905c672b15)]
32
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`4ab2144`](https://github.com/eea/volto-eea-website-policy/commit/4ab2144e02291d98064b001d9eb40417da4d1795)]
33
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`5af4642`](https://github.com/eea/volto-eea-website-policy/commit/5af464227c6695c7e2d3ccd9f240c2a5071bfefa)]
34
+ ## [2.0.0](https://github.com/eea/volto-eea-website-policy/compare/1.15.0...2.0.0) - 22 April 2024
8
35
 
9
36
  #### :rocket: New Features
10
37
 
11
38
  - feat: Release 2.0.0 - Volto 17 support [alin - [`d6cf5c8`](https://github.com/eea/volto-eea-website-policy/commit/d6cf5c8f41950a94cd68e7a36a45b5be8cc6195b)]
12
- - feat: Default view layout restriction to Manager - refs #268249 [ichim-david - [`1840c1b`](https://github.com/eea/volto-eea-website-policy/commit/1840c1bd9aae6ce18a23800ce618f8bbe47525ab)]
13
39
 
14
40
  #### :nail_care: Enhancements
15
41
 
16
42
  - refactor: Move customizations to volto-eea-website-theme [alin - [`9641437`](https://github.com/eea/volto-eea-website-policy/commit/9641437c7f10ba6c7ec1f896b180b49d2718a7d0)]
17
43
 
44
+ ### [1.15.0](https://github.com/eea/volto-eea-website-policy/compare/1.14.1-beta.1...1.15.0) - 9 May 2024
45
+
46
+ #### :rocket: New Features
47
+
48
+ - feat: integrated EEA Azure AD authentication - refs #258877 [Alexandru Ghica - [`1897659`](https://github.com/eea/volto-eea-website-policy/commit/18976594a9c7b4f2640dc79ab6420f509e7de668)]
49
+ - feat: Default view layout restriction to Manager - refs #268249 [ichim-david - [`1840c1b`](https://github.com/eea/volto-eea-website-policy/commit/1840c1bd9aae6ce18a23800ce618f8bbe47525ab)]
50
+
51
+ #### :hammer_and_wrench: Others
52
+
53
+ - Release 1.15.0 [alin - [`f0d61d8`](https://github.com/eea/volto-eea-website-policy/commit/f0d61d8bd99687f0460acd0a1ad6e200206b5b6a)]
18
54
  ### [1.14.1-beta.1](https://github.com/eea/volto-eea-website-policy/compare/1.14.1-beta.0...1.14.1-beta.1) - 19 April 2024
19
55
 
20
56
  #### :hammer_and_wrench: Others
@@ -67,6 +103,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
67
103
 
68
104
  #### :hammer_and_wrench: Others
69
105
 
106
+ - test: [JENKINS] fail with logs on coverage [valentinab25 - [`5cf68f8`](https://github.com/eea/volto-eea-website-policy/commit/5cf68f8db34448d10fe993d16541ad9732434cc8)]
70
107
  ### [1.12.0-beta.1](https://github.com/eea/volto-eea-website-policy/compare/1.11.1...1.12.0-beta.1) - 12 January 2024
71
108
 
72
109
  #### :hammer_and_wrench: Others
@@ -87,6 +124,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
87
124
  #### :hammer_and_wrench: Others
88
125
 
89
126
  - Release 1.11.0 [Alin Voinea - [`3249160`](https://github.com/eea/volto-eea-website-policy/commit/3249160422c6c6e0cf14823b614f8885101a847a)]
127
+ - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`8beb7e7`](https://github.com/eea/volto-eea-website-policy/commit/8beb7e7a12cbc314e56e4b1aceab5ef8d00ca6f3)]
128
+ - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`12d3da1`](https://github.com/eea/volto-eea-website-policy/commit/12d3da12e9a3b0882cf55efe2d40f3032724d41b)]
129
+ - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`0af0764`](https://github.com/eea/volto-eea-website-policy/commit/0af076467120ed9a80c697931e869837b92a0a4c)]
130
+ - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`8662e3e`](https://github.com/eea/volto-eea-website-policy/commit/8662e3e5fc3640d678ce320eb8856a37d419306c)]
131
+ - test: [JENKINS] Improve cypress time [valentinab25 - [`ef1074f`](https://github.com/eea/volto-eea-website-policy/commit/ef1074fdf968cafdf476d4ee4951eb18ebac048a)]
90
132
  ### [1.10.0](https://github.com/eea/volto-eea-website-policy/compare/1.9.2...1.10.0) - 2 November 2023
91
133
 
92
134
  #### :rocket: New Features
@@ -95,6 +137,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
95
137
 
96
138
  #### :house: Internal changes
97
139
 
140
+ - chore: [JENKINS] Refactor automated testing [valentinab25 - [`8b1b422`](https://github.com/eea/volto-eea-website-policy/commit/8b1b42297b46d9fb7325589b3bd043233c0d66e9)]
98
141
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`44ac62e`](https://github.com/eea/volto-eea-website-policy/commit/44ac62e6f8b7e5b7d57edfbf82812c91dc5d6bba)]
99
142
  - chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`b9a46d8`](https://github.com/eea/volto-eea-website-policy/commit/b9a46d85a64739188a3df9e8cbe645418b5d8b0a)]
100
143
 
@@ -215,6 +258,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
215
258
 
216
259
  - Release 1.5.0 [Alin Voinea - [`a3dea8e`](https://github.com/eea/volto-eea-website-policy/commit/a3dea8ea15cb8d2a876dc10da926ece3a5707ea9)]
217
260
  - test(Jenkinsfile): Use latest stable volto for testing [Alin Voinea - [`a8f7123`](https://github.com/eea/volto-eea-website-policy/commit/a8f712364187f9638886667c249fa102cb49b5c0)]
261
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`124a8f8`](https://github.com/eea/volto-eea-website-policy/commit/124a8f8ad4ced507aeec27012d725f2e2b977e08)]
218
262
  ### [1.4.0](https://github.com/eea/volto-eea-website-policy/compare/1.3.4...1.4.0) - 21 February 2023
219
263
 
220
264
  #### :rocket: New Features
@@ -294,6 +338,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
294
338
  #### :hammer_and_wrench: Others
295
339
 
296
340
  - Release 1.1.0 [Alin Voinea - [`0291b3b`](https://github.com/eea/volto-eea-website-policy/commit/0291b3bb7b4c6ab09ca98728885cea4051eac8e3)]
341
+ - yarn 3 [Alin Voinea - [`593aa58`](https://github.com/eea/volto-eea-website-policy/commit/593aa58eaa4d28aced0603b7f7dd125c857a6f54)]
297
342
  ### [1.0.4](https://github.com/eea/volto-eea-website-policy/compare/1.0.3...1.0.4) - 22 November 2022
298
343
 
299
344
  #### :nail_care: Enhancements
@@ -339,6 +384,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
339
384
 
340
385
  #### :hammer_and_wrench: Others
341
386
 
387
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`d153f54`](https://github.com/eea/volto-eea-website-policy/commit/d153f54e55e918fa4746e05488c734624eaf14a9)]
342
388
  ### [0.4.0](https://github.com/eea/volto-eea-website-policy/compare/0.3.3...0.4.0) - 19 September 2022
343
389
 
344
390
  #### :hammer_and_wrench: Others
@@ -414,6 +460,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
414
460
  - format index.js [Andrei Grigore - [`db4481a`](https://github.com/eea/volto-eea-website-policy/commit/db4481aeeba59a769272659f33278c902fc69bec)]
415
461
  - Update index.js [Alexandru Ghica - [`dc09886`](https://github.com/eea/volto-eea-website-policy/commit/dc0988640a76a9914381b120f58bb61a9ab1eb39)]
416
462
  - Added externalRoutes [Alexandru Ghica - [`b68135b`](https://github.com/eea/volto-eea-website-policy/commit/b68135b013fafa93a41ea602ea2fad30879abe0f)]
463
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`575cca6`](https://github.com/eea/volto-eea-website-policy/commit/575cca674602ca2e1c2a41300c47ba594ff49aa0)]
417
464
  ### [0.1.1](https://github.com/eea/volto-eea-website-policy/compare/0.1.0...0.1.1) - 4 March 2022
418
465
 
419
466
  #### :hammer_and_wrench: Others
@@ -426,4 +473,5 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
426
473
 
427
474
  #### :hammer_and_wrench: Others
428
475
 
476
+ - yarn bootstrap [Alin Voinea - [`9b4d197`](https://github.com/eea/volto-eea-website-policy/commit/9b4d197cbc7992566cb36524d190078d5ad21a44)]
429
477
  - Initial commit [Alin Voinea - [`3800692`](https://github.com/eea/volto-eea-website-policy/commit/3800692f7a4de6460815bd6061facacb986cbef0)]
@@ -1,4 +1,4 @@
1
- require('dotenv').config({ path: __dirname + '/.env' })
1
+ require('dotenv').config({ path: __dirname + '/.env' });
2
2
 
3
3
  module.exports = {
4
4
  testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
@@ -8,6 +8,8 @@ module.exports = {
8
8
  ],
9
9
  moduleNameMapper: {
10
10
  '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
11
+ '@plone-collective/volto-authomatic/(.*)$':
12
+ '<rootDir>/node_modules/@plone-collective/volto-authomatic/src/$1',
11
13
  '@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
12
14
  '@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
13
15
  '@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
@@ -26,7 +28,7 @@ module.exports = {
26
28
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
27
29
  },
28
30
  transformIgnorePatterns: [
29
- '/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
31
+ '/node_modules/(?!(@plone|@root|@package|@eeacms|@plone-collective)/).*/',
30
32
  ],
31
33
  transform: {
32
34
  '^.+\\.js(x)?$': 'babel-jest',
@@ -48,4 +50,4 @@ module.exports = {
48
50
  '<rootDir>/node_modules/@eeacms/volto-eea-website-policy/jest.setup.js',
49
51
  ],
50
52
  }),
51
- }
53
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-website-policy",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "@eeacms/volto-eea-website-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -17,15 +17,18 @@
17
17
  "url": "git@github.com:eea/volto-eea-website-policy.git"
18
18
  },
19
19
  "addons": [
20
- "@eeacms/volto-widget-dataprovenance"
20
+ "@eeacms/volto-widget-dataprovenance",
21
+ "@plone-collective/volto-authomatic"
21
22
  ],
22
23
  "dependencies": {
23
- "@eeacms/volto-widget-dataprovenance": "*"
24
+ "@eeacms/volto-widget-dataprovenance": "*",
25
+ "@plone-collective/volto-authomatic": "*"
24
26
  },
25
27
  "devDependencies": {
26
28
  "@cypress/code-coverage": "^3.10.0",
27
29
  "@plone/scripts": "*",
28
30
  "babel-plugin-transform-class-properties": "^6.24.1",
31
+ "cypress": "13.1.0",
29
32
  "dotenv": "^16.3.2",
30
33
  "husky": "^8.0.3",
31
34
  "lint-staged": "^14.0.1",
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Login container.
3
+ * @module components/Login/Login
4
+ */
5
+ import React, { useEffect, useState } from 'react';
6
+ import {
7
+ authomaticRedirect,
8
+ listAuthOptions,
9
+ oidcRedirect,
10
+ } from '@plone-collective/volto-authomatic/actions';
11
+ import { injectIntl } from 'react-intl';
12
+ import { useSelector, useDispatch } from 'react-redux';
13
+ import { useLocation } from 'react-router-dom';
14
+ import LoginForm from '@plone-collective/volto-authomatic/components/Login/LoginForm';
15
+ import qs from 'query-string';
16
+ import { useCookies } from 'react-cookie';
17
+
18
+ /**
19
+ * Get retur url function.
20
+ * @function getReturnUrl
21
+ * @param {Object} location Location object.
22
+ * @returns {string} Return url.
23
+ */
24
+ function getReturnUrl(location) {
25
+ return `${
26
+ qs.parse(location.search).return_url ||
27
+ (location.pathname === '/azure_login'
28
+ ? '/'
29
+ : location.pathname.replace('/azure_login', ''))
30
+ }`;
31
+ }
32
+
33
+ /**
34
+ * Login function.
35
+ * @function Login
36
+ * @returns {JSX.Element} Markup of the Login page.
37
+ */
38
+ function Login({ intl }) {
39
+ const dispatch = useDispatch();
40
+ const [startedOAuth, setStartedOAuth] = useState(false);
41
+ const [startedOIDC, setStartedOIDC] = useState(false);
42
+ const loading = useSelector((state) => state.authOptions.loading);
43
+ const options = useSelector((state) => state.authOptions.options);
44
+ const loginOAuthValues = useSelector((state) => state.authomaticRedirect);
45
+ const loginOIDCValues = useSelector((state) => state.oidcRedirect);
46
+ const location = useLocation();
47
+ const [, setCookie] = useCookies();
48
+
49
+ useEffect(() => {
50
+ dispatch(listAuthOptions());
51
+ }, [dispatch]);
52
+
53
+ useEffect(() => {
54
+ const next_url = loginOAuthValues.next_url;
55
+ const session = loginOAuthValues.session;
56
+ if (next_url && session && startedOAuth) {
57
+ setStartedOAuth(false);
58
+ // Give time to save state to localstorage
59
+ setTimeout(function () {
60
+ window.location.href = next_url;
61
+ }, 500);
62
+ }
63
+ }, [startedOAuth, loginOAuthValues]);
64
+
65
+ const onSelectProvider = (provider) => {
66
+ setStartedOAuth(true);
67
+ setCookie('return_url', getReturnUrl(location), { path: '/' });
68
+ dispatch(authomaticRedirect(provider.id));
69
+ };
70
+
71
+ useEffect(() => {
72
+ const next_url = loginOIDCValues.next_url;
73
+ if (next_url && startedOIDC) {
74
+ setStartedOIDC(false);
75
+ // Give time to save state to localstorage
76
+ setTimeout(function () {
77
+ window.location.href = next_url;
78
+ }, 500);
79
+ }
80
+ }, [startedOIDC, loginOIDCValues]);
81
+
82
+ useEffect(() => {
83
+ if (
84
+ options !== undefined &&
85
+ options.length === 1 &&
86
+ options[0].id === 'oidc'
87
+ ) {
88
+ setStartedOIDC(true);
89
+ dispatch(oidcRedirect('oidc'));
90
+ }
91
+ }, [options, dispatch]);
92
+
93
+ return (
94
+ <LoginForm
95
+ loading={loading}
96
+ providers={options}
97
+ action={'login'}
98
+ onSelectProvider={onSelectProvider}
99
+ />
100
+ );
101
+ }
102
+
103
+ export default injectIntl(Login);
@@ -0,0 +1,179 @@
1
+ import { render, screen, fireEvent } from '@testing-library/react';
2
+ import { Provider } from 'react-intl-redux';
3
+ import configureStore from 'redux-mock-store';
4
+ import { useLocation } from 'react-router-dom';
5
+ import { listAuthOptions } from '@plone-collective/volto-authomatic/actions';
6
+ import '@testing-library/jest-dom/extend-expect';
7
+
8
+ import Login from './Login';
9
+
10
+ const mockStore = configureStore();
11
+
12
+ jest.mock('react-router-dom', () => ({
13
+ ...jest.requireActual('react-router-dom'),
14
+ useLocation: jest.fn(),
15
+ }));
16
+
17
+ jest.useFakeTimers();
18
+
19
+ describe('Login component', () => {
20
+ beforeEach(() => {
21
+ useLocation.mockReturnValue({ pathname: '/azure_login' });
22
+ });
23
+
24
+ it('renders correctly with loading state', () => {
25
+ const store = mockStore({
26
+ authOptions: { loading: true, options: [] },
27
+ authomaticRedirect: {
28
+ next_url: '/dashboard',
29
+ session: true,
30
+ },
31
+ oidcRedirect: {
32
+ next_url: '/dashboard',
33
+ session: true,
34
+ },
35
+ intl: {
36
+ locale: 'en',
37
+ messages: {},
38
+ formatMessage: jest.fn(),
39
+ },
40
+ });
41
+
42
+ render(
43
+ <Provider store={store}>
44
+ <Login />
45
+ </Provider>,
46
+ );
47
+
48
+ expect(screen.getByText('Loading')).toBeInTheDocument();
49
+ });
50
+
51
+ it('dispatches listAuthOptions on mount', () => {
52
+ const store = mockStore({
53
+ authOptions: { loading: true, options: [] },
54
+ authomaticRedirect: {
55
+ next_url: '/dashboard',
56
+ session: true,
57
+ },
58
+ oidcRedirect: {
59
+ next_url: '/dashboard',
60
+ session: true,
61
+ },
62
+ intl: {
63
+ locale: 'en',
64
+ messages: {},
65
+ formatMessage: jest.fn(),
66
+ },
67
+ });
68
+ const dispatch = jest.spyOn(store, 'dispatch');
69
+
70
+ render(
71
+ <Provider store={store}>
72
+ <Login />
73
+ </Provider>,
74
+ );
75
+
76
+ expect(dispatch).toHaveBeenCalledWith(listAuthOptions());
77
+ });
78
+
79
+ it('renders providers from the store', () => {
80
+ const store = mockStore({
81
+ authOptions: {
82
+ loading: false,
83
+ options: [
84
+ { id: 'facebook', title: 'Facebook' },
85
+ { id: 'twitter', title: 'Twitter' },
86
+ ],
87
+ },
88
+ authomaticRedirect: {
89
+ next_url: '/dashboard',
90
+ session: true,
91
+ },
92
+ oidcRedirect: {
93
+ next_url: '/dashboard',
94
+ session: true,
95
+ },
96
+ intl: {
97
+ locale: 'en',
98
+ messages: {},
99
+ formatMessage: jest.fn(),
100
+ },
101
+ });
102
+
103
+ render(
104
+ <Provider store={store}>
105
+ <Login />
106
+ </Provider>,
107
+ );
108
+
109
+ // Assert that the provider buttons are present
110
+ expect(
111
+ screen.getByRole('button', { name: /Facebook/i }),
112
+ ).toBeInTheDocument();
113
+ expect(
114
+ screen.getByRole('button', { name: /Twitter/i }),
115
+ ).toBeInTheDocument();
116
+
117
+ fireEvent.click(screen.getByRole('button', { name: /Facebook/i }));
118
+ });
119
+
120
+ it('clicks on GitHub button for OAuth login', () => {
121
+ useLocation.mockReturnValue({ pathname: '/login' });
122
+
123
+ const store = mockStore({
124
+ authOptions: {
125
+ loading: false,
126
+ options: [{ id: 'github', title: 'GitHub' }],
127
+ },
128
+ authomaticRedirect: { next_url: '/dashboard', session: true },
129
+ oidcRedirect: {
130
+ next_url: '/dashboard',
131
+ session: true,
132
+ },
133
+ intl: {
134
+ locale: 'en',
135
+ messages: {},
136
+ formatMessage: jest.fn(),
137
+ },
138
+ });
139
+
140
+ render(
141
+ <Provider store={store}>
142
+ <Login />
143
+ </Provider>,
144
+ );
145
+
146
+ fireEvent.click(screen.getByRole('button', { name: /GitHub/i }));
147
+ });
148
+
149
+ it('renders correctly with loading state', () => {
150
+ const store = mockStore({
151
+ authOptions: {
152
+ loading: true,
153
+ options: [{ id: 'oidc', title: 'OIDC' }],
154
+ },
155
+ authomaticRedirect: {
156
+ next_url: '/dashboard',
157
+ session: true,
158
+ },
159
+ oidcRedirect: {
160
+ next_url: '/dashboard',
161
+ session: true,
162
+ },
163
+ intl: {
164
+ locale: 'en',
165
+ messages: {},
166
+ formatMessage: jest.fn(),
167
+ },
168
+ });
169
+
170
+ render(
171
+ <Provider store={store}>
172
+ <Login />
173
+ </Provider>,
174
+ );
175
+
176
+ expect(screen.getByText('Loading')).toBeInTheDocument();
177
+ jest.advanceTimersByTime(500);
178
+ });
179
+ });
package/src/index.js CHANGED
@@ -2,6 +2,9 @@ import { runtimeConfig } from '@plone/volto/runtime_config';
2
2
  import installContextNavigationBlock from '@eeacms/volto-eea-website-policy/components/Blocks/ContextNavigation';
3
3
  import { appendGroup } from './helpers';
4
4
  import { FrequencyOfDissemination } from '@eeacms/volto-eea-website-policy/components/Widgets/FrequencyOfDissemination';
5
+ import Login from '@eeacms/volto-eea-website-policy/components/AzureLogin/Login.jsx';
6
+ import Logout from '@plone-collective/volto-authomatic/components/Logout/Logout.jsx';
7
+ import { Login as VoltoLogin } from '@plone/volto/components';
5
8
 
6
9
  const restrictedBlocks = [
7
10
  'imagecards',
@@ -40,7 +43,7 @@ const overrideBlocks = {
40
43
  const applyConfig = (config) => {
41
44
  // #158717#note-25 any path that isn't static, en or controlpanel is treated as external
42
45
  const notInEN =
43
- /^(?!(#|\/en|\/login-authomatic|\/fallback_login|\/static|\/controlpanel|\/cypress|\/login|\/logout|\/contact-form|\/passwordreset)).*$/;
46
+ /^(?!(#|\/en|\/login-authomatic|\/azure_login|\/fallback_login|\/static|\/controlpanel|\/cypress|\/login|\/logout|\/contact-form|\/passwordreset)).*$/;
44
47
  config.settings.externalRoutes = [
45
48
  ...(config.settings.externalRoutes || []),
46
49
  {
@@ -52,6 +55,17 @@ const applyConfig = (config) => {
52
55
  },
53
56
  ];
54
57
 
58
+ // #258877 Make Azure AD login to be at route /azure_login and EIONET LDAP login to be at /login
59
+ config.addonRoutes = [
60
+ { path: '/azure_login', component: Login },
61
+ { path: '/**/azure_login', component: Login },
62
+ { path: '/login', component: VoltoLogin },
63
+ { path: '/**/login', component: VoltoLogin },
64
+ { path: '/logout', component: Logout },
65
+ { path: '/**/logout', component: Logout },
66
+ ...(config.addonRoutes || []),
67
+ ];
68
+
55
69
  // #160689 Redirect contact-form to contact-us
56
70
  config.settings.contactForm = '/en/about/contact-us';
57
71