diff --git a/package.json b/package.json index bb5245dee..b551f636b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openstax/ui-components", - "version": "1.18.7", + "version": "1.19.0", "license": "MIT", "source": "./src/index.ts", "types": "./dist/index.d.ts", @@ -40,6 +40,7 @@ "@types/dompurify": "^3.0.0", "@testing-library/jest-dom": "^6.4.8", "@testing-library/react": "^12.0.0", + "@testing-library/react-hooks": "^8.0.1", "@testing-library/user-event": "^14.5.2", "@types/jest": "^28.1.4", "@types/node": "^18.7.5", diff --git a/src/components/HelpMenu.spec.tsx b/src/components/HelpMenu.spec.tsx deleted file mode 100644 index db2d6cc2b..000000000 --- a/src/components/HelpMenu.spec.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { render } from '@testing-library/react'; -import { BodyPortalSlotsContext } from './BodyPortalSlotsContext'; -import { HelpMenu, HelpMenuItem } from './HelpMenu'; -import { NavBar } from './NavBar'; - -describe('HelpMenu', () => { - let root: HTMLElement; - - beforeEach(() => { - root = document.createElement('main'); - root.id = 'root'; - document.body.append(root); - }); - - it('matches snapshot', () => { - render( - - - - window.alert('Ran HelpMenu callback function')}> - Test Callback - - - - - ); - - expect(document.body).toMatchSnapshot(); - }); -}); diff --git a/src/components/HelpMenu.stories.tsx b/src/components/HelpMenu.stories.tsx deleted file mode 100644 index 4c7dd2cc3..000000000 --- a/src/components/HelpMenu.stories.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { createGlobalStyle } from 'styled-components'; -import { BodyPortalSlotsContext } from './BodyPortalSlotsContext'; -import { HelpMenu, HelpMenuItem } from './HelpMenu'; -import { NavBar } from './NavBar'; - -const BodyPortalGlobalStyle = createGlobalStyle` - [data-portal-slot="nav"] { - position: fixed; - top: 0; - width: 100%; - } -`; - -export const Default = () => { - return ( - - - - - window.alert('Ran HelpMenu callback function')}> - Test Callback - - - - - ); -}; diff --git a/src/components/HelpMenu/HelpMenu.stories.tsx b/src/components/HelpMenu/HelpMenu.stories.tsx new file mode 100644 index 000000000..db90653bb --- /dev/null +++ b/src/components/HelpMenu/HelpMenu.stories.tsx @@ -0,0 +1,46 @@ +import { createGlobalStyle } from 'styled-components'; +import { BodyPortalSlotsContext } from '../BodyPortalSlotsContext'; +import { HelpMenu, HelpMenuItem, HelpMenuProps } from '.'; +import { NavBar } from '../NavBar'; +import { ChatConfiguration } from './hooks'; + +const BodyPortalGlobalStyle = createGlobalStyle` + [data-portal-slot="nav"] { + position: fixed; + top: 0; + width: 100%; + } +`; + +const happyHoursResponse: ChatConfiguration['businessHours'] = { + businessHoursInfo: { + businessHours: [ + { startTime: Date.now() - 60_000, endTime: Date.now() + 1_440_000 } + ] + }, + timestamp: Date.now(), +}; + +const contactParams: HelpMenuProps['contactFormParams'] = [ + { key: 'userId', value: 'test' }, + { key: 'userFirstName', value: 'test' }, + { key: 'organizationName', value: 'org' }, +]; + +const chatEmbedPath = 'https://localhost/assignable-chat'; +const chatEmbedParams: HelpMenuProps['chatConfig'] = {chatEmbedPath, businessHours: happyHoursResponse}; + +export const Default = () => { + return ( + + + + + window.alert('Ran HelpMenu callback function')}> + Test Callback + + + + + ); +}; diff --git a/src/components/__snapshots__/HelpMenu.spec.tsx.snap b/src/components/HelpMenu/__snapshots__/index.spec.tsx.snap similarity index 61% rename from src/components/__snapshots__/HelpMenu.spec.tsx.snap rename to src/components/HelpMenu/__snapshots__/index.spec.tsx.snap index 1cb9b0f48..19ed30bb2 100644 --- a/src/components/__snapshots__/HelpMenu.spec.tsx.snap +++ b/src/components/HelpMenu/__snapshots__/index.spec.tsx.snap @@ -3,6 +3,7 @@ exports[`HelpMenu matches snapshot 1`] = `
-
+