diff --git a/packages/core/admin/admin/src/hooks/useSettingsForm/index.js b/packages/core/admin/admin/src/hooks/useSettingsForm/index.js
index dd2425a7af..a67b463dfa 100644
--- a/packages/core/admin/admin/src/hooks/useSettingsForm/index.js
+++ b/packages/core/admin/admin/src/hooks/useSettingsForm/index.js
@@ -82,6 +82,7 @@ const useSettingsForm = (endPoint, schema, cbSuccess, fieldsToPick) => {
});
if (!errors) {
+
try {
lockApp();
@@ -116,7 +117,7 @@ const useSettingsForm = (endPoint, schema, cbSuccess, fieldsToPick) => {
});
} catch (err) {
const data = err?.response?.payload ?? { data: {} };
-
+
if (!!data?.data && typeof data.data === 'string') {
toggleNotification({
type: 'warning',
diff --git a/packages/core/admin/admin/src/hooks/useSettingsForm/tests/index.test.js b/packages/core/admin/admin/src/hooks/useSettingsForm/tests/index.test.js
new file mode 100644
index 0000000000..89bdf056a7
--- /dev/null
+++ b/packages/core/admin/admin/src/hooks/useSettingsForm/tests/index.test.js
@@ -0,0 +1,113 @@
+import * as React from 'react';
+import { setupServer } from 'msw/node';
+import { rest } from 'msw';
+import { renderHook, act } from '@testing-library/react-hooks';
+import { IntlProvider } from 'react-intl';
+import useSettingsForm from '../index';
+
+const toggleNotification = jest.fn();
+
+jest.mock('@strapi/helper-plugin', () => ({
+ ...jest.requireActual('@strapi/helper-plugin'),
+ useNotification: jest.fn().mockImplementation(() => toggleNotification),
+ useOverlayBlocker: () => ({ lockApp: jest.fn(), unlockApp: jest.fn() }),
+}));
+
+jest.mock('../../../utils', () => ({
+ ...jest.requireActual('../../../utils'),
+ checkFormValidity: () => (null),
+}));
+
+const server = setupServer(
+ rest.get('*/providers/options', (req, res, ctx) =>
+ res(
+ ctx.status(200),
+ ctx.json({
+ data: {
+ autoRegister: false,
+ defaultRole: "1",
+ ssoLockedRoles: ["1","2"]
+ }
+ })
+ )
+ ),
+ rest.put('*/providers/options', (req, res, ctx) => {
+ res(
+ ctx.status(200),
+ ctx.json({
+ data: {
+ data: {
+ autoRegister: false,
+ defaultRole: "1",
+ ssoLockedRoles: ["1","2","3"]
+ }
+ }
+ })
+ )
+ })
+);
+
+const setup = (...args) =>
+ renderHook(() => useSettingsForm(...args), {
+ wrapper({ children }) {
+ return (
+
Select the roles for which you want to disable the local authentication