Skip to content

Commit

Permalink
test: add env variable to setup test
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanttV committed Apr 10, 2024
1 parent 8b64635 commit 2716b5f
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ScoringCard = ({
learningContextId,
isLibrary,
}) => {
const isGradingMethodEnabled = getConfig().ENABLE_GRADING_METHOD_IN_PROBLEMS || false;
const isGradingMethodEnabled = getConfig().ENABLE_GRADING_METHOD_IN_PROBLEMS;
const {
handleUnlimitedChange,
handleMaxAttemptChange,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import React from 'react';
import { shallow } from '@edx/react-unit-test-utils';
import { mergeConfig } from '@edx/frontend-platform';
import { formatMessage } from '../../../../../../../testUtils';
import { scoringCardHooks } from '../hooks';
import { ScoringCard } from './ScoringCard';
import { GradingMethodKeys } from '../../../../../../data/constants/problem';

mergeConfig({
ENABLE_GRADING_METHOD_IN_PROBLEMS: true,
});

jest.mock('../hooks', () => ({
scoringCardHooks: jest.fn(),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,58 @@ exports[`ScoringCard snapshot snapshot: scoring setting card 1`] = `
className="scoringCard"
extraSections={Array []}
hasExpandableTextArea={false}
summary="{weight, plural, =0 {Ungraded} other {# points}} · {attempts, plural, =1 {# attempt} other {# attempts}}"
summary="{weight, plural, =0 {Ungraded} other {# points}} · {attempts, plural, =1 {# attempt} other {# attempts}} · Last Score"
title="Scoring"
>
<div
className="mb-4"
>
<FormattedMessage
defaultMessage="Specify point weight and the number of answer attempts"
description="Descriptive text for scoring settings"
id="authoring.problemeditor.settings.scoring.label"
defaultMessage="Specify grading method, point weight and the number of answer attempts"
description="Descriptive text for scoring settings when grading method is enabled"
id="authoring.problemeditor.settings.scoring.label.withGradingMethod"
/>
</div>
<Form.Group>
<Form.Control
as="select"
floatingLabel="Grading Method"
onChange={[MockFunction scoringCardHooks.handleGradingMethodChange]}
value="last_score"
>
<option
key="last_score"
value="last_score"
>
Last Score
</option>
<option
key="highest_score"
value="highest_score"
>
Highest Score
</option>
<option
key="average_score"
value="average_score"
>
Average Score
</option>
<option
key="first_score"
value="first_score"
>
First Score
</option>
</Form.Control>
<Form.Control.Feedback>
<FormattedMessage
defaultMessage="Define the grading method for this problem. By default, it is the score of the last submission made by the student."
description="Summary text for scoring grading method"
id="authoring.problemeditor.settings.scoring.grading.method.hint"
/>
</Form.Control.Feedback>
</Form.Group>
<Form.Group>
<Form.Control
floatingLabel="Points"
Expand Down Expand Up @@ -80,18 +120,58 @@ exports[`ScoringCard snapshot snapshot: scoring setting card max attempts 1`] =
className="scoringCard"
extraSections={Array []}
hasExpandableTextArea={false}
summary="{weight, plural, =0 {Ungraded} other {# points}} · Unlimited attempts"
summary="{weight, plural, =0 {Ungraded} other {# points}} · Unlimited attempts · Last Score"
title="Scoring"
>
<div
className="mb-4"
>
<FormattedMessage
defaultMessage="Specify point weight and the number of answer attempts"
description="Descriptive text for scoring settings"
id="authoring.problemeditor.settings.scoring.label"
defaultMessage="Specify grading method, point weight and the number of answer attempts"
description="Descriptive text for scoring settings when grading method is enabled"
id="authoring.problemeditor.settings.scoring.label.withGradingMethod"
/>
</div>
<Form.Group>
<Form.Control
as="select"
floatingLabel="Grading Method"
onChange={[MockFunction scoringCardHooks.handleGradingMethodChange]}
value="last_score"
>
<option
key="last_score"
value="last_score"
>
Last Score
</option>
<option
key="highest_score"
value="highest_score"
>
Highest Score
</option>
<option
key="average_score"
value="average_score"
>
Average Score
</option>
<option
key="first_score"
value="first_score"
>
First Score
</option>
</Form.Control>
<Form.Control.Feedback>
<FormattedMessage
defaultMessage="Define the grading method for this problem. By default, it is the score of the last submission made by the student."
description="Summary text for scoring grading method"
id="authoring.problemeditor.settings.scoring.grading.method.hint"
/>
</Form.Control.Feedback>
</Form.Group>
<Form.Group>
<Form.Control
floatingLabel="Points"
Expand Down Expand Up @@ -155,18 +235,58 @@ exports[`ScoringCard snapshot snapshot: scoring setting card zero zero weight 1`
className="scoringCard"
extraSections={Array []}
hasExpandableTextArea={false}
summary="{weight, plural, =0 {Ungraded} other {# points}} · {attempts, plural, =1 {# attempt} other {# attempts}}"
summary="{weight, plural, =0 {Ungraded} other {# points}} · {attempts, plural, =1 {# attempt} other {# attempts}} · Last Score"
title="Scoring"
>
<div
className="mb-4"
>
<FormattedMessage
defaultMessage="Specify point weight and the number of answer attempts"
description="Descriptive text for scoring settings"
id="authoring.problemeditor.settings.scoring.label"
defaultMessage="Specify grading method, point weight and the number of answer attempts"
description="Descriptive text for scoring settings when grading method is enabled"
id="authoring.problemeditor.settings.scoring.label.withGradingMethod"
/>
</div>
<Form.Group>
<Form.Control
as="select"
floatingLabel="Grading Method"
onChange={[MockFunction scoringCardHooks.handleGradingMethodChange]}
value="last_score"
>
<option
key="last_score"
value="last_score"
>
Last Score
</option>
<option
key="highest_score"
value="highest_score"
>
Highest Score
</option>
<option
key="average_score"
value="average_score"
>
Average Score
</option>
<option
key="first_score"
value="first_score"
>
First Score
</option>
</Form.Control>
<Form.Control.Feedback>
<FormattedMessage
defaultMessage="Define the grading method for this problem. By default, it is the score of the last submission made by the student."
description="Summary text for scoring grading method"
id="authoring.problemeditor.settings.scoring.grading.method.hint"
/>
</Form.Control.Feedback>
</Form.Group>
<Form.Group>
<Form.Control
floatingLabel="Points"
Expand Down

0 comments on commit 2716b5f

Please sign in to comment.