Skip to content

Commit

Permalink
Moved reports data into file to align with other test data. Improved …
Browse files Browse the repository at this point in the history
…util helper docs.
  • Loading branch information
patcon committed Oct 21, 2024
1 parent 20268fa commit a0bd01c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
23 changes: 23 additions & 0 deletions .storybook/data/3ntrtcehas-reports.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"report_id": "r68fknmmmyhdpi3sh4ctc",
"created": "1515990588733",
"modified": "1515991093181",
"label_x_neg": null,
"label_y_neg": null,
"label_y_pos": null,
"label_x_pos": null,
"label_group_0": null,
"label_group_1": null,
"label_group_2": null,
"label_group_3": null,
"label_group_4": null,
"label_group_5": null,
"label_group_6": null,
"label_group_7": null,
"label_group_8": null,
"label_group_9": null,
"report_name": "SamplePoll14Jan",
"conversation_id": "3ntrtcehas"
}
]
30 changes: 8 additions & 22 deletions .storybook/utils.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import * as globals from "../codebases/compdem/client-report/src/components/globals";
import participationData from './data/3ntrtcehas-participation-init.json'
import commentsData from './data/3ntrtcehas-comments.json'
import reportsData from './data/3ntrtcehas-reports.json'

// Simulates response data from /api/v3/math/pca2?conversation_id=3ntrtcehas
export const getMath = () => {
return JSON.parse(participationData.pca)
}

// Simulates manipulation of response data done in application code.
export const getExtremity = () => {
const mathResult = getMath()
return mathResult.pca["comment-extremity"].reduce(
Expand All @@ -17,36 +20,19 @@ export const getExtremity = () => {
)
}

// Simulates response data from /api/v3/conversations?conversation_id=3ntrtcehas
export const getConversation = () => {
return participationData.conversation
}

// Simulates response data from /api/v3/comments?conversation_id=3ntrtcehas&moderation=true&include_voting_patterns=true
export const getComments = () => {
return commentsData
}

export const getReport = () => {
return {
"report_id": "r3bpnywujybyru4rkx92i", // example; might not match
"created": participationData.conversation.created,
"modified": participationData.conversation.modified,
"label_x_neg": null,
"label_y_neg": null,
"label_y_pos": null,
"label_x_pos": null,
"label_group_0": null,
"label_group_1": null,
"label_group_2": null,
"label_group_3": null,
"label_group_4": null,
"label_group_5": null,
"label_group_6": null,
"label_group_7": null,
"label_group_8": null,
"label_group_9": null,
"report_name": null,
"conversation_id": participationData.conversation.conversation_id
}
// Simulates response data from /api/v3/reports?report_id=r3bpnywujybyru4rkx92i
export const getReports = () => {
return reportsData
}

export const getVoteColors = () => ({
Expand Down
4 changes: 2 additions & 2 deletions stories/compdem/client-report/ParticipantsGraph.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import ParticipantsGraph from '../../../codebases/compdem/client-report/src/components/participantsGraph/participantsGraph';

import '../../../codebases/compdem/client-report/src/index.css';
import { getComments, getMath, getReport, getVoteColors } from '../../../.storybook/utils';
import { getComments, getMath, getReports, getVoteColors } from '../../../.storybook/utils';

export default {
title: 'compdem/client-report/ParticipantsGraph',
Expand Down Expand Up @@ -58,6 +58,6 @@ Default.args = {
repfulAgreeTidsByGroup: null,
math: getMath(),
renderHeading: true,
report: getReport(),
report: getReports()[0],
voteColors: getVoteColors(),
}

0 comments on commit a0bd01c

Please sign in to comment.