Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Added new organization onboarding UI and associated tests #493

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
266 changes: 266 additions & 0 deletions __tests__/components/__snapshots__/orgOnboardingModal.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Onboarding modal renders the combobox correctly when University is selected 1`] = `
[
<button
aria-hidden={true}
data-headlessui-focus-guard={true}
onFocus={[Function]}
style={
{
"borderWidth": "0",
"clip": "rect(0, 0, 0, 0)",
"height": 0,
"left": 1,
"margin": -1,
"overflow": "hidden",
"padding": 0,
"position": "fixed",
"top": 1,
"whiteSpace": "nowrap",
"width": 1,
}
}
type="button"
/>,
<div
onBlur={[Function]}
onKeyDown={[Function]}
>
<div
aria-labelledby="headlessui-dialog-title-:r2:"
aria-modal={true}
className="relative z-10"
data-headlessui-state="open"
id="headlessui-dialog-:r0:"
role="dialog"
>
<div
className="fixed inset-0 bg-black bg-opacity-25"
/>
<div
className="fixed inset-0 overflow-y-auto"
>
<div
className="flex min-h-full items-center justify-center p-4 text-center"
>
<div
className="w-full max-w-md transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all"
data-headlessui-state="open"
id="headlessui-dialog-panel-:r1:"
onClick={[Function]}
>
<h3
className="text-lg font-medium leading-6 text-gray-900"
data-headlessui-state="open"
id="headlessui-dialog-title-:r2:"
>
Welcome! Please fill out this information to get started with Classroom Mode!
</h3>
<div
className="mt-2"
>
<label>
Organization name:
<input
className="w-full"
name="organizationName"
onChange={[Function]}
placeholder="ACME State University"
required={true}
/>
</label>
<label>
Full Name:
<input
className="w-full"
name="primaryUserFullName"
onChange={[Function]}
placeholder="John Acme"
required={true}
/>
</label>
<label>
Email:
<input
className="w-full"
name="primaryUserEmail"
onChange={[Function]}
placeholder="[email protected]"
required={true}
/>
</label>
<div
className="w-full h-fill mt-2"
>
<input
hidden={true}
name="organizationType[id]"
readOnly={true}
style={
{
"borderWidth": "0",
"clip": "rect(0, 0, 0, 0)",
"display": "none",
"height": 0,
"left": 1,
"margin": -1,
"overflow": "hidden",
"padding": 0,
"position": "fixed",
"top": 1,
"whiteSpace": "nowrap",
"width": 1,
}
}
type="hidden"
value="1"
/>
<input
hidden={true}
name="organizationType[name]"
readOnly={true}
style={
{
"borderWidth": "0",
"clip": "rect(0, 0, 0, 0)",
"display": "none",
"height": 0,
"left": 1,
"margin": -1,
"overflow": "hidden",
"padding": 0,
"position": "fixed",
"top": 1,
"whiteSpace": "nowrap",
"width": 1,
}
}
type="hidden"
value="University"
/>
<div
className="relative mt-1"
>
<div
className="relative w-full cursor-default overflow-hidden rounded-lg bg-white text-left shadow-md focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-teal-300 sm:text-sm"
>
<label
data-headlessui-state=""
id="headlessui-combobox-label-:r3:"
onClick={[Function]}
>
Organization Type:
</label>
<input
aria-autocomplete="list"
aria-expanded={false}
aria-labelledby="headlessui-combobox-label-:r3:"
className="w-full border-none py-2 pl-3 pr-10 text-sm leading-5 text-gray-900 focus:ring-0"
data-headlessui-state=""
disabled={false}
id="headlessui-combobox-input-:r4:"
onBlur={[Function]}
onChange={[Function]}
onCompositionEnd={[Function]}
onCompositionStart={[Function]}
onKeyDown={[Function]}
role="combobox"
type="text"
/>
<button
aria-expanded={false}
aria-haspopup="listbox"
aria-labelledby="headlessui-combobox-label-:r3: headlessui-combobox-button-:r5:"
className="absolute inset-y-0 right-0 flex items-center pr-2"
data-headlessui-state=""
disabled={false}
id="headlessui-combobox-button-:r5:"
onClick={[Function]}
onKeyDown={[Function]}
tabIndex={-1}
type="button"
>
<svg
className="w-6 h-6"
fill="none"
stroke="currentColor"
strokeWidth={1.5}
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M19.5 8.25l-7.5 7.5-7.5-7.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</button>
</div>
</div>
</div>
</div>
<div
className="flex mt-4 justify-between"
>
<button
className="inline-flex justify-center rounded-md border border-transparent bg-red-700 px-4 py-2 text-sm font-medium text-white hover:bg-red-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-red-500 focus-visible:ring-offset-2"
onClick={[Function]}
type="button"
>
Cancel
</button>
<button
className="inline-flex justify-center rounded-md border border-transparent bg-blue-100 px-4 py-2 text-sm font-medium text-blue-900 hover:bg-blue-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2"
onClick={[Function]}
type="button"
>
Submit
</button>
</div>
</div>
</div>
</div>
</div>
</div>,
<button
aria-hidden={true}
data-headlessui-focus-guard={true}
onFocus={[Function]}
style={
{
"borderWidth": "0",
"clip": "rect(0, 0, 0, 0)",
"height": 0,
"left": 1,
"margin": -1,
"overflow": "hidden",
"padding": 0,
"position": "fixed",
"top": 1,
"whiteSpace": "nowrap",
"width": 1,
}
}
type="button"
/>,
<div
style={
{
"borderWidth": "0",
"clip": "rect(0, 0, 0, 0)",
"display": "none",
"height": 0,
"left": 1,
"margin": -1,
"overflow": "hidden",
"padding": 0,
"position": "fixed",
"top": 1,
"whiteSpace": "nowrap",
"width": 1,
}
}
/>,
]
`;
34 changes: 34 additions & 0 deletions __tests__/components/orgOnboardingModal.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { screen, render } from '@testing-library/react'
import '@testing-library/jest-dom'
import OrgOnboardingModal from '../../components/orgOnboardingModal'
import React from 'react'
import renderer from 'react-test-renderer'

// Allows us to mock createPortal which is used to render our Modal.
jest.mock('react-dom', () => ({
// @ts-ignore
...jest.requireActual('react-dom'),
createPortal: node => node
}))

// Used when rendering our <OrgOnboardingModal /> by Jest.
global.ResizeObserver = jest.fn().mockImplementation(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
}))

describe('Onboarding modal', () => {
it('renders the combobox correctly when University is selected', () => {
const tree = renderer.create(
<OrgOnboardingModal></OrgOnboardingModal>
).toJSON();
expect(tree).toMatchSnapshot();
})

// This test passes selectedOrg into our component. However, this pattern is not followed inside of our parent page where we call <OrgOnboardingModal />. This props should only be included when testing the component.
it(`should render the 'otherType' input`, () => {
render(<OrgOnboardingModal selectedOrg={4}></OrgOnboardingModal>)
expect(screen.getByLabelText('Please specify:')).toBeInTheDocument();
})
})
Loading