@khanacademy/perseus-editor 4.1.5 → 4.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +9 -6
- package/.babelrc.js +0 -8
- package/.eslintrc.js +0 -12
- package/CHANGELOG.md +0 -1155
- package/src/README.md +0 -7
- package/src/__stories__/editor-page.stories.tsx +0 -65
- package/src/__stories__/editor.stories.tsx +0 -134
- package/src/__stories__/item-editor.stories.tsx +0 -41
- package/src/__stories__/tex-error-view.stories.tsx +0 -26
- package/src/__testdata__/input-number.testdata.ts +0 -27
- package/src/__tests__/editor.test.tsx +0 -142
- package/src/__tests__/hint-editor.test.tsx +0 -83
- package/src/__tests__/i18n.test.ts +0 -501
- package/src/__tests__/integration.test.ts +0 -5
- package/src/__tests__/item-extras-editor.test.tsx +0 -85
- package/src/__tests__/traversal.test.ts +0 -377
- package/src/all-editors.test.ts +0 -16
- package/src/all-editors.ts +0 -83
- package/src/all-widgets.ts +0 -7
- package/src/article-editor.tsx +0 -438
- package/src/components/__stories__/blur-input.stories.tsx +0 -22
- package/src/components/__stories__/section-control-button.stories.tsx +0 -26
- package/src/components/__tests__/blur-input.test.tsx +0 -67
- package/src/components/blur-input.tsx +0 -69
- package/src/components/checkbox.tsx +0 -194
- package/src/components/device-framer.tsx +0 -90
- package/src/components/drag-target.tsx +0 -87
- package/src/components/dropdown-option.tsx +0 -311
- package/src/components/form-wrapped-text-field.tsx +0 -245
- package/src/components/graph-points-count-selector.tsx +0 -31
- package/src/components/graph-settings.tsx +0 -627
- package/src/components/graph-type-selector.tsx +0 -31
- package/src/components/hover-behavior.ts +0 -177
- package/src/components/json-editor.tsx +0 -121
- package/src/components/link.ts +0 -173
- package/src/components/section-control-button.tsx +0 -53
- package/src/components/segment-count-selector.tsx +0 -27
- package/src/components/simple-button.tsx +0 -85
- package/src/components/sortable.tsx +0 -187
- package/src/components/util.ts +0 -38
- package/src/components/viewport-resizer.tsx +0 -72
- package/src/components/widget-editor.tsx +0 -222
- package/src/components/widget-select.tsx +0 -48
- package/src/diffs/__stories__/perseus-diff-wrapper.tsx +0 -11
- package/src/diffs/__stories__/structured-item-diff.stories.tsx +0 -855
- package/src/diffs/__stories__/tags-diff.stories.tsx +0 -36
- package/src/diffs/__stories__/text-diff.stories.tsx +0 -35
- package/src/diffs/__tests__/split-diff.test.ts +0 -33
- package/src/diffs/__tests__/string-array-diff.test.ts +0 -73
- package/src/diffs/__tests__/structured-item-diff.test.ts +0 -433
- package/src/diffs/__tests__/widget-diff-performer.test.ts +0 -43
- package/src/diffs/article-diff.tsx +0 -69
- package/src/diffs/item-diff.tsx +0 -76
- package/src/diffs/renderer-diff.tsx +0 -137
- package/src/diffs/split-diff.ts +0 -31
- package/src/diffs/string-array-diff.ts +0 -74
- package/src/diffs/structured-item-diff.tsx +0 -275
- package/src/diffs/tags-diff.tsx +0 -49
- package/src/diffs/text-diff.tsx +0 -193
- package/src/diffs/widget-diff-performer.ts +0 -69
- package/src/diffs/widget-diff.tsx +0 -290
- package/src/editor-page.tsx +0 -325
- package/src/editor.tsx +0 -1099
- package/src/hint-editor.tsx +0 -469
- package/src/i18n.ts +0 -140
- package/src/iframe-content-renderer.tsx +0 -188
- package/src/index.ts +0 -30
- package/src/item-editor.tsx +0 -158
- package/src/item-extras-editor.tsx +0 -230
- package/src/katex-mhchem/index.js +0 -73
- package/src/katex-mhchem/parser.js +0 -2659
- package/src/multirenderer-editor.tsx +0 -1061
- package/src/stateful-article-editor.tsx +0 -173
- package/src/stateful-editor-page.tsx +0 -88
- package/src/styles/perseus-editor.less +0 -1321
- package/src/testing-widgets.ts +0 -11
- package/src/tex-error-view.tsx +0 -90
- package/src/util/points.test.ts +0 -24
- package/src/util/points.ts +0 -13
- package/src/util/register-all-widgets-and-editors-for-testing.test.ts +0 -17
- package/src/util/register-all-widgets-and-editors-for-testing.ts +0 -17
- package/src/version.ts +0 -10
- package/src/widgets/__stories__/categorizer-editor.stories.tsx +0 -24
- package/src/widgets/__stories__/definition-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/dropdown-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/explanation-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/expression-editor.stories.tsx +0 -122
- package/src/widgets/__stories__/image-editor.stories.tsx +0 -72
- package/src/widgets/__stories__/input-number-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/interaction-editor.stories.tsx +0 -37
- package/src/widgets/__stories__/label-image-editor.stories.tsx +0 -99
- package/src/widgets/__stories__/matcher-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/number-line-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/numeric-input-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/radio-editor.stories.tsx +0 -116
- package/src/widgets/__stories__/sorter-editor.stories.tsx +0 -18
- package/src/widgets/__tests__/categorizer-editor.test.tsx +0 -51
- package/src/widgets/__tests__/definition-editor.test.tsx +0 -41
- package/src/widgets/__tests__/dropdown-editor.test.tsx +0 -57
- package/src/widgets/__tests__/explanation-editor.test.tsx +0 -59
- package/src/widgets/__tests__/expression-editor.test.tsx +0 -403
- package/src/widgets/__tests__/input-number-editor.test.tsx +0 -128
- package/src/widgets/__tests__/matcher-editor.test.tsx +0 -47
- package/src/widgets/__tests__/number-line-editor.test.tsx +0 -144
- package/src/widgets/__tests__/numeric-input-editor.test.tsx +0 -177
- package/src/widgets/__tests__/radio-editor.test.tsx +0 -118
- package/src/widgets/__tests__/sorter-editor.test.tsx +0 -55
- package/src/widgets/categorizer-editor.tsx +0 -104
- package/src/widgets/cs-program-editor.tsx +0 -256
- package/src/widgets/definition-editor.tsx +0 -77
- package/src/widgets/deprecated-standin-editor.tsx +0 -29
- package/src/widgets/dropdown-editor.tsx +0 -211
- package/src/widgets/example-graphie-widget-editor.tsx +0 -70
- package/src/widgets/example-graphie-widget.tsx +0 -172
- package/src/widgets/example-widget-editor.tsx +0 -62
- package/src/widgets/example-widget.tsx +0 -154
- package/src/widgets/explanation-editor.tsx +0 -92
- package/src/widgets/expression-editor.tsx +0 -557
- package/src/widgets/graded-group-editor.tsx +0 -161
- package/src/widgets/graded-group-set-editor.tsx +0 -104
- package/src/widgets/grapher-editor.tsx +0 -155
- package/src/widgets/group-editor.tsx +0 -83
- package/src/widgets/iframe-editor.tsx +0 -202
- package/src/widgets/image-editor.tsx +0 -367
- package/src/widgets/input-number-editor.tsx +0 -288
- package/src/widgets/interaction-editor/constraint-editor.tsx +0 -134
- package/src/widgets/interaction-editor/function-editor.tsx +0 -108
- package/src/widgets/interaction-editor/index.ts +0 -3
- package/src/widgets/interaction-editor/interaction-editor.tsx +0 -749
- package/src/widgets/interaction-editor/label-editor.tsx +0 -87
- package/src/widgets/interaction-editor/line-editor.tsx +0 -125
- package/src/widgets/interaction-editor/mathquill-input.tsx +0 -81
- package/src/widgets/interaction-editor/movable-line-editor.tsx +0 -121
- package/src/widgets/interaction-editor/movable-point-editor.tsx +0 -89
- package/src/widgets/interaction-editor/parametric-editor.tsx +0 -117
- package/src/widgets/interaction-editor/point-editor.tsx +0 -72
- package/src/widgets/interaction-editor/rectangle-editor.tsx +0 -96
- package/src/widgets/interactive-graph-editor.tsx +0 -571
- package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +0 -82
- package/src/widgets/label-image/__stories__/behavior.stories.tsx +0 -31
- package/src/widgets/label-image/__stories__/marker.stories.tsx +0 -75
- package/src/widgets/label-image/__stories__/question-markers.stories.tsx +0 -107
- package/src/widgets/label-image/__stories__/select-image.stories.tsx +0 -59
- package/src/widgets/label-image/answer-choices.tsx +0 -231
- package/src/widgets/label-image/behavior.tsx +0 -122
- package/src/widgets/label-image/marker.tsx +0 -290
- package/src/widgets/label-image/question-markers.tsx +0 -176
- package/src/widgets/label-image/select-image.tsx +0 -81
- package/src/widgets/label-image-editor.tsx +0 -252
- package/src/widgets/lights-puzzle-editor.tsx +0 -278
- package/src/widgets/matcher-editor.tsx +0 -149
- package/src/widgets/matrix-editor.tsx +0 -156
- package/src/widgets/measurer-editor.tsx +0 -253
- package/src/widgets/molecule-editor.tsx +0 -64
- package/src/widgets/number-line-editor.tsx +0 -512
- package/src/widgets/numeric-input-editor.tsx +0 -536
- package/src/widgets/orderer-editor.tsx +0 -172
- package/src/widgets/passage-editor.tsx +0 -117
- package/src/widgets/passage-ref-editor.tsx +0 -80
- package/src/widgets/passage-ref-target-editor.tsx +0 -49
- package/src/widgets/plotter-editor.tsx +0 -542
- package/src/widgets/radio/editor.tsx +0 -398
- package/src/widgets/reaction-diagram-editor.tsx +0 -131
- package/src/widgets/sequence-editor.tsx +0 -205
- package/src/widgets/simple-markdown-tester-editor.tsx +0 -86
- package/src/widgets/simple-markdown-tester.tsx +0 -92
- package/src/widgets/simulator-editor.tsx +0 -146
- package/src/widgets/sorter-editor.tsx +0 -103
- package/src/widgets/table-editor.tsx +0 -164
- package/src/widgets/unit-editor.tsx +0 -299
- package/src/widgets/video-editor.tsx +0 -73
- package/tsconfig-build.json +0 -22
- package/tsconfig-build.tsbuildinfo +0 -1
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import TagsDiff from "../tags-diff";
|
|
4
|
-
|
|
5
|
-
import Wrapper from "./perseus-diff-wrapper";
|
|
6
|
-
|
|
7
|
-
type StoryArgs = Record<any, any>;
|
|
8
|
-
|
|
9
|
-
type Story = {
|
|
10
|
-
title: string;
|
|
11
|
-
decorators: ReadonlyArray<
|
|
12
|
-
(StoryComponent: typeof React.Component) => React.ReactElement
|
|
13
|
-
>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
title: "Perseus/Editor/Diffs/Tags Diff",
|
|
18
|
-
decorators: [
|
|
19
|
-
(StoryComponent) => (
|
|
20
|
-
<Wrapper>
|
|
21
|
-
<StoryComponent />
|
|
22
|
-
</Wrapper>
|
|
23
|
-
),
|
|
24
|
-
],
|
|
25
|
-
} as Story;
|
|
26
|
-
|
|
27
|
-
export const Example = (args: StoryArgs): React.ReactElement => {
|
|
28
|
-
return (
|
|
29
|
-
<TagsDiff
|
|
30
|
-
title="tags"
|
|
31
|
-
beforeOnly={["Math", "Biology", "History"]}
|
|
32
|
-
afterOnly={["World War I"]}
|
|
33
|
-
intersection={["Physics", "Chemistry"]}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import TextDiff from "../text-diff";
|
|
4
|
-
|
|
5
|
-
import Wrapper from "./perseus-diff-wrapper";
|
|
6
|
-
|
|
7
|
-
type StoryArgs = Record<any, any>;
|
|
8
|
-
|
|
9
|
-
type Story = {
|
|
10
|
-
title: string;
|
|
11
|
-
decorators: ReadonlyArray<
|
|
12
|
-
(StoryComponent: typeof React.Component) => React.ReactElement
|
|
13
|
-
>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
title: "Perseus/Editor/Diffs/Text Diff",
|
|
18
|
-
decorators: [
|
|
19
|
-
(StoryComponent) => (
|
|
20
|
-
<Wrapper>
|
|
21
|
-
<StoryComponent />
|
|
22
|
-
</Wrapper>
|
|
23
|
-
),
|
|
24
|
-
],
|
|
25
|
-
} as Story;
|
|
26
|
-
|
|
27
|
-
export const Example = (args: StoryArgs): React.ReactElement => {
|
|
28
|
-
return (
|
|
29
|
-
<TextDiff
|
|
30
|
-
title="A day in the life of a text diff"
|
|
31
|
-
before="🥱 Hello world!"
|
|
32
|
-
after="😴 Goodbye world!"
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import splitDiff from "../split-diff";
|
|
2
|
-
|
|
3
|
-
describe("split diff", function () {
|
|
4
|
-
it("splits an empty diff", function () {
|
|
5
|
-
expect(splitDiff([])).toEqual([]);
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
it("does not split a one line string", function () {
|
|
9
|
-
expect(splitDiff([{value: "hello"}])).toEqual([[{value: "hello"}]]);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("splits a multiline string into two parts", function () {
|
|
13
|
-
expect(splitDiff([{value: "he\nllo"}])).toEqual([
|
|
14
|
-
[{value: "he"}],
|
|
15
|
-
[{value: "llo"}],
|
|
16
|
-
]);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("keeps things on the same line when splitting a changed value", () => {
|
|
20
|
-
expect(
|
|
21
|
-
splitDiff([{value: "hello"}, {value: "goodbye", removed: true}]),
|
|
22
|
-
).toEqual([[{value: "hello"}, {value: "goodbye", removed: true}]]);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("splits a string with a change and a newline", function () {
|
|
26
|
-
expect(
|
|
27
|
-
splitDiff([{value: "hello"}, {value: "good\nbye", removed: true}]),
|
|
28
|
-
).toEqual([
|
|
29
|
-
[{value: "hello"}, {value: "good", removed: true}],
|
|
30
|
-
[{value: "bye", removed: true}],
|
|
31
|
-
]);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import stringArrayDiff from "../string-array-diff";
|
|
2
|
-
|
|
3
|
-
describe("string array diff", function () {
|
|
4
|
-
it("diffs an empty diff", function () {
|
|
5
|
-
expect(stringArrayDiff([], [])).toEqual({
|
|
6
|
-
before: [],
|
|
7
|
-
after: [],
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("diffs the same values", function () {
|
|
12
|
-
expect(stringArrayDiff([1], [1])).toEqual({
|
|
13
|
-
before: [
|
|
14
|
-
{
|
|
15
|
-
status: "unchanged",
|
|
16
|
-
value: 1,
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
after: [
|
|
20
|
-
{
|
|
21
|
-
status: "unchanged",
|
|
22
|
-
value: 1,
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("diffs an added value", function () {
|
|
29
|
-
expect(stringArrayDiff([1], [1, 2])).toEqual({
|
|
30
|
-
before: [
|
|
31
|
-
{
|
|
32
|
-
status: "unchanged",
|
|
33
|
-
value: 1,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
after: [
|
|
37
|
-
{
|
|
38
|
-
status: "unchanged",
|
|
39
|
-
value: 1,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
status: "added",
|
|
43
|
-
value: 2,
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("diffs a removed value", function () {
|
|
50
|
-
expect(stringArrayDiff([1, 2, 3], [1])).toEqual({
|
|
51
|
-
before: [
|
|
52
|
-
{
|
|
53
|
-
status: "unchanged",
|
|
54
|
-
value: 1,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
status: "removed",
|
|
58
|
-
value: 2,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
status: "removed",
|
|
62
|
-
value: 3,
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
after: [
|
|
66
|
-
{
|
|
67
|
-
status: "unchanged",
|
|
68
|
-
value: 1,
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
import {buildEmptyItemTreeForShape, shapes} from "@khanacademy/perseus";
|
|
2
|
-
|
|
3
|
-
import StructuredItemDiff from "../structured-item-diff";
|
|
4
|
-
|
|
5
|
-
import type {Path} from "@khanacademy/perseus";
|
|
6
|
-
|
|
7
|
-
const gtpPassageShape = shapes.shape({
|
|
8
|
-
directions: shapes.content,
|
|
9
|
-
passage: shapes.content,
|
|
10
|
-
overview: shapes.content,
|
|
11
|
-
hints: shapes.hints,
|
|
12
|
-
|
|
13
|
-
questions: shapes.arrayOf(
|
|
14
|
-
shapes.shape({
|
|
15
|
-
tags: shapes.tags,
|
|
16
|
-
question: shapes.content,
|
|
17
|
-
keepInMind: shapes.content,
|
|
18
|
-
overview: shapes.content,
|
|
19
|
-
hints: shapes.hints,
|
|
20
|
-
}),
|
|
21
|
-
),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const gtpSingleQuestionShape = shapes.shape({
|
|
25
|
-
blurb: shapes.content,
|
|
26
|
-
question: shapes.content,
|
|
27
|
-
hints: shapes.hints,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const emptyContent = buildEmptyItemTreeForShape(shapes.content);
|
|
31
|
-
const emptyHint = buildEmptyItemTreeForShape(shapes.hint);
|
|
32
|
-
|
|
33
|
-
describe("StructuredItemDiff", function () {
|
|
34
|
-
/**
|
|
35
|
-
* Testing adding all empty content items,
|
|
36
|
-
* and then testing removing by reversing the order.
|
|
37
|
-
*/
|
|
38
|
-
it("test adding empty items, removing empty items", function () {
|
|
39
|
-
const beforeList = [
|
|
40
|
-
[emptyContent, ["directions"]],
|
|
41
|
-
[emptyContent, ["passage"]],
|
|
42
|
-
[emptyContent, ["overview"]],
|
|
43
|
-
];
|
|
44
|
-
|
|
45
|
-
const afterList = [
|
|
46
|
-
[emptyContent, ["directions"]],
|
|
47
|
-
[emptyContent, ["passage"]],
|
|
48
|
-
[emptyContent, ["overview"]],
|
|
49
|
-
[emptyHint, ["hints", 0]],
|
|
50
|
-
[emptyHint, ["hints", 1]],
|
|
51
|
-
[emptyContent, ["questions", 0, "tags"]],
|
|
52
|
-
[emptyContent, ["questions", 0, "question"]],
|
|
53
|
-
[emptyContent, ["questions", 0, "keepInMind"]],
|
|
54
|
-
[emptyContent, ["questions", 0, "overview"]],
|
|
55
|
-
[emptyContent, ["questions", 1, "tags"]],
|
|
56
|
-
[emptyContent, ["questions", 1, "question"]],
|
|
57
|
-
[emptyContent, ["questions", 1, "keepInMind"]],
|
|
58
|
-
[emptyContent, ["questions", 1, "overview"]],
|
|
59
|
-
[emptyHint, ["questions", 1, "hints", 0]],
|
|
60
|
-
[emptyHint, ["questions", 1, "hints", 1]],
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
const addingResult: Array<Path> = [];
|
|
64
|
-
StructuredItemDiff.generateCompletePathsList(
|
|
65
|
-
// @ts-expect-error - TS2345 - Argument of type 'any[][]' is not assignable to parameter of type 'ItemList[]'.
|
|
66
|
-
beforeList.slice(),
|
|
67
|
-
afterList.slice(),
|
|
68
|
-
addingResult,
|
|
69
|
-
gtpPassageShape,
|
|
70
|
-
[],
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const removingResult = [];
|
|
74
|
-
StructuredItemDiff.generateCompletePathsList(
|
|
75
|
-
// @ts-expect-error - TS2345 - Argument of type 'any[][]' is not assignable to parameter of type 'ItemList[]'.
|
|
76
|
-
afterList,
|
|
77
|
-
beforeList,
|
|
78
|
-
removingResult,
|
|
79
|
-
gtpPassageShape,
|
|
80
|
-
[],
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
expect(addingResult).toEqual([
|
|
84
|
-
["directions"],
|
|
85
|
-
["passage"],
|
|
86
|
-
["overview"],
|
|
87
|
-
["hints", 0],
|
|
88
|
-
["hints", 1],
|
|
89
|
-
["questions", 0, "tags"],
|
|
90
|
-
["questions", 0, "question"],
|
|
91
|
-
["questions", 0, "keepInMind"],
|
|
92
|
-
["questions", 0, "overview"],
|
|
93
|
-
["questions", 1, "tags"],
|
|
94
|
-
["questions", 1, "question"],
|
|
95
|
-
["questions", 1, "keepInMind"],
|
|
96
|
-
["questions", 1, "overview"],
|
|
97
|
-
["questions", 1, "hints", 0],
|
|
98
|
-
["questions", 1, "hints", 1],
|
|
99
|
-
]);
|
|
100
|
-
|
|
101
|
-
expect(removingResult).toEqual([
|
|
102
|
-
["directions"],
|
|
103
|
-
["passage"],
|
|
104
|
-
["overview"],
|
|
105
|
-
["hints", 0],
|
|
106
|
-
["hints", 1],
|
|
107
|
-
["questions", 0, "tags"],
|
|
108
|
-
["questions", 0, "question"],
|
|
109
|
-
["questions", 0, "keepInMind"],
|
|
110
|
-
["questions", 0, "overview"],
|
|
111
|
-
["questions", 1, "tags"],
|
|
112
|
-
["questions", 1, "question"],
|
|
113
|
-
["questions", 1, "keepInMind"],
|
|
114
|
-
["questions", 1, "overview"],
|
|
115
|
-
["questions", 1, "hints", 0],
|
|
116
|
-
["questions", 1, "hints", 1],
|
|
117
|
-
]);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Testing editing content of items,
|
|
122
|
-
* including top level items, as well as hints,
|
|
123
|
-
* and items within questions.
|
|
124
|
-
*/
|
|
125
|
-
it("test editing items", function () {
|
|
126
|
-
const passage = buildEmptyItemTreeForShape(shapes.content);
|
|
127
|
-
passage.content = "passage";
|
|
128
|
-
const firstQuestion = buildEmptyItemTreeForShape(shapes.content);
|
|
129
|
-
firstQuestion.content = "question 1";
|
|
130
|
-
const firstHint = buildEmptyItemTreeForShape(shapes.hint);
|
|
131
|
-
firstHint.content = "hint 1";
|
|
132
|
-
const secondQuestionFirstHint = buildEmptyItemTreeForShape(shapes.hint);
|
|
133
|
-
secondQuestionFirstHint.content = "question 1 hint 1";
|
|
134
|
-
const beforeList = [
|
|
135
|
-
[emptyContent, ["directions"]],
|
|
136
|
-
[passage, ["passage"]],
|
|
137
|
-
[emptyContent, ["overview"]],
|
|
138
|
-
[firstHint, ["hints", 0]],
|
|
139
|
-
[emptyHint, ["hints", 1]],
|
|
140
|
-
[emptyContent, ["questions", 0, "tags"]],
|
|
141
|
-
[firstQuestion, ["questions", 0, "question"]],
|
|
142
|
-
[emptyContent, ["questions", 0, "keepInMind"]],
|
|
143
|
-
[emptyContent, ["questions", 0, "overview"]],
|
|
144
|
-
[emptyContent, ["questions", 1, "tags"]],
|
|
145
|
-
[emptyContent, ["questions", 1, "question"]],
|
|
146
|
-
[emptyContent, ["questions", 1, "keepInMind"]],
|
|
147
|
-
[emptyContent, ["questions", 1, "overview"]],
|
|
148
|
-
[secondQuestionFirstHint, ["questions", 1, "hints", 0]],
|
|
149
|
-
[emptyHint, ["questions", 1, "hints", 1]],
|
|
150
|
-
];
|
|
151
|
-
|
|
152
|
-
const passageEdited = buildEmptyItemTreeForShape(shapes.content);
|
|
153
|
-
passageEdited.content = "passage edited";
|
|
154
|
-
const firstQuestionEdited = buildEmptyItemTreeForShape(shapes.content);
|
|
155
|
-
firstQuestionEdited.content = "question edited 1";
|
|
156
|
-
const firstHintEdited = buildEmptyItemTreeForShape(shapes.hint);
|
|
157
|
-
firstHintEdited.content = "edited hint 1";
|
|
158
|
-
const secondQuestionFirstHintEdited = buildEmptyItemTreeForShape(
|
|
159
|
-
shapes.hint,
|
|
160
|
-
);
|
|
161
|
-
secondQuestionFirstHintEdited.content = "question 1 hint 1 edited";
|
|
162
|
-
const afterList = [
|
|
163
|
-
[emptyContent, ["directions"]],
|
|
164
|
-
[passageEdited, ["passage"]],
|
|
165
|
-
[emptyContent, ["overview"]],
|
|
166
|
-
[firstHintEdited, ["hints", 0]],
|
|
167
|
-
[emptyHint, ["hints", 1]],
|
|
168
|
-
[emptyContent, ["questions", 0, "tags"]],
|
|
169
|
-
[firstQuestionEdited, ["questions", 0, "question"]],
|
|
170
|
-
[emptyContent, ["questions", 0, "keepInMind"]],
|
|
171
|
-
[emptyContent, ["questions", 0, "overview"]],
|
|
172
|
-
[emptyContent, ["questions", 1, "tags"]],
|
|
173
|
-
[emptyContent, ["questions", 1, "question"]],
|
|
174
|
-
[emptyContent, ["questions", 1, "keepInMind"]],
|
|
175
|
-
[emptyContent, ["questions", 1, "overview"]],
|
|
176
|
-
[secondQuestionFirstHintEdited, ["questions", 1, "hints", 0]],
|
|
177
|
-
[emptyHint, ["questions", 1, "hints", 1]],
|
|
178
|
-
];
|
|
179
|
-
|
|
180
|
-
const firstResult: Array<Path> = [];
|
|
181
|
-
StructuredItemDiff.generateCompletePathsList(
|
|
182
|
-
// @ts-expect-error - TS2345 - Argument of type 'any[][]' is not assignable to parameter of type 'ItemList[]'.
|
|
183
|
-
beforeList.slice(),
|
|
184
|
-
afterList.slice(),
|
|
185
|
-
firstResult,
|
|
186
|
-
gtpPassageShape,
|
|
187
|
-
[],
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
const secondResult = [];
|
|
191
|
-
StructuredItemDiff.generateCompletePathsList(
|
|
192
|
-
// @ts-expect-error - TS2345 - Argument of type 'any[][]' is not assignable to parameter of type 'ItemList[]'.
|
|
193
|
-
afterList,
|
|
194
|
-
beforeList,
|
|
195
|
-
secondResult,
|
|
196
|
-
gtpPassageShape,
|
|
197
|
-
[],
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
expect(firstResult).toEqual([
|
|
201
|
-
["directions"],
|
|
202
|
-
["passage"],
|
|
203
|
-
["overview"],
|
|
204
|
-
["hints", 0],
|
|
205
|
-
["hints", 1],
|
|
206
|
-
["questions", 0, "tags"],
|
|
207
|
-
["questions", 0, "question"],
|
|
208
|
-
["questions", 0, "keepInMind"],
|
|
209
|
-
["questions", 0, "overview"],
|
|
210
|
-
["questions", 1, "tags"],
|
|
211
|
-
["questions", 1, "question"],
|
|
212
|
-
["questions", 1, "keepInMind"],
|
|
213
|
-
["questions", 1, "overview"],
|
|
214
|
-
["questions", 1, "hints", 0],
|
|
215
|
-
["questions", 1, "hints", 1],
|
|
216
|
-
]);
|
|
217
|
-
|
|
218
|
-
expect(secondResult).toEqual([
|
|
219
|
-
["directions"],
|
|
220
|
-
["passage"],
|
|
221
|
-
["overview"],
|
|
222
|
-
["hints", 0],
|
|
223
|
-
["hints", 1],
|
|
224
|
-
["questions", 0, "tags"],
|
|
225
|
-
["questions", 0, "question"],
|
|
226
|
-
["questions", 0, "keepInMind"],
|
|
227
|
-
["questions", 0, "overview"],
|
|
228
|
-
["questions", 1, "tags"],
|
|
229
|
-
["questions", 1, "question"],
|
|
230
|
-
["questions", 1, "keepInMind"],
|
|
231
|
-
["questions", 1, "overview"],
|
|
232
|
-
["questions", 1, "hints", 0],
|
|
233
|
-
["questions", 1, "hints", 1],
|
|
234
|
-
]);
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Testing these cases:
|
|
239
|
-
* (1) adding/removing overall hints
|
|
240
|
-
* (2) adding/removing question hints of a middle question
|
|
241
|
-
* (question is surrounded by other questions)
|
|
242
|
-
* (3) adding/removing question hints of the last question
|
|
243
|
-
* (4) adding/removing questions entirely
|
|
244
|
-
*
|
|
245
|
-
* This test is done with empty items, since we've tested for edits,
|
|
246
|
-
* and generateCompletePathLists() doesn't look at the contents.
|
|
247
|
-
*/
|
|
248
|
-
it("testing adding and removing in special cases", function () {
|
|
249
|
-
const beforeList = [
|
|
250
|
-
[emptyContent, ["directions"]],
|
|
251
|
-
[emptyContent, ["passage"]],
|
|
252
|
-
[emptyContent, ["overview"]],
|
|
253
|
-
[emptyContent, ["questions", 0, "tags"]],
|
|
254
|
-
[emptyContent, ["questions", 0, "question"]],
|
|
255
|
-
[emptyContent, ["questions", 0, "keepInMind"]],
|
|
256
|
-
[emptyContent, ["questions", 0, "overview"]],
|
|
257
|
-
[emptyContent, ["questions", 1, "tags"]],
|
|
258
|
-
[emptyContent, ["questions", 1, "question"]],
|
|
259
|
-
[emptyContent, ["questions", 1, "keepInMind"]],
|
|
260
|
-
[emptyContent, ["questions", 1, "overview"]],
|
|
261
|
-
[emptyHint, ["questions", 1, "hints", 0]],
|
|
262
|
-
[emptyHint, ["questions", 1, "hints", 1]],
|
|
263
|
-
[emptyContent, ["questions", 2, "tags"]],
|
|
264
|
-
[emptyContent, ["questions", 2, "question"]],
|
|
265
|
-
[emptyContent, ["questions", 2, "keepInMind"]],
|
|
266
|
-
[emptyContent, ["questions", 2, "overview"]],
|
|
267
|
-
[emptyHint, ["questions", 2, "hints", 0]],
|
|
268
|
-
[emptyHint, ["questions", 2, "hints", 1]],
|
|
269
|
-
[emptyContent, ["questions", 3, "tags"]],
|
|
270
|
-
[emptyContent, ["questions", 3, "question"]],
|
|
271
|
-
[emptyContent, ["questions", 3, "keepInMind"]],
|
|
272
|
-
[emptyContent, ["questions", 3, "overview"]],
|
|
273
|
-
];
|
|
274
|
-
|
|
275
|
-
const afterList = [
|
|
276
|
-
[emptyContent, ["directions"]],
|
|
277
|
-
[emptyContent, ["passage"]],
|
|
278
|
-
[emptyContent, ["overview"]],
|
|
279
|
-
[emptyHint, ["hints", 0]], // add
|
|
280
|
-
[emptyHint, ["hints", 1]], // add
|
|
281
|
-
[emptyContent, ["questions", 0, "tags"]],
|
|
282
|
-
[emptyContent, ["questions", 0, "question"]],
|
|
283
|
-
[emptyContent, ["questions", 0, "keepInMind"]],
|
|
284
|
-
[emptyContent, ["questions", 0, "overview"]],
|
|
285
|
-
[emptyHint, ["questions", 0, "hints", 0]], // add
|
|
286
|
-
[emptyHint, ["questions", 0, "hints", 1]], // add
|
|
287
|
-
[emptyContent, ["questions", 1, "tags"]],
|
|
288
|
-
[emptyContent, ["questions", 1, "question"]],
|
|
289
|
-
[emptyContent, ["questions", 1, "keepInMind"]],
|
|
290
|
-
[emptyContent, ["questions", 1, "overview"]],
|
|
291
|
-
[emptyHint, ["questions", 1, "hints", 0]],
|
|
292
|
-
// remove second hint of question 1
|
|
293
|
-
[emptyContent, ["questions", 2, "tags"]],
|
|
294
|
-
[emptyContent, ["questions", 2, "question"]],
|
|
295
|
-
[emptyContent, ["questions", 2, "keepInMind"]],
|
|
296
|
-
[emptyContent, ["questions", 2, "overview"]],
|
|
297
|
-
[emptyHint, ["questions", 2, "hints", 0]],
|
|
298
|
-
[emptyHint, ["questions", 2, "hints", 1]],
|
|
299
|
-
// removed question 2, added two hints to question 3
|
|
300
|
-
];
|
|
301
|
-
|
|
302
|
-
const firstResult: Array<Path> = [];
|
|
303
|
-
StructuredItemDiff.generateCompletePathsList(
|
|
304
|
-
// @ts-expect-error - TS2345 - Argument of type 'any[][]' is not assignable to parameter of type 'ItemList[]'.
|
|
305
|
-
beforeList.slice(),
|
|
306
|
-
afterList.slice(),
|
|
307
|
-
firstResult,
|
|
308
|
-
gtpPassageShape,
|
|
309
|
-
[],
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
const secondResult: Array<Path> = [];
|
|
313
|
-
StructuredItemDiff.generateCompletePathsList(
|
|
314
|
-
// @ts-expect-error - TS2345 - Argument of type 'any[][]' is not assignable to parameter of type 'ItemList[]'.
|
|
315
|
-
afterList,
|
|
316
|
-
beforeList,
|
|
317
|
-
secondResult,
|
|
318
|
-
gtpPassageShape,
|
|
319
|
-
[],
|
|
320
|
-
);
|
|
321
|
-
|
|
322
|
-
expect(firstResult).toEqual([
|
|
323
|
-
["directions"],
|
|
324
|
-
["passage"],
|
|
325
|
-
["overview"],
|
|
326
|
-
["hints", 0],
|
|
327
|
-
["hints", 1],
|
|
328
|
-
["questions", 0, "tags"],
|
|
329
|
-
["questions", 0, "question"],
|
|
330
|
-
["questions", 0, "keepInMind"],
|
|
331
|
-
["questions", 0, "overview"],
|
|
332
|
-
["questions", 0, "hints", 0],
|
|
333
|
-
["questions", 0, "hints", 1],
|
|
334
|
-
["questions", 1, "tags"],
|
|
335
|
-
["questions", 1, "question"],
|
|
336
|
-
["questions", 1, "keepInMind"],
|
|
337
|
-
["questions", 1, "overview"],
|
|
338
|
-
["questions", 1, "hints", 0],
|
|
339
|
-
["questions", 1, "hints", 1],
|
|
340
|
-
["questions", 2, "tags"],
|
|
341
|
-
["questions", 2, "question"],
|
|
342
|
-
["questions", 2, "keepInMind"],
|
|
343
|
-
["questions", 2, "overview"],
|
|
344
|
-
["questions", 2, "hints", 0],
|
|
345
|
-
["questions", 2, "hints", 1],
|
|
346
|
-
["questions", 3, "tags"],
|
|
347
|
-
["questions", 3, "question"],
|
|
348
|
-
["questions", 3, "keepInMind"],
|
|
349
|
-
["questions", 3, "overview"],
|
|
350
|
-
]);
|
|
351
|
-
|
|
352
|
-
expect(secondResult).toEqual([
|
|
353
|
-
["directions"],
|
|
354
|
-
["passage"],
|
|
355
|
-
["overview"],
|
|
356
|
-
["hints", 0],
|
|
357
|
-
["hints", 1],
|
|
358
|
-
["questions", 0, "tags"],
|
|
359
|
-
["questions", 0, "question"],
|
|
360
|
-
["questions", 0, "keepInMind"],
|
|
361
|
-
["questions", 0, "overview"],
|
|
362
|
-
["questions", 0, "hints", 0],
|
|
363
|
-
["questions", 0, "hints", 1],
|
|
364
|
-
["questions", 1, "tags"],
|
|
365
|
-
["questions", 1, "question"],
|
|
366
|
-
["questions", 1, "keepInMind"],
|
|
367
|
-
["questions", 1, "overview"],
|
|
368
|
-
["questions", 1, "hints", 0],
|
|
369
|
-
["questions", 1, "hints", 1],
|
|
370
|
-
["questions", 2, "tags"],
|
|
371
|
-
["questions", 2, "question"],
|
|
372
|
-
["questions", 2, "keepInMind"],
|
|
373
|
-
["questions", 2, "overview"],
|
|
374
|
-
["questions", 2, "hints", 0],
|
|
375
|
-
["questions", 2, "hints", 1],
|
|
376
|
-
["questions", 3, "tags"],
|
|
377
|
-
["questions", 3, "question"],
|
|
378
|
-
["questions", 3, "keepInMind"],
|
|
379
|
-
["questions", 3, "overview"],
|
|
380
|
-
]);
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Testing single question layout shape.
|
|
385
|
-
*/
|
|
386
|
-
it("testing single question layout", function () {
|
|
387
|
-
const beforeList = [
|
|
388
|
-
[emptyContent, ["blurb"]],
|
|
389
|
-
[emptyContent, ["question"]],
|
|
390
|
-
];
|
|
391
|
-
|
|
392
|
-
const afterList = [
|
|
393
|
-
[emptyContent, ["blurb"]],
|
|
394
|
-
[emptyContent, ["question"]],
|
|
395
|
-
[emptyHint, ["hints", 0]],
|
|
396
|
-
[emptyHint, ["hints", 1]],
|
|
397
|
-
];
|
|
398
|
-
|
|
399
|
-
const firstResult = [];
|
|
400
|
-
StructuredItemDiff.generateCompletePathsList(
|
|
401
|
-
// @ts-expect-error - TS2345 - Argument of type 'any[][]' is not assignable to parameter of type 'ItemList[]'.
|
|
402
|
-
beforeList.slice(),
|
|
403
|
-
afterList.slice(),
|
|
404
|
-
firstResult,
|
|
405
|
-
gtpSingleQuestionShape,
|
|
406
|
-
[],
|
|
407
|
-
);
|
|
408
|
-
|
|
409
|
-
const secondResult = [];
|
|
410
|
-
StructuredItemDiff.generateCompletePathsList(
|
|
411
|
-
// @ts-expect-error - TS2345 - Argument of type 'any[][]' is not assignable to parameter of type 'ItemList[]'.
|
|
412
|
-
afterList,
|
|
413
|
-
beforeList,
|
|
414
|
-
secondResult,
|
|
415
|
-
gtpSingleQuestionShape,
|
|
416
|
-
[],
|
|
417
|
-
);
|
|
418
|
-
|
|
419
|
-
expect(firstResult).toEqual([
|
|
420
|
-
["blurb"],
|
|
421
|
-
["question"],
|
|
422
|
-
["hints", 0],
|
|
423
|
-
["hints", 1],
|
|
424
|
-
]);
|
|
425
|
-
|
|
426
|
-
expect(secondResult).toEqual([
|
|
427
|
-
["blurb"],
|
|
428
|
-
["question"],
|
|
429
|
-
["hints", 0],
|
|
430
|
-
["hints", 1],
|
|
431
|
-
]);
|
|
432
|
-
});
|
|
433
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import diff from "../widget-diff-performer";
|
|
2
|
-
|
|
3
|
-
describe("widget-diff-performer", function () {
|
|
4
|
-
it("diffs a same single value", function () {
|
|
5
|
-
const sameValue = diff("a", "a");
|
|
6
|
-
expect(sameValue.status).toEqual("unchanged");
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it("diffs a different single value", function () {
|
|
10
|
-
const differentValue = diff("a", "b");
|
|
11
|
-
expect(differentValue.status).toEqual("changed");
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("diffs two identical objects", function () {
|
|
15
|
-
const objSame = diff({a: "b"}, {a: "b"});
|
|
16
|
-
expect(objSame.status).toEqual("unchanged");
|
|
17
|
-
|
|
18
|
-
expect(objSame.children).toHaveLength(1);
|
|
19
|
-
|
|
20
|
-
const child = objSame.children[0];
|
|
21
|
-
expect(child.status).toEqual("unchanged");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("diffs two different objects", function () {
|
|
25
|
-
const objDiff = diff({a: "b"}, {a: "c"});
|
|
26
|
-
expect(objDiff.status).toEqual("changed");
|
|
27
|
-
|
|
28
|
-
expect(objDiff.children).toHaveLength(1);
|
|
29
|
-
|
|
30
|
-
const diffChild = objDiff.children[0];
|
|
31
|
-
expect(diffChild.status).toEqual("changed");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("diffs a removed object", function () {
|
|
35
|
-
const removedObj = diff({a: "b"}, {});
|
|
36
|
-
expect(removedObj.children[0].status).toEqual("removed");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("diffs an added object", function () {
|
|
40
|
-
const addedObj = diff({}, {a: "c"});
|
|
41
|
-
expect(addedObj.children[0].status).toEqual("added");
|
|
42
|
-
});
|
|
43
|
-
});
|