Skip to content

Commit

Permalink
Got Visualization stories working in UT-HAI fork.
Browse files Browse the repository at this point in the history
  • Loading branch information
patcon committed Oct 17, 2024
1 parent 3e5000f commit 1afb066
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export default {
}

// TODO: Need to mock PolisNet API calls.
const Template = (args) => <div>Not Yet Implemented</div>
const Template = (args) => <VisualisationTutorial {...args} />

export const Default = Template.bind({})
Default.args = {}
Default.args = {
// In theory, something happens at 15, but doesn't seem to work.
currentIndex: 14,
}
8 changes: 6 additions & 2 deletions stories/UT-HAI/client-deliberation/Visualization.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import React from 'react'
import Visualization from '../../../codebases/UT-HAI/client-deliberation/src/components/Visualization'
import { withDelibThemeUi } from '../../../.storybook/decorators'



export default {
component: Visualization,
decorators: [withDelibThemeUi],
}

// TODO: Need to mock PolisNet API calls.
const Template = (args) => <div>Not Yet Implemented</div>
const Template = (args) => <Visualization {...args} />

export const Default = Template.bind({})
// No props on this component.
// We pass in all data by mocking jQuery $.ajax calls made by PolisNet.
// See: .storybook/preview.js
Default.args = {}

0 comments on commit 1afb066

Please sign in to comment.