diff --git a/packages/doenetml-worker/src/test/tagSpecific/copy.test.ts b/packages/doenetml-worker/src/test/tagSpecific/copy.test.ts
index fbaccfb31..689aec71a 100644
--- a/packages/doenetml-worker/src/test/tagSpecific/copy.test.ts
+++ b/packages/doenetml-worker/src/test/tagSpecific/copy.test.ts
@@ -7383,8 +7383,6 @@ describe("Copy tag tests", async () => {
let P21Dec4 = round({ val: P21, decimals: 4 });
let P22Dec4 = round({ val: P22, decimals: 4 });
- console.log({ P11Dig2 });
-
const stateVariables = await returnAllStateVariables(core);
expect(stateVariables["/p1"].stateValues.text).eq(
@@ -8589,8 +8587,6 @@ describe("Copy tag tests", async () => {
expect(stateVariables["/num"].stateValues.value).eqls(NaN);
- console.log(tiName);
-
await updateMathInputValue({ latex: "4", componentName: tiName, core });
await core.requestAction({
componentName: "/ans",
diff --git a/packages/doenetml-worker/src/test/tagSpecific/function.test.ts b/packages/doenetml-worker/src/test/tagSpecific/function.test.ts
index 20e8f5581..b8a111023 100644
--- a/packages/doenetml-worker/src/test/tagSpecific/function.test.ts
+++ b/packages/doenetml-worker/src/test/tagSpecific/function.test.ts
@@ -1,18 +1,18 @@
import { describe, expect, it, vi } from "vitest";
import { createTestCore, returnAllStateVariables } from "../utils/test-core";
import { cleanLatex } from "../utils/math";
-import {
- updateBooleanInputValue,
- updateMathInputValue,
- updateMatrixInputValue,
- updateTextInputValue,
-} from "../utils/actions";
+import { updateMathInputValue } from "../utils/actions";
import { createFunctionFromDefinition } from "@doenet/utils";
import me from "math-expressions";
const Mock = vi.fn();
vi.stubGlobal("postMessage", Mock);
+function constantFromAst(tree) {
+ //@ts-ignore
+ return me.fromAst(tree).evaluate_to_constant();
+}
+
describe("Function tag tests", async () => {
it("function with nothing", async () => {
let core = await createTestCore({
@@ -1070,8 +1070,8 @@ describe("Function tag tests", async () => {
let p = stateVariables["/P"];
- let x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- let y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ let x = constantFromAst(p.stateValues.xs[0]);
+ let y = constantFromAst(p.stateValues.xs[1]);
expect(6 - ((x - 5) * (x - 5)) / 25).closeTo(y, 1e-5);
@@ -1087,9 +1087,9 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
// @ts-ignore
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
// @ts-ignore
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ y = constantFromAst(p.stateValues.xs[1]);
expect(6 - ((x - 5) * (x - 5)) / 25).closeTo(y, 1e-5);
@@ -1105,9 +1105,9 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
// @ts-ignore
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
// @ts-ignore
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ y = constantFromAst(p.stateValues.xs[1]);
expect(6 - (x - 5) * (x - 5) * (2 / 9)).closeTo(y, 1e-5);
});
@@ -1131,14 +1131,11 @@ describe("Function tag tests", async () => {
let p = stateVariables["/P"];
- expect(me.fromAst(p.stateValues.xs[0]).evaluate_to_constant()).closeTo(
+ expect(constantFromAst(p.stateValues.xs[0])).closeTo(
Math.sqrt(2),
1e-6,
);
- expect(me.fromAst(p.stateValues.xs[1]).evaluate_to_constant()).closeTo(
- 2,
- 1e-6,
- );
+ expect(constantFromAst(p.stateValues.xs[1])).closeTo(2, 1e-6);
await core.requestAction({
actionName: "movePoint",
@@ -1151,14 +1148,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- expect(me.fromAst(p.stateValues.xs[0]).evaluate_to_constant()).closeTo(
- -2,
- 1e-6,
- );
- expect(me.fromAst(p.stateValues.xs[1]).evaluate_to_constant()).closeTo(
- 4,
- 1e-6,
- );
+ expect(constantFromAst(p.stateValues.xs[0])).closeTo(-2, 1e-6);
+ expect(constantFromAst(p.stateValues.xs[1])).closeTo(4, 1e-6);
});
it("point constrained to function, restrict to closed domain", async () => {
@@ -1179,8 +1170,8 @@ describe("Function tag tests", async () => {
let p = stateVariables["/P"];
- let x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- let y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ let x = constantFromAst(p.stateValues.xs[0]);
+ let y = constantFromAst(p.stateValues.xs[1]);
expect(x).closeTo(1, 1e-12);
expect(6 - ((x - 5) * (x - 5)) / 25).closeTo(y, 1e-5);
@@ -1196,8 +1187,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).closeTo(-4, 1e-12);
expect(6 - ((x - 5) * (x - 5)) / 25).closeTo(y, 1e-5);
@@ -1213,8 +1204,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).closeTo(6, 1e-12);
expect(6 - (x - 5) * (x - 5) * (2 / 9)).closeTo(y, 1e-5);
@@ -1230,8 +1221,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).closeTo(7, 1e-12);
expect(6 - (x - 5) * (x - 5) * (2 / 9)).closeTo(y, 1e-5);
@@ -1255,8 +1246,8 @@ describe("Function tag tests", async () => {
let p = stateVariables["/P"];
- let x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- let y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ let x = constantFromAst(p.stateValues.xs[0]);
+ let y = constantFromAst(p.stateValues.xs[1]);
expect(x).closeTo(1, 1e-12);
expect(6 - ((x - 5) * (x - 5)) / 25).closeTo(y, 1e-5);
@@ -1272,8 +1263,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).greaterThan(-4 + 1e-12);
expect(x).lessThan(-4 + 1e-3);
@@ -1290,8 +1281,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).closeTo(6, 1e-12);
expect(6 - (x - 5) * (x - 5) * (2 / 9)).closeTo(y, 1e-5);
@@ -1307,8 +1298,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).lessThan(7 - 1e-12);
expect(x).greaterThan(7 - 1e-3);
@@ -1321,14 +1312,8 @@ describe("Function tag tests", async () => {
let stateVariables = await returnAllStateVariables(core);
let p = stateVariables["/P"];
- expect(me.fromAst(p.stateValues.xs[0]).evaluate_to_constant()).closeTo(
- 1,
- 1e-6,
- );
- expect(me.fromAst(p.stateValues.xs[1]).evaluate_to_constant()).closeTo(
- f(1),
- 1e-6,
- );
+ expect(constantFromAst(p.stateValues.xs[0])).closeTo(1, 1e-6);
+ expect(constantFromAst(p.stateValues.xs[1])).closeTo(f(1), 1e-6);
await core.requestAction({
actionName: "movePoint",
@@ -1341,10 +1326,9 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- let x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- let y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ let x = constantFromAst(p.stateValues.xs[0]);
+ let y = constantFromAst(p.stateValues.xs[1]);
- console.log({ x, y });
expect(y).closeTo(f(x), 1e-6);
await core.requestAction({
@@ -1358,8 +1342,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(y).closeTo(f(x), 1e-6);
@@ -1374,8 +1358,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(y).closeTo(f(x), 1e-6);
@@ -1390,8 +1374,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(y).closeTo(f(x), 1e-6);
}
@@ -1744,8 +1728,8 @@ describe("Function tag tests", async () => {
let p = stateVariables["/P"];
- let x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- let y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ let x = constantFromAst(p.stateValues.xs[0]);
+ let y = constantFromAst(p.stateValues.xs[1]);
expect(Math.log(2 * x)).closeTo(y, 1e-5);
@@ -1760,8 +1744,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(Math.log(2 * x)).closeTo(y, 1e-5);
@@ -1776,8 +1760,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(Math.log(2 * x)).closeTo(y, 1e-5);
});
@@ -1802,8 +1786,8 @@ describe("Function tag tests", async () => {
let p = stateVariables["/P"];
- let x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- let y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ let x = constantFromAst(p.stateValues.xs[0]);
+ let y = constantFromAst(p.stateValues.xs[1]);
expect(x).greaterThan(0.1 + 1e-12);
expect(x).lessThan(0.1 + 1e-3);
@@ -1820,8 +1804,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).closeTo(4, 1e-12);
expect(Math.log(2 * x)).closeTo(y, 1e-5);
@@ -1837,8 +1821,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).closeTo(6, 1e-12);
expect(Math.log(2 * x)).closeTo(y, 1e-5);
@@ -1854,8 +1838,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).greaterThan(0.1 + 1e-12);
expect(x).lessThan(0.1 + 1e-3);
@@ -1882,8 +1866,8 @@ describe("Function tag tests", async () => {
let p = stateVariables["/P"];
- let x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- let y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ let x = constantFromAst(p.stateValues.xs[0]);
+ let y = constantFromAst(p.stateValues.xs[1]);
expect(x).eq(0.1);
expect(Math.log(2 * x)).closeTo(y, 1e-5);
@@ -1899,8 +1883,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).closeTo(4, 1e-12);
expect(Math.log(2 * x)).closeTo(y, 1e-5);
@@ -1916,8 +1900,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).lessThan(6 - 1e-12);
expect(x).greaterThan(6 - 1e-3);
@@ -1934,8 +1918,8 @@ describe("Function tag tests", async () => {
p = stateVariables["/P"];
- x = me.fromAst(p.stateValues.xs[0]).evaluate_to_constant();
- y = me.fromAst(p.stateValues.xs[1]).evaluate_to_constant();
+ x = constantFromAst(p.stateValues.xs[0]);
+ y = constantFromAst(p.stateValues.xs[1]);
expect(x).closeTo(0.1, 1e-12);
expect(Math.log(2 * x)).closeTo(y, 1e-5);
diff --git a/packages/doenetml-worker/src/test/tagSpecific/substitute.test.ts b/packages/doenetml-worker/src/test/tagSpecific/substitute.test.ts
new file mode 100644
index 000000000..6eb52aa26
--- /dev/null
+++ b/packages/doenetml-worker/src/test/tagSpecific/substitute.test.ts
@@ -0,0 +1,1586 @@
+import { describe, expect, it, vi } from "vitest";
+import { createTestCore, returnAllStateVariables } from "../utils/test-core";
+import { cleanLatex } from "../utils/math";
+import {
+ updateBooleanInputValue,
+ updateMathInputValue,
+ updateMatrixInputValue,
+ updateTextInputValue,
+} from "../utils/actions";
+import me from "math-expressions";
+
+const Mock = vi.fn();
+vi.stubGlobal("postMessage", Mock);
+
+describe("Substitute tag tests", async () => {
+ async function test_sub_alpha_x2(core) {
+ const stateVariables = await returnAllStateVariables(core);
+ expect(stateVariables["/s_one"].stateValues.value.tree).eqls([
+ "+",
+ "alpha",
+ ["^", "b", 2],
+ ]);
+ expect(stateVariables["/one"].stateValues.value.tree).eqls([
+ "+",
+ "alpha",
+ ["^", "b", 2],
+ ]);
+ expect(stateVariables["/s_two"].stateValues.value.tree).eqls([
+ "+",
+ "d",
+ ["^", "b", 2],
+ ]);
+ expect(stateVariables["/two"].stateValues.value.tree).eqls([
+ "+",
+ "d",
+ ["^", "b", 2],
+ ]);
+ }
+
+ it("substitute into string sugared to math", async () => {
+ let core = await createTestCore({
+ doenetML: `
+
Original:
Original 2:
+ +Match:
Replacement:
Substituted:
Substituted 2:
Original:
Original 2:
Match:
Match whole word:
Match case:
Replacement:
Preserve case:
Substituted:
Substituted 2:
$matchCase.value{assignNames="matchCase2"}
+ `, + }); + + let stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq("hello there"); + expect(stateVariables["/orig2"].stateValues.value).eq("hello there"); + expect(stateVariables["/subbed"].stateValues.value).eq("bye there"); + expect(stateVariables["/subbed2"].stateValues.value).eq("bye there"); + + // change original + await updateTextInputValue({ + text: "hello thereHello", + componentName: "/orig", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello thereHello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello thereHello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq("bye therebye"); + expect(stateVariables["/subbed2"].stateValues.value).eq("bye therebye"); + + // change subbed + await updateTextInputValue({ + text: "bye therebyeBye", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello therehellohello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello therehellohello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "bye therebyebye", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "bye therebyebye", + ); + + // change replacement so that it is in original + await updateTextInputValue({ + text: "There", + componentName: "/replacement", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello therehellohello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello therehellohello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "There thereThereThere", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "There thereThereThere", + ); + + // Cannot modify subbed + await updateTextInputValue({ + text: "There thereThereThere extra", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello therehellohello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello therehellohello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "There thereThereThere", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "There thereThereThere", + ); + + // change original to not contain replacement + await updateTextInputValue({ + text: "hello thenhellohello", + componentName: "/orig", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello thenhellohello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello thenhellohello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "There thenThereThere", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "There thenThereThere", + ); + + // Can modify subbed again + await updateTextInputValue({ + text: "There thenThereThe", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello thenhelloThe", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello thenhelloThe", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "There thenThereThe", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "There thenThereThe", + ); + + // Cannot modify subbed to include match + await updateTextInputValue({ + text: "There thenThereTheHELLO", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello thenhelloThe", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello thenhelloThe", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "There thenThereThe", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "There thenThereThe", + ); + + await updateBooleanInputValue({ + boolean: true, + componentName: "/wholeWord", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello thenhelloThe", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello thenhelloThe", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "There thenhelloThe", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "There thenhelloThe", + ); + + //change replacement so matches original, but not as a whole word + await updateTextInputValue({ + text: "Then", + componentName: "/replacement", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello thenhelloThe", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello thenhelloThe", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Then thenhelloThe", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Then thenhelloThe", + ); + + // Can still modify subbed + await updateTextInputValue({ + text: "Then thenhelloThere", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello thenhelloThere", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello thenhelloThere", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Then thenhelloThere", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Then thenhelloThere", + ); + + // Cannot modify subbed by adding spaces to separate match + await updateTextInputValue({ + text: "Then then hello There", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello thenhelloThere", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello thenhelloThere", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Then thenhelloThere", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Then thenhelloThere", + ); + + // change original so that replacement matches original as a whole word + await updateTextInputValue({ + text: "hello then helloThere", + componentName: "/orig", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello then helloThere", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello then helloThere", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Then then helloThere", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Then then helloThere", + ); + + // Cannot modify subbed due to replacement match + await updateTextInputValue({ + text: "Then then helloTherenothing", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello then helloThere", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello then helloThere", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Then then helloThere", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Then then helloThere", + ); + + // match case + await updateBooleanInputValue({ + boolean: true, + componentName: "/matchCase", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello then helloThere", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello then helloThere", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Then then helloThere", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Then then helloThere", + ); + + // Now can modify subbed due to replacement not matching original case + await updateTextInputValue({ + text: "Then then helloThere Hello", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello then helloThere Hello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello then helloThere Hello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Then then helloThere Hello", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Then then helloThere Hello", + ); + + // Cannot add match to subbed + await updateTextInputValue({ + text: "Then then helloThere Hello hello", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "hello then helloThere Hello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "hello then helloThere Hello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Then then helloThere Hello", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Then then helloThere Hello", + ); + + // Change subbed to switch cases + await updateTextInputValue({ + text: "then Then helloThere Hello", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "then hello helloThere Hello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "then hello helloThere Hello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "then Then helloThere Hello", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "then Then helloThere Hello", + ); + + // preserve case + await updateBooleanInputValue({ + boolean: true, + componentName: "/preserveCase", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "then hello helloThere Hello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "then hello helloThere Hello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "then then helloThere Hello", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "then then helloThere Hello", + ); + + // Cannot change subbed since original contains effective replacement + await updateTextInputValue({ + text: "then Then helloThere Hello more", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "then hello helloThere Hello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "then hello helloThere Hello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "then then helloThere Hello", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "then then helloThere Hello", + ); + + // change case of match so that effective replacement is not in original + await updateTextInputValue({ + text: "Hello", + componentName: "/match", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "then hello helloThere Hello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "then hello helloThere Hello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "then hello helloThere Then", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "then hello helloThere Then", + ); + + // Can now change subbed + await updateTextInputValue({ + text: "Then HELLO THEN helloThere Then", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "Hello HELLO THEN helloThere Hello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "Hello HELLO THEN helloThere Hello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Then HELLO THEN helloThere Then", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Then HELLO THEN helloThere Then", + ); + + // change case of match so that effective replacement is again in original + await updateTextInputValue({ + text: "HELLO", + componentName: "/match", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "Hello HELLO THEN helloThere Hello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "Hello HELLO THEN helloThere Hello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Hello THEN THEN helloThere Hello", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Hello THEN THEN helloThere Hello", + ); + + // Cannot change subbed + await updateTextInputValue({ + text: "Hello THEN THEN helloThere Hello ineffective", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "Hello HELLO THEN helloThere Hello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "Hello HELLO THEN helloThere Hello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Hello THEN THEN helloThere Hello", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Hello THEN THEN helloThere Hello", + ); + + // change original so no longer has effective replacement + await updateTextInputValue({ + text: "Hello HELLO Then helloThere Hello", + componentName: "/orig", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "Hello HELLO Then helloThere Hello", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "Hello HELLO Then helloThere Hello", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Hello THEN Then helloThere Hello", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Hello THEN Then helloThere Hello", + ); + + // Can change subbed once more + await updateTextInputValue({ + text: "Hello THEN Then helloThere THEN", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "Hello HELLO Then helloThere HELLO", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "Hello HELLO Then helloThere HELLO", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Hello THEN Then helloThere THEN", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Hello THEN Then helloThere THEN", + ); + + // Cannot add match to subbed + await updateTextInputValue({ + text: "Hello THEN Then helloThere THEN HELLO", + componentName: "/subbed2", + core, + }); + + stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/orig"].stateValues.value).eq( + "Hello HELLO Then helloThere HELLO", + ); + expect(stateVariables["/orig2"].stateValues.value).eq( + "Hello HELLO Then helloThere HELLO", + ); + expect(stateVariables["/subbed"].stateValues.value).eq( + "Hello THEN Then helloThere THEN", + ); + expect(stateVariables["/subbed2"].stateValues.value).eq( + "Hello THEN Then helloThere THEN", + ); + }); + + it("substitute with incomplete attributes does nothing", async () => { + let core = await createTestCore({ + doenetML: ` ++ + +
+ + ++ + +
+ ++ + +
+ ++ + +
+ + `, + }); + + let stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/e1"]); + + expect(cleanLatex(stateVariables["/e1"].stateValues.latex)).eq( + "0.0739x+847.29+5y", + ); + expect(cleanLatex(stateVariables["/e1Dig4"].stateValues.latex)).eq( + "0.07395x+847.3+5y", + ); + expect(cleanLatex(stateVariables["/e1Dec4"].stateValues.latex)).eq( + "0.0739x+847.2942+5y", + ); + expect(cleanLatex(stateVariables["/e1Pad"].stateValues.latex)).eq( + "0.0739x+847.29+5.00y", + ); + expect(cleanLatex(stateVariables["/e1Dig4a"].stateValues.latex)).eq( + "0.07395x+847.3+5y", + ); + expect(cleanLatex(stateVariables["/e1Dec4a"].stateValues.latex)).eq( + "0.0739x+847.2942+5y", + ); + expect(cleanLatex(stateVariables["/e2"].stateValues.latex)).eq( + "0.0739x+847+5y", + ); + expect(cleanLatex(stateVariables["/e2Dig4"].stateValues.latex)).eq( + "0.07395x+847.3+5y", + ); + expect(cleanLatex(stateVariables["/e2Dec4"].stateValues.latex)).eq( + "0.0739x+847.2942+5y", + ); + expect(cleanLatex(stateVariables["/e2Pad"].stateValues.latex)).eq( + "0.0739x+847+5.00y", + ); + expect(cleanLatex(stateVariables["/e2Dig4a"].stateValues.latex)).eq( + "0.07395x+847.3+5y", + ); + expect(cleanLatex(stateVariables["/e2Dec4a"].stateValues.latex)).eq( + "0.0739x+847.2942+5y", + ); + expect(cleanLatex(stateVariables["/e3"].stateValues.latex)).eq( + "0.074x+847.294+5y", + ); + expect(cleanLatex(stateVariables["/e3Dig4"].stateValues.latex)).eq( + "0.07395x+847.3+5y", + ); + expect(cleanLatex(stateVariables["/e3Dec4"].stateValues.latex)).eq( + "0.0739x+847.2942+5y", + ); + expect(cleanLatex(stateVariables["/e3Pad"].stateValues.latex)).eq( + "0.074x+847.294+5.000y", + ); + expect(cleanLatex(stateVariables["/e3Dig4a"].stateValues.latex)).eq( + "0.07395x+847.3+5y", + ); + expect(cleanLatex(stateVariables["/e3Dec4a"].stateValues.latex)).eq( + "0.0739x+847.2942+5y", + ); + expect(cleanLatex(stateVariables["/e4"].stateValues.latex)).eq( + "0.0739x+847.29+5.00y", + ); + expect(cleanLatex(stateVariables["/e4Dig4"].stateValues.latex)).eq( + "0.07395x+847.3+5.000y", + ); + expect(cleanLatex(stateVariables["/e4Dec4"].stateValues.latex)).eq( + "0.0739x+847.2942+5.0000y", + ); + expect(cleanLatex(stateVariables["/e4NoPad"].stateValues.latex)).eq( + "0.0739x+847.29+5y", + ); + expect(cleanLatex(stateVariables["/e4Dig4a"].stateValues.latex)).eq( + "0.07395x+847.3+5.000y", + ); + expect(cleanLatex(stateVariables["/e4Dec4a"].stateValues.latex)).eq( + "0.0739x+847.2942+5.0000y", + ); + }); +}); diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/substitute.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/substitute.cy.js deleted file mode 100644 index 64254ffb1..000000000 --- a/packages/test-cypress/cypress/e2e/tagSpecific/substitute.cy.js +++ /dev/null @@ -1,2853 +0,0 @@ -import me from "math-expressions"; -import { cesc } from "@doenet/utils"; - -describe("Substitute Tag Tests", function () { - beforeEach(() => { - cy.clearIndexedDB(); - cy.visit("/"); - }); - - it("substitute into string sugared to math", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -Original:
Original 2:
- -Match:
Replacement:
Substituted:
Substituted 2:
Original:
Original 2:
Match:
Match whole word:
Match case:
Replacement:
Preserve case:
Substituted:
Substituted 2:
$matchCase.value{assignNames="matchCase2"}
- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load - - cy.get(cesc("#\\/orig_input")).should("have.value", "hello there"); - cy.get(cesc("#\\/orig2")).should("have.text", "hello there"); - cy.get(cesc("#\\/subbed")).should("have.text", "bye there"); - cy.get(cesc("#\\/subbed2_input")).should("have.value", "bye there"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq("hello there"); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello there", - ); - expect(stateVariables["/subbed"].stateValues.value).eq("bye there"); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "bye there", - ); - }); - - cy.log("change original"); - cy.get(cesc("#\\/orig_input")).type(`{end}Hello{enter}`); - - cy.get(cesc("#\\/orig2")).should("have.text", "hello thereHello"); - cy.get(cesc("#\\/orig_input")).should("have.value", "hello thereHello"); - cy.get(cesc("#\\/subbed")).should("have.text", "bye therebye"); - cy.get(cesc("#\\/subbed2_input")).should("have.value", "bye therebye"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello thereHello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello thereHello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "bye therebye", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "bye therebye", - ); - }); - - cy.log("change subbed"); - cy.get(cesc("#\\/subbed2_input")).type(`{end}Bye{enter}`); - - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello therehellohello", - ); - cy.get(cesc("#\\/orig2")).should("have.text", "hello therehellohello"); - cy.get(cesc("#\\/subbed")).should("have.text", "bye therebyebye"); - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "bye therebyebye", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello therehellohello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello therehellohello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "bye therebyebye", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "bye therebyebye", - ); - }); - - cy.log("change replacement so that it is in original"); - cy.get(cesc("#\\/replacement_input")).clear().type(`There{enter}`); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "There thereThereThere", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello therehellohello", - ); - cy.get(cesc("#\\/orig2")).should("have.text", "hello therehellohello"); - cy.get(cesc("#\\/subbed")).should("have.text", "There thereThereThere"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello therehellohello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello therehellohello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "There thereThereThere", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "There thereThereThere", - ); - }); - - cy.log("Cannot modify subbed"); - cy.get(cesc("#\\/subbed2_input")).type(`{end} extra{enter}`); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "There thereThereThere", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello therehellohello", - ); - cy.get(cesc("#\\/orig2")).should("have.text", "hello therehellohello"); - cy.get(cesc("#\\/subbed")).should("have.text", "There thereThereThere"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello therehellohello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello therehellohello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "There thereThereThere", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "There thereThereThere", - ); - }); - - cy.log("change original to not contain replacement"); - cy.get(cesc("#\\/orig_input")).type( - "{end}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{backspace}{backspace}n{enter}", - ); - - cy.get(cesc("#\\/orig2")).should("have.text", "hello thenhellohello"); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello thenhellohello", - ); - cy.get(cesc("#\\/subbed")).should("have.text", "There thenThereThere"); - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "There thenThereThere", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello thenhellohello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello thenhellohello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "There thenThereThere", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "There thenThereThere", - ); - }); - - cy.log("Can modify subbed again"); - cy.get(cesc("#\\/subbed2_input")).type( - `{end}{backspace}{backspace}{enter}`, - ); - - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello thenhelloThe", - ); - cy.get(cesc("#\\/orig2")).should("have.text", "hello thenhelloThe"); - cy.get(cesc("#\\/subbed")).should("have.text", "There thenThereThe"); - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "There thenThereThe", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello thenhelloThe", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello thenhelloThe", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "There thenThereThe", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "There thenThereThe", - ); - }); - - cy.log("Cannot modify subbed to include match"); - cy.get(cesc("#\\/subbed2_input")).type(`{end}HELLO{enter}`); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "There thenThereThe", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello thenhelloThe", - ); - cy.get(cesc("#\\/orig2")).should("have.text", "hello thenhelloThe"); - cy.get(cesc("#\\/subbed")).should("have.text", "There thenThereThe"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello thenhelloThe", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello thenhelloThe", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "There thenThereThe", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "There thenThereThe", - ); - }); - - cy.log("match whole word"); - cy.get(cesc("#\\/wholeWord")).click(); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "There thenhelloThe", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello thenhelloThe", - ); - cy.get(cesc("#\\/orig2")).should("have.text", "hello thenhelloThe"); - cy.get(cesc("#\\/subbed")).should("have.text", "There thenhelloThe"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello thenhelloThe", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello thenhelloThe", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "There thenhelloThe", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "There thenhelloThe", - ); - }); - - cy.log( - "change replacement so matches original, but not as a whole word", - ); - cy.get(cesc("#\\/replacement_input")).clear().type(`Then{enter}`); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Then thenhelloThe", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello thenhelloThe", - ); - cy.get(cesc("#\\/orig2")).should("have.text", "hello thenhelloThe"); - cy.get(cesc("#\\/subbed")).should("have.text", "Then thenhelloThe"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello thenhelloThe", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello thenhelloThe", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Then thenhelloThe", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Then thenhelloThe", - ); - }); - - cy.log("Can still modify subbed"); - cy.get(cesc("#\\/subbed2_input")).type(`{end}re{enter}`); - - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello thenhelloThere", - ); - cy.get(cesc("#\\/orig2")).should("have.text", "hello thenhelloThere"); - cy.get(cesc("#\\/subbed")).should("have.text", "Then thenhelloThere"); - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Then thenhelloThere", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello thenhelloThere", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello thenhelloThere", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Then thenhelloThere", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Then thenhelloThere", - ); - }); - - cy.log("Cannnot modify subbed by adding spaces to separate match"); - cy.get(cesc("#\\/subbed2_input")).type( - `{end}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow} {leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow} {enter}`, - ); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Then thenhelloThere", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello thenhelloThere", - ); - cy.get(cesc("#\\/orig2")).should("have.text", "hello thenhelloThere"); - cy.get(cesc("#\\/subbed")).should("have.text", "Then thenhelloThere"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello thenhelloThere", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello thenhelloThere", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Then thenhelloThere", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Then thenhelloThere", - ); - }); - - cy.log( - "change original so that replacement matches original as a whole word", - ); - cy.get(cesc("#\\/orig_input")).type( - "{end}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow} {enter}", - ); - - cy.get(cesc("#\\/orig2")).should("have.text", "hello then helloThere"); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello then helloThere", - ); - cy.get(cesc("#\\/subbed")).should("have.text", "Then then helloThere"); - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Then then helloThere", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello then helloThere", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello then helloThere", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Then then helloThere", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Then then helloThere", - ); - }); - - cy.log("Cannot modify subbed due to replacement match"); - cy.get(cesc("#\\/subbed2_input")).type(`{end}nothing{enter}`); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Then then helloThere", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello then helloThere", - ); - cy.get(cesc("#\\/orig2")).should("have.text", "hello then helloThere"); - cy.get(cesc("#\\/subbed")).should("have.text", "Then then helloThere"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello then helloThere", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello then helloThere", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Then then helloThere", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Then then helloThere", - ); - }); - - cy.log("match case"); - cy.get(cesc("#\\/matchCase")).click(); - - cy.get(cesc("#\\/matchCase2")).should("have.text", "true"); - - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello then helloThere", - ); - cy.get(cesc("#\\/orig2")).should("have.text", "hello then helloThere"); - cy.get(cesc("#\\/subbed")).should("have.text", "Then then helloThere"); - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Then then helloThere", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello then helloThere", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello then helloThere", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Then then helloThere", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Then then helloThere", - ); - }); - - cy.log( - "Now cannot modify subbed due to replacement not matching original case", - ); - cy.get(cesc("#\\/subbed2_input")).type(`{end} Hello{enter}`); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Then then helloThere Hello", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello then helloThere Hello", - ); - cy.get(cesc("#\\/orig2")).should( - "have.text", - "hello then helloThere Hello", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "Then then helloThere Hello", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello then helloThere Hello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello then helloThere Hello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Then then helloThere Hello", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Then then helloThere Hello", - ); - }); - - cy.log("Cannot add match to subbed"); - cy.get(cesc("#\\/subbed2_input")).type(`{end} hello{enter}`); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Then then helloThere Hello", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "hello then helloThere Hello", - ); - cy.get(cesc("#\\/orig2")).should( - "have.text", - "hello then helloThere Hello", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "Then then helloThere Hello", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "hello then helloThere Hello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "hello then helloThere Hello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Then then helloThere Hello", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Then then helloThere Hello", - ); - }); - - cy.log("Change subbed to switch cases"); - cy.get(cesc("#\\/subbed2_input")).type( - `{home}{rightArrow}{backspace}t{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{backspace}T{enter}`, - ); - - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "then hello helloThere Hello", - ); - cy.get(cesc("#\\/orig2")).should( - "have.text", - "then hello helloThere Hello", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "then Then helloThere Hello", - ); - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "then Then helloThere Hello", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "then hello helloThere Hello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "then hello helloThere Hello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "then Then helloThere Hello", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "then Then helloThere Hello", - ); - }); - - cy.log("preserve case"); - cy.get(cesc("#\\/preserveCase")).click(); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "then then helloThere Hello", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "then hello helloThere Hello", - ); - cy.get(cesc("#\\/orig2")).should( - "have.text", - "then hello helloThere Hello", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "then then helloThere Hello", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "then hello helloThere Hello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "then hello helloThere Hello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "then then helloThere Hello", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "then then helloThere Hello", - ); - }); - - cy.log( - "Cannot change subbed since original contains effective replacement", - ); - cy.get(cesc("#\\/subbed2_input")).type(`{end} more{enter}`); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "then then helloThere Hello", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "then hello helloThere Hello", - ); - cy.get(cesc("#\\/orig2")).should( - "have.text", - "then hello helloThere Hello", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "then then helloThere Hello", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "then hello helloThere Hello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "then hello helloThere Hello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "then then helloThere Hello", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "then then helloThere Hello", - ); - }); - - cy.log( - "change case of match so that effective replacement is not in original", - ); - cy.get(cesc("#\\/match_input")).type( - `{home}{rightArrow}{backspace}H{enter}`, - ); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "then hello helloThere Then", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "then hello helloThere Hello", - ); - cy.get(cesc("#\\/orig2")).should( - "have.text", - "then hello helloThere Hello", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "then hello helloThere Then", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "then hello helloThere Hello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "then hello helloThere Hello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "then hello helloThere Then", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "then hello helloThere Then", - ); - }); - - cy.log("Can now change subbed"); - cy.get(cesc("#\\/subbed2_input")).type( - `{home}{rightArrow}{backspace}T{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{backspace}{backspace}{backspace}{backspace}{backspace}HELLO THEN{enter}`, - ); - - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "Hello HELLO THEN helloThere Hello", - ); - cy.get(cesc("#\\/orig2")).should( - "have.text", - "Hello HELLO THEN helloThere Hello", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "Then HELLO THEN helloThere Then", - ); - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Then HELLO THEN helloThere Then", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "Hello HELLO THEN helloThere Hello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "Hello HELLO THEN helloThere Hello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Then HELLO THEN helloThere Then", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Then HELLO THEN helloThere Then", - ); - }); - - cy.log( - "change case of match so that effective replacement is again in original", - ); - cy.get(cesc("#\\/match_input")).type( - `{home}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{backspace}{backspace}{backspace}{backspace}ELLO{enter}`, - ); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Hello THEN THEN helloThere Hello", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "Hello HELLO THEN helloThere Hello", - ); - cy.get(cesc("#\\/orig2")).should( - "have.text", - "Hello HELLO THEN helloThere Hello", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "Hello THEN THEN helloThere Hello", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "Hello HELLO THEN helloThere Hello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "Hello HELLO THEN helloThere Hello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Hello THEN THEN helloThere Hello", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Hello THEN THEN helloThere Hello", - ); - }); - - cy.log("Cannot change subbed"); - cy.get(cesc("#\\/subbed2_input")).type(`{end} ineffective{enter}`); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Hello THEN THEN helloThere Hello", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "Hello HELLO THEN helloThere Hello", - ); - cy.get(cesc("#\\/orig2")).should( - "have.text", - "Hello HELLO THEN helloThere Hello", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "Hello THEN THEN helloThere Hello", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "Hello HELLO THEN helloThere Hello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "Hello HELLO THEN helloThere Hello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Hello THEN THEN helloThere Hello", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Hello THEN THEN helloThere Hello", - ); - }); - - cy.log("change original so no longer has effective replacement"); - cy.get(cesc("#\\/orig_input")).type( - `{home}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{rightArrow}{backspace}{backspace}{backspace}hen{enter}`, - ); - - cy.get(cesc("#\\/orig2")).should( - "have.text", - "Hello HELLO Then helloThere Hello", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "Hello HELLO Then helloThere Hello", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "Hello THEN Then helloThere Hello", - ); - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Hello THEN Then helloThere Hello", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "Hello HELLO Then helloThere Hello", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "Hello HELLO Then helloThere Hello", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Hello THEN Then helloThere Hello", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Hello THEN Then helloThere Hello", - ); - }); - - cy.log("Can change subbed once more"); - cy.get(cesc("#\\/subbed2_input")).type( - `{end}{backspace}{backspace}{backspace}{backspace}{backspace}THEN{enter}`, - ); - - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "Hello HELLO Then helloThere HELLO", - ); - cy.get(cesc("#\\/orig2")).should( - "have.text", - "Hello HELLO Then helloThere HELLO", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "Hello THEN Then helloThere THEN", - ); - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Hello THEN Then helloThere THEN", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "Hello HELLO Then helloThere HELLO", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "Hello HELLO Then helloThere HELLO", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Hello THEN Then helloThere THEN", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Hello THEN Then helloThere THEN", - ); - }); - - cy.log("Cannot add match to subbed"); - cy.get(cesc("#\\/subbed2_input")).type(`{end} HELLO{enter}`); - - cy.get(cesc("#\\/subbed2_input")).should( - "have.value", - "Hello THEN Then helloThere THEN", - ); - cy.get(cesc("#\\/orig_input")).should( - "have.value", - "Hello HELLO Then helloThere HELLO", - ); - cy.get(cesc("#\\/orig2")).should( - "have.text", - "Hello HELLO Then helloThere HELLO", - ); - cy.get(cesc("#\\/subbed")).should( - "have.text", - "Hello THEN Then helloThere THEN", - ); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/orig"].stateValues.value).eq( - "Hello HELLO Then helloThere HELLO", - ); - expect(stateVariables["/orig2"].stateValues.value).eq( - "Hello HELLO Then helloThere HELLO", - ); - expect(stateVariables["/subbed"].stateValues.value).eq( - "Hello THEN Then helloThere THEN", - ); - expect(stateVariables["/subbed2"].stateValues.value).eq( - "Hello THEN Then helloThere THEN", - ); - }); - }); - - it("substitute with incomplete attributes does nothing", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -- - -
- - -- - -
- -- - -
- -- - -
- - `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load - - cy.get(cesc("#\\/e1") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.29+5y"); - }); - cy.get(cesc("#\\/e1Dig4") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.07395x+847.3+5y"); - }); - cy.get(cesc("#\\/e1Dec4") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.2942+5y"); - }); - cy.get(cesc("#\\/e1Pad") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.29+5.00y"); - }); - cy.get(cesc("#\\/e1Dig4a") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.07395x+847.3+5y"); - }); - cy.get(cesc("#\\/e1Dec4a") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.2942+5y"); - }); - - cy.get(cesc("#\\/e2") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847+5y"); - }); - cy.get(cesc("#\\/e2Dig4") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.07395x+847.3+5y"); - }); - cy.get(cesc("#\\/e2Dec4") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.2942+5y"); - }); - cy.get(cesc("#\\/e2Pad") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847+5.00y"); - }); - cy.get(cesc("#\\/e2Dig4a") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.07395x+847.3+5y"); - }); - cy.get(cesc("#\\/e2Dec4a") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.2942+5y"); - }); - - cy.get(cesc("#\\/e3") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.074x+847.294+5y"); - }); - cy.get(cesc("#\\/e3Dig4") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.07395x+847.3+5y"); - }); - cy.get(cesc("#\\/e3Dec4") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.2942+5y"); - }); - cy.get(cesc("#\\/e3Pad") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.074x+847.294+5.000y"); - }); - cy.get(cesc("#\\/e3Dig4a") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.07395x+847.3+5y"); - }); - cy.get(cesc("#\\/e3Dec4a") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.2942+5y"); - }); - - cy.get(cesc("#\\/e4") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.29+5.00y"); - }); - cy.get(cesc("#\\/e4Dig4") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.07395x+847.3+5.000y"); - }); - cy.get(cesc("#\\/e4Dec4") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.2942+5.0000y"); - }); - cy.get(cesc("#\\/e4NoPad") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.29+5y"); - }); - cy.get(cesc("#\\/e4Dig4a") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.07395x+847.3+5.000y"); - }); - cy.get(cesc("#\\/e4Dec4a") + " .mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text).equal("0.0739x+847.2942+5.0000y"); - }); - }); -});