diff --git a/.github/workflows/deploy-github-pages.yml b/.github/workflows/deploy-github-pages.yml index 8b6d447..57bb80d 100644 --- a/.github/workflows/deploy-github-pages.yml +++ b/.github/workflows/deploy-github-pages.yml @@ -37,6 +37,17 @@ jobs: # Done manually so we can checkout submodule checkout: false + - name: Fail if PR portion of build failed + if: ${{ github.event_name == 'pull_request_target' }} + shell: bash + env: + DIRECTORY: dist/storybook-bundle/PR-${{ github.event.number }} + run: | + if [ ! -d "$DIRECTORY" ]; then + echo Pull Request build directory "$DIRECTORY does not exist." + exit 1 + fi + # See: https://github.com/ouzi-dev/commit-status-updater/pull/533 - uses: patcon/commit-status-updater@patch-1 if: ${{ github.event_name == 'pull_request_target' }} diff --git a/.storybook/preview.js b/.storybook/preview.js index 8627357..180ba53 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -1,5 +1,29 @@ /** @type { import('@storybook/react').Preview } */ import "./style.css" +import { getMath, getComments } from "./utils"; + +// Needed at the very least for Graph component stories of UT-HAI client-deliberation. +import jquery from 'jquery'; +global.$ = jquery; +global.jQuery = jquery; + +// This is where we mock responses for PolisNet endpoints. +// TODO: Create a storybook plugin to do this dynamically. +function ajax_responses(responses) { + return function (params) { + const mockedPathname = new URL(params.url).pathname + const mockResponse = responses[mockedPathname] + var deferred = global.$.Deferred().resolve(mockResponse) + return deferred + }; +} + +global.$.ajax = ajax_responses({ + '/api/v3/math/pca2': getMath(), + '/api/v3/comments': [getComments()], + '/api/v3/votes': [], + '/api/v3/votes/famous': [], +}) const isGithubBuild = !!process.env["GITHUB_REPOSITORY"] const preview = { diff --git a/stories/UT-HAI/client-deliberation/VisualisationTutorial.stories.js b/stories/UT-HAI/client-deliberation/VisualisationTutorial.stories.js index 7635dd2..c69f0bd 100644 --- a/stories/UT-HAI/client-deliberation/VisualisationTutorial.stories.js +++ b/stories/UT-HAI/client-deliberation/VisualisationTutorial.stories.js @@ -8,7 +8,10 @@ export default { } // TODO: Need to mock PolisNet API calls. -const Template = (args) =>