Skip to content

Commit

Permalink
Consolidate Interactive Graph tests and stories (#1592)
Browse files Browse the repository at this point in the history
This commit just moves files around. Specifically, it moves the
tests, test data, and stories for the Interactive Graph widget into
the `widgets/interactive-graphs` directory.

Issue: none

## Test plan:

`yarn test`

Author: benchristel

Reviewers: handeyeco, jeremywiebe

Required Reviewers:

Approved By: handeyeco

Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Jest Coverage (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald

Pull Request URL: #1592
  • Loading branch information
benchristel authored Sep 5, 2024
1 parent 79b05b3 commit d88b0ff
Show file tree
Hide file tree
Showing 43 changed files with 56 additions and 46 deletions.
7 changes: 7 additions & 0 deletions .changeset/neat-ghosts-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@khanacademy/perseus-dev-ui": patch
"@khanacademy/perseus": patch
"@khanacademy/perseus-editor": patch
---

Internal: Move tests, test data, and Storybook stories for the Interactive Graph widget to the directory specific to that widget.
2 changes: 1 addition & 1 deletion dev/gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {useEffect, useMemo, useState} from "react";
import {Renderer} from "../packages/perseus/src";
import {mockStrings} from "../packages/perseus/src/strings";
import {MafsGraphTypeFlags} from "../packages/perseus/src/types";
import * as interactiveGraph from "../packages/perseus/src/widgets/__testdata__/interactive-graph.testdata";
import * as grapher from "../packages/perseus/src/widgets/grapher/grapher.testdata";
import * as interactiveGraph from "../packages/perseus/src/widgets/interactive-graphs/interactive-graph.testdata";
import * as numberLine from "../packages/perseus/src/widgets/number-line/number-line.testdata";

import {Header} from "./header";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
segmentWithStartingCoordsQuestion,
segmentsWithStartingCoordsQuestion,
sinusoidWithStartingCoordsQuestion,
} from "../../../perseus/src/widgets/__testdata__/interactive-graph.testdata";
} from "../../../perseus/src/widgets/interactive-graphs/interactive-graph.testdata";
import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing";

import EditorPageWithStorybookPreview from "./editor-page-with-storybook-preview";
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/__tests__/renderer-api.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {ClassNames} from "../perseus-api";
import Renderer from "../renderer";
import {mockStrings} from "../strings";
import {registerAllWidgetsForTesting} from "../util/register-all-widgets-for-testing";
import {renderQuestion} from "../widgets/__tests__/renderQuestion";
import {renderQuestion} from "../widgets/__testutils__/renderQuestion";

import imageItem from "./test-items/image-item";
import inputNumber1Item from "./test-items/input-number-1-item";
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/__tests__/renderer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from "../__testdata__/renderer.testdata";
import * as Dependencies from "../dependencies";
import {registerWidget} from "../widgets";
import {renderQuestion} from "../widgets/__tests__/renderQuestion";
import {renderQuestion} from "../widgets/__testutils__/renderQuestion";
import InputNumberExport from "../widgets/input-number";
import RadioWidgetExport from "../widgets/radio";

Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/components/__tests__/sorter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as React from "react";
import {testDependencies} from "../../../../../testing/test-dependencies";
import {wait} from "../../../../../testing/wait";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../../widgets/__tests__/renderQuestion";
import {renderQuestion} from "../../widgets/__testutils__/renderQuestion";
import {question1} from "../__testdata__/sorter.testdata";

import type {APIOptions} from "../../types";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
randomLetter,
randomSentence,
randomWord,
} from "../__testdata__/randomizers";
} from "./randomizers";

describe("randomizers", () => {
describe("randomLetter", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {userEvent as userEventLib} from "@testing-library/user-event";
import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {mockStrings} from "../../strings";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {Categorizer} from "./categorizer";
import {question1} from "./categorizer.testdata";
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/cs-program/cs-program.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question1} from "./cs-program.testdata";

Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/definition/definition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {userEvent as userEventLib} from "@testing-library/user-event";

import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import type {UserEvent} from "@testing-library/user-event";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {testDependencies} from "../../../../../../testing/test-dependencies";
import * as Dependencies from "../../../dependencies";
import {renderQuestion} from "../../__tests__/renderQuestion";
import {renderQuestion} from "../../__testutils__/renderQuestion";

const question = {
content:
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/dropdown/dropdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {userEvent as userEventLib} from "@testing-library/user-event";

import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question1} from "./dropdown.testdata";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {userEvent as userEventLib} from "@testing-library/user-event";
import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import * as Changeable from "../../mixins/changeable";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import ExplanationWidgetExports from "./explanation";
import {question1} from "./explanation.testdata";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {mockStrings} from "../../strings";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {Expression} from "./expression";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {article1} from "./graded-group-set.testdata";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {userEvent as userEventLib} from "@testing-library/user-event";

import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {article1} from "./graded-group-set.testdata";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {userEvent as userEventLib} from "@testing-library/user-event";

import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question1} from "./graded-group.testdata";

Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/grapher/grapher.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {testDependencies} from "../../../../../testing/test-dependencies";
import {waitForInitialGraphieRender} from "../../../../../testing/wait";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {
linearQuestion,
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/group/group.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {mockStrings} from "../../strings";
import {traverse} from "../../traversal";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question1} from "./group.testdata";

Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/iframe/iframe.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question1} from "./iframe.testdata";

Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/image/image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {describe, beforeEach, it} from "@jest/globals";
import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {isAccessible} from "../../widgets";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question} from "./image.testdata";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import _ from "underscore";
import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {mockStrings} from "../../strings";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import InputNumber from "./input-number";
import {question3 as question} from "./input-number.testdata";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {testDependencies} from "../../../../../testing/test-dependencies";
import {waitForInitialGraphieRender} from "../../../../../testing/wait";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question1} from "./interaction.testdata";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as React from "react";

import Renderer from "../../renderer";
import {mockStrings} from "../../strings";
import {interactiveGraphQuestionBuilder} from "../interactive-graphs/interactive-graph-question-builder";

import {interactiveGraphQuestionBuilder} from "./interactive-graph-question-builder";

import type {PerseusRenderer} from "../../perseus-types";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from "react";

import {Flipbook} from "../../../../../dev/flipbook";
import {RendererWithDebugUI} from "../../../../../testing/renderer-with-debug-ui";

import {
angleQuestion,
circleQuestion,
Expand All @@ -23,7 +24,7 @@ import {
staticGraphQuestion,
staticGraphQuestionWithAnotherWidget,
segmentWithLockedLabels,
} from "../__testdata__/interactive-graph.testdata";
} from "./interactive-graph.testdata";

import type {APIOptions} from "../../types";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {waitForInitialGraphieRender} from "../../../../../testing/wait";
import * as Dependencies from "../../dependencies";
import {ApiOptions} from "../../perseus-api";
import {lockedFigureColors} from "../../perseus-types";
import {renderQuestion} from "../__testutils__/renderQuestion";
import {sinusoidQuestion} from "../grapher/grapher.testdata";

import {
angleQuestion,
angleQuestionWithDefaultCorrect,
Expand Down Expand Up @@ -42,17 +45,14 @@ import {
segmentWithLockedPolygonWhite,
segmentWithLockedVectors,
sinusoidQuestionWithDefaultCorrect,
} from "../__testdata__/interactive-graph.testdata";
import {sinusoidQuestion} from "../grapher/grapher.testdata";
import {trueForAllMafsSupportedGraphTypes} from "../interactive-graphs/mafs-supported-graph-types";

import {renderQuestion} from "./renderQuestion";
} from "./interactive-graph.testdata";
import {trueForAllMafsSupportedGraphTypes} from "./mafs-supported-graph-types";

import type {mafsSupportedGraphTypes} from "./mafs-supported-graph-types";
import type {Coord} from "../../interactive2/types";
import type {PerseusRenderer} from "../../perseus-types";
import type Renderer from "../../renderer";
import type {APIOptions} from "../../types";
import type {mafsSupportedGraphTypes} from "../interactive-graphs/mafs-supported-graph-types";
import type {UserEvent} from "@testing-library/user-event";

const updateWidgetState = (renderer: Renderer, widgetId: string, update) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {interactiveGraphQuestionBuilder} from "../interactive-graphs/interactive-graph-question-builder";
import {interactiveGraphQuestionBuilder} from "./interactive-graph-question-builder";

import type {LockedFunctionOptions} from "./interactive-graph-question-builder";
import type {Coord} from "../../interactive2/types";
import type {PerseusRenderer, RadioWidget} from "../../perseus-types";
import type {LockedFunctionOptions} from "../interactive-graphs/interactive-graph-question-builder";

// Data for the interactive graph widget

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from "react";

import {RendererWithDebugUI} from "../../../../../testing/renderer-with-debug-ui";
import {segmentWithLockedFunction} from "../__testdata__/interactive-graph.testdata";
import {RendererWithDebugUI} from "../../../../../../testing/renderer-with-debug-ui";
import {segmentWithLockedFunction} from "../interactive-graph.testdata";

export default {
title: "Perseus/Widgets/Interactive Graph/Locked Functions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
testDependenciesV2,
} from "../../../../../../testing/test-dependencies";
import * as Dependencies from "../../../dependencies";
import {renderQuestion} from "../../__tests__/renderQuestion";
import {renderQuestion} from "../../__testutils__/renderQuestion";
import {LabelImage} from "../label-image";

import {textQuestion} from "./label-image.testdata";
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/matcher/matcher.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as React from "react";
import {testDependencies} from "../../../../../testing/test-dependencies";
import {wait} from "../../../../../testing/wait";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question1} from "./matcher.testdata";

Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/matrix/matrix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {userEvent as userEventLib} from "@testing-library/user-event";

import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question1} from "./matrix.testdata";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {act} from "@testing-library/react";

import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question1} from "./number-line.testdata";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {userEvent as userEventLib} from "@testing-library/user-event";
import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {mockStrings} from "../../strings";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {
maybeParsePercentInput,
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/orderer/orderer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {act} from "@testing-library/react";

import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question2} from "./orderer.testdata";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {act, screen} from "@testing-library/react";

import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";
import PassageExport from "../passage";

import {question1} from "./passage-ref.testdata";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from "react";
import {testDependencies} from "../../../../../../testing/test-dependencies";
import * as Dependencies from "../../../dependencies";
import {ApiOptions} from "../../../perseus-api";
import {renderQuestion} from "../../__tests__/renderQuestion";
import {renderQuestion} from "../../__testutils__/renderQuestion";
import PassageWidgetExport, {LineHeightMeasurer} from "../passage";

import {question1, question2} from "./passage.testdata";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {screen, waitFor} from "@testing-library/react";

import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {makeSafeUrl} from "./phet-simulation";
import {nonPhetUrl, question1} from "./phet-simulation.testdata";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question1} from "./python-program.testdata";

Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/radio/__tests__/radio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {userEvent as userEventLib} from "@testing-library/user-event";
import {clone} from "../../../../../../testing/object-utils";
import {testDependencies} from "../../../../../../testing/test-dependencies";
import * as Dependencies from "../../../dependencies";
import {renderQuestion} from "../../__tests__/renderQuestion";
import {renderQuestion} from "../../__testutils__/renderQuestion";
import PassageWidget from "../../passage";

import {
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/video/video.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {testDependencies} from "../../../../../testing/test-dependencies";
import * as Dependencies from "../../dependencies";
import {renderQuestion} from "../__tests__/renderQuestion";
import {renderQuestion} from "../__testutils__/renderQuestion";

import {question1, question2} from "./video.testdata";

Expand Down
1 change: 1 addition & 0 deletions packages/tsconfig-shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"**/__tests__/**",
"**/*.testdata.*",
"**/__testdata__/**",
"**/__testutils__/**",
"**/*.stories.*",
"**/__stories__/**",
"**/*.cypress.*"
Expand Down

0 comments on commit d88b0ff

Please sign in to comment.