Skip to content

Commit

Permalink
fix: storybook runner tests and vrt
Browse files Browse the repository at this point in the history
  • Loading branch information
SiTaggart committed Oct 17, 2023
1 parent 25ebf5e commit 6ae0c62
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Text } from "@twilio-paste/text";
import * as React from "react";
import { useHotkeys } from "react-hotkeys-hook";

Check failure on line 7 in packages/paste-website/src/components/site-wrapper/site-header/SiteHeaderSearch.tsx

View workflow job for this annotation

GitHub Actions / Lint repository

There should be no empty line within import group

import { ScreenReaderOnly } from "@twilio-paste/screen-reader-only";

Check failure on line 9 in packages/paste-website/src/components/site-wrapper/site-header/SiteHeaderSearch.tsx

View workflow job for this annotation

GitHub Actions / Lint repository

There should be at least one empty line between import groups
import { SiteSearch } from "../../site-search";

const SiteHeaderSearch: React.FC = () => {
Expand Down Expand Up @@ -58,10 +59,11 @@ const SiteHeaderSearch: React.FC = () => {
Search
</Text>
</Box>
<Box as="span">
<Box as="span" aria-hidden="true">
<InlineCode></InlineCode>
<InlineCode>K</InlineCode>
</Box>
<ScreenReaderOnly>Keyboard shortcut: Command / Control K</ScreenReaderOnly>
</Box>
</Button>
<SiteSearch isOpen={isOpen} onDismiss={onClose} />
Expand Down
20 changes: 17 additions & 3 deletions packages/paste-website/stories/SiteSearch.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { type StoryFn } from "@storybook/react";
import { Box } from "@twilio-paste/box";
import { useUID } from "@twilio-paste/uid-library";
import * as React from "react";

import { SearchEmptyState } from "../src/components/site-search/SearchEmptyState";
import { SearchForm } from "../src/components/site-search/SearchForm";
import { SearchModal } from "../src/components/site-search/SearchModal";
import { SearchResultsList } from "../src/components/site-search/SearchResults";
import { SearchResultsLoading } from "../src/components/site-search/SearchResultsLoading";
import { type GroupedSearchResults } from "../src/components/site-search/types";
Expand All @@ -20,7 +20,8 @@ const MockSearchModal: React.FC<{
const modalHeadingId = useUID();
const inputRef = React.useRef<HTMLInputElement>(null);
return (
<SearchModal isOpen={true} ariaLabelledby={modalHeadingId} onDismiss={() => {}} initialFocusRef={inputRef}>
// we don't need to VRT a modal, we know what they look like else where, we only care about the content
<Box>
<SearchForm
onSubmit={() => {}}
hasResults={Object.keys(results).length > 0}
Expand All @@ -33,12 +34,25 @@ const MockSearchModal: React.FC<{
{loading && Object.keys(results).length === 0 && <SearchResultsLoading />}
{showEmptyState && Object.keys(results).length === 0 && <SearchEmptyState searchQuery={searchQuery} />}
<SearchResultsList results={results} />
</SearchModal>
</Box>
);
};
export const SiteSearchTrigger: StoryFn = () => {
return <SiteHeaderSearch />;
};
SiteSearchTrigger.parameters = {
a11y: {
config: {
rules: [
{
id: "color-contrast",
// This uses a symbol as text content and even though it's ignored aXe can't cope with figuring out if it's accessible or not
enabled: false,
},
],
},
},
};

export const SiteSearchModalInitialState: StoryFn = () => {
return <MockSearchModal results={{}} searchQuery="" />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { GroupedSearchResults } from "../../src/components/site-search/types";

export const mockResults = {
"src/pages/components/in-page-navigation/index": [
{
Expand Down Expand Up @@ -150,4 +152,4 @@ export const mockResults = {
slug: "discussion-5372221",
},
],
};
} as GroupedSearchResults;

0 comments on commit 6ae0c62

Please sign in to comment.