-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create randomized storybook stories for Radio, Categorizer, Dropdown,…
… Explanation, Expression, and interactive graph (#788) ## Summary: Created during hackathon 2023 - Basically manual fuzz testing - random configurations for widgets. Issue: None ## Test plan: None
- Loading branch information
Showing
11 changed files
with
698 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/perseus": minor | ||
--- | ||
|
||
create randomized storybook stories for some widgets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/perseus/src/widgets/__stories__/random-widgets.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import Button from "@khanacademy/wonder-blocks-button"; | ||
import * as React from "react"; | ||
|
||
import {RendererWithDebugUI} from "../../../../../testing/renderer-with-debug-ui"; | ||
import {randomCategorizerGenerator} from "../__testdata__/categorizer.testdata"; | ||
import {randomDropdownGenerator} from "../__testdata__/dropdown.testdata"; | ||
import {randomExplanationGenerator} from "../__testdata__/explanation.testdata"; | ||
import {randomExpressionGenerator} from "../__testdata__/expression.testdata"; | ||
import {randomInteractiveGraphGenerator} from "../__testdata__/interactive-graph-random.testdata"; | ||
import {randomRadioGenerator} from "../__testdata__/radio.testdata"; | ||
|
||
import type {PerseusRenderer} from "@khanacademy/perseus"; | ||
|
||
export default { | ||
title: "Perseus/Randomized Widgets", | ||
}; | ||
|
||
const RandomizedWidgetContainer = ( | ||
randomizer: () => PerseusRenderer, | ||
): React.ReactElement => { | ||
const [question, setQuestion] = React.useState(randomizer()); | ||
const randomize = () => { | ||
setQuestion(randomizer()); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Button size="small" style={{marginBottom: 24}} onClick={randomize}> | ||
Randomize | ||
</Button> | ||
|
||
<RendererWithDebugUI question={question} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export const RandomCategorizer = (): React.ReactElement => { | ||
return RandomizedWidgetContainer(randomCategorizerGenerator); | ||
}; | ||
|
||
export const RandomDropdown = (): React.ReactElement => { | ||
return RandomizedWidgetContainer(randomDropdownGenerator); | ||
}; | ||
|
||
export const RandomExplanation = (): React.ReactElement => { | ||
return RandomizedWidgetContainer(randomExplanationGenerator); | ||
}; | ||
|
||
export const RandomExpression = (): React.ReactElement => { | ||
return RandomizedWidgetContainer(randomExpressionGenerator); | ||
}; | ||
|
||
export const RandomInteractiveGraph = (): React.ReactElement => { | ||
return RandomizedWidgetContainer(randomInteractiveGraphGenerator); | ||
}; | ||
|
||
export const RandomRadio = (): React.ReactElement => { | ||
return RandomizedWidgetContainer(randomRadioGenerator); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.