Unverified Commit d1242f8f authored by Paul Kaplan's avatar Paul Kaplan Committed by GitHub

Merge pull request #5645 from paulkaplan/fix-admin-panel-spacing

parents d575928e d35cee93
......@@ -48,8 +48,11 @@ const StudioAdminPanel = ({studioId, showAdminPanel}) => {
const [adminPanelOpen, setAdminPanelOpen] = useState(getAdminPanelOpen());
useEffect(() => {
storeAdminPanelOpen(adminPanelOpen);
}, [adminPanelOpen]);
// This effect will both keep localStorage up-to-date AND cause
// the spacing to change to allow for the open admin panel, so make
// sure the admin panel should be visible at all before making any changes.
if (showAdminPanel) storeAdminPanelOpen(adminPanelOpen);
}, [showAdminPanel, adminPanelOpen]);
useEffect(() => {
if (!showAdminPanel) return;
......
......@@ -39,6 +39,19 @@ describe('Studio comments', () => {
expect(child.prop('isOpen')).toBe(false);
});
});
describe('non admins', () => {
test('should not have localStorage set with a false value', () => {
mountWithIntl(<StudioAdminPanel showAdminPanel={false} />);
expect(global.localStorage.getItem(adminPanelOpenKey)).toBe(null);
});
test('should not have css class set even if localStorage contains open key', () => {
// Regression test for situation where admin logs out but localStorage still
// contains "open", causing extra space to appear
global.localStorage.setItem(adminPanelOpenKey, 'open');
mountWithIntl(<StudioAdminPanel showAdminPanel={false} />);
expect(viewEl.classList.contains(adminPanelOpenClass)).toBe(false);
});
});
test('calling onOpen sets a class on the #viewEl and records in local storage', () => {
const component = mountWithIntl(<StudioAdminPanel showAdminPanel />);
let child = component.find(AdminPanel);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment