Skip to content

Commit

Permalink
Provide a more appropriate 'staticUrl' mock for storybook (#248)
Browse files Browse the repository at this point in the history
## Summary:
The mock we were using 'staticUrl' was returning invalid URLs.  This is fine for @testing-library tests since we don't care about broken images there.  This PR fixes the situation for storybook but using a pass-through function.

Issue: None

## Test plan:
- yarn storybook
- look at the grapher stories, see that they all have graph paper backgrounds

<img width="1375" alt="Screen Shot 2022-05-23 at 6 26 33 PM" src="https://user-images.githubusercontent.com/1044413/169914748-86106bfe-16f6-4aee-bd73-327b22d8ea7f.png">

Author: kevinbarabash

Reviewers: jeremywiebe

Required Reviewers:

Approved By: jeremywiebe

Checks: ✅ Extract i18n strings (ubuntu-latest, 16.x), ⌛ Check builds for changes in size (ubuntu-latest, 16.x), ⌛ Jest Coverage (ubuntu-latest, 16.x), ✅ Cypress Coverage (ubuntu-latest, 16.x), ✅ gerald, ⌛ Lint, Flow, and Test (ubuntu-latest, 16.x), ✅ Check for .changeset file (ubuntu-latest, 16.x)

Pull Request URL: #248
  • Loading branch information
kevinbarabash authored May 25, 2022
1 parent d511209 commit 2bfc2f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .changeset/pink-otters-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
8 changes: 2 additions & 6 deletions testing/renderer-with-debug-ui.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {Dependencies, Renderer} from "../packages/perseus/src/index.js";
import {registerAllWidgetsForTesting} from "../packages/perseus/src/util/register-all-widgets-for-testing.js";

import SideBySide from "./side-by-side.jsx";
import {testDependencies} from "./test-dependencies.js";
import {TestTeX} from "./test-tex.jsx";
import {storybookTestDependencies} from "./test-dependencies.js";

import type {PerseusRenderer} from "../packages/perseus/src/perseus-types.js";
import type {APIOptions} from "../packages/perseus/src/types.js";
Expand All @@ -30,10 +29,7 @@ export const RendererWithDebugUI = ({
registerAllWidgetsForTesting();
const ref = React.useRef<?Renderer>(null);
const [state, setState] = React.useState(null);
Dependencies.setDependencies({
...testDependencies,
TeX: TestTeX,
});
Dependencies.setDependencies(storybookTestDependencies);

return (
<SideBySide
Expand Down
7 changes: 7 additions & 0 deletions testing/test-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ export const testDependencies: PerseusDependencies = {
Log: LogForTesting,
};

export const storybookTestDependencies: PerseusDependencies = {
...testDependencies,
TeX: TestTeX,
// $FlowIgnore[incompatible-type]
staticUrl: (str) => str,
};

export const cypressTestDependencies: PerseusDependencies = {
...testDependencies,
TeX: TestTeX,
Expand Down

0 comments on commit 2bfc2f8

Please sign in to comment.