fix: handle inIframe query_param when it is False

This commit is contained in:
SaadYousaf
2022-08-23 19:24:26 +05:00
committed by Saad Yousaf
parent 418f78cfc8
commit 19666b88d2
2 changed files with 33 additions and 2 deletions

View File

@@ -42,8 +42,7 @@ export default function DiscussionsHome() {
learnerUsername,
} = params;
const inContext = new URLSearchParams(location.search).get('inContext') !== null;
const inIframe = new URLSearchParams(location.search).get('inIframe') !== null;
const inIframe = new URLSearchParams(location.search).get('inIframe')?.toLowerCase() === 'true';
// Display the content area if we are currently viewing/editing a post or creating one.
const displayContentArea = postId || postEditorVisible || (learnerUsername && postId);
let displaySidebar = useSidebarVisible();

View File

@@ -87,4 +87,36 @@ describe('DiscussionsHome', () => {
await waitFor(() => expect(window.parent.postMessage).toHaveBeenCalled());
window.parent = parent;
});
describe.each([
{
queryParam: 'inIframe=True',
iframeView: true,
},
{
queryParam: 'inIframe=False',
iframeView: false,
},
{
queryParam: '',
iframeView: false,
},
])(
'Header/Footer visibility',
({
queryParam,
iframeView,
}) => {
test(`inIframe query param ${queryParam}`, async () => {
renderComponent(`/${courseId}/topics?${queryParam}`);
if (iframeView) {
expect(screen.queryByRole('banner')).not.toBeInTheDocument();
expect(screen.queryByRole('contentinfo')).not.toBeInTheDocument();
} else {
expect(screen.queryByRole('banner')).toBeInTheDocument();
expect(screen.queryByRole('contentinfo')).toBeInTheDocument();
}
});
},
);
});