Skip to content

Commit 6b5c8e2

Browse files
committed
update snaps
1 parent a04de58 commit 6b5c8e2

File tree

5 files changed

+120
-19
lines changed

5 files changed

+120
-19
lines changed

src/components/Print.stories.tsx

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { ExerciseData, ExerciseQueryData, ExerciseQuestionData, StepBase } from '../../src/types';
2+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
3+
// @ts-ignore
4+
import data from '../../exercises.json';
5+
import styled from 'styled-components';
6+
import { Exercise } from './Exercise';
7+
8+
const ExerciseWrapper = styled.div`
9+
break-inside: avoid;
10+
11+
.step-card-body {
12+
padding: 24px 48px !important;
13+
}
14+
15+
.step-card-footer {
16+
display: none;
17+
}
18+
19+
.exercise-id {
20+
height: auto;
21+
}
22+
23+
.exercise-step {
24+
min-height: auto;
25+
}
26+
27+
.question-feedback {
28+
box-shadow: none !important;
29+
}
30+
31+
.openstax-answer {
32+
break-inside: avoid;
33+
34+
.answer-letter-wrapper::after {
35+
content: '' !important;
36+
}
37+
}
38+
`;
39+
40+
const exercises = (data as ExerciseQueryData).exercises as ExerciseData[];
41+
42+
const firstQuestionNumByExercise = exercises.reduce((acc, ex) => ({
43+
...acc,
44+
[ex.uuid]: acc.questionCounter + 1,
45+
questionCounter: acc.questionCounter + ex.questions.length
46+
}), {questionCounter: 0});
47+
48+
// placeholder until exercise data contains correct answer IDs
49+
const formatAnswerData = (questions: ExerciseQuestionData[]) => questions.map((q) => (
50+
{id: q.id, correct_answer_id: (q.answers.find((a) => a.correctness === '1.0')?.id || '')}));
51+
52+
const questionStateFields = {
53+
available_points: '1.0',
54+
is_completed: true,
55+
answer_id: '1',
56+
free_response: '',
57+
feedback_html: '',
58+
correct_answer_feedback_html: '',
59+
attempts_remaining: 0,
60+
attempt_number: 1,
61+
incorrectAnswerId: 0
62+
}
63+
64+
export const Default = () => (
65+
<>
66+
{data.title && <h2>Exercises for {data.title}</h2>}
67+
{exercises.map(((exercise) => {
68+
69+
const step: StepBase = {
70+
id: 1,
71+
uid: exercise.uid,
72+
available_points: '1.0',
73+
};
74+
75+
const questionStates = formatAnswerData(exercise.questions).reduce((acc, answer) => {
76+
const {id, correct_answer_id} = answer;
77+
return {...acc, [id]: {...questionStateFields, correct_answer_id}};
78+
}, {});
79+
80+
return (
81+
<ExerciseWrapper key={exercise.uid}>
82+
<Exercise
83+
key={exercise.uid}
84+
canAnswer={true}
85+
needsSaved={true}
86+
hasMultipleAttempts={false}
87+
onAnswerChange={() => undefined}
88+
onAnswerSave={() => undefined}
89+
onNextStep={() => undefined}
90+
apiIsPending={false}
91+
canUpdateCurrentStep={false}
92+
exercise={exercise}
93+
step={step}
94+
questionNumber={firstQuestionNumByExercise[exercise.uuid]}
95+
numberOfQuestions={exercises.length}
96+
questionStates={questionStates}
97+
show_all_feedback={true} />
98+
</ExerciseWrapper>
99+
)
100+
}))}
101+
</>);

src/components/__snapshots__/Card.spec.tsx.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`StepCard matches snapshot 1`] = `
55
className="sc-gsnTZi dxdISE"
66
>
77
<div
8-
className="sc-bczRLJ LfjAZ"
8+
className="sc-bczRLJ eAXREJ"
99
>
1010
<div>
1111
<div
@@ -58,7 +58,7 @@ exports[`StepCard matches snapshot with more than one question 1`] = `
5858
className="sc-gsnTZi dxdISE"
5959
>
6060
<div
61-
className="sc-bczRLJ LfjAZ"
61+
className="sc-bczRLJ eAXREJ"
6262
>
6363
<div>
6464
<div
@@ -118,7 +118,7 @@ exports[`TaskStepCard can optionally provide task 1`] = `
118118
data-task-step-id={1}
119119
>
120120
<div
121-
className="sc-bczRLJ LfjAZ exercise-step"
121+
className="sc-bczRLJ eAXREJ exercise-step"
122122
>
123123
<div>
124124
<div
@@ -163,7 +163,7 @@ exports[`TaskStepCard can optionally provide type 1`] = `
163163
data-task-step-id={1}
164164
>
165165
<div
166-
className="sc-bczRLJ LfjAZ exercise-step"
166+
className="sc-bczRLJ eAXREJ exercise-step"
167167
>
168168
<div>
169169
<div
@@ -208,7 +208,7 @@ exports[`TaskStepCard matches snapshot 1`] = `
208208
data-task-step-id={1}
209209
>
210210
<div
211-
className="sc-bczRLJ LfjAZ exercise-step"
211+
className="sc-bczRLJ eAXREJ exercise-step"
212212
>
213213
<div>
214214
<div

src/components/__snapshots__/CompletionStatus.spec.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`CompletionStatus matches snapshot 1`] = `
44
<div
5-
className="sc-bczRLJ sc-gKXOVf LfjAZ hSbqXj sc-ftvSup"
5+
className="sc-bczRLJ sc-gKXOVf eAXREJ hSbqXj sc-ftvSup"
66
>
77
<h2
88
className="sc-iBkjds jcQjIn"
@@ -24,7 +24,7 @@ exports[`CompletionStatus matches snapshot 1`] = `
2424

2525
exports[`CompletionStatus matches snapshot with all questions completed 1`] = `
2626
<div
27-
className="sc-bczRLJ sc-gKXOVf LfjAZ hSbqXj sc-ftvSup"
27+
className="sc-bczRLJ sc-gKXOVf eAXREJ hSbqXj sc-ftvSup"
2828
>
2929
<h2
3030
className="sc-iBkjds jcQjIn"
@@ -46,7 +46,7 @@ exports[`CompletionStatus matches snapshot with all questions completed 1`] = `
4646

4747
exports[`CompletionStatus matches snapshot with some questions completed 1`] = `
4848
<div
49-
className="sc-bczRLJ sc-gKXOVf LfjAZ hSbqXj sc-ftvSup"
49+
className="sc-bczRLJ sc-gKXOVf eAXREJ hSbqXj sc-ftvSup"
5050
>
5151
<h2
5252
className="sc-iBkjds jcQjIn"

src/components/__snapshots__/Exercise.spec.tsx.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ exports[`Exercise using step data matches snapshot 1`] = `
99
data-task-step-id={1}
1010
>
1111
<div
12-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl QazMO"
12+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl QCsJH"
1313
>
1414
<div>
1515
<div
@@ -206,7 +206,7 @@ exports[`Exercise with overlay rendering matches snapshot 1`] = `
206206
data-task-step-id={1}
207207
>
208208
<div
209-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl QazMO"
209+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl QCsJH"
210210
>
211211
<div
212212
onBlur={[Function]}
@@ -408,7 +408,7 @@ exports[`Exercise with overlay rendering matches snapshot with previewMode 1`] =
408408
data-task-step-id={1}
409409
>
410410
<div
411-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl QazMO"
411+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl QCsJH"
412412
>
413413
<div
414414
onBlur={[Function]}
@@ -581,7 +581,7 @@ exports[`Exercise with question state data matches snapshot 1`] = `
581581
data-task-step-id={1}
582582
>
583583
<div
584-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl QazMO"
584+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl QCsJH"
585585
>
586586
<div>
587587
<div
@@ -826,7 +826,7 @@ exports[`Exercise with question state data renders header icons with multiple ch
826826
data-task-step-id={1}
827827
>
828828
<div
829-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl QazMO"
829+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl QCsJH"
830830
>
831831
<div>
832832
<div
@@ -1157,7 +1157,7 @@ exports[`Exercise with question state data renders header icons with two-step ex
11571157
data-task-step-id={1}
11581158
>
11591159
<div
1160-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl QazMO"
1160+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl QCsJH"
11611161
>
11621162
<div>
11631163
<div
@@ -1474,7 +1474,7 @@ exports[`Exercise with question state data shows a detailed solution 1`] = `
14741474
data-task-step-id={1}
14751475
>
14761476
<div
1477-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl QazMO"
1477+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl QCsJH"
14781478
>
14791479
<div>
14801480
<div

src/components/__snapshots__/ExercisePreview.spec.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ exports[`ExercisePreview using step data matches snapshot with overlay and corre
99
data-task-step-id={1}
1010
>
1111
<div
12-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-fEOsli QazMO ubRcZ preview-card is-selected"
12+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-fEOsli QCsJH ubRcZ preview-card is-selected"
1313
>
1414
<div
1515
onBlur={[Function]}
@@ -199,7 +199,7 @@ exports[`ExercisePreview using step data matches snapshot with overlay and selec
199199
data-task-step-id={1}
200200
>
201201
<div
202-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-bjUoiL QazMO cePIaL preview-card is-selected"
202+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-bjUoiL QCsJH cePIaL preview-card is-selected"
203203
>
204204
<div
205205
onBlur={[Function]}
@@ -383,7 +383,7 @@ exports[`ExercisePreview using step data matches snapshot with overlay and selec
383383
data-task-step-id={1}
384384
>
385385
<div
386-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-fnykZs QazMO dNZVdw preview-card is-selected"
386+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-fnykZs QCsJH dNZVdw preview-card is-selected"
387387
>
388388
<div
389389
onBlur={[Function]}
@@ -573,7 +573,7 @@ exports[`ExercisePreview using step data matches snapshot without overlay 1`] =
573573
data-task-step-id={1}
574574
>
575575
<div
576-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-idiyUo QazMO mjsmp preview-card "
576+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-idiyUo QCsJH mjsmp preview-card "
577577
>
578578
<div>
579579
<div

0 commit comments

Comments
 (0)