@plone/volto 19.0.0-alpha.35 → 19.0.0-alpha.36
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 +24 -0
- package/locales/af/LC_MESSAGES/volto.po +0 -10
- package/locales/af.json +1 -1
- package/locales/ar/LC_MESSAGES/volto.po +0 -10
- package/locales/ar.json +1 -1
- package/locales/bg/LC_MESSAGES/volto.po +0 -10
- package/locales/bg.json +1 -1
- package/locales/bn/LC_MESSAGES/volto.po +0 -10
- package/locales/bn.json +1 -1
- package/locales/ca/LC_MESSAGES/volto.po +0 -10
- package/locales/ca.json +1 -1
- package/locales/cs/LC_MESSAGES/volto.po +0 -10
- package/locales/cs.json +1 -1
- package/locales/cy/LC_MESSAGES/volto.po +0 -10
- package/locales/cy.json +1 -1
- package/locales/da/LC_MESSAGES/volto.po +0 -10
- package/locales/da.json +1 -1
- package/locales/de/LC_MESSAGES/volto.po +0 -10
- package/locales/de.json +1 -1
- package/locales/el/LC_MESSAGES/volto.po +0 -10
- package/locales/el.json +1 -1
- package/locales/en/LC_MESSAGES/volto.po +0 -10
- package/locales/en.json +1 -1
- package/locales/en_AU/LC_MESSAGES/volto.po +0 -10
- package/locales/en_AU.json +1 -1
- package/locales/en_GB/LC_MESSAGES/volto.po +0 -10
- package/locales/en_GB.json +1 -1
- package/locales/eo/LC_MESSAGES/volto.po +0 -10
- package/locales/eo.json +1 -1
- package/locales/es/LC_MESSAGES/volto.po +41 -51
- package/locales/es.json +1 -1
- package/locales/et/LC_MESSAGES/volto.po +0 -10
- package/locales/et.json +1 -1
- package/locales/eu/LC_MESSAGES/volto.po +27 -37
- package/locales/eu.json +1 -1
- package/locales/fa/LC_MESSAGES/volto.po +0 -10
- package/locales/fa.json +1 -1
- package/locales/fi/LC_MESSAGES/volto.po +0 -10
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +0 -10
- package/locales/fr.json +1 -1
- package/locales/fu/LC_MESSAGES/volto.po +0 -10
- package/locales/fu.json +1 -1
- package/locales/gl/LC_MESSAGES/volto.po +33 -43
- package/locales/gl.json +1 -1
- package/locales/he/LC_MESSAGES/volto.po +0 -10
- package/locales/he.json +1 -1
- package/locales/hi/LC_MESSAGES/volto.po +0 -10
- package/locales/hi.json +1 -1
- package/locales/hr/LC_MESSAGES/volto.po +0 -10
- package/locales/hr.json +1 -1
- package/locales/hu/LC_MESSAGES/volto.po +0 -10
- package/locales/hu.json +1 -1
- package/locales/hy/LC_MESSAGES/volto.po +0 -10
- package/locales/hy.json +1 -1
- package/locales/id/LC_MESSAGES/volto.po +0 -10
- package/locales/id.json +1 -1
- package/locales/it/LC_MESSAGES/volto.po +8 -17
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +0 -10
- package/locales/ja.json +1 -1
- package/locales/ka/LC_MESSAGES/volto.po +0 -10
- package/locales/ka.json +1 -1
- package/locales/kn/LC_MESSAGES/volto.po +0 -10
- package/locales/kn.json +1 -1
- package/locales/ko/LC_MESSAGES/volto.po +0 -10
- package/locales/ko.json +1 -1
- package/locales/lt/LC_MESSAGES/volto.po +0 -10
- package/locales/lt.json +1 -1
- package/locales/lv/LC_MESSAGES/volto.po +0 -10
- package/locales/lv.json +1 -1
- package/locales/mi/LC_MESSAGES/volto.po +0 -10
- package/locales/mi.json +1 -1
- package/locales/mk/LC_MESSAGES/volto.po +0 -10
- package/locales/mk.json +1 -1
- package/locales/my/LC_MESSAGES/volto.po +0 -10
- package/locales/my.json +1 -1
- package/locales/nb_NO/LC_MESSAGES/volto.po +0 -10
- package/locales/nb_NO.json +1 -1
- package/locales/nl/LC_MESSAGES/volto.po +0 -10
- package/locales/nl.json +1 -1
- package/locales/nn/LC_MESSAGES/volto.po +0 -10
- package/locales/nn.json +1 -1
- package/locales/pl/LC_MESSAGES/volto.po +0 -10
- package/locales/pl.json +1 -1
- package/locales/pt/LC_MESSAGES/volto.po +0 -10
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +0 -10
- package/locales/pt_BR.json +1 -1
- package/locales/rm/LC_MESSAGES/volto.po +0 -10
- package/locales/rm.json +1 -1
- package/locales/ro/LC_MESSAGES/volto.po +0 -10
- package/locales/ro.json +1 -1
- package/locales/ru/LC_MESSAGES/volto.po +0 -10
- package/locales/ru.json +1 -1
- package/locales/sk/LC_MESSAGES/volto.po +0 -10
- package/locales/sk.json +1 -1
- package/locales/sl/LC_MESSAGES/volto.po +0 -10
- package/locales/sl.json +1 -1
- package/locales/sm/LC_MESSAGES/volto.po +0 -10
- package/locales/sm.json +1 -1
- package/locales/sq/LC_MESSAGES/volto.po +0 -10
- package/locales/sq.json +1 -1
- package/locales/sr/LC_MESSAGES/volto.po +0 -10
- package/locales/sr.json +1 -1
- package/locales/sr@cyrl/LC_MESSAGES/volto.po +0 -10
- package/locales/sr@cyrl.json +1 -1
- package/locales/sr@latn/LC_MESSAGES/volto.po +0 -10
- package/locales/sr@latn.json +1 -1
- package/locales/sv/LC_MESSAGES/volto.po +0 -10
- package/locales/sv.json +1 -1
- package/locales/ta/LC_MESSAGES/volto.po +0 -10
- package/locales/ta.json +1 -1
- package/locales/te/LC_MESSAGES/volto.po +0 -10
- package/locales/te.json +1 -1
- package/locales/th/LC_MESSAGES/volto.po +0 -10
- package/locales/th.json +1 -1
- package/locales/to/LC_MESSAGES/volto.po +0 -10
- package/locales/to.json +1 -1
- package/locales/tr/LC_MESSAGES/volto.po +0 -10
- package/locales/tr.json +1 -1
- package/locales/uk/LC_MESSAGES/volto.po +0 -10
- package/locales/uk.json +1 -1
- package/locales/vi/LC_MESSAGES/volto.po +0 -10
- package/locales/vi.json +1 -1
- package/locales/volto.pot +1 -11
- package/locales/zh_CN/LC_MESSAGES/volto.po +0 -10
- package/locales/zh_CN.json +1 -1
- package/locales/zh_Hant/LC_MESSAGES/volto.po +0 -10
- package/locales/zh_Hant.json +1 -1
- package/locales/zh_Hant_HK/LC_MESSAGES/volto.po +0 -10
- package/locales/zh_Hant_HK.json +1 -1
- package/package.json +10 -10
- package/src/components/manage/Add/Add.test.jsx +10 -3
- package/src/components/manage/Aliases/Aliases.test.jsx +5 -2
- package/src/components/manage/Contents/Contents.test.jsx +7 -4
- package/src/components/manage/Controlpanels/AddonsControlpanel.test.jsx +7 -4
- package/src/components/manage/Controlpanels/Aliases.test.jsx +7 -4
- package/src/components/manage/Controlpanels/ContentType.test.jsx +12 -9
- package/src/components/manage/Controlpanels/ContentTypeLayout.test.jsx +12 -9
- package/src/components/manage/Controlpanels/ContentTypes.test.jsx +7 -4
- package/src/components/manage/Controlpanels/Controlpanel.test.jsx +7 -4
- package/src/components/manage/Controlpanels/Controlpanels.test.jsx +13 -8
- package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.test.jsx +7 -4
- package/src/components/manage/Controlpanels/ModerateComments.test.jsx +7 -4
- package/src/components/manage/Controlpanels/Rules/AddRule.test.jsx +7 -4
- package/src/components/manage/Controlpanels/Rules/ConfigureRule.test.jsx +9 -6
- package/src/components/manage/Controlpanels/Rules/EditRule.test.jsx +7 -4
- package/src/components/manage/Controlpanels/Rules/Rules.test.jsx +7 -4
- package/src/components/manage/Controlpanels/UndoControlpanel.test.jsx +7 -4
- package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.test.jsx +7 -4
- package/src/components/manage/Controlpanels/Users/UsersControlpanel.test.jsx +13 -8
- package/src/components/manage/Delete/Delete.test.jsx +13 -8
- package/src/components/manage/Diff/Diff.test.jsx +7 -4
- package/src/components/manage/Edit/Edit.test.jsx +11 -6
- package/src/components/manage/History/History.test.jsx +15 -8
- package/src/components/manage/LinksToItem/LinksToItem.test.jsx +7 -4
- package/src/components/manage/Multilingual/ManageTranslations.test.jsx +15 -12
- package/src/components/manage/Preferences/ChangePassword.test.jsx +7 -4
- package/src/components/manage/Preferences/PersonalPreferences.test.jsx +9 -6
- package/src/components/manage/Rules/Rules.test.jsx +5 -2
- package/src/components/manage/Sharing/Sharing.test.jsx +9 -6
- package/src/components/manage/Sidebar/Sidebar.test.jsx +4 -1
- package/src/components/manage/Toolbar/Toolbar.test.jsx +15 -10
- package/src/components/manage/Widgets/FormFieldWrapper.jsx +7 -5
- package/src/components/manage/Widgets/QuerystringWidget.test.jsx +3 -1
- package/src/components/manage/Widgets/TextWidget.jsx +4 -0
- package/src/components/theme/App/App.test.jsx +13 -10
- package/src/components/theme/ContactForm/ContactForm.test.jsx +13 -8
- package/src/components/theme/MultilingualRedirector/MultilingualRedirector.test.jsx +6 -3
- package/src/components/theme/Search/Search.test.jsx +13 -8
- package/src/components/theme/Unauthorized/Unauthorized.jsx +23 -30
- package/src/components/theme/Unauthorized/Unauthorized.test.jsx +6 -4
- package/src/components/theme/View/View.test.jsx +37 -24
- package/src/helpers/Api/Api.js +2 -2
- package/src/helpers/Robots/Robots.js +1 -1
- package/src/helpers/Robots/Robots.test.js +34 -0
|
@@ -19,6 +19,8 @@ const TextWidget = (props) => {
|
|
|
19
19
|
placeholder,
|
|
20
20
|
isDisabled,
|
|
21
21
|
focus,
|
|
22
|
+
required,
|
|
23
|
+
error,
|
|
22
24
|
} = props;
|
|
23
25
|
|
|
24
26
|
const ref = useRef();
|
|
@@ -49,6 +51,8 @@ const TextWidget = (props) => {
|
|
|
49
51
|
onClick={() => onClick()}
|
|
50
52
|
minLength={minLength || null}
|
|
51
53
|
maxLength={maxLength || null}
|
|
54
|
+
aria-required={required ? 'true' : undefined}
|
|
55
|
+
aria-invalid={error?.length > 0 ? 'true' : undefined}
|
|
52
56
|
/>
|
|
53
57
|
{icon && iconAction && (
|
|
54
58
|
<button className={`field-${id}-action-button`} onClick={iconAction}>
|
|
@@ -4,6 +4,7 @@ import { Provider } from 'react-intl-redux';
|
|
|
4
4
|
import { MemoryRouter } from 'react-router-dom';
|
|
5
5
|
import renderer from 'react-test-renderer';
|
|
6
6
|
import configureStore from 'redux-mock-store';
|
|
7
|
+
import { CookiesProvider } from 'react-cookie';
|
|
7
8
|
|
|
8
9
|
import { __test__ as App } from './App';
|
|
9
10
|
|
|
@@ -55,16 +56,18 @@ describe('App', () => {
|
|
|
55
56
|
});
|
|
56
57
|
const component = renderer.create(
|
|
57
58
|
<Provider store={store}>
|
|
58
|
-
<
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
<CookiesProvider>
|
|
60
|
+
<MemoryRouter initialEntries={['/blog/edit']}>
|
|
61
|
+
<App
|
|
62
|
+
location={{ pathname: '/blog/edit' }}
|
|
63
|
+
route={{
|
|
64
|
+
routes: '',
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
<div />
|
|
68
|
+
</App>
|
|
69
|
+
</MemoryRouter>
|
|
70
|
+
</CookiesProvider>
|
|
68
71
|
</Provider>,
|
|
69
72
|
);
|
|
70
73
|
const json = component.toJSON();
|
|
@@ -3,6 +3,7 @@ import { render } from '@testing-library/react';
|
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
5
|
import { MemoryRouter } from 'react-router-dom';
|
|
6
|
+
import { CookiesProvider } from 'react-cookie';
|
|
6
7
|
import ContactForm from './ContactForm';
|
|
7
8
|
|
|
8
9
|
vi.mock('../../manage/Toolbar/Toolbar', () => ({
|
|
@@ -29,10 +30,12 @@ describe('Contact form', () => {
|
|
|
29
30
|
});
|
|
30
31
|
const { container } = render(
|
|
31
32
|
<Provider store={store}>
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
<CookiesProvider>
|
|
34
|
+
<MemoryRouter>
|
|
35
|
+
<ContactForm />
|
|
36
|
+
<div id="toolbar"></div>
|
|
37
|
+
</MemoryRouter>
|
|
38
|
+
</CookiesProvider>
|
|
36
39
|
</Provider>,
|
|
37
40
|
);
|
|
38
41
|
|
|
@@ -57,10 +60,12 @@ describe('Contact form', () => {
|
|
|
57
60
|
});
|
|
58
61
|
const { container } = render(
|
|
59
62
|
<Provider store={store}>
|
|
60
|
-
<
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
<CookiesProvider>
|
|
64
|
+
<MemoryRouter>
|
|
65
|
+
<ContactForm />
|
|
66
|
+
<div id="toolbar"></div>
|
|
67
|
+
</MemoryRouter>
|
|
68
|
+
</CookiesProvider>
|
|
64
69
|
</Provider>,
|
|
65
70
|
);
|
|
66
71
|
|
|
@@ -3,6 +3,7 @@ import renderer from 'react-test-renderer';
|
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
5
|
import { MemoryRouter } from 'react-router-dom';
|
|
6
|
+
import { CookiesProvider } from 'react-cookie';
|
|
6
7
|
|
|
7
8
|
import MultilingualRedirector from './MultilingualRedirector';
|
|
8
9
|
|
|
@@ -21,9 +22,11 @@ describe('MultilingualRedirector', () => {
|
|
|
21
22
|
});
|
|
22
23
|
const component = renderer.create(
|
|
23
24
|
<Provider store={store}>
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
|
|
25
|
+
<CookiesProvider>
|
|
26
|
+
<MemoryRouter>
|
|
27
|
+
<MultilingualRedirector pathname={'/'} />
|
|
28
|
+
</MemoryRouter>
|
|
29
|
+
</CookiesProvider>
|
|
27
30
|
</Provider>,
|
|
28
31
|
);
|
|
29
32
|
const json = component.toJSON();
|
|
@@ -3,6 +3,7 @@ import { render } from '@testing-library/react';
|
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
5
|
import { MemoryRouter } from 'react-router-dom';
|
|
6
|
+
import { CookiesProvider } from 'react-cookie';
|
|
6
7
|
|
|
7
8
|
import { __test__ as Search } from './Search';
|
|
8
9
|
|
|
@@ -32,10 +33,12 @@ describe('Search', () => {
|
|
|
32
33
|
};
|
|
33
34
|
const { container } = render(
|
|
34
35
|
<Provider store={store}>
|
|
35
|
-
<
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
<CookiesProvider>
|
|
37
|
+
<MemoryRouter>
|
|
38
|
+
<Search history={history} />
|
|
39
|
+
<div id="toolbar"></div>
|
|
40
|
+
</MemoryRouter>
|
|
41
|
+
</CookiesProvider>
|
|
39
42
|
</Provider>,
|
|
40
43
|
);
|
|
41
44
|
|
|
@@ -65,10 +68,12 @@ describe('Search', () => {
|
|
|
65
68
|
};
|
|
66
69
|
const { container } = render(
|
|
67
70
|
<Provider store={store}>
|
|
68
|
-
<
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
<CookiesProvider>
|
|
72
|
+
<MemoryRouter>
|
|
73
|
+
<Search history={history} />
|
|
74
|
+
<div id="toolbar"></div>
|
|
75
|
+
</MemoryRouter>
|
|
76
|
+
</CookiesProvider>
|
|
72
77
|
</Provider>,
|
|
73
78
|
);
|
|
74
79
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormattedMessage } from 'react-intl';
|
|
2
|
-
import { Link } from 'react-router-dom';
|
|
2
|
+
import { Link, Redirect } from 'react-router-dom';
|
|
3
3
|
import { Container } from 'semantic-ui-react';
|
|
4
4
|
import { useSelector } from 'react-redux';
|
|
5
5
|
import { useLocation } from 'react-router-dom';
|
|
@@ -11,6 +11,24 @@ const Unauthorized = () => {
|
|
|
11
11
|
const error_message = useSelector((state) => state.apierror?.message);
|
|
12
12
|
let location = useLocation();
|
|
13
13
|
|
|
14
|
+
if (!token) {
|
|
15
|
+
return (
|
|
16
|
+
<Redirect
|
|
17
|
+
to={{
|
|
18
|
+
pathname: `${location.pathname.replace(/\/$/, '')}/login`,
|
|
19
|
+
search: `?return_url=${encodeURIComponent(location.pathname)}`,
|
|
20
|
+
state: {
|
|
21
|
+
// This is needed to cover the use case of being logged in in
|
|
22
|
+
// another backend (eg. in development), having a token for
|
|
23
|
+
// localhost and try to use it, the login route has to know that
|
|
24
|
+
// it's the same as it comes from a logout
|
|
25
|
+
isLogout: true,
|
|
26
|
+
},
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
14
32
|
return (
|
|
15
33
|
<Container className="view-wrapper">
|
|
16
34
|
<BodyClass className="view-unauthorized" />
|
|
@@ -19,35 +37,10 @@ const Unauthorized = () => {
|
|
|
19
37
|
</h1>
|
|
20
38
|
<h3>{error_message}</h3>
|
|
21
39
|
<p className="description">
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/>
|
|
27
|
-
) : (
|
|
28
|
-
<FormattedMessage
|
|
29
|
-
id="You are trying to access a protected resource, please {login} first."
|
|
30
|
-
defaultMessage="You are trying to access a protected resource, please {login} first."
|
|
31
|
-
values={{
|
|
32
|
-
login: (
|
|
33
|
-
<Link
|
|
34
|
-
to={{
|
|
35
|
-
pathname: `${location.pathname.replace(/\/$/, '')}/login`,
|
|
36
|
-
state: {
|
|
37
|
-
// This is needed to cover the use case of being logged in in
|
|
38
|
-
// another backend (eg. in development), having a token for
|
|
39
|
-
// localhost and try to use it, the login route has to know that
|
|
40
|
-
// it's the same as it comes from a logout
|
|
41
|
-
isLogout: true,
|
|
42
|
-
},
|
|
43
|
-
}}
|
|
44
|
-
>
|
|
45
|
-
<FormattedMessage id="log in" defaultMessage="log in" />
|
|
46
|
-
</Link>
|
|
47
|
-
),
|
|
48
|
-
}}
|
|
49
|
-
/>
|
|
50
|
-
)}
|
|
40
|
+
<FormattedMessage
|
|
41
|
+
id="You are trying to access a protected resource."
|
|
42
|
+
defaultMessage="You are trying to access a protected resource."
|
|
43
|
+
/>
|
|
51
44
|
</p>
|
|
52
45
|
<p>
|
|
53
46
|
<FormattedMessage
|
|
@@ -2,14 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import renderer from 'react-test-renderer';
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
5
|
+
import { MemoryRouter, StaticRouter } from 'react-router-dom';
|
|
6
6
|
|
|
7
7
|
import Unauthorized from './Unauthorized';
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
11
11
|
describe('Unauthorized', () => {
|
|
12
|
-
it('
|
|
12
|
+
it('redirects to login', () => {
|
|
13
13
|
const store = mockStore({
|
|
14
14
|
userSession: {
|
|
15
15
|
token: null,
|
|
@@ -22,15 +22,17 @@ describe('Unauthorized', () => {
|
|
|
22
22
|
message: 'You are not authorized to access this resource',
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
|
+
const context = {};
|
|
25
26
|
const component = renderer.create(
|
|
26
27
|
<Provider store={store}>
|
|
27
|
-
<
|
|
28
|
+
<StaticRouter context={context} location="/private">
|
|
28
29
|
<Unauthorized />
|
|
29
|
-
</
|
|
30
|
+
</StaticRouter>
|
|
30
31
|
</Provider>,
|
|
31
32
|
);
|
|
32
33
|
const json = component.toJSON();
|
|
33
34
|
expect(json).toMatchSnapshot();
|
|
35
|
+
expect(context.url).toEqual('/private/login?return_url=%2Fprivate');
|
|
34
36
|
});
|
|
35
37
|
|
|
36
38
|
it('renders an unauthorized component for authenticated user', () => {
|
|
@@ -2,6 +2,7 @@ import React, { useEffect } from 'react';
|
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
|
+
import { CookiesProvider } from 'react-cookie';
|
|
5
6
|
|
|
6
7
|
import View from './View';
|
|
7
8
|
import config from '@plone/volto/registry';
|
|
@@ -158,10 +159,12 @@ describe('View', () => {
|
|
|
158
159
|
});
|
|
159
160
|
const { container } = render(
|
|
160
161
|
<Provider store={store}>
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
<CookiesProvider>
|
|
163
|
+
<>
|
|
164
|
+
<View location={{ pathname: '/test' }} />
|
|
165
|
+
<div id="toolbar"></div>
|
|
166
|
+
</>
|
|
167
|
+
</CookiesProvider>
|
|
165
168
|
</Provider>,
|
|
166
169
|
);
|
|
167
170
|
|
|
@@ -181,10 +184,12 @@ describe('View', () => {
|
|
|
181
184
|
});
|
|
182
185
|
const { container } = render(
|
|
183
186
|
<Provider store={store}>
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
<CookiesProvider>
|
|
188
|
+
<>
|
|
189
|
+
<View location={{ pathname: '/test' }} />
|
|
190
|
+
<div id="toolbar"></div>
|
|
191
|
+
</>
|
|
192
|
+
</CookiesProvider>
|
|
188
193
|
</Provider>,
|
|
189
194
|
);
|
|
190
195
|
|
|
@@ -204,10 +209,12 @@ describe('View', () => {
|
|
|
204
209
|
});
|
|
205
210
|
const { container } = render(
|
|
206
211
|
<Provider store={store}>
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
212
|
+
<CookiesProvider>
|
|
213
|
+
<>
|
|
214
|
+
<View location={{ pathname: '/test' }} />
|
|
215
|
+
<div id="toolbar"></div>
|
|
216
|
+
</>
|
|
217
|
+
</CookiesProvider>
|
|
211
218
|
</Provider>,
|
|
212
219
|
);
|
|
213
220
|
|
|
@@ -227,10 +234,12 @@ describe('View', () => {
|
|
|
227
234
|
});
|
|
228
235
|
const { container } = render(
|
|
229
236
|
<Provider store={store}>
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
237
|
+
<CookiesProvider>
|
|
238
|
+
<>
|
|
239
|
+
<View location={{ pathname: '/test' }} />
|
|
240
|
+
<div id="toolbar"></div>
|
|
241
|
+
</>
|
|
242
|
+
</CookiesProvider>
|
|
234
243
|
</Provider>,
|
|
235
244
|
);
|
|
236
245
|
|
|
@@ -258,20 +267,24 @@ describe('View', () => {
|
|
|
258
267
|
});
|
|
259
268
|
const { rerender } = render(
|
|
260
269
|
<Provider store={store}>
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
270
|
+
<CookiesProvider>
|
|
271
|
+
<>
|
|
272
|
+
<View location={{ pathname: '/test' }} />
|
|
273
|
+
<div id="toolbar"></div>
|
|
274
|
+
</>
|
|
275
|
+
</CookiesProvider>
|
|
265
276
|
</Provider>,
|
|
266
277
|
);
|
|
267
278
|
expect(instanceCount).toBe(1);
|
|
268
279
|
store.getState().content.data['@id'] = '/b';
|
|
269
280
|
rerender(
|
|
270
281
|
<Provider store={store}>
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
282
|
+
<CookiesProvider>
|
|
283
|
+
<>
|
|
284
|
+
<View location={{ pathname: '/test' }} />
|
|
285
|
+
<div id="toolbar"></div>
|
|
286
|
+
</>
|
|
287
|
+
</CookiesProvider>
|
|
275
288
|
</Provider>,
|
|
276
289
|
);
|
|
277
290
|
expect(instanceCount).toBe(2);
|
package/src/helpers/Api/Api.js
CHANGED
|
@@ -102,7 +102,7 @@ class Api {
|
|
|
102
102
|
request.attach.apply(request, attachment);
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
request.end((err, response) => {
|
|
105
|
+
request.end((err, response = {}) => {
|
|
106
106
|
if (
|
|
107
107
|
checkUrl &&
|
|
108
108
|
request.url &&
|
|
@@ -126,7 +126,7 @@ class Api {
|
|
|
126
126
|
if ([301, 302].includes(err?.status)) {
|
|
127
127
|
return reject({
|
|
128
128
|
code: err.status,
|
|
129
|
-
url: err.response
|
|
129
|
+
url: err.response?.headers?.location,
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -24,7 +24,7 @@ export const generateRobots = (req) =>
|
|
|
24
24
|
request.set('Authorization', `Bearer ${authToken}`);
|
|
25
25
|
}
|
|
26
26
|
request.use(addHeadersFactory(req));
|
|
27
|
-
request.end((error, { text, body }) => {
|
|
27
|
+
request.end((error, { text, body } = {}) => {
|
|
28
28
|
if (error) {
|
|
29
29
|
resolve(text || error);
|
|
30
30
|
} else {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { generateRobots } from './Robots';
|
|
2
|
+
|
|
3
|
+
const request = {
|
|
4
|
+
set: vi.fn(() => request),
|
|
5
|
+
use: vi.fn(() => request),
|
|
6
|
+
end: vi.fn(),
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
vi.mock('superagent', () => ({
|
|
10
|
+
default: {
|
|
11
|
+
get: vi.fn(() => request),
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
vi.mock('@plone/volto/helpers/Proxy/Proxy', () => ({
|
|
16
|
+
addHeadersFactory: vi.fn(() => vi.fn()),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
describe('generateRobots', () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
vi.clearAllMocks();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('resolves the original error when superagent does not provide a response', async () => {
|
|
25
|
+
const error = new Error('network error');
|
|
26
|
+
request.end.mockImplementationOnce((callback) => callback(error));
|
|
27
|
+
|
|
28
|
+
await expect(
|
|
29
|
+
generateRobots({
|
|
30
|
+
universalCookies: { get: vi.fn(() => null) },
|
|
31
|
+
}),
|
|
32
|
+
).resolves.toBe(error);
|
|
33
|
+
});
|
|
34
|
+
});
|