Skip to content

Commit

Permalink
Revert loader-page, which was breaking Role Selector
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyEJohnson committed Sep 7, 2023
1 parent 38d1cd2 commit e50b63c
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 85 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openstax/os-webview",
"version": "2.111.0",
"version": "2.111.1",
"description": "OpenStax webview",
"scripts": {
"test": "jest ./test/src",
Expand Down
43 changes: 43 additions & 0 deletions src/app/components/jsx-helpers/loader-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';
import {camelCaseKeys} from '~/helpers/page-data-utils';
import usePageData from '~/helpers/use-page-data';
import {setPageTitleAndDescriptionFromBookData, useCanonicalLink} from '~/helpers/use-document-head';
import LoadingPlaceholder from '~/components/loading-placeholder/loading-placeholder';
import Error404 from '~/pages/404/404';

function LoadedPage({
Child, data, props, doDocumentSetup, noCamelCase
}) {
const camelCaseData = React.useMemo(
() => noCamelCase ? data : camelCaseKeys(data),
[data, noCamelCase]
);

useCanonicalLink(doDocumentSetup);
React.useEffect(() => {
if (doDocumentSetup) {
setPageTitleAndDescriptionFromBookData(data);
}
}, [data, doDocumentSetup]);

if (data.error) {
return (<Error404 />);
}

return (
<Child {...{data: camelCaseData, ...props}} />
);
}

export default function LoaderPage({
slug, Child, props={}, preserveWrapping=false, doDocumentSetup=false,
noCamelCase=false
}) {
const data = usePageData(slug, preserveWrapping, noCamelCase);

if (!data) {
return <LoadingPlaceholder />;
}

return (<LoadedPage {...{Child, data, props, doDocumentSetup, noCamelCase}} />);
}
61 changes: 0 additions & 61 deletions src/app/components/jsx-helpers/loader-page.tsx

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 11 additions & 15 deletions test/src/pages/adoption/adoption.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,15 @@ beforeEach(async () => {
test('creates with role selector', () =>
expect(screen.queryAllByRole('option', {hidden: true})).toHaveLength(8));

/* This test works locally, but not on checkin
* Moreover, the form it finds is just the one around the role selector
*/
// test(
// 'form appears when role is selected',
// async () => {
// const listBox = screen.queryByRole('listbox');
// const user = userEvent.setup();
test('form appears when role is selected', async () => {
const listBox = screen.queryByRole('listbox');
const user = userEvent.setup();

// await user.click(listBox);
// const options = await screen.findAllByRole('option', {hidden: true});
// const instructorOption = options.find((o) => o.textContent === 'Instructor');
// await user.click(instructorOption);
// await screen.findByRole('form');
// }
// )
await user.click(listBox);
const options = await screen.findAllByRole('option', {hidden: true});
const instructorOption = options.find(
(o) => o.textContent === 'Instructor'
);
await user.click(instructorOption);
await screen.findByRole('form');
});
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3285,9 +3285,9 @@
integrity sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==

"@types/uglify-js@*":
version "3.17.1"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.17.1.tgz#e0ffcef756476410e5bce2cb01384ed878a195b5"
integrity sha512-GkewRA4i5oXacU/n4MA9+bLgt5/L3F1mKrYvFGm7r2ouLXhRKjuWwo9XHNnbx6WF3vlGW21S3fCvgqxvxXXc5g==
version "3.17.2"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.17.2.tgz#a2ba86fd524f6281a7655463338c546f845b29c3"
integrity sha512-9SjrHO54LINgC/6Ehr81NjAxAYvwEZqjUHLjJYvC4Nmr9jbLQCIZbWSvl4vXQkkmR1UAuaKDycau3O1kWGFyXQ==
dependencies:
source-map "^0.6.1"

Expand Down

0 comments on commit e50b63c

Please sign in to comment.