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 5, 2024
1 parent 8b64635 commit 8a00df7
Show file tree
Hide file tree
Showing 3 changed files with 140 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
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
7 changes: 7 additions & 0 deletions src/setupTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import 'babel-polyfill';
import 'jest-canvas-mock';

import { mergeConfig } from '@edx/frontend-platform';

/* need to mock window for tinymce on import, as it is JSDOM incompatible */

Object.defineProperty(window, 'matchMedia', {
Expand Down Expand Up @@ -40,6 +42,11 @@ process.env.LOGO_URL = 'https://edx-cdn.org/v3/default/logo.svg';
process.env.LOGO_TRADEMARK_URL = 'https://edx-cdn.org/v3/default/logo-trademark.svg';
process.env.LOGO_WHITE_URL = 'https://edx-cdn.org/v3/default/logo-white.svg';
process.env.FAVICON_URL = 'https://edx-cdn.org/v3/default/favicon.ico';
process.env.ENABLE_GRADING_METHOD_IN_PROBLEMS = 'true';

mergeConfig({
...process.env,
});

jest.mock('@edx/frontend-platform/i18n', () => {
const i18n = jest.requireActual('@edx/frontend-platform/i18n');
Expand Down

0 comments on commit 8a00df7

Please sign in to comment.