tag is ignoring the onChange event
- // unless first select option 3 before selecting them all!
- // No idea what's going on
- cy.get(cesc("#\\/ci2")).select(["3"]);
- cy.get(cesc(`#\\/ci2`)).select(selectedIndices.map(String));
-
- checkChoices(selectedChoices, inputText);
-
- cy.log("type no dog at end");
- inputText += ", no dog";
- cy.get(cesc("#\\/_textinput1_input")).type(`{end}, no dog{enter}`);
- checkChoices(selectedChoices, inputText);
-
- cy.log("type dog, DOG");
- selectedChoices = [" dog "];
- inputText = "dog, DOG";
- cy.get(cesc("#\\/_textinput1_input"))
- .clear()
- .type(`${inputText}{enter}`);
- checkChoices(selectedChoices, inputText);
-
- cy.log("select cat from first input");
- selectedChoices = [" dog ", "caT"];
- selectedChoices.sort(
- (a, b) => choices.indexOf(a) - choices.indexOf(b),
- );
- selectedIndex = choices.indexOf("caT") + 1;
- inputText = selectedChoices.join(", ");
- cy.get(cesc(`#\\/ci1_choice${selectedIndex}_input`)).click();
- checkChoices(selectedChoices, inputText);
-
- cy.log("deselect dog from first input");
- selectedIndex = choices.indexOf(" dog ") + 1;
- selectedChoices = ["caT"];
- inputText = selectedChoices.join(", ");
- cy.get(cesc(`#\\/ci1_choice${selectedIndex}_input`)).click();
- checkChoices(selectedChoices, inputText);
- });
- });
-
- it("bind value to fixed text, choiceinput reverts to fixed value", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- cat
- dog
- monkey
-
-
- Fixed to be: monkey
-
-
-
- Selected values:
- $ci1.selectedValue
- $ci2.selectedValue
-
- Selected indices:
- $ci1.selectedindex
- $ci2.selectedindex
-
-
- Check for core round trip: $bi.value{assignNames="b"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- function checkStillMonkey() {
- for (let i = 1; i <= 3; i++) {
- if (i === 3) {
- cy.get(cesc(`#\\/ci1_choice${i}_input`)).should(
- "be.checked",
- );
- } else {
- cy.get(cesc(`#\\/ci1_choice${i}_input`)).should(
- "not.be.checked",
- );
- }
- }
- cy.get(cesc(`#\\/ci2`)).should("have.value", "3");
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- `Selected values: monkey, monkey`,
- );
- cy.get(cesc("#\\/_p3")).should(
- "have.text",
- `Selected indices: 3, 3`,
- );
- }
-
- checkStillMonkey();
-
- cy.get(cesc(`#\\/ci1_choice1_input`)).click();
- cy.get(cesc(`#\\/bi`)).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
- checkStillMonkey();
-
- cy.get(cesc(`#\\/ci1_choice2_input`)).click();
- cy.get(cesc(`#\\/bi`)).click();
- cy.get(cesc("#\\/b")).should("have.text", "false");
- checkStillMonkey();
-
- cy.get(cesc(`#\\/ci2`)).select(`1`);
- cy.get(cesc(`#\\/bi`)).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
- checkStillMonkey();
-
- cy.get(cesc(`#\\/ci2`)).select(`2`);
- cy.get(cesc(`#\\/bi`)).click();
- cy.get(cesc("#\\/b")).should("have.text", "false");
- checkStillMonkey();
- });
-
- it("bind value to mathinput", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- x^2/2
- y
- \\frac{\\partial f}{\\partial x}
- 3
- 1/(e^x)
-
-
- Select by typing:
-
-
-
- Selected values:
- $ci1.selectedValue
- $ci2.selectedValue
-
- Selected indices:
- $ci1.selectedindex
- $ci2.selectedindex
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let textOrder = ["(x²)/2", "y", "∂f/∂x", "3", "1/(e^x)"];
-
- let checkChoices = function (selectedIndex, inputText, inputMath) {
- let choiceArray, indexArray;
-
- let selectedChoice = null;
-
- if (selectedIndex === null) {
- choiceArray = indexArray = [];
-
- for (let i = 1; i <= 3; i++) {
- cy.get(cesc(`#\\/ci1_choice${i}_input`)).should(
- "not.be.checked",
- );
- }
- cy.get(cesc(`#\\/ci2`)).should("have.value", "");
-
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- `Selected values: `,
- );
- cy.get(cesc("#\\/_p3")).should(
- "have.text",
- `Selected indices: `,
- );
- } else {
- selectedChoice = textOrder[selectedIndex - 1];
- choiceArray = [selectedChoice];
- indexArray = [selectedIndex];
-
- for (let i = 1; i <= 3; i++) {
- if (i === selectedIndex) {
- cy.get(cesc(`#\\/ci1_choice${i}_input`)).should(
- "be.checked",
- );
- } else {
- cy.get(cesc(`#\\/ci1_choice${i}_input`)).should(
- "not.be.checked",
- );
- }
- }
- cy.get(cesc(`#\\/ci2`)).should(
- "have.value",
- String(selectedIndex),
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- `Selected values: ${selectedChoice}, ${selectedChoice}`,
- );
- cy.get(cesc("#\\/_p3")).should(
- "have.text",
- `Selected indices: ${selectedIndex}, ${selectedIndex}`,
- );
- }
-
- cy.get(cesc(`#\\/_mathinput1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- inputText,
- );
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/ci1"].stateValues.selectedValues).eqls(
- choiceArray,
- );
- expect(stateVariables["/ci1"].stateValues.selectedIndices).eqls(
- indexArray,
- );
- expect(stateVariables["/ci2"].stateValues.selectedValues).eqls(
- choiceArray,
- );
- expect(stateVariables["/ci2"].stateValues.selectedIndices).eqls(
- indexArray,
- );
- expect(stateVariables["/_mathinput1"].stateValues.value).eqls(
- inputMath,
- );
- });
- };
-
- cy.get(cesc("#\\/_math1")).should("contain.text", "x22");
-
- checkChoices(2, "y", "y");
-
- cy.log("select x^2/2 from first input");
- let selectedIndex = 1;
- let inputText = "x22";
- cy.get(cesc(`#\\/ci1_choice${selectedIndex}_input`))
- .should("not.be.visible")
- .click({ force: true }); // input is invisible (covered by text), but click it anyway
- checkChoices(selectedIndex, inputText, ["/", ["^", "x", 2], 2]);
-
- cy.log("Type 3");
- selectedIndex = 4;
- inputText = "3";
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(
- `{ctrl+home}{shift+end}{backspace}${inputText}{enter}`,
- { force: true },
- );
- checkChoices(selectedIndex, inputText, 3);
-
- cy.log("select ∂f/∂x from second input");
- selectedIndex = 3;
- inputText = "∂f∂x";
- cy.get(cesc(`#\\/ci2`)).select(`${selectedIndex}`);
- checkChoices(selectedIndex, inputText, [
- "partial_derivative_leibniz",
- "f",
- ["tuple", "x"],
- ]);
-
- cy.log("type e^{-x}");
- selectedIndex = null;
- inputText = "e−x";
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(
- `{ctrl+home}{shift+end}{backspace}e^-x{enter}`,
- { force: true },
- );
- checkChoices(selectedIndex, inputText, ["^", "e", ["-", "x"]]);
-
- cy.log("type 1/e^{x}");
- selectedIndex = 5;
- inputText = "1ex";
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(
- `{ctrl+home}{shift+end}{backspace}1/e^x{enter}`,
- { force: true },
- );
- checkChoices(selectedIndex, inputText, ["/", 1, ["^", "e", "x"]]);
-
- cy.log("select y from second input");
- selectedIndex = 2;
- inputText = "y";
- cy.get(cesc(`#\\/ci2`)).select(`${selectedIndex}`);
- checkChoices(selectedIndex, inputText, "y");
- });
-
- it("preselect choices", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- cat
- dog
- monkey
- mouse
- rabbit
- emu
- giraffe
- aardvark
-
-
-
- cat
- dog
- monkey
- mouse
- rabbit
- emu
- giraffe
- aardvark
-
-
-
- cat
- dog
- monkey
- mouse
- rabbit
- emu
- giraffe
- aardvark
-
-
-
-
- cat
- dog
- monkey
- mouse
- rabbit
- emu
- giraffe
- aardvark
-
-
-
- cat
- dog
- monkey
- mouse
- rabbit
- emu
- giraffe
- aardvark
-
-
-
-
- cat
- dog
- monkey
- mouse
- rabbit
- emu
- giraffe
- aardvark
-
-
-
-
- cat
- dog
- monkey
- mouse
- rabbit
- emu
- giraffe
- aardvark
-
-
-
-
- cat
- dog
- monkey
- mouse
- rabbit
- emu
- giraffe
- aardvark
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- cy.get(cesc("#\\/c1_choice2_input")).should("be.checked");
-
- cy.get(cesc("#\\/c2")).should("have.value", "2");
-
- cy.get(cesc("#\\/c3")).should("have.value", "4");
-
- let mouseInd4 =
- stateVariables["/c4"].stateValues.choiceTexts.indexOf("mouse");
- cy.get(cesc(`#\\/c4_choice${mouseInd4 + 1}_input`)).should(
- "be.checked",
- );
-
- cy.get(cesc("#\\/c5")).should("have.value", "2");
-
- let dogInd6 =
- stateVariables["/c6"].stateValues.choiceTexts.indexOf("dog");
- let mouseInd6 =
- stateVariables["/c6"].stateValues.choiceTexts.indexOf("mouse");
- let selectedInd6 = Math.min(dogInd6, mouseInd6);
-
- cy.get(cesc(`#\\/c6_choice${selectedInd6 + 1}_input`)).should(
- "be.checked",
- );
-
- cy.get(cesc("#\\/c7_choice4_input")).should("be.checked");
-
- let mouseInd8 =
- stateVariables["/c8"].stateValues.choiceTexts.indexOf("mouse");
- cy.get(cesc("#\\/c8")).should("have.value", `${mouseInd8 + 1}`);
- });
- });
-
- it("disabled choice with inline choiceinput", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- cat
- dog
- monkey
- mouse
-
-
- Selected value:
- Selected index:
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let originalChoices = ["cat", "dog", "monkey", "mouse"];
- cy.get(cesc("#\\/_p1")).should("have.text", "Selected value: ");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected index: ");
-
- cy.get(cesc("#\\/_choiceinput1")).should("have.value", "");
-
- let choices, choiceOrder;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- choices = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceTexts,
- ];
- choiceOrder = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceOrder,
- ];
- expect(choices.length).eq(4);
- expect(originalChoices.includes(choices[0])).eq(true);
- expect(originalChoices.includes(choices[1])).eq(true);
- expect(originalChoices.includes(choices[2])).eq(true);
- expect(originalChoices.includes(choices[3])).eq(true);
- expect(choices[1]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[0]);
- expect(choices[3]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[2]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls([]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedIndices,
- ).eqls([]);
- // expect(stateVariables['/_choiceinput1'].stateValues.selectedoriginalindices).eqls([])
- expect(stateVariables["/_choiceinput1"].stateValues.inline).eq(
- true,
- );
- expect(
- stateVariables["/_choiceinput1"].stateValues.shuffleOrder,
- ).eq(false);
- expect(stateVariables["/_choice1"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice2"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice3"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice4"].stateValues.selected).eq(false);
- });
-
- cy.log("select options in order");
-
- for (let i = 0; i < 4; i++) {
- if (i === 2) {
- cy.get(cesc(`#\\/_choiceinput1`))
- .get('[value="3"]')
- .should("be.disabled");
- } else {
- cy.get(cesc(`#\\/_choiceinput1`))
- .select(`${i + 1}`)
- .then(() => {
- // make this asynchronous so that choices is populated before line is executed
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "Selected value: " + choices[i],
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "Selected index: " + (i + 1),
- );
-
- cy.window().then(async (win) => {
- let stateVariables =
- await win.returnAllStateVariables1();
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedValues,
- ).eqls([choices[i]]);
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedIndices,
- ).eqls([i + 1]);
- expect(
- stateVariables["/_choice1"].stateValues
- .selected,
- ).eq(choiceOrder[i] === 1);
- expect(
- stateVariables["/_choice2"].stateValues
- .selected,
- ).eq(choiceOrder[i] === 2);
- expect(
- stateVariables["/_choice3"].stateValues
- .selected,
- ).eq(choiceOrder[i] === 3);
- expect(
- stateVariables["/_choice4"].stateValues
- .selected,
- ).eq(choiceOrder[i] === 4);
- });
- });
- }
- }
- });
-
- it("hidden choice with inline choiceinput", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- cat
- dog
- monkey
- mouse
-
-
- Selected value:
- Selected index:
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let originalChoices = ["cat", "dog", "monkey", "mouse"];
- cy.get(cesc("#\\/_p1")).should("have.text", "Selected value: ");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected index: ");
-
- cy.get(cesc("#\\/_choiceinput1")).should("have.value", "");
-
- let choices, choiceOrder;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- choices = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceTexts,
- ];
- choiceOrder = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceOrder,
- ];
- expect(choices.length).eq(4);
- expect(originalChoices.includes(choices[0])).eq(true);
- expect(originalChoices.includes(choices[1])).eq(true);
- expect(originalChoices.includes(choices[2])).eq(true);
- expect(originalChoices.includes(choices[3])).eq(true);
- expect(choices[1]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[0]);
- expect(choices[3]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[2]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls([]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedIndices,
- ).eqls([]);
- expect(stateVariables["/_choiceinput1"].stateValues.inline).eq(
- true,
- );
- expect(
- stateVariables["/_choiceinput1"].stateValues.shuffleOrder,
- ).eq(false);
- expect(stateVariables["/_choice1"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice2"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice3"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice4"].stateValues.selected).eq(false);
- });
-
- cy.log("select options in order");
-
- for (let i = 0; i < 4; i++) {
- if (i === 2) {
- cy.get(cesc(`#\\/_choiceinput1`))
- .get('[value="3"]')
- .should("not.exist");
- } else {
- cy.get(cesc(`#\\/_choiceinput1`))
- .select(`${i + 1}`)
- .then(() => {
- // make this asynchronous so that choices is populated before line is executed
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "Selected value: " + choices[i],
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "Selected index: " + (i + 1),
- );
-
- cy.window().then(async (win) => {
- let stateVariables =
- await win.returnAllStateVariables1();
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedValues,
- ).eqls([choices[i]]);
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedIndices,
- ).eqls([i + 1]);
- expect(
- stateVariables["/_choice1"].stateValues
- .selected,
- ).eq(choiceOrder[i] === 1);
- expect(
- stateVariables["/_choice2"].stateValues
- .selected,
- ).eq(choiceOrder[i] === 2);
- expect(
- stateVariables["/_choice3"].stateValues
- .selected,
- ).eq(choiceOrder[i] === 3);
- expect(
- stateVariables["/_choice4"].stateValues
- .selected,
- ).eq(choiceOrder[i] === 4);
- });
- });
- }
- }
- });
-
- it("disabled choice with block choiceinput", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- cat
- dog
- monkey
- mouse
-
-
- Selected value:
- Selected index:
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let originalChoices = ["cat", "dog", "monkey", "mouse"];
- cy.get(cesc("#\\/_p1")).should("have.text", "Selected value: ");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected index: ");
-
- let choices;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- choices = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceTexts,
- ];
- expect(choices).eqls(originalChoices);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls([]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedIndices,
- ).eqls([]);
- expect(stateVariables["/_choiceinput1"].stateValues.inline).eq(
- false,
- );
- expect(
- stateVariables["/_choiceinput1"].stateValues.shuffleOrder,
- ).eq(false);
- expect(stateVariables["/_choice1"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice2"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice3"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice4"].stateValues.selected).eq(false);
- });
-
- cy.log("select options in order");
-
- for (let i = 0; i < 4; i++) {
- if (i === 2) {
- cy.get(cesc(`#\\/_choiceinput1_choice${i + 1}_input`)).should(
- "be.disabled",
- );
- } else {
- cy.get(cesc(`#\\/_choiceinput1_choice${i + 1}_input`))
- .click()
- .then(() => {
- // make this asynchronous so that choices is populated before line is executed
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "Selected value: " + choices[i],
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "Selected index: " + (i + 1),
- );
-
- cy.window().then(async (win) => {
- let stateVariables =
- await win.returnAllStateVariables1();
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedValues,
- ).eqls([choices[i]]);
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedIndices,
- ).eqls([i + 1]);
- expect(
- stateVariables["/_choice1"].stateValues
- .selected,
- ).eq(i === 0);
- expect(
- stateVariables["/_choice2"].stateValues
- .selected,
- ).eq(i === 1);
- expect(
- stateVariables["/_choice3"].stateValues
- .selected,
- ).eq(i === 2);
- expect(
- stateVariables["/_choice4"].stateValues
- .selected,
- ).eq(i === 3);
- });
- });
- }
- }
- });
-
- it("hidden choice with block choiceinput", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- cat
- dog
- monkey
- mouse
-
-
- Selected value:
- Selected index:
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let originalChoices = ["cat", "dog", "monkey", "mouse"];
- cy.get(cesc("#\\/_p1")).should("have.text", "Selected value: ");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected index: ");
-
- let choices;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- choices = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceTexts,
- ];
- expect(choices).eqls(originalChoices);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls([]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedIndices,
- ).eqls([]);
- expect(stateVariables["/_choiceinput1"].stateValues.inline).eq(
- false,
- );
- expect(
- stateVariables["/_choiceinput1"].stateValues.shuffleOrder,
- ).eq(false);
- expect(stateVariables["/_choice1"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice2"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice3"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice4"].stateValues.selected).eq(false);
- });
-
- cy.log("select options in order");
-
- for (let i = 0; i < 4; i++) {
- if (i === 2) {
- cy.get(cesc(`#\\/_choiceinput1_choice${i + 1}_input`)).should(
- "not.exist",
- );
- } else {
- cy.get(cesc(`#\\/_choiceinput1_choice${i + 1}_input`))
- .click()
- .then(() => {
- // make this asynchronous so that choices is populated before line is executed
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "Selected value: " + choices[i],
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "Selected index: " + (i + 1),
- );
-
- cy.window().then(async (win) => {
- let stateVariables =
- await win.returnAllStateVariables1();
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedValues,
- ).eqls([choices[i]]);
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedIndices,
- ).eqls([i + 1]);
- expect(
- stateVariables["/_choice1"].stateValues
- .selected,
- ).eq(i === 0);
- expect(
- stateVariables["/_choice2"].stateValues
- .selected,
- ).eq(i === 1);
- expect(
- stateVariables["/_choice3"].stateValues
- .selected,
- ).eq(i === 2);
- expect(
- stateVariables["/_choice4"].stateValues
- .selected,
- ).eq(i === 3);
- });
- });
- }
- }
- });
-
- it("select multiple with block choiceinput", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- cat
- dog
- monkey
- mouse
-
-
- Selected values:
- Selected indices:
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let originalChoices = ["cat", "dog", "monkey", "mouse"];
- cy.get(cesc("#\\/_p1")).should("have.text", "Selected values: ");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected indices: ");
-
- let choices, choiceOrder;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- choices = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceTexts,
- ];
- choiceOrder = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceOrder,
- ];
- expect(choices.length).eq(4);
- expect(originalChoices.includes(choices[0])).eq(true);
- expect(originalChoices.includes(choices[1])).eq(true);
- expect(originalChoices.includes(choices[2])).eq(true);
- expect(originalChoices.includes(choices[3])).eq(true);
- expect(choices[1]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[0]);
- expect(choices[3]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[2]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls([]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedIndices,
- ).eqls([]);
- expect(stateVariables["/_choiceinput1"].stateValues.inline).eq(
- false,
- );
- expect(
- stateVariables["/_choiceinput1"].stateValues.shuffleOrder,
- ).eq(true);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectMultiple,
- ).eq(true);
- expect(stateVariables["/_choice1"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice2"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice3"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice4"].stateValues.selected).eq(false);
- });
-
- cy.log("select options in order");
-
- for (let i = 0; i < 4; i++) {
- cy.get(cesc(`#\\/_choiceinput1_choice${i + 1}_input`))
- .click()
- .then(() => {
- // make this asynchronous so that choices is populated before line is executed
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "Selected values: " +
- choices.slice(0, i + 1).join(", "),
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "Selected indices: " +
- [...Array(i + 1).keys()]
- .map((x) => x + 1)
- .join(", "),
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls(choices.slice(0, i + 1));
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedIndices,
- ).eqls([...Array(i + 1).keys()].map((x) => x + 1));
- expect(stateVariables["/_choice1"].stateValues.selected).eq(
- choiceOrder.indexOf(1) <= i,
- );
- expect(stateVariables["/_choice2"].stateValues.selected).eq(
- choiceOrder.indexOf(2) <= i,
- );
- expect(stateVariables["/_choice3"].stateValues.selected).eq(
- choiceOrder.indexOf(3) <= i,
- );
- expect(stateVariables["/_choice4"].stateValues.selected).eq(
- choiceOrder.indexOf(4) <= i,
- );
- });
- }
-
- cy.log("deselect options in order");
-
- for (let i = 0; i < 4; i++) {
- cy.get(cesc(`#\\/_choiceinput1_choice${i + 1}_input`))
- .click()
- .then(() => {
- // make this asynchronous so that choices is populated before line is executed
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "Selected values: " + choices.slice(i + 1).join(", "),
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "Selected indices: " +
- [...Array(3 - i).keys()]
- .map((x) => x + 2 + i)
- .join(", "),
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls(choices.slice(i + 1));
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedIndices,
- ).eqls([...Array(3 - i).keys()].map((x) => x + 2 + i));
- expect(stateVariables["/_choice1"].stateValues.selected).eq(
- choiceOrder.indexOf(1) > i,
- );
- expect(stateVariables["/_choice2"].stateValues.selected).eq(
- choiceOrder.indexOf(2) > i,
- );
- expect(stateVariables["/_choice3"].stateValues.selected).eq(
- choiceOrder.indexOf(3) > i,
- );
- expect(stateVariables["/_choice4"].stateValues.selected).eq(
- choiceOrder.indexOf(4) > i,
- );
- });
- }
-
- cy.log("select options in reverse order");
-
- for (let i = 3; i >= 0; i--) {
- cy.get(cesc(`#\\/_choiceinput1_choice${i + 1}_input`))
- .click()
- .then(() => {
- // make this asynchronous so that choices is populated before line is executed
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "Selected values: " + choices.slice(i).join(", "),
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "Selected indices: " +
- [...Array(4 - i).keys()]
- .map((x) => x + 1 + i)
- .join(", "),
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls(choices.slice(i));
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedIndices,
- ).eqls([...Array(4 - i).keys()].map((x) => x + 1 + i));
- expect(stateVariables["/_choice1"].stateValues.selected).eq(
- choiceOrder.indexOf(1) >= i,
- );
- expect(stateVariables["/_choice2"].stateValues.selected).eq(
- choiceOrder.indexOf(2) >= i,
- );
- expect(stateVariables["/_choice3"].stateValues.selected).eq(
- choiceOrder.indexOf(3) >= i,
- );
- expect(stateVariables["/_choice4"].stateValues.selected).eq(
- choiceOrder.indexOf(4) >= i,
- );
- });
- }
- });
-
- it("select multiple with inline choiceinput", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- cat
- dog
- monkey
- mouse
-
-
- Selected values:
- Selected indices:
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/_choiceinput1"))
- .invoke("val")
- .should("deep.equal", []);
-
- let originalChoices = ["cat", "dog", "monkey", "mouse"];
- cy.get(cesc("#\\/_p1")).should("have.text", "Selected values: ");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected indices: ");
-
- let choices, choiceOrder;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- choices = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceTexts,
- ];
- choiceOrder = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceOrder,
- ];
- expect(choices.length).eq(4);
- expect(originalChoices.includes(choices[0])).eq(true);
- expect(originalChoices.includes(choices[1])).eq(true);
- expect(originalChoices.includes(choices[2])).eq(true);
- expect(originalChoices.includes(choices[3])).eq(true);
- expect(choices[1]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[0]);
- expect(choices[3]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[2]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls([]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedIndices,
- ).eqls([]);
- expect(stateVariables["/_choiceinput1"].stateValues.inline).eq(
- true,
- );
- expect(
- stateVariables["/_choiceinput1"].stateValues.shuffleOrder,
- ).eq(true);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectMultiple,
- ).eq(true);
- expect(stateVariables["/_choice1"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice2"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice3"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice4"].stateValues.selected).eq(false);
- });
-
- cy.log("select options in order");
-
- for (let i = 0; i < 4; i++) {
- // TODO: the onChange handler wasn't triggering when didn't first deselect
- // so, as a stopgap, we're deselecting all here.
- // We shouldn't need to do this!
-
- cy.get(cesc(`#\\/_choiceinput1`)).select([]);
-
- cy.get(cesc(`#\\/_choiceinput1`))
- .select([...Array(i + 1).keys()].map((x) => String(x + 1)))
- .then(() => {
- let selectedInds = [...Array(i + 1).keys()].map((x) =>
- String(x + 1),
- );
- cy.get(cesc("#\\/_choiceinput1"))
- .invoke("val")
- .should("deep.equal", selectedInds);
-
- // make this asynchronous so that choices is populated before line is executed
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "Selected values: " +
- choices.slice(0, i + 1).join(", "),
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "Selected indices: " +
- [...Array(i + 1).keys()]
- .map((x) => x + 1)
- .join(", "),
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls(choices.slice(0, i + 1));
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedIndices,
- ).eqls([...Array(i + 1).keys()].map((x) => x + 1));
- expect(stateVariables["/_choice1"].stateValues.selected).eq(
- choiceOrder.indexOf(1) <= i,
- );
- expect(stateVariables["/_choice2"].stateValues.selected).eq(
- choiceOrder.indexOf(2) <= i,
- );
- expect(stateVariables["/_choice3"].stateValues.selected).eq(
- choiceOrder.indexOf(3) <= i,
- );
- expect(stateVariables["/_choice4"].stateValues.selected).eq(
- choiceOrder.indexOf(4) <= i,
- );
- });
- }
-
- cy.log("deselect options in order");
-
- for (let i = 0; i < 4; i++) {
- cy.window().then(async (win) => {
- let indicesToSelect = [...Array(3 - i).keys()].map((x) =>
- String(x + 2 + i),
- );
- if (i === 3) {
- indicesToSelect = [""];
- }
-
- cy.get(cesc(`#\\/_choiceinput1`))
- .select(indicesToSelect)
- .then(() => {
- let selectedInds = [...Array(3 - i).keys()].map((x) =>
- String(x + 2 + i),
- );
- cy.get(cesc("#\\/_choiceinput1"))
- .invoke("val")
- .should("deep.equal", selectedInds);
-
- // make this asynchronous so that choices is populated before line is executed
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "Selected values: " +
- choices.slice(i + 1).join(", "),
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "Selected indices: " +
- [...Array(3 - i).keys()]
- .map((x) => x + 2 + i)
- .join(", "),
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedValues,
- ).eqls(choices.slice(i + 1));
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedIndices,
- ).eqls([...Array(3 - i).keys()].map((x) => x + 2 + i));
- expect(stateVariables["/_choice1"].stateValues.selected).eq(
- choiceOrder.indexOf(1) > i,
- );
- expect(stateVariables["/_choice2"].stateValues.selected).eq(
- choiceOrder.indexOf(2) > i,
- );
- expect(stateVariables["/_choice3"].stateValues.selected).eq(
- choiceOrder.indexOf(3) > i,
- );
- expect(stateVariables["/_choice4"].stateValues.selected).eq(
- choiceOrder.indexOf(4) > i,
- );
- });
- });
- }
-
- cy.log("select options in reverse order");
-
- for (let i = 3; i >= 0; i--) {
- cy.get(cesc(`#\\/_choiceinput1`))
- .select([...Array(4 - i).keys()].map((x) => String(x + 1 + i)))
- .then(() => {
- let selectedInds = [...Array(4 - i).keys()].map((x) =>
- String(x + 1 + i),
- );
- cy.get(cesc("#\\/_choiceinput1"))
- .invoke("val")
- .should("deep.equal", selectedInds);
-
- // make this asynchronous so that choices is populated before line is executed
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "Selected values: " + choices.slice(i).join(", "),
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "Selected indices: " +
- [...Array(4 - i).keys()]
- .map((x) => x + 1 + i)
- .join(", "),
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls(choices.slice(i));
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedIndices,
- ).eqls([...Array(4 - i).keys()].map((x) => x + 1 + i));
- expect(stateVariables["/_choice1"].stateValues.selected).eq(
- choiceOrder.indexOf(1) >= i,
- );
- expect(stateVariables["/_choice2"].stateValues.selected).eq(
- choiceOrder.indexOf(2) >= i,
- );
- expect(stateVariables["/_choice3"].stateValues.selected).eq(
- choiceOrder.indexOf(3) >= i,
- );
- expect(stateVariables["/_choice4"].stateValues.selected).eq(
- choiceOrder.indexOf(4) >= i,
- );
- });
- }
- });
-
- it("chain update off choiceinput", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- red
- orange
- yellow
- green
- blue
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/t")).should("have.text", "");
-
- cy.get(cesc(`#\\/ci_choice2_input`)).click();
- cy.get(cesc("#\\/t")).should("have.text", " orange");
-
- cy.get(cesc(`#\\/ci_choice5_input`)).click();
- cy.get(cesc("#\\/t")).should("have.text", " orange blue");
-
- cy.get(cesc(`#\\/ci_choice1_input`)).click();
- cy.get(cesc("#\\/t")).should("have.text", " orange blue red");
- });
-
- // verify fixed bug where shuffle order was recalculated
- // causing a copy with no link to have a different shuffle order
- it("shuffleOrder is not recalculated when copy with no link", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- a
- b
- c
- d
- e
-
-
-
- $g{name="g2" link="false"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- let choices = ["a", "b", "c", "d", "e"];
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let choiceOrder = stateVariables["/g/ci"].stateValues.choiceOrder;
- let choiceOrder2 = stateVariables["/g2/ci"].stateValues.choiceOrder;
-
- expect(choiceOrder2).eqls(choiceOrder);
-
- cy.get(`label[for=${cesc2("/g/ci_choice1_input")}]`).should(
- "have.text",
- choices[choiceOrder[0] - 1],
- );
- cy.get(`label[for=${cesc2("/g/ci_choice2_input")}]`).should(
- "have.text",
- choices[choiceOrder[1] - 1],
- );
- cy.get(`label[for=${cesc2("/g/ci_choice3_input")}]`).should(
- "have.text",
- choices[choiceOrder[2] - 1],
- );
- cy.get(`label[for=${cesc2("/g/ci_choice4_input")}]`).should(
- "have.text",
- choices[choiceOrder[3] - 1],
- );
- cy.get(`label[for=${cesc2("/g/ci_choice5_input")}]`).should(
- "have.text",
- choices[choiceOrder[4] - 1],
- );
- cy.get(`label[for=${cesc2("/g2/ci_choice1_input")}]`).should(
- "have.text",
- choices[choiceOrder[0] - 1],
- );
- cy.get(`label[for=${cesc2("/g2/ci_choice2_input")}]`).should(
- "have.text",
- choices[choiceOrder[1] - 1],
- );
- cy.get(`label[for=${cesc2("/g2/ci_choice3_input")}]`).should(
- "have.text",
- choices[choiceOrder[2] - 1],
- );
- cy.get(`label[for=${cesc2("/g2/ci_choice4_input")}]`).should(
- "have.text",
- choices[choiceOrder[3] - 1],
- );
- cy.get(`label[for=${cesc2("/g2/ci_choice5_input")}]`).should(
- "have.text",
- choices[choiceOrder[4] - 1],
- );
- });
- });
-
- it("math choices", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- x + x
- y+y
- z+z
- u+u
-
-
- Selected value:
- Selected index:
- Selected value: $_choiceinput1
- Selected value simplified: $_choiceinput1{simplify}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/_p1")).should("have.text", "Selected value: ");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected index: ");
- cy.get(cesc("#\\/_p3")).should("have.text", "Selected value: ");
- cy.get(cesc("#\\/_p4")).should(
- "have.text",
- "Selected value simplified: ",
- );
-
- cy.get(cesc(`#\\/_choiceinput1_choice1_input`)).click({ force: true });
-
- cy.get(cesc("#\\/_p1") + " .mjx-mrow").should("contain.text", "x+x");
- cy.get(cesc("#\\/_p1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x+x");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected index: 1");
- cy.get(cesc("#\\/_p3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x+x");
- cy.get(cesc("#\\/_p4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "2x");
-
- cy.get(cesc(`#\\/_choiceinput1_choice2_input`)).click({ force: true });
-
- cy.get(cesc("#\\/_p1") + " .mjx-mrow").should("contain.text", "y+y");
- cy.get(cesc("#\\/_p1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "y+y");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected index: 2");
- cy.get(cesc("#\\/_p3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "y+y");
- cy.get(cesc("#\\/_p4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "2y");
-
- cy.get(cesc(`#\\/_choiceinput1_choice3_input`)).click({ force: true });
-
- cy.get(cesc("#\\/_p1") + " .mjx-mrow").should("contain.text", "z+z");
- cy.get(cesc("#\\/_p1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "z+z");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected index: 3");
- cy.get(cesc("#\\/_p3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "z+z");
- cy.get(cesc("#\\/_p4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "2z");
-
- cy.get(cesc(`#\\/_choiceinput1_choice4_input`)).click({ force: true });
-
- cy.get(cesc("#\\/_p1") + " .mjx-mrow").should("contain.text", "u+u");
- cy.get(cesc("#\\/_p1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "u+u");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected index: 4");
- cy.get(cesc("#\\/_p3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "u+u");
- cy.get(cesc("#\\/_p4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "2u");
- });
-
- it("consistent order for n elements for given variant", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- m:
- n:
-
-
-
- $v
-
-
-
-
-
-
- `,
- requestedVariantIndex: 1,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/n2")).should("have.text", "6");
-
- let orders = {};
-
- cy.window().then(async (win) => {
- let m = 1,
- n = 6;
-
- let stateVariables = await win.returnAllStateVariables1();
- let choiceOrder = stateVariables["/ci"].stateValues.choiceOrder;
-
- expect([...choiceOrder].sort((a, b) => a - b)).eqls(
- [...Array(n - m + 1).keys()].map((x) => x + m),
- );
-
- orders[[m, n]] = choiceOrder;
- });
-
- cy.log("switch n to 8");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}8{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/n2")).should("have.text", "8");
-
- cy.window().then(async (win) => {
- let m = 1,
- n = 8;
-
- let stateVariables = await win.returnAllStateVariables1();
- let choiceOrder = stateVariables["/ci"].stateValues.choiceOrder;
-
- expect([...choiceOrder].sort((a, b) => a - b)).eqls(
- [...Array(n - m + 1).keys()].map((x) => x + m),
- );
-
- orders[[m, n]] = choiceOrder;
- });
-
- cy.log("get another list of length 6 by setting m to 3");
-
- cy.get(cesc("#\\/m") + " textarea").type("{end}{backspace}3{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/m2")).should("have.text", "3");
-
- cy.window().then(async (win) => {
- let m = 3,
- n = 8;
-
- let stateVariables = await win.returnAllStateVariables1();
- let choiceOrder = stateVariables["/ci"].stateValues.choiceOrder;
-
- expect(choiceOrder).eqls(orders[[1, 6]]);
-
- orders[[m, n]] = choiceOrder;
- });
-
- cy.log("get another list of length 8 by setting n to 10");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}10{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/n2")).should("have.text", "10");
-
- cy.window().then(async (win) => {
- let m = 3,
- n = 10;
-
- let stateVariables = await win.returnAllStateVariables1();
- let choiceOrder = stateVariables["/ci"].stateValues.choiceOrder;
-
- expect(choiceOrder).eqls(orders[[1, 8]]);
-
- orders[[m, n]] = choiceOrder;
- });
-
- cy.log("values change with another variant");
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- m:
- n:
-
-
-
- $v
-
-
-
-
-
-
- `,
- requestedVariantIndex: 2,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/m2")).should("have.text", "1");
- cy.get(cesc("#\\/n2")).should("have.text", "6");
-
- cy.window().then(async (win) => {
- let m = 1,
- n = 6;
-
- let stateVariables = await win.returnAllStateVariables1();
- let choiceOrder = stateVariables["/ci"].stateValues.choiceOrder;
-
- expect(choiceOrder).not.eqls(orders[[m, n]]);
-
- expect([...choiceOrder].sort((a, b) => a - b)).eqls(
- [...Array(n - m + 1).keys()].map((x) => x + m),
- );
-
- orders[[m, n]] = choiceOrder;
- });
-
- cy.log("switch n to 8");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}8{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/n2")).should("have.text", "8");
-
- cy.window().then(async (win) => {
- let m = 1,
- n = 8;
-
- let stateVariables = await win.returnAllStateVariables1();
- let choiceOrder = stateVariables["/ci"].stateValues.choiceOrder;
-
- expect(choiceOrder).not.eqls(orders[[m, n]]);
-
- expect([...choiceOrder].sort((a, b) => a - b)).eqls(
- [...Array(n - m + 1).keys()].map((x) => x + m),
- );
-
- orders[[m, n]] = choiceOrder;
- });
-
- cy.log("get another list of length 6 by setting m to 3");
-
- cy.get(cesc("#\\/m") + " textarea").type("{end}{backspace}3{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/m2")).should("have.text", "3");
-
- cy.window().then(async (win) => {
- let m = 3,
- n = 8;
-
- let stateVariables = await win.returnAllStateVariables1();
- let choiceOrder = stateVariables["/ci"].stateValues.choiceOrder;
-
- expect(choiceOrder).eqls(orders[[1, 6]]);
-
- orders[[m, n]] = choiceOrder;
- });
-
- cy.log("get another list of length 8 by setting n to 10");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}10{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/n2")).should("have.text", "10");
-
- cy.window().then(async (win) => {
- let m = 3,
- n = 10;
-
- let stateVariables = await win.returnAllStateVariables1();
- let choiceOrder = stateVariables["/ci"].stateValues.choiceOrder;
-
- expect(choiceOrder).eqls(orders[[1, 8]]);
-
- orders[[m, n]] = choiceOrder;
- });
- });
-
- it("shuffle all but last choice", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- cat
- dog
- monkey
-
- none of the above
-
-
- Selected value:
- Selected index:
-
- Selected cat: $_choice1.selected
- Selected dog: $_choice2.selected
- Selected monkey: $_choice3.selected
- Selected none of the above: $_choice4.selected
- `,
- requestedVariantIndex: 4,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let originalChoices = ["cat", "dog", "monkey", "none of the above"];
- cy.get(cesc("#\\/_p1")).should("have.text", "Selected value: ");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected index: ");
- cy.get(cesc("#\\/pCat")).should("have.text", "Selected cat: false");
- cy.get(cesc("#\\/pDog")).should("have.text", "Selected dog: false");
- cy.get(cesc("#\\/pMonkey")).should(
- "have.text",
- "Selected monkey: false",
- );
- cy.get(cesc("#\\/pNone")).should(
- "have.text",
- "Selected none of the above: false",
- );
-
- let choices, choiceOrder;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- choices = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceTexts,
- ];
- choiceOrder = [
- ...stateVariables["/_shuffle1"].stateValues.componentOrder,
- 4,
- ];
- expect(choices.length).eq(4);
- expect(originalChoices.includes(choices[0])).eq(true);
- expect(originalChoices.includes(choices[1])).eq(true);
- expect(originalChoices.includes(choices[2])).eq(true);
- expect(originalChoices.includes(choices[3])).eq(true);
- expect(originalChoices[3]).eq(choices[3]);
- expect(choices[1]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[0]);
- expect(choices[3]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[2]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls([]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedIndices,
- ).eqls([]);
- expect(stateVariables["/_choiceinput1"].stateValues.inline).eq(
- false,
- );
- expect(
- stateVariables["/_choiceinput1"].stateValues.shuffleOrder,
- ).eq(false);
- expect(stateVariables["/_choice1"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice2"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice3"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice4"].stateValues.selected).eq(false);
- });
-
- cy.log("select options in order");
-
- for (let i = 0; i < 4; i++) {
- cy.get(cesc(`#\\/_choiceinput1_choice${i + 1}_input`))
- .click()
- .then(() => {
- // make this asynchronous so that choices is populated before line is executed
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "Selected value: " + choices[i],
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "Selected index: " + (i + 1),
- );
-
- cy.get(cesc("#\\/pCat")).should(
- "have.text",
- `Selected cat: ${choiceOrder[i] === 1}`,
- );
- cy.get(cesc("#\\/pDog")).should(
- "have.text",
- `Selected dog: ${choiceOrder[i] === 2}`,
- );
- cy.get(cesc("#\\/pMonkey")).should(
- "have.text",
- `Selected monkey: ${choiceOrder[i] === 3}`,
- );
- cy.get(cesc("#\\/pNone")).should(
- "have.text",
- `Selected none of the above: ${choiceOrder[i] === 4}`,
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls([choices[i]]);
- expect(
- stateVariables["/_choiceinput1"].stateValues
- .selectedIndices,
- ).eqls([i + 1]);
- expect(stateVariables["/_choice1"].stateValues.selected).eq(
- choiceOrder[i] === 1,
- );
- expect(stateVariables["/_choice2"].stateValues.selected).eq(
- choiceOrder[i] === 2,
- );
- expect(stateVariables["/_choice3"].stateValues.selected).eq(
- choiceOrder[i] === 3,
- );
- expect(stateVariables["/_choice4"].stateValues.selected).eq(
- choiceOrder[i] === 4,
- );
- });
- }
- });
-
- it("sorted choices", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- mouse
- dog
- cat
- monkey
-
-
-
- Selected value:
- Selected index:
-
- Selected mouse: $_choice1.selected
- Selected dog: $_choice2.selected
- Selected cat: $_choice3.selected
- Selected monkey: $_choice4.selected
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let originalChoices = ["mouse", "dog", "cat", "monkey"];
- cy.get(cesc("#\\/_p1")).should("have.text", "Selected value: ");
- cy.get(cesc("#\\/_p2")).should("have.text", "Selected index: ");
- cy.get(cesc("#\\/pMouse")).should("have.text", "Selected mouse: false");
- cy.get(cesc("#\\/pDog")).should("have.text", "Selected dog: false");
- cy.get(cesc("#\\/pCat")).should("have.text", "Selected cat: false");
- cy.get(cesc("#\\/pMonkey")).should(
- "have.text",
- "Selected monkey: false",
- );
-
- let choices, choiceOrder;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- choices = [
- ...stateVariables["/_choiceinput1"].stateValues.choiceTexts,
- ];
- choiceOrder = [3, 2, 4, 1];
- expect(choices.length).eq(4);
- expect(originalChoices.includes(choices[0])).eq(true);
- expect(originalChoices.includes(choices[1])).eq(true);
- expect(originalChoices.includes(choices[2])).eq(true);
- expect(originalChoices.includes(choices[3])).eq(true);
- expect(choices[1]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[0]);
- expect(choices[2]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[0]);
- expect(choices[3]).not.eq(choices[1]);
- expect(choices[3]).not.eq(choices[2]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls([]);
- expect(
- stateVariables["/_choiceinput1"].stateValues.selectedIndices,
- ).eqls([]);
- expect(stateVariables["/_choiceinput1"].stateValues.inline).eq(
- false,
- );
- expect(
- stateVariables["/_choiceinput1"].stateValues.shuffleOrder,
- ).eq(false);
- expect(stateVariables["/_choice1"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice2"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice3"].stateValues.selected).eq(false);
- expect(stateVariables["/_choice4"].stateValues.selected).eq(false);
- });
-
- cy.log("select options in order");
-
- for (let i = 0; i < 4; i++) {
- cy.get(cesc(`#\\/_choiceinput1_choice${i + 1}_input`))
- .click()
- .then(() => {
// make this asynchronous so that choices is populated before line is executed
cy.get(cesc("#\\/_p1")).should(
"have.text",
- "Selected value: " + choices[i],
+ "Selected values: " + choices.slice(i).join(", "),
);
cy.get(cesc("#\\/_p2")).should(
"have.text",
- "Selected index: " + (i + 1),
- );
-
- cy.get(cesc("#\\/pMouse")).should(
- "have.text",
- `Selected mouse: ${choiceOrder[i] === 1}`,
- );
- cy.get(cesc("#\\/pDog")).should(
- "have.text",
- `Selected dog: ${choiceOrder[i] === 2}`,
- );
- cy.get(cesc("#\\/pCat")).should(
- "have.text",
- `Selected cat: ${choiceOrder[i] === 3}`,
- );
- cy.get(cesc("#\\/pMonkey")).should(
- "have.text",
- `Selected monkey: ${choiceOrder[i] === 4}`,
+ "Selected indices: " +
+ [...Array(4 - i).keys()]
+ .map((x) => x + 1 + i)
+ .join(", "),
);
});
@@ -3199,1337 +886,24 @@ describe("ChoiceInput Tag Tests", function () {
let stateVariables = await win.returnAllStateVariables1();
expect(
stateVariables["/_choiceinput1"].stateValues.selectedValues,
- ).eqls([choices[i]]);
+ ).eqls(choices.slice(i));
expect(
stateVariables["/_choiceinput1"].stateValues
.selectedIndices,
- ).eqls([i + 1]);
+ ).eqls([...Array(4 - i).keys()].map((x) => x + 1 + i));
expect(stateVariables["/_choice1"].stateValues.selected).eq(
- choiceOrder[i] === 1,
+ choiceOrder.indexOf(1) >= i,
);
expect(stateVariables["/_choice2"].stateValues.selected).eq(
- choiceOrder[i] === 2,
+ choiceOrder.indexOf(2) >= i,
);
expect(stateVariables["/_choice3"].stateValues.selected).eq(
- choiceOrder[i] === 3,
+ choiceOrder.indexOf(3) >= i,
);
expect(stateVariables["/_choice4"].stateValues.selected).eq(
- choiceOrder[i] === 4,
+ choiceOrder.indexOf(4) >= i,
);
});
}
});
-
- it("copy choices", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- cat
-
-
-
- dog
- monkey
-
-
-
-
-
- monkey
-
-
- Selected value 1:
- Selected index 1:
-
- Selected value 2:
- Selected index 2:
-
- Selected cat0: $cat0.selected
-
- Selected cat1: $cat1.selected
- Selected dog1: $dog1.selected
- Selected monkey1: $monkey1.selected
-
- Selected cat2: $cat2.selected
- Selected dog2: $dog2.selected
- Selected monkey2: $monkey2.selected
-
- `,
- },
- "*",
- );
- });
-
- let choices = ["cat", "dog", "monkey"];
- cy.get(cesc("#\\/pSv1")).should("have.text", "Selected value 1: ");
- cy.get(cesc("#\\/pSi1")).should("have.text", "Selected index 1: ");
- cy.get(cesc("#\\/pSv2")).should("have.text", "Selected value 2: ");
- cy.get(cesc("#\\/pSi2")).should("have.text", "Selected index 2: ");
-
- cy.get(cesc("#\\/pCat1")).should("have.text", "Selected cat1: false");
- cy.get(cesc("#\\/pDog1")).should("have.text", "Selected dog1: false");
- cy.get(cesc("#\\/pMonkey1")).should(
- "have.text",
- "Selected monkey1: false",
- );
- cy.get(cesc("#\\/pCat2")).should("have.text", "Selected cat2: false");
- cy.get(cesc("#\\/pDog2")).should("have.text", "Selected dog2: false");
- cy.get(cesc("#\\/pMonkey2")).should(
- "have.text",
- "Selected monkey2: false",
- );
-
- cy.log("select options 1 in order");
-
- for (let i = 0; i < 3; i++) {
- cy.get(cesc(`#\\/_choiceinput1_choice${i + 1}_input`)).click();
-
- cy.get(cesc("#\\/pSv1")).should(
- "have.text",
- "Selected value 1: " + choices[i],
- );
- cy.get(cesc("#\\/pSi1")).should(
- "have.text",
- "Selected index 1: " + (i + 1),
- );
-
- cy.get(cesc("#\\/pSv2")).should("have.text", "Selected value 2: ");
- cy.get(cesc("#\\/pSi2")).should("have.text", "Selected index 2: ");
-
- cy.get(cesc("#\\/pCat1")).should(
- "have.text",
- `Selected cat1: ${i === 0}`,
- );
- cy.get(cesc("#\\/pDog1")).should(
- "have.text",
- `Selected dog1: ${i === 1}`,
- );
- cy.get(cesc("#\\/pMonkey1")).should(
- "have.text",
- `Selected monkey1: ${i == 2}`,
- );
- cy.get(cesc("#\\/pCat2")).should(
- "have.text",
- "Selected cat2: false",
- );
- cy.get(cesc("#\\/pDog2")).should(
- "have.text",
- "Selected dog2: false",
- );
- cy.get(cesc("#\\/pMonkey2")).should(
- "have.text",
- "Selected monkey2: false",
- );
- }
-
- cy.log("select options 2 in order");
-
- for (let i = 0; i < 3; i++) {
- cy.get(cesc(`#\\/_choiceinput2_choice${i + 1}_input`)).click();
-
- cy.get(cesc("#\\/pSv2")).should(
- "have.text",
- "Selected value 2: " + choices[i],
- );
- cy.get(cesc("#\\/pSi2")).should(
- "have.text",
- "Selected index 2: " + (i + 1),
- );
-
- cy.get(cesc("#\\/pSv1")).should(
- "have.text",
- "Selected value 1: monkey",
- );
- cy.get(cesc("#\\/pSi1")).should("have.text", "Selected index 1: 3");
-
- cy.get(cesc("#\\/pCat1")).should(
- "have.text",
- "Selected cat1: false",
- );
- cy.get(cesc("#\\/pDog1")).should(
- "have.text",
- "Selected dog1: false",
- );
- cy.get(cesc("#\\/pMonkey1")).should(
- "have.text",
- "Selected monkey1: true",
- );
-
- cy.get(cesc("#\\/pCat2")).should(
- "have.text",
- `Selected cat2: ${i === 0}`,
- );
- cy.get(cesc("#\\/pDog2")).should(
- "have.text",
- `Selected dog2: ${i === 1}`,
- );
- cy.get(cesc("#\\/pMonkey2")).should(
- "have.text",
- `Selected monkey2: ${i == 2}`,
- );
- }
- });
-
- it("valueChanged", () => {
- let doenetML = `
- Yes No
-
- Yes No
-
- Yes No
-
- Yes No
-
- `;
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/ci1changed")).should("have.text", "false");
- cy.get(cesc2("#/ci2changed")).should("have.text", "false");
- cy.get(cesc2("#/ci3changed")).should("have.text", "false");
- cy.get(cesc2("#/ci4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ci1a")).should("have.text", "");
- cy.get(cesc2("#/ci2a")).should("have.text", "No");
- cy.get(cesc2("#/ci3a")).should("have.text", "");
- cy.get(cesc2("#/ci4a")).should("have.text", "No");
-
- cy.log("selecting from first and third marks only them as changed");
-
- cy.get(cesc2("#/ci1")).select("Yes");
- cy.get(cesc2("#/ci2") + "_choice1_input").click();
-
- cy.get(cesc2("#/ci1a")).should("have.text", "Yes");
- cy.get(cesc2("#/ci2a")).should("have.text", "Yes");
- cy.get(cesc2("#/ci3a")).should("have.text", "Yes");
- cy.get(cesc2("#/ci4a")).should("have.text", "Yes");
-
- cy.get(cesc2("#/ci1changed")).should("have.text", "true");
- cy.get(cesc2("#/ci2changed")).should("have.text", "true");
- cy.get(cesc2("#/ci3changed")).should("have.text", "false");
- cy.get(cesc2("#/ci4changed")).should("have.text", "false");
-
- // TODO: cannot change choiceInputs from bound values, so can't change third and fourth
- // Should we add this features?
- });
-
- it("label", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- Select an option Yes No
-
- Yes No Select another option
-
-
- Toggle labels
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/ci1-label")).should("contain.text", "Select an option");
- cy.get(cesc2("#/ci2-label")).should(
- "contain.text",
- "Select another option",
- );
-
- cy.log("hide labels");
- cy.get(cesc2("#/toggleLabels")).click();
- cy.get(cesc2("#/ci1-label")).should(
- "not.contain.text",
- "Select an option",
- );
- cy.get(cesc2("#/ci2-label")).should(
- "not.contain.text",
- "Select another option",
- );
-
- cy.log("show labels again");
- cy.get(cesc2("#/toggleLabels")).click();
- cy.get(cesc2("#/ci1-label")).should("contain.text", "Select an option");
- cy.get(cesc2("#/ci2-label")).should(
- "contain.text",
- "Select another option",
- );
- });
-
- it("change choice input from copied value, text", () => {
- let doenetML = `
-
- yes
- no
- maybe
-
-
- Change from text of ci:
- Change from text of ci.selectedValue:
- Change from macro of $ci: $ci
- Change from macro of $ci.selectedValue: $ci.selectedValue
- Change from math of ci.selectedIndices:
- Change from math of ci.selectedIndex:
- Change from macro of $ci.selectedIndices: $ci.selectedIndices
- Change from macro of $ci.selectedIndex: $ci.selectedIndex
-
- Selected value:
-
- `;
-
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
-
- cy.get(cesc2("#/p")).should("have.text", "Selected value: ");
-
- cy.log("typing in wrong value doesn't do anything");
- cy.get(cesc2("#/fromTextCi") + "_input").type("nothing{enter}");
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/p")).should("have.text", "Selected value: ");
-
- cy.log("Select value from text ci");
- cy.get(cesc2("#/fromTextCi") + "_input").type("maybe{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected value: maybe");
-
- cy.log("Change value from text ci.selectedValue");
- cy.get(cesc2("#/fromTextSelectedValue") + "_input")
- .clear()
- .type("no{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected value: no");
-
- cy.log("Invalid value into text ci.selectedValue does nothing");
- cy.get(cesc2("#/fromTextSelectedValue") + "_input")
- .clear()
- .type("bad{enter}");
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/p")).should("have.text", "Selected value: no");
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/p")).should("have.text", "Selected value: ");
-
- cy.log("Cannot change value from macros after starting afresh");
- cy.get(cesc2("#/fromMacroCi") + "_input")
- .clear()
- .type("yes{enter}");
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/p")).should("have.text", "Selected value: ");
- cy.get(cesc2("#/fromMacroCi") + "_input").should("have.value", "yes");
-
- cy.get(cesc2("#/fromMacroSelectedValue") + "_input")
- .clear()
- .type("no{enter}");
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/p")).should("have.text", "Selected value: ");
- cy.get(cesc2("#/fromMacroSelectedValue") + "_input").should(
- "have.value",
- "no",
- );
- cy.get(cesc2("#/fromMacroCi") + "_input").should("have.value", "yes");
-
- cy.log(
- "Change value from text ci.selectedValue works after starting afresh",
- );
- cy.get(cesc2("#/fromTextSelectedValue") + "_input")
- .clear()
- .type("maybe{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected value: maybe");
-
- cy.log("Textinputs from macros are now attached");
- cy.get(cesc2("#/fromMacroCi") + "_input").should("have.value", "maybe");
- cy.get(cesc2("#/fromMacroSelectedValue") + "_input").should(
- "have.value",
- "maybe",
- );
-
- cy.log("We can now change from macros");
- cy.get(cesc2("#/fromMacroCi") + "_input")
- .clear()
- .type("yes{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected value: yes");
-
- cy.get(cesc2("#/fromMacroSelectedValue") + "_input")
- .clear()
- .type("no{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected value: no");
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/p")).should("have.text", "Selected value: ");
-
- cy.log(
- "Change value from math ci.selectedIndices works after starting afresh",
- );
- cy.get(cesc2("#/fromMathSelectedIndices") + " textarea").type(
- "3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected value: maybe");
-
- cy.log(
- "Invalid value into from math ci.selectedIndex deselects all options",
- );
- cy.get(cesc2("#/fromMathSelectedIndex") + " textarea").type(
- "{end}{backspace}4{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected value: ");
-
- cy.log("Enter valid value into from math ci.selectedIndex");
- cy.get(cesc2("#/fromMathSelectedIndex") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected value: maybe");
-
- cy.log("Enter value into from macro ci.selectedIndices");
- cy.get(cesc2("#/fromMacroSelectedIndices") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected value: no");
-
- cy.log("Enter value into from macro ci.selectedIndex");
- cy.get(cesc2("#/fromMacroSelectedIndex") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected value: yes");
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/p")).should("have.text", "Selected value: ");
-
- cy.log("Cannot change value from macros after starting afresh");
-
- cy.get(cesc2("#/fromMacroSelectedIndices") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/p")).should("have.text", "Selected value: ");
-
- cy.log("Enter value into from macro ci.selectedIndex");
- cy.get(cesc2("#/fromMacroSelectedIndex") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/p")).should("have.text", "Selected value: ");
-
- cy.log(
- "can add value into from math ci.selectedIndex even after starting afresh",
- );
- cy.get(cesc2("#/fromMathSelectedIndex") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected value: no");
- });
-
- it("change choice input from copied value, text, select multiple", () => {
- let doenetML = `
-
- yes
- no
- maybe
-
-
- Change from text of ci.selectedValue:
- Change from text of ci.selectedValue2:
- Change from macro of $ci.selectedValue: $ci.selectedValue
- Change from macro of $ci.selectedValue2: $ci.selectedValue2
- Change from math of ci.selectedIndex:
- Change from math of ci.selectedIndex2:
- Change from macro of $ci.selectedIndex: $ci.selectedIndex
- Change from macro of $ci.selectedIndex2: $ci.selectedIndex2
-
- Selected values: $ci.selectedValues
-
- `;
-
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
-
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log("typing in wrong value doesn't do anything");
- cy.get(cesc2("#/fromTextSelectedValue") + "_input").type(
- "nothing{enter}",
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log("Select value from text ci.selectedValue");
- cy.get(cesc2("#/fromTextSelectedValue") + "_input").type(
- "maybe{enter}",
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected values: maybe");
-
- cy.log("Add second value from text ci.selectedValue2");
- cy.get(cesc2("#/fromTextSelectedValue2") + "_input")
- .clear()
- .type("no{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: no, maybe");
-
- cy.log("Invalid value into text ci.selectedValue does nothing");
- cy.get(cesc2("#/fromTextSelectedValue") + "_input")
- .clear()
- .type("bad{enter}");
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: no, maybe");
-
- cy.log(
- "Repeat first value from text ci.selectedValue2 reduces to one value",
- );
- cy.get(cesc2("#/fromTextSelectedValue2") + "_input")
- .clear()
- .type("no{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: no");
-
- cy.log("Add second value from text ci.selectedValue2");
- cy.get(cesc2("#/fromTextSelectedValue2") + "_input")
- .clear()
- .type("yes{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: yes, no");
-
- cy.log(
- "Repeat second value from text ci.selectedValue reduces to one value",
- );
- cy.get(cesc2("#/fromTextSelectedValue") + "_input")
- .clear()
- .type("no{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: no");
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log("Cannot change value from macros after starting afresh");
- cy.get(cesc2("#/fromMacroSelectedValue") + "_input")
- .clear()
- .type("yes{enter}");
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
- cy.get(cesc2("#/fromMacroSelectedValue") + "_input").should(
- "have.value",
- "yes",
- );
-
- cy.get(cesc2("#/fromMacroSelectedValue2") + "_input")
- .clear()
- .type("no{enter}");
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
- cy.get(cesc2("#/fromMacroSelectedValue2") + "_input").should(
- "have.value",
- "no",
- );
- cy.get(cesc2("#/fromMacroSelectedValue") + "_input").should(
- "have.value",
- "yes",
- );
-
- cy.log(
- "Change value from text ci.selectedValue2 works after starting afresh",
- );
- cy.get(cesc2("#/fromTextSelectedValue2") + "_input")
- .clear()
- .type("maybe{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: maybe");
-
- cy.log("Textinput from first macro is now attached");
- cy.get(cesc2("#/fromMacroSelectedValue") + "_input").should(
- "have.value",
- "maybe",
- );
- cy.get(cesc2("#/fromMacroSelectedValue2") + "_input").should(
- "have.value",
- "no",
- );
- cy.log("Add second value from text ci.selectedValue2");
- cy.get(cesc2("#/fromTextSelectedValue2") + "_input")
- .clear()
- .type("yes{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: yes, maybe");
- cy.log("Textinputs from both macros are now attached");
- cy.get(cesc2("#/fromMacroSelectedValue") + "_input").should(
- "have.value",
- "yes",
- );
- cy.get(cesc2("#/fromMacroSelectedValue2") + "_input").should(
- "have.value",
- "maybe",
- );
-
- cy.log("We can now change from macros");
- cy.get(cesc2("#/fromMacroSelectedValue") + "_input")
- .clear()
- .type("no{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: no, maybe");
-
- cy.get(cesc2("#/fromMacroSelectedValue2") + "_input")
- .clear()
- .type("yes{enter}");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: yes, no");
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log(
- "Change value from math ci.selectedIndex works after starting afresh",
- );
- cy.get(cesc2("#/fromMathSelectedIndex") + " textarea").type(
- "3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected values: maybe");
-
- cy.log("Invalid value into from math ci.selectedIndex is reverted");
- cy.get(cesc2("#/fromMathSelectedIndex") + " textarea").type(
- "{end}{backspace}4{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: maybe");
-
- cy.log("Enter valid value into from math ci.selectedIndex2");
- cy.get(cesc2("#/fromMathSelectedIndex2") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected values: yes, maybe");
-
- cy.log("Enter value into from macro ci.selectedIndex");
- cy.get(cesc2("#/fromMacroSelectedIndex") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected values: no, maybe");
-
- cy.log("Enter value into from macro ci.selectedIndex2");
- cy.get(cesc2("#/fromMacroSelectedIndex2") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected values: yes, no");
-
- cy.log(
- "Enter repeated value into from macro ci.selectedIndex2 selects just one",
- );
- cy.get(cesc2("#/fromMacroSelectedIndex2") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected values: yes");
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log("Cannot change value from macros after starting afresh");
-
- cy.get(cesc2("#/fromMacroSelectedIndex") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log("Enter value into from macro ci.selectedIndex2");
- cy.get(cesc2("#/fromMacroSelectedIndex2") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log(
- "can add value into from math ci.selectedIndex2 even after starting afresh",
- );
- cy.get(cesc2("#/fromMathSelectedIndex2") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p")).should("have.text", "Selected values: no");
- });
-
- it("change choice input from copied value, math", () => {
- let doenetML = `
-
- x
- y
- z
-
-
- Change from math of ci:
- Change from math of ci.selectedValue:
- Change from macro of $ci: $ci
- Change from macro of $ci.selectedValue: $ci.selectedValue
- Change from math of ci.selectedIndices:
- Change from math of ci.selectedIndex:
- Change from macro of $ci.selectedIndices: $ci.selectedIndices
- Change from macro of $ci.selectedIndex: $ci.selectedIndex
-
- Selected value:
-
- `;
-
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
-
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
-
- cy.log("typing in wrong value doesn't do anything");
- cy.get(cesc2("#/fromMathCi") + " textarea").type("a{enter}", {
- force: true,
- });
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
-
- cy.log("Select value from math ci");
- cy.get(cesc2("#/fromMathCi") + " textarea").type("z{enter}", {
- force: true,
- });
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "have.text",
- "z",
- );
-
- cy.log("Change value from math ci.selectedValue");
- cy.get(cesc2("#/fromMathSelectedValue") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "have.text",
- "y",
- );
-
- cy.log("Invalid value into math ci.selectedValue does nothing");
- cy.get(cesc2("#/fromMathSelectedValue") + " textarea").type(
- "{end}{backspace}bad{enter}",
- { force: true },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "have.text",
- "y",
- );
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
-
- cy.log("Cannot change value from macros after starting afresh");
- cy.get(cesc2("#/fromMacroCi") + " textarea").type("x{enter}", {
- force: true,
- });
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
- cy.get(cesc2(`#/fromMacroCi`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("x");
- });
-
- cy.get(cesc2("#/fromMacroSelectedValue") + " textarea").type(
- "y{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
- cy.get(cesc2(`#/fromMacroCi`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("x");
- });
- cy.get(cesc2(`#/fromMacroSelectedValue`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("y");
- });
-
- cy.log(
- "Change value from math ci.selectedValue works after starting afresh",
- );
- cy.get(cesc2("#/fromMathSelectedValue") + " textarea").type(
- "z{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "have.text",
- "z",
- );
-
- cy.log("Mathinputs from macros are now attached");
- cy.get(cesc2(`#/fromMacroCi`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc2(`#/fromMacroSelectedValue`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
-
- cy.log("We can now change from macros");
- cy.get(cesc2("#/fromMacroCi") + " textarea").type(
- "{end}{backspace}x{enter}",
- { force: true },
- );
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "have.text",
- "x",
- );
-
- cy.get(cesc2("#/fromMacroSelectedValue") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "have.text",
- "y",
- );
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
-
- cy.log(
- "Change value from math ci.selectedIndices works after starting afresh",
- );
- cy.get(cesc2("#/fromMathSelectedIndices") + " textarea").type(
- "3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "have.text",
- "z",
- );
-
- cy.log(
- "Invalid value into from math ci.selectedIndex deselects all options",
- );
- cy.get(cesc2("#/fromMathSelectedIndex") + " textarea").type(
- "{end}{backspace}4{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "contain.text",
- "\uff3f",
- );
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
-
- cy.log("Enter valid value into from math ci.selectedIndex");
- cy.get(cesc2("#/fromMathSelectedIndex") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "have.text",
- "z",
- );
-
- cy.log("Enter value into from macro ci.selectedIndices");
- cy.get(cesc2("#/fromMacroSelectedIndices") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "have.text",
- "y",
- );
-
- cy.log("Enter value into from macro ci.selectedIndex");
- cy.get(cesc2("#/fromMacroSelectedIndex") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "have.text",
- "x",
- );
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
-
- cy.log("Cannot change value from macros after starting afresh");
-
- cy.get(cesc2("#/fromMacroSelectedIndices") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
-
- cy.log("Enter value into from macro ci.selectedIndex");
- cy.get(cesc2("#/fromMacroSelectedIndex") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
-
- cy.log(
- "can add value into from math ci.selectedIndex even after starting afresh",
- );
- cy.get(cesc2("#/fromMathSelectedIndex") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/selectedValue") + " .mjx-mrow").should(
- "have.text",
- "y",
- );
- });
-
- it("change choice input from copied value, math, select multiple", () => {
- let doenetML = `
-
- x
- y
- z
-
-
- Change from math of ci.selectedValue:
- Change from math of ci.selectedValue2:
- Change from macro of $ci.selectedValue: $ci.selectedValue
- Change from macro of $ci.selectedValue2: $ci.selectedValue2
- Change from math of ci.selectedIndex:
- Change from math of ci.selectedIndex2:
- Change from macro of $ci.selectedIndex: $ci.selectedIndex
- Change from macro of $ci.selectedIndex2: $ci.selectedIndex2
-
- Selected values: $ci.selectedValues
-
- `;
-
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
-
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log("typing in wrong value doesn't do anything");
- cy.get(cesc2("#/fromMathSelectedValue") + " textarea").type(
- "nothing{enter}",
- { force: true },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log("Select value from math ci.selectedValue");
- cy.get(cesc2("#/fromMathSelectedValue") + " textarea").type(
- "z{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "z");
-
- cy.log("Add second value from math ci.selectedValue2");
- cy.get(cesc2("#/fromMathSelectedValue2") + " textarea").type(
- "y{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "yz");
-
- cy.log("Invalid value into math ci.selectedValue does nothing");
- cy.get(cesc2("#/fromMathSelectedValue") + " textarea").type(
- "bad{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "yz");
-
- cy.log(
- "Repeat first value from math ci.selectedValue2 reduces to one value",
- );
- cy.get(cesc2("#/fromMathSelectedValue2") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "y");
-
- cy.log("Add second value from math ci.selectedValue2");
- cy
- .get(cesc2("#/fromMathSelectedValue2") + " textarea")
- .type("x{enter}"),
- { force: true };
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "xy");
-
- cy.log(
- "Repeat second value from math ci.selectedValue reduces to one value",
- );
- cy.get(cesc2("#/fromMathSelectedValue") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "y");
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log("Cannot change value from macros after starting afresh");
- cy.get(cesc2("#/fromMacroSelectedValue") + " textarea").type(
- "x{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
- cy.get(cesc2(`#/fromMacroSelectedValue`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("x");
- });
-
- cy.get(cesc2("#/fromMacroSelectedValue2") + " textarea").type(
- "y{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
- cy.get(cesc2(`#/fromMacroSelectedValue2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("y");
- });
- cy.get(cesc2(`#/fromMacroSelectedValue`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("x");
- });
-
- cy.log(
- "Change value from math ci.selectedValue2 works after starting afresh",
- );
- cy.get(cesc2("#/fromMathSelectedValue2") + " textarea").type(
- "z{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "z");
-
- cy.log("Mathinput from first macro is now attached");
- cy.get(cesc2(`#/fromMacroSelectedValue`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc2(`#/fromMacroSelectedValue2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("y");
- });
-
- cy.log("Add second value from math ci.selectedValue2");
- cy.get(cesc2("#/fromMathSelectedValue2") + " textarea").type(
- "x{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "xz");
- cy.log("Mathinputs from both macros are now attached");
- cy.get(cesc2(`#/fromMacroSelectedValue`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("x");
- });
- cy.get(cesc2(`#/fromMacroSelectedValue2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
-
- cy.log("We can now change from macros");
- cy.get(cesc2("#/fromMacroSelectedValue") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "yz");
-
- cy.get(cesc2("#/fromMacroSelectedValue2") + " textarea").type(
- "{end}{backspace}x{enter}",
- { force: true },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "xy");
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log(
- "Change value from math ci.selectedIndex works after starting afresh",
- );
- cy.get(cesc2("#/fromMathSelectedIndex") + " textarea").type(
- "3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "z");
-
- cy.log("Invalid value into from math ci.selectedIndex is reverted");
- cy.get(cesc2("#/fromMathSelectedIndex") + " textarea").type(
- "{end}{backspace}4{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "z");
-
- cy.log("Enter valid value into from math ci.selectedIndex2");
- cy.get(cesc2("#/fromMathSelectedIndex2") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "xz");
-
- cy.log("Enter value into from macro ci.selectedIndex");
- cy.get(cesc2("#/fromMacroSelectedIndex") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "yz");
-
- cy.log("Enter value into from macro ci.selectedIndex2");
- cy.get(cesc2("#/fromMacroSelectedIndex2") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "xy");
-
- cy.log(
- "Enter repeated value into from macro ci.selectedIndex2 selects just one",
- );
- cy.get(cesc2("#/fromMacroSelectedIndex2") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "x");
-
- cy.reload();
- cy.window().then(async (win) => {
- win.postMessage({ doenetML }, "*");
- });
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log("Cannot change value from macros after starting afresh");
-
- cy.get(cesc2("#/fromMacroSelectedIndex") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "true");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log("Enter value into from macro ci.selectedIndex2");
- cy.get(cesc2("#/fromMacroSelectedIndex2") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- // since nothing will change, wait for core to respond to booleaninput change
- cy.get(cesc2("#/bi")).click();
- cy.get(cesc2("#/b")).should("have.text", "false");
- cy.get(cesc2("#/p")).should("have.text", "Selected values: ");
-
- cy.log(
- "can add value into from math ci.selectedIndex2 even after starting afresh",
- );
- cy.get(cesc2("#/fromMathSelectedIndex2") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/p") + " .mjx-mrow").should("have.text", "y");
- });
});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/codeeditor.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/codeeditor.cy.js
index 218d8e7c6..f37c4182b 100644
--- a/packages/test-cypress/cypress/e2e/tagSpecific/codeeditor.cy.js
+++ b/packages/test-cypress/cypress/e2e/tagSpecific/codeeditor.cy.js
@@ -1269,92 +1269,6 @@ describe("Code Editor Tag Tests", function () {
cy.get(cesc("#\\/piv")).should("have.text", "immediate value: hello");
});
- it("bind value to", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- value: $ce
- immediate value: $ce.immediateValue
- value: $ti
- immediate value: $ti.immediateValue
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/piv")).should("have.text", "immediate value: Hello!");
- cy.get(cesc2("#/pv")).should("have.text", "value: Hello!");
- cy.get(cesc2("#/piv2")).should("have.text", "immediate value: Hello!");
- cy.get(cesc2("#/pv2")).should("have.text", "value: Hello!");
-
- cy.get(cesc2("#/ti_input")).type("{ctrl+end}{enter}Selam!", {
- delay: 10,
- });
- cy.get(cesc2("#/piv2")).should(
- "have.text",
- "immediate value: Hello!\nSelam!",
- );
- cy.get(cesc2("#/pv2")).should("have.text", "value: Hello!");
-
- cy.get(cesc2("#/piv")).should("have.text", "immediate value: Hello!");
- cy.get(cesc2("#/pv")).should("have.text", "value: Hello!");
-
- cy.get(cesc2("#/ti_input")).blur();
-
- cy.get(cesc2("#/piv")).should(
- "have.text",
- "immediate value: Hello!\nSelam!",
- );
- cy.get(cesc2("#/pv")).should("have.text", "value: Hello!\nSelam!");
- cy.get(cesc2("#/piv2")).should(
- "have.text",
- "immediate value: Hello!\nSelam!",
- );
- cy.get(cesc2("#/pv2")).should("have.text", "value: Hello!\nSelam!");
-
- cy.get(cesc("#\\/ce") + " .cm-content").type(
- "{ctrl+end}{enter}Kaixo!",
- {
- delay: 10,
- },
- );
- cy.get(cesc2("#/piv")).should(
- "have.text",
- "immediate value: Hello!\nSelam!\nKaixo!",
- );
- cy.get(cesc2("#/pv")).should("have.text", "value: Hello!\nSelam!");
- cy.get(cesc2("#/piv2")).should(
- "have.text",
- "immediate value: Hello!\nSelam!",
- );
- cy.get(cesc2("#/pv2")).should("have.text", "value: Hello!\nSelam!");
-
- cy.get(cesc("#\\/ce") + " .cm-content").blur();
-
- cy.get(cesc2("#/piv2")).should(
- "have.text",
- "immediate value: Hello!\nSelam!\nKaixo!",
- );
- cy.get(cesc2("#/pv2")).should(
- "have.text",
- "value: Hello!\nSelam!\nKaixo!",
- );
- cy.get(cesc2("#/piv")).should(
- "have.text",
- "immediate value: Hello!\nSelam!\nKaixo!",
- );
- cy.get(cesc2("#/pv")).should(
- "have.text",
- "value: Hello!\nSelam!\nKaixo!",
- );
- });
-
it("undo prompts save", () => {
let doenetML = `
a
@@ -1599,434 +1513,4 @@ describe("Code Editor Tag Tests", function () {
cy.get(cesc2("#/_p3")).should("have.text", "Cherry
\n");
cy.get(cesc2("#/editor3/_p1")).should("contain.text", "Cherry");
});
-
- it("valueChanged", () => {
- let doenetML = `
-
-
-
-
-
- `;
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/ce1a")).should("have.text", "");
- cy.get(cesc2("#/ce2a")).should("have.text", "apple");
- cy.get(cesc2("#/ce3a")).should("have.text", "");
- cy.get(cesc2("#/ce4a")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "");
- cy.get(cesc2("#/ce2iva")).should("have.text", "apple");
- cy.get(cesc2("#/ce3iva")).should("have.text", "");
- cy.get(cesc2("#/ce4iva")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "false");
- cy.get(cesc2("#/ce2changed")).should("have.text", "false");
- cy.get(cesc2("#/ce3changed")).should("have.text", "false");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "false");
-
- cy.log("type in first marks only first immediate value as changed");
-
- cy.get(cesc2("#/ce1") + " .cm-content").type("banana");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "banana");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "");
- cy.get(cesc2("#/ce2a")).should("have.text", "apple");
- cy.get(cesc2("#/ce3a")).should("have.text", "");
- cy.get(cesc2("#/ce4a")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce2iva")).should("have.text", "apple");
- cy.get(cesc2("#/ce3iva")).should("have.text", "");
- cy.get(cesc2("#/ce4iva")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "false");
- cy.get(cesc2("#/ce2changed")).should("have.text", "false");
- cy.get(cesc2("#/ce3changed")).should("have.text", "false");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "false");
-
- cy.log("blur in first marks only first value as changed");
-
- cy.get(cesc2("#/ce1") + " .cm-content").blur();
-
- cy.get(cesc2("#/ce1a")).should("have.text", "banana");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "banana");
- cy.get(cesc2("#/ce2a")).should("have.text", "apple");
- cy.get(cesc2("#/ce3a")).should("have.text", "banana");
- cy.get(cesc2("#/ce4a")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce2iva")).should("have.text", "apple");
- cy.get(cesc2("#/ce3iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce4iva")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "true");
- cy.get(cesc2("#/ce2changed")).should("have.text", "false");
- cy.get(cesc2("#/ce3changed")).should("have.text", "false");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "false");
-
- cy.log("type in second marks only second immediate value as changed");
-
- cy.get(cesc2("#/ce2") + " .cm-content")
- .clear()
- .type("cherry", {
- force: true,
- });
-
- cy.get(cesc2("#/ce2iva")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "banana");
- cy.get(cesc2("#/ce2a")).should("have.text", "apple");
- cy.get(cesc2("#/ce3a")).should("have.text", "banana");
- cy.get(cesc2("#/ce4a")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce2iva")).should("have.text", "cherry");
- cy.get(cesc2("#/ce3iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce4iva")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "true");
- cy.get(cesc2("#/ce2changed")).should("have.text", "false");
- cy.get(cesc2("#/ce3changed")).should("have.text", "false");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "false");
-
- cy.log("blur in second marks only second value as changed");
-
- cy.get(cesc2("#/ce2") + " .cm-content").blur();
-
- cy.get(cesc2("#/ce2a")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "banana");
- cy.get(cesc2("#/ce2a")).should("have.text", "cherry");
- cy.get(cesc2("#/ce3a")).should("have.text", "banana");
- cy.get(cesc2("#/ce4a")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce2iva")).should("have.text", "cherry");
- cy.get(cesc2("#/ce3iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce4iva")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "true");
- cy.get(cesc2("#/ce2changed")).should("have.text", "true");
- cy.get(cesc2("#/ce3changed")).should("have.text", "false");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "false");
-
- cy.log("type in third marks third immediate value as changed");
-
- cy.get(cesc2("#/ce3") + " .cm-content")
- .clear()
- .type("dragonfruit", {
- force: true,
- });
-
- cy.get(cesc2("#/ce3iva")).should("have.text", "dragonfruit");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "banana");
- cy.get(cesc2("#/ce2a")).should("have.text", "cherry");
- cy.get(cesc2("#/ce3a")).should("have.text", "banana");
- cy.get(cesc2("#/ce4a")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce2iva")).should("have.text", "cherry");
- cy.get(cesc2("#/ce3iva")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce4iva")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "true");
- cy.get(cesc2("#/ce2changed")).should("have.text", "true");
- cy.get(cesc2("#/ce3changed")).should("have.text", "false");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "false");
-
- cy.log("blur in third marks third value as changed");
-
- cy.get(cesc2("#/ce3") + " .cm-content").blur();
-
- cy.get(cesc2("#/ce3a")).should("have.text", "dragonfruit");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce2a")).should("have.text", "cherry");
- cy.get(cesc2("#/ce3a")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce4a")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce2iva")).should("have.text", "cherry");
- cy.get(cesc2("#/ce3iva")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce4iva")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "true");
- cy.get(cesc2("#/ce2changed")).should("have.text", "true");
- cy.get(cesc2("#/ce3changed")).should("have.text", "true");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "false");
-
- cy.log("type in fourth marks fourth immediate value as changed");
-
- cy.get(cesc2("#/ce4") + " .cm-content")
- .clear()
- .type("eggplant", {
- force: true,
- });
-
- cy.get(cesc2("#/ce4iva")).should("have.text", "eggplant");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce2a")).should("have.text", "cherry");
- cy.get(cesc2("#/ce3a")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce4a")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce2iva")).should("have.text", "cherry");
- cy.get(cesc2("#/ce3iva")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce4iva")).should("have.text", "eggplant");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "true");
- cy.get(cesc2("#/ce2changed")).should("have.text", "true");
- cy.get(cesc2("#/ce3changed")).should("have.text", "true");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "true");
-
- cy.log("blur in fourth marks fourth value as changed");
-
- cy.get(cesc2("#/ce4") + " .cm-content").blur();
-
- cy.get(cesc2("#/ce4a")).should("have.text", "eggplant");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce2a")).should("have.text", "eggplant");
- cy.get(cesc2("#/ce3a")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce4a")).should("have.text", "eggplant");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce2iva")).should("have.text", "eggplant");
- cy.get(cesc2("#/ce3iva")).should("have.text", "dragonfruit");
- cy.get(cesc2("#/ce4iva")).should("have.text", "eggplant");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "true");
- cy.get(cesc2("#/ce2changed")).should("have.text", "true");
- cy.get(cesc2("#/ce3changed")).should("have.text", "true");
- cy.get(cesc2("#/ce4changed")).should("have.text", "true");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "true");
-
- cy.log("reload");
- cy.reload();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/ce1a")).should("have.text", "");
- cy.get(cesc2("#/ce2a")).should("have.text", "apple");
- cy.get(cesc2("#/ce3a")).should("have.text", "");
- cy.get(cesc2("#/ce4a")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "");
- cy.get(cesc2("#/ce2iva")).should("have.text", "apple");
- cy.get(cesc2("#/ce3iva")).should("have.text", "");
- cy.get(cesc2("#/ce4iva")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "false");
- cy.get(cesc2("#/ce2changed")).should("have.text", "false");
- cy.get(cesc2("#/ce3changed")).should("have.text", "false");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "false");
-
- cy.log("type in third marks only third immediate value as changed");
-
- cy.get(cesc2("#/ce3") + " .cm-content").type("banana");
-
- cy.get(cesc2("#/ce3iva")).should("have.text", "banana");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "");
- cy.get(cesc2("#/ce2a")).should("have.text", "apple");
- cy.get(cesc2("#/ce3a")).should("have.text", "");
- cy.get(cesc2("#/ce4a")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "");
- cy.get(cesc2("#/ce2iva")).should("have.text", "apple");
- cy.get(cesc2("#/ce3iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce4iva")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "false");
- cy.get(cesc2("#/ce2changed")).should("have.text", "false");
- cy.get(cesc2("#/ce3changed")).should("have.text", "false");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "false");
-
- cy.log(
- "blur in third marks first and third value/immediateValue as changed",
- );
-
- cy.get(cesc2("#/ce3") + " .cm-content").blur();
-
- cy.get(cesc2("#/ce3a")).should("have.text", "banana");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "banana");
- cy.get(cesc2("#/ce2a")).should("have.text", "apple");
- cy.get(cesc2("#/ce3a")).should("have.text", "banana");
- cy.get(cesc2("#/ce4a")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce2iva")).should("have.text", "apple");
- cy.get(cesc2("#/ce3iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce4iva")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "true");
- cy.get(cesc2("#/ce2changed")).should("have.text", "false");
- cy.get(cesc2("#/ce3changed")).should("have.text", "true");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "false");
-
- cy.log("type in fourth marks only fourth immediate value as changed");
-
- cy.get(cesc2("#/ce4") + " .cm-content")
- .clear()
- .type("cherry", {
- force: true,
- });
-
- cy.get(cesc2("#/ce4iva")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "banana");
- cy.get(cesc2("#/ce2a")).should("have.text", "apple");
- cy.get(cesc2("#/ce3a")).should("have.text", "banana");
- cy.get(cesc2("#/ce4a")).should("have.text", "apple");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce2iva")).should("have.text", "apple");
- cy.get(cesc2("#/ce3iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce4iva")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "true");
- cy.get(cesc2("#/ce2changed")).should("have.text", "false");
- cy.get(cesc2("#/ce3changed")).should("have.text", "true");
- cy.get(cesc2("#/ce4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "true");
-
- cy.log(
- "blur in fourth marks third and fourth value/immediateValue as changed",
- );
-
- cy.get(cesc2("#/ce4") + " .cm-content").blur();
-
- cy.get(cesc2("#/ce4a")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1a")).should("have.text", "banana");
- cy.get(cesc2("#/ce2a")).should("have.text", "cherry");
- cy.get(cesc2("#/ce3a")).should("have.text", "banana");
- cy.get(cesc2("#/ce4a")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce2iva")).should("have.text", "cherry");
- cy.get(cesc2("#/ce3iva")).should("have.text", "banana");
- cy.get(cesc2("#/ce4iva")).should("have.text", "cherry");
-
- cy.get(cesc2("#/ce1changed")).should("have.text", "true");
- cy.get(cesc2("#/ce2changed")).should("have.text", "true");
- cy.get(cesc2("#/ce3changed")).should("have.text", "true");
- cy.get(cesc2("#/ce4changed")).should("have.text", "true");
-
- cy.get(cesc2("#/ce1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/ce4ivchanged")).should("have.text", "true");
- });
-
- it("ignore variants from children", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get(cesc2("#/_text1")).should("have.text", "a");
-
- cy.log("Have only one variant despite selectFromSequence child");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- expect(
- stateVariables["/_document1"].sharedParameters
- .allPossibleVariants,
- ).eqls(["a"]);
- });
- });
});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/document.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/document.cy.js
deleted file mode 100644
index e5b146c33..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/document.cy.js
+++ /dev/null
@@ -1,241 +0,0 @@
-import { cesc, cesc2 } from "@doenet/utils";
-
-describe("Document Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("get 1 for document credit with nothing", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- $_document1.creditAchieved{assignNames="docCa"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
- cy.get(cesc("#\\/docCa")).should("have.text", "1");
- });
-
- it("document credit when have problem with nothing", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- $_document1.creditAchieved{assignNames="docCa"}
- x
-
- Problem with nothing
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
- cy.get(cesc("#\\/docCa")).should("have.text", "0.5");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinputName =
- stateVariables["/ans"].stateValues.inputChildren[0]
- .componentName;
- let mathinputAnchor = cesc2("#" + mathinputName) + " textarea";
-
- cy.get(mathinputAnchor).type("x{enter}", { force: true });
-
- cy.get(cesc("#\\/docCa")).should("have.text", "1");
- });
- });
-
- it("get document credit even when have composites as a siblings", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- $_document1.creditAchieved{assignNames="docCa"}
-
- x
-
-
- $m1
-
- $m2
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
- cy.get(cesc("#\\/docCa")).should("have.text", "0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinputName =
- stateVariables["/ans"].stateValues.inputChildren[0]
- .componentName;
- let mathinputAnchor = cesc2("#" + mathinputName) + " textarea";
-
- cy.get(mathinputAnchor).type("x{enter}", { force: true });
-
- cy.get(cesc("#\\/docCa")).should("have.text", "1");
- });
- });
-
- it(`item credit achieved, don't skip weight 0`, () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- $_document1.creditAchieved{assignNames="docCa"}
- x: x
- a: a
-
- y: y
-
-
- b: b
-
-
- z: z
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
- cy.get(cesc("#\\/docCa")).should("have.text", "0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_document1"].stateValues.itemCreditAchieved,
- ).eqls([0, 0, 0, 0, 0]);
-
- let mathinputXName =
- stateVariables["/x"].stateValues.inputChildren[0].componentName;
- let mathinputXAnchor = cesc2("#" + mathinputXName) + " textarea";
- let mathinputXCorrect = cesc2("#" + mathinputXName) + "_correct";
- let mathinputYName =
- stateVariables["/y"].stateValues.inputChildren[0].componentName;
- let mathinputYAnchor = cesc2("#" + mathinputYName) + " textarea";
- let mathinputYCorrect = cesc2("#" + mathinputYName) + "_correct";
- let mathinputZName =
- stateVariables["/z"].stateValues.inputChildren[0].componentName;
- let mathinputZAnchor = cesc2("#" + mathinputZName) + " textarea";
- let mathinputZCorrect = cesc2("#" + mathinputZName) + "_correct";
- let mathinputAName =
- stateVariables["/a"].stateValues.inputChildren[0].componentName;
- let mathinputAAnchor = cesc2("#" + mathinputAName) + " textarea";
- let mathinputACorrect = cesc2("#" + mathinputAName) + "_correct";
- let mathinputBName =
- stateVariables["/b"].stateValues.inputChildren[0].componentName;
- let mathinputBAnchor = cesc2("#" + mathinputBName) + " textarea";
- let mathinputBCorrect = cesc2("#" + mathinputBName) + "_correct";
-
- cy.get(mathinputXAnchor).type("x{enter}", { force: true });
- cy.get(mathinputXCorrect).should("be.visible");
- cy.get(cesc("#\\/docCa")).should("have.text", "0.333");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_document1"].stateValues
- .itemCreditAchieved,
- ).eqls([1, 0, 0, 0, 0]);
- });
-
- cy.get(mathinputAAnchor).type("a{enter}", { force: true });
- cy.get(mathinputACorrect).should("be.visible");
- cy.get(cesc("#\\/docCa")).should("have.text", "0.333");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_document1"].stateValues
- .itemCreditAchieved,
- ).eqls([1, 1, 0, 0, 0]);
- });
-
- cy.get(mathinputYAnchor).type("y{enter}", { force: true });
- cy.get(mathinputYCorrect).should("be.visible");
- cy.get(cesc("#\\/docCa")).should("have.text", "0.667");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_document1"].stateValues
- .itemCreditAchieved,
- ).eqls([1, 1, 1, 0, 0]);
- });
-
- cy.get(mathinputBAnchor).type("b{enter}", { force: true });
- cy.get(mathinputBCorrect).should("be.visible");
- cy.get(cesc("#\\/docCa")).should("have.text", "0.667");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_document1"].stateValues
- .itemCreditAchieved,
- ).eqls([1, 1, 1, 1, 0]);
- });
-
- cy.get(mathinputZAnchor).type("z{enter}", { force: true });
- cy.get(mathinputZCorrect).should("be.visible");
- cy.get(cesc("#\\/docCa")).should("have.text", "1");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_document1"].stateValues
- .itemCreditAchieved,
- ).eqls([1, 1, 1, 1, 1]);
- });
- });
- });
-
- it("explicit document tag, ignore outer blank strings", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- a
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_document1")).should("contain.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- expect(Object.keys(stateVariables).length).eq(1);
-
- expect(stateVariables["/_document1"].activeChildren).eqls(["a"]);
- });
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/feedback.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/feedback.cy.js
deleted file mode 100644
index c059ce434..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/feedback.cy.js
+++ /dev/null
@@ -1,3261 +0,0 @@
-import { cesc, cesc2 } from "@doenet/utils";
-
-describe("Feedback Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("feedback from answer value or credit", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- x+y
-
-
- You got full credit!
-
- You typed the right answer!
-
- That's a bad answer.
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinputName =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let mathinputAnchor = cesc2("#" + mathinputName) + " textarea";
- let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit");
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', '');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Type correct answer in");
- cy.get(mathinputAnchor).type(`x+y`, { force: true });
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x+y');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Blur");
- cy.get(mathinputAnchor).blur();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x+y');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x+y');
- cy.get(cesc("#\\/_section1") + " p")
- .eq(0)
- .should("have.text", "You got full credit!");
- cy.get(cesc("#\\/_section1") + " p")
- .eq(1)
- .should("have.text", "You typed the right answer!");
- cy.get(cesc("#\\/_section1") + " p")
- .eq(2)
- .should("not.exist");
-
- cy.log("Type wrong answer");
- cy.get(mathinputAnchor)
- .type(`{end}{backspace}{backspace}`, { force: true })
- .blur();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x');
- cy.get(cesc("#\\/_section1") + " p")
- .eq(0)
- .should("have.text", "You got full credit!");
- cy.get(cesc("#\\/_section1") + " p")
- .eq(1)
- .should("have.text", "You typed the right answer!");
- cy.get(cesc("#\\/_section1") + " p")
- .eq(2)
- .should("not.exist");
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x');
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- "That's a bad answer.",
- );
-
- cy.log("Enter different wrong answer");
- cy.get(mathinputAnchor)
- .type(`{end}{backspace}y`, { force: true })
- .blur();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'y');
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- "That's a bad answer.",
- );
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'y');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
- });
- });
-
- it("feedback from answer value or credit, set showFeedback=false", () => {
- cy.get("#testRunner_toggleControls").click();
- cy.get("#testRunner_showFeedback").click();
- cy.wait(100);
- cy.get("#testRunner_toggleControls").click();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- x+y
-
-
- You got full credit!
-
- You typed the right answer!
-
- That's a bad answer.
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinputName =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let mathinputAnchor = cesc2("#" + mathinputName) + " textarea";
- let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit");
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', '');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Type correct answer in");
- cy.get(mathinputAnchor).type(`x+y`, { force: true });
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x+y');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Blur");
- cy.get(mathinputAnchor).blur();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x+y');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x+y');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Type wrong answer");
- cy.get(mathinputAnchor)
- .type(`{end}{backspace}{backspace}`, { force: true })
- .blur();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Enter different wrong answer");
- cy.get(mathinputAnchor)
- .type(`{end}{backspace}y`, { force: true })
- .blur();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'y');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'y');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
- });
- });
-
- it("feedback from award", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- x+y x
-
-
- You got award 1.
-
-
- You got award 2.
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinputName =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let mathinputAnchor = cesc2("#" + mathinputName) + " textarea";
- let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit");
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', '');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Type correct answer in");
- cy.get(mathinputAnchor).type(`x+y`, { force: true });
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x+y');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Blur");
- cy.get(mathinputAnchor).blur();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x+y');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x+y');
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `You got award 1.`,
- );
-
- cy.log("Enter wrong answer");
- cy.get(mathinputAnchor)
- .type(`{end}{backspace}{backspace}`, { force: true })
- .blur();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x');
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `You got award 1.`,
- );
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'x');
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `You got award 2.`,
- );
-
- cy.log("Enter different wrong answer");
- cy.get(mathinputAnchor)
- .type(`{end}{backspace}y`, { force: true })
- .blur();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'y');
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `You got award 2.`,
- );
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', 'y');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
- });
- });
-
- it("feedback from full awards", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- $_mathinput1.immediateValue > 1
- $_mathinput1.immediateValue > 10
- $_mathinput1.immediateValue > 2
- $_mathinput1.immediateValue > 0.9
- $_mathinput1.immediateValue < 0
-
- Credit achieved: $_answer1.creditAchieved{assignNames="ca"}
-
-
- Larger than 1
-
-
- Larger than 10
-
-
- Larger than 2
-
-
- Larger than 0.9
-
-
- A negative number?
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.log("Test value displayed in browser");
- // cy.get(cesc('#\\/_mathinput1_input')).should('have.value', '');
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Type 11");
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(`11`, {
- force: true,
- });
-
- cy.log("Test value displayed in browser");
- // cy.get(cesc('#\\/_mathinput1_input')).should('have.value', '11');
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Blur");
- cy.get(cesc("#\\/_mathinput1") + " textarea").blur();
-
- cy.log("Test value displayed in browser");
- // cy.get(cesc('#\\/_mathinput1_input')).should('have.value', '11');
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Submit answer");
- cy.get(cesc("#\\/_mathinput1_submit")).click();
-
- cy.log("Test value displayed in browser");
- // cy.get(cesc('#\\/_mathinput1_input')).should('have.value', '11');
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `Larger than 10`,
- );
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("1");
- });
-
- cy.log("submit 10");
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(
- `{end}{backspace}0`,
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/_mathinput1_submit")).should("be.visible");
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(`{enter}`, {
- force: true,
- });
-
- cy.log("Test value displayed in browser");
- // cy.get(cesc('#\\/_mathinput1_input')).should('have.value', '10');
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `Larger than 2`,
- );
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.2");
- });
-
- cy.log("submit 2");
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(
- `{end}{backspace}{backspace}2`,
- { force: true },
- );
- cy.get(cesc("#\\/_mathinput1_submit")).should("be.visible");
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(`{enter}`, {
- force: true,
- });
-
- cy.log("Test value displayed in browser");
- // cy.get(cesc('#\\/_mathinput1_input')).should('have.value', '2');
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `Larger than 1`,
- );
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.1");
- });
-
- cy.log("submit 1");
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(
- `{end}{backspace}1`,
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/_mathinput1_submit")).should("be.visible");
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(`{enter}`, {
- force: true,
- });
-
- cy.log("Test value displayed in browser");
- // cy.get(cesc('#\\/_mathinput1_input')).should('have.value', '1');
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `Larger than 0.9`,
- );
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.1");
- });
-
- cy.log("submit 0");
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(
- `{end}{backspace}0`,
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/_mathinput1_submit")).should("be.visible");
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(`{enter}`, {
- force: true,
- });
-
- cy.log("Test value displayed in browser");
- // cy.get(cesc('#\\/_mathinput1_input')).should('have.value', '0');
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
-
- cy.log("submit -1");
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(
- `{end}{backspace}-1`,
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/_mathinput1_submit")).should("be.visible");
- cy.get(cesc("#\\/_mathinput1") + " textarea").type(`{enter}`, {
- force: true,
- });
-
- cy.log("Test value displayed in browser");
- // cy.get(cesc('#\\/_mathinput1_input')).should('have.value', '-1');
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `A negative number?`,
- );
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
- });
-
- it("feedback from copied awards", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- x+y x
-
-
- You got award 1.
-
-
- You got award 2.
-
-
-
-
-
- You got award 1.
-
-
- You got award 2.
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinput1Name =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let mathinput1Anchor = cesc2("#" + mathinput1Name) + " textarea";
- let mathinput1SubmitAnchor = cesc2(
- "#" + mathinput1Name + "_submit",
- );
- let mathinput1CorrectAnchor = cesc2(
- "#" + mathinput1Name + "_correct",
- );
- let mathinput1IncorrectAnchor = cesc2(
- "#" + mathinput1Name + "_incorrect",
- );
- let mathinput1PartialAnchor = cesc2(
- "#" + mathinput1Name + "_partial",
- );
-
- let mathinput2Name =
- stateVariables["/_answer2"].stateValues.inputChildren[0]
- .componentName;
- let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea";
- let mathinput2SubmitAnchor = cesc2(
- "#" + mathinput2Name + "_submit",
- );
- let mathinput2CorrectAnchor = cesc2(
- "#" + mathinput2Name + "_correct",
- );
- let mathinput2IncorrectAnchor = cesc2(
- "#" + mathinput2Name + "_incorrect",
- );
- let mathinput2PartialAnchor = cesc2(
- "#" + mathinput2Name + "_partial",
- );
-
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
- cy.get(cesc("#\\/_section2") + " p").should("not.exist");
- cy.get(mathinput1SubmitAnchor).should("be.visible");
- cy.get(mathinput2SubmitAnchor).should("be.visible");
-
- cy.log("Submit correct answer 1");
- cy.get(mathinput1Anchor).type(`x+y{enter}`, { force: true });
- cy.get(mathinput1CorrectAnchor).should("be.visible");
- cy.get(mathinput2SubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `You got award 1.`,
- );
- cy.get(cesc("#\\/_section2") + " p").should("not.exist");
-
- cy.log("Submit wrong answer 1");
- cy.get(mathinput1Anchor).type(
- `{end}{backspace}{backspace}{enter}`,
- {
- force: true,
- },
- );
- cy.get(mathinput1PartialAnchor).should("be.visible");
- cy.get(mathinput2SubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `You got award 2.`,
- );
- cy.get(cesc("#\\/_section2") + " p").should("not.exist");
-
- cy.log("Submit wrong answer 2");
- cy.get(mathinput2Anchor).type(`x+y{enter}`, { force: true });
- cy.get(mathinput2PartialAnchor).should("be.visible");
- cy.get(mathinput1PartialAnchor).should("be.visible");
- cy.get(cesc("#\\/_section2") + " p").should(
- "have.text",
- `You got award 1.`,
- );
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `You got award 2.`,
- );
-
- cy.log("Submit correct answer 2");
- cy.get(mathinput2Anchor).type(
- `{end}{backspace}{backspace}{enter}`,
- {
- force: true,
- },
- );
- cy.get(mathinput2CorrectAnchor).should("be.visible");
- cy.get(mathinput1PartialAnchor).should("be.visible");
- cy.get(cesc("#\\/_section2") + " p").should(
- "have.text",
- `You got award 2.`,
- );
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `You got award 2.`,
- );
-
- cy.log("Enter different wrong answer 1");
- cy.get(mathinput1Anchor).type(`{end}{backspace}y{enter}`, {
- force: true,
- });
- cy.get(mathinput1IncorrectAnchor).should("be.visible");
- cy.get(mathinput2CorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
- cy.get(cesc("#\\/_section2") + " p").should(
- "have.text",
- `You got award 2.`,
- );
-
- cy.log("Enter different wrong answer 2");
- cy.get(mathinput2Anchor).type(`{end}{backspace}y{enter}`, {
- force: true,
- });
- cy.get(mathinput2IncorrectAnchor).should("be.visible");
- cy.get(mathinput1IncorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/_section2") + " p").should("not.exist");
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
- });
- });
-
- it("feedback from multiple choice", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- cat
- dog
- cow
- mouse
- banana
-
-
- Credit achieved: $_answer1.creditAchieved{assignNames="ca"}
-
-
- Meow
-
-
- Ruff
-
-
- Moo
-
-
- Squeak
-
-
- Huh?
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let choiceinputName =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let choiceinputAnchor = cesc2("#" + choiceinputName);
- let choiceinputSubmitAnchor = cesc2(
- "#" + choiceinputName + "_submit",
- );
-
- cy.log("Test value displayed in browser");
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Select dog");
- cy.get(choiceinputAnchor).contains(`dog`).click({ force: true });
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
-
- cy.log("Submit answer");
- cy.get(choiceinputSubmitAnchor).click();
-
- cy.log("Test value displayed in browser");
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Ruff`);
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("1");
- });
-
- cy.log("submit cow");
- cy.get(choiceinputAnchor).contains(`cow`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).click();
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Moo`);
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.2");
- });
-
- cy.log("submit cat");
- cy.get(choiceinputAnchor).contains(`cat`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).click();
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Meow`);
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.1");
- });
-
- cy.log("submit mouse");
- cy.get(choiceinputAnchor).contains(`mouse`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).click();
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Squeak`);
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.1");
- });
-
- cy.log("submit banana");
- cy.get(choiceinputAnchor).contains(`banana`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).click();
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Huh?`);
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
- });
- });
-
- it("feedback from multiple choice, some choices inside shuffle", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- cat
-
- dog
- cow
-
- mouse
- banana
-
-
- Credit achieved: $_answer1.creditAchieved{assignNames="ca"}
-
-
- Meow
-
-
- Ruff
-
-
- Moo
-
-
- Squeak
-
-
- Huh?
-
-
- `,
- requestedVariantIndex: 2,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let choiceinputName =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let choiceinputAnchor = cesc2("#" + choiceinputName);
- let choiceinputSubmitAnchor = cesc2(
- "#" + choiceinputName + "_submit",
- );
-
- cy.log("Test value displayed in browser");
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Select dog");
- cy.get(choiceinputAnchor).contains(`dog`).click({ force: true });
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
-
- cy.log("Submit answer");
- cy.get(choiceinputSubmitAnchor).click();
-
- cy.log("Test value displayed in browser");
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Ruff`);
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("1");
- });
-
- cy.log("submit cow");
- cy.get(choiceinputAnchor).contains(`cow`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).click();
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Moo`);
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.2");
- });
-
- cy.log("submit cat");
- cy.get(choiceinputAnchor).contains(`cat`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).click();
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Meow`);
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.1");
- });
-
- cy.log("submit mouse");
- cy.get(choiceinputAnchor).contains(`mouse`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).click();
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Squeak`);
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.1");
- });
-
- cy.log("submit banana");
- cy.get(choiceinputAnchor).contains(`banana`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).click();
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Huh?`);
- cy.get(cesc("#\\/ca"))
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
- });
- });
-
- it("feedback from multiple choice, copied choices, some choices inside shuffle", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- cat
-
- dog
- cow
-
-
-
- Credit achieved 1: $_answer1.creditAchieved{assignNames="ca1"}
-
-
- Meow
-
-
- Ruff
-
-
- Moo
-
-
-
-
-
-
-
-
-
-
-
-
- Credit achieved 2: $_answer2.creditAchieved{assignNames="ca2"}
-
-
- Ruff
-
-
- Meow
-
-
- Moo
-
-
- `,
- requestedVariantIndex: 2,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let choiceinput1Name =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let choiceinput1Anchor = cesc2("#" + choiceinput1Name);
- let choiceinput1SubmitAnchor = cesc2(
- "#" + choiceinput1Name + "_submit",
- );
- let choiceinput2Name =
- stateVariables["/_answer2"].stateValues.inputChildren[0]
- .componentName;
- let choiceinput2Anchor = cesc2("#" + choiceinput2Name);
- let choiceinput2SubmitAnchor = cesc2(
- "#" + choiceinput2Name + "_submit",
- );
-
- cy.log("Test value displayed in browser");
- cy.get(cesc("#\\/ca1")).should("have.text", "0");
- cy.get(cesc("#\\/ca2")).should("have.text", "0");
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
- cy.get(cesc("#\\/_section2") + " p").should("not.exist");
-
- cy.log("Submit dog1");
- cy.get(choiceinput1Anchor).contains(`dog`).click({ force: true });
- cy.get(choiceinput1SubmitAnchor).click();
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Ruff`);
- cy.get(cesc("#\\/_section2") + " p").should("not.exist");
- cy.get(cesc("#\\/ca1")).should("have.text", "1");
- cy.get(cesc("#\\/ca2")).should("have.text", "0");
-
- cy.log("submit cow1");
- cy.get(choiceinput1Anchor).contains(`cow`).click({ force: true });
- cy.get(choiceinput1SubmitAnchor).click();
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Moo`);
- cy.get(cesc("#\\/_section2") + " p").should("not.exist");
-
- cy.get(cesc("#\\/ca1")).should("have.text", "0");
- cy.get(cesc("#\\/ca2")).should("have.text", "0");
-
- cy.log("Submit dog2");
- cy.get(choiceinput2Anchor).contains(`dog`).click({ force: true });
- cy.get(choiceinput2SubmitAnchor).click();
- cy.get(cesc("#\\/_section2") + " p").should("have.text", `Ruff`);
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Moo`);
- cy.get(cesc("#\\/ca2")).should("have.text", "0.1");
- cy.get(cesc("#\\/ca1")).should("have.text", "0");
-
- cy.log("Submit cat2");
- cy.get(choiceinput2Anchor).contains(`cat`).click({ force: true });
- cy.get(choiceinput2SubmitAnchor).click();
- cy.get(cesc("#\\/_section2") + " p").should("have.text", `Meow`);
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Moo`);
- cy.get(cesc("#\\/ca2")).should("have.text", "1");
- cy.get(cesc("#\\/ca1")).should("have.text", "0");
-
- cy.log("Submit cat1");
- cy.get(choiceinput1Anchor).contains(`cat`).click({ force: true });
- cy.get(choiceinput1SubmitAnchor).click();
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Meow`);
- cy.get(cesc("#\\/_section2") + " p").should("have.text", `Meow`);
- cy.get(cesc("#\\/ca1")).should("have.text", "0.1");
- cy.get(cesc("#\\/ca2")).should("have.text", "1");
-
- cy.log("Submit cow2");
- cy.get(choiceinput2Anchor).contains(`cow`).click({ force: true });
- cy.get(choiceinput2SubmitAnchor).click();
- cy.get(cesc("#\\/_section2") + " p").should("have.text", `Moo`);
- cy.get(cesc("#\\/_section1") + " p").should("have.text", `Meow`);
- cy.get(cesc("#\\/ca2")).should("have.text", "0");
- cy.get(cesc("#\\/ca1")).should("have.text", "0.1");
- });
- });
-
- it("feedback for any incorrect response", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- hello there
-
-
- Your response $_answer1.submittedresponse is incorrect.
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let textinputName =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let textinputAnchor = cesc2("#" + textinputName + "_input");
- let textinputSubmitAnchor = cesc2("#" + textinputName + "_submit");
-
- cy.log("Test value displayed in browser");
- cy.get(textinputAnchor).should("have.value", "");
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Enter incorrect answer in");
- cy.get(textinputAnchor).clear().type(`wrong{enter}`);
- cy.get(textinputAnchor).should("have.value", "wrong");
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `Your response wrong is incorrect.`,
- );
-
- cy.log("Enter correct answer");
- cy.get(textinputAnchor).clear().type(`hello there`);
- cy.get(textinputSubmitAnchor).should("be.visible");
- cy.get(textinputAnchor).type(`{enter}`);
- cy.get(textinputAnchor).should("have.value", "hello there");
- cy.get(cesc("#\\/_section1") + " p").should("not.exist");
-
- cy.log("Enter blank answer");
- cy.get(textinputAnchor).clear();
- cy.get(textinputSubmitAnchor).should("be.visible");
- cy.get(textinputAnchor).type(`{enter}`);
- cy.get(textinputAnchor).should("have.value", "");
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `Your response is incorrect.`,
- );
-
- cy.log("Enter another incorrect answer in");
- cy.get(textinputAnchor).clear().type(`bye`);
- cy.get(textinputSubmitAnchor).should("be.visible");
- cy.get(textinputAnchor).type(`{enter}`);
- cy.get(textinputAnchor).should("have.value", "bye");
- cy.get(cesc("#\\/_section1") + " p").should(
- "have.text",
- `Your response bye is incorrect.`,
- );
- });
- });
-
- it("feedback defined in awards", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- sin(pi x)
- cos(pi x)
- sin(x)
-
-
- Award 1 feedback:
- $_award1.feedback
-
- Award 2 feedback:
- $_award2.feedback
-
- Award 3 feedback:
- $_award3.feedback
-
- Answer feedbacks:
- $_answer1.feedbacks
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinputName =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let mathinputAnchor = cesc2("#" + mathinputName) + " textarea";
- let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit");
- let mathinputCorrectAnchor = cesc2(
- "#" + mathinputName + "_correct",
- );
- let mathinputIncorrectAnchor = cesc2(
- "#" + mathinputName + "_incorrect",
- );
- let mathinputPartialAnchor = cesc2(
- "#" + mathinputName + "_partial",
- );
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', '');
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
-
- cy.log("submit blank answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.get(mathinputIncorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Type sin(pi x)");
- cy.get(mathinputAnchor).type(`sin(pi x)`, { force: true });
-
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Blur");
- cy.get(mathinputAnchor).blur();
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
- cy.get(mathinputCorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Type cos(pi x)");
- cy.get(mathinputAnchor).type(
- `{ctrl+home}{shift+end}{backspace}cos(pi x)`,
- { force: true },
- );
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Blur");
- cy.get(mathinputAnchor).blur();
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
- cy.get(mathinputPartialAnchor).should("have.text", "70 %");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2")).should(
- "contain.text",
- "FeedbackClose, but wrong trignometric function",
- );
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackClose, but wrong trignometric function",
- );
-
- cy.log("Enter x");
- cy.get(mathinputAnchor).type(`{ctrl+home}{shift+end}{backspace}x`, {
- force: true,
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(mathinputAnchor).type(`{enter}`, { force: true });
- cy.get(mathinputIncorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Enter sin(x)");
- cy.get(mathinputAnchor).type(`{end}{backspace}sin(x)`, {
- force: true,
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(mathinputAnchor).type(`{enter}`, { force: true });
- cy.get(mathinputPartialAnchor).should("have.text", "30 %");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3")).should(
- "contain.text",
- "FeedbackYou lost pi",
- );
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackYou lost pi",
- );
- });
- });
-
- it("feedback defined in awards, new feedback definitions", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
- sin(pi x)
- cos(pi x)
- sin(x)
-
-
- Award 1 feedback:
- $_award1.feedback
-
- Award 2 feedback:
- $_award2.feedback
-
- Award 3 feedback:
- $_award3.feedback
-
- Answer feedbacks:
- $_answer1.feedbacks
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinputName =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let mathinputAnchor = cesc2("#" + mathinputName) + " textarea";
- let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit");
- let mathinputCorrectAnchor = cesc2(
- "#" + mathinputName + "_correct",
- );
- let mathinputIncorrectAnchor = cesc2(
- "#" + mathinputName + "_incorrect",
- );
- let mathinputPartialAnchor = cesc2(
- "#" + mathinputName + "_partial",
- );
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', '');
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
-
- cy.log("submit blank answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.get(mathinputIncorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Type sin(pi x)");
- cy.get(mathinputAnchor).type(`sin(pi x)`, { force: true });
-
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Blur");
- cy.get(mathinputAnchor).blur();
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
- cy.get(mathinputCorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Type cos(pi x)");
- cy.get(mathinputAnchor).type(
- `{ctrl+home}{shift+end}{backspace}cos(pi x)`,
- { force: true },
- );
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Blur");
- cy.get(mathinputAnchor).blur();
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
- cy.get(mathinputPartialAnchor).should("have.text", "70 %");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2")).should(
- "contain.text",
- "FeedbackClose, but wrong trignometric function",
- );
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackClose, but wrong trignometric function",
- );
-
- cy.log("Enter x");
- cy.get(mathinputAnchor).type(`{ctrl+home}{shift+end}{backspace}x`, {
- force: true,
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(mathinputAnchor).type(`{enter}`, { force: true });
- cy.get(mathinputIncorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Enter sin(x)");
- cy.get(mathinputAnchor).type(`{end}{backspace}sin(x)`, {
- force: true,
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(mathinputAnchor).type(`{enter}`, { force: true });
- cy.get(mathinputPartialAnchor).should("have.text", "30 %");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3")).should(
- "contain.text",
- "FeedbackYou lost pi",
- );
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackYou lost pi",
- );
- });
- });
-
- it("feedback defined in awards, new feedback definitions in document and section", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- sin(pi x)
- cos(pi x)
- sin(x)
-
-
- Award 1 feedback:
- $_award1.feedback
-
- Award 2 feedback:
- $_award2.feedback
-
- Award 3 feedback:
- $_award3.feedback
-
- Answer feedbacks:
- $_answer1.feedbacks
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinputName =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let mathinputAnchor = cesc2("#" + mathinputName) + " textarea";
- let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit");
- let mathinputCorrectAnchor = cesc2(
- "#" + mathinputName + "_correct",
- );
- let mathinputIncorrectAnchor = cesc2(
- "#" + mathinputName + "_incorrect",
- );
- let mathinputPartialAnchor = cesc2(
- "#" + mathinputName + "_partial",
- );
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', '');
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
-
- cy.log("submit blank answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.get(mathinputIncorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Type sin(pi x)");
- cy.get(mathinputAnchor).type(`sin(pi x)`, { force: true });
-
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Blur");
- cy.get(mathinputAnchor).blur();
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
- cy.get(mathinputCorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Type cos(pi x)");
- cy.get(mathinputAnchor).type(
- `{ctrl+home}{shift+end}{backspace}cos(pi x)`,
- { force: true },
- );
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Blur");
- cy.get(mathinputAnchor).blur();
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
- cy.get(mathinputPartialAnchor).should("have.text", "70 %");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2")).should(
- "contain.text",
- "FeedbackClose, but wrong trignometric function",
- );
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackClose, but wrong trignometric function",
- );
-
- cy.log("Enter x");
- cy.get(mathinputAnchor).type(`{ctrl+home}{shift+end}{backspace}x`, {
- force: true,
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(mathinputAnchor).type(`{enter}`, { force: true });
- cy.get(mathinputIncorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Enter sin(x)");
- cy.get(mathinputAnchor).type(`{end}{backspace}sin(x)`, {
- force: true,
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(mathinputAnchor).type(`{enter}`, { force: true });
- cy.get(mathinputPartialAnchor).should("have.text", "30 %");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3")).should(
- "contain.text",
- "FeedbackYou lost pi",
- );
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackYou lost pi",
- );
- });
- });
-
- it("feedback defined in awards, new feedback definitions in document, incorrect codes", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
- sin(pi x)
- cos(pi x)
- sin(x)
-
-
- Award 1 feedback:
- $_award1.feedback
-
- Award 2 feedback:
- $_award2.feedback
-
- Award 3 feedback:
- $_award3.feedback
-
- Answer feedbacks:
- $_answer1.feedbacks
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinputName =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let mathinputAnchor = cesc2("#" + mathinputName) + " textarea";
- let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit");
- let mathinputCorrectAnchor = cesc2(
- "#" + mathinputName + "_correct",
- );
- let mathinputIncorrectAnchor = cesc2(
- "#" + mathinputName + "_incorrect",
- );
- let mathinputPartialAnchor = cesc2(
- "#" + mathinputName + "_partial",
- );
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', '');
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
-
- cy.log("submit blank answer");
- cy.get(mathinputSubmitAnchor).click();
-
- cy.get(mathinputIncorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Type sin(pi x)");
- cy.get(mathinputAnchor).type(`sin(pi x)`, { force: true });
-
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Blur");
- cy.get(mathinputAnchor).blur();
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
- cy.get(mathinputCorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Type cos(pi x)");
- cy.get(mathinputAnchor).type(
- `{ctrl+home}{shift+end}{backspace}cos(pi x)`,
- { force: true },
- );
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Blur");
- cy.get(mathinputAnchor).blur();
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1")).should(
- "contain.text",
- "FeedbackGood job!",
- );
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Submit answer");
- cy.get(mathinputSubmitAnchor).click();
- cy.get(mathinputPartialAnchor).should("have.text", "70 %");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Enter x");
- cy.get(mathinputAnchor).type(`{ctrl+home}{shift+end}{backspace}x`, {
- force: true,
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(mathinputAnchor).type(`{enter}`, { force: true });
- cy.get(mathinputIncorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback4"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Enter sin(x)");
- cy.get(mathinputAnchor).type(`{end}{backspace}sin(x)`, {
- force: true,
- });
- cy.get(mathinputSubmitAnchor).should("be.visible");
- cy.get(mathinputAnchor).type(`{enter}`, { force: true });
- cy.get(mathinputPartialAnchor).should("have.text", "30 %");
- cy.get(cesc("#\\/feedback1"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback2"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- cy.get(cesc("#\\/feedback3")).should(
- "contain.text",
- "FeedbackYou lost pi",
- );
- cy.get(cesc("#\\/feedback4")).should(
- "contain.text",
- "FeedbackYou lost pi",
- );
- });
- });
-
- it("feedback defined in choices", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
- cat
- dog
- monkey
-
-
-
-
- Answer feedbacks:
- $_answer1.feedbacks
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let choiceinputName = cesc2(
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName,
- );
- let choiceinputAnchor = "#" + choiceinputName;
- let choiceinputSubmitAnchor = "#" + choiceinputName + "_submit";
- let choiceinputCorrectAnchor = "#" + choiceinputName + "_correct";
- let choiceinputIncorrectAnchor =
- "#" + choiceinputName + "_incorrect";
- let choiceinputPartialAnchor = "#" + choiceinputName + "_partial";
-
- cy.log("Test value displayed in browser");
- cy.get(choiceinputAnchor).should("have.value", "");
- cy.get(choiceinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Select correct answer");
- cy.get(choiceinputAnchor).contains(`dog`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Click submit button");
- cy.get(choiceinputSubmitAnchor).click({ force: true });
- cy.get(choiceinputCorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Select half correct answer");
- cy.get(choiceinputAnchor).contains(`cat`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks")).should(
- "contain.text",
- "FeedbackGood job!",
- );
-
- cy.log("Click submit button");
- cy.get(choiceinputSubmitAnchor).click({ force: true });
- cy.get(choiceinputPartialAnchor)
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
- cy.get(cesc("#\\/feedbacks")).should(
- "contain.text",
- "Feedbackmeow",
- );
-
- cy.log("Select incorrect answer");
- cy.get(choiceinputAnchor).contains(`monkey`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks")).should(
- "contain.text",
- "Feedbackmeow",
- );
-
- cy.log("Click submit button");
- cy.get(choiceinputSubmitAnchor).click({ force: true });
- cy.get(choiceinputIncorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- });
- });
-
- it("feedback defined in choices, new feedback definitions in document and section", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- cat
- dog
- monkey
-
-
-
-
- Answer feedbacks:
- $_answer1.feedbacks
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let choiceinputName = cesc2(
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName,
- );
- let choiceinputAnchor = "#" + choiceinputName;
- let choiceinputSubmitAnchor = "#" + choiceinputName + "_submit";
- let choiceinputCorrectAnchor = "#" + choiceinputName + "_correct";
- let choiceinputIncorrectAnchor =
- "#" + choiceinputName + "_incorrect";
- let choiceinputPartialAnchor = "#" + choiceinputName + "_partial";
-
- cy.log("Test value displayed in browser");
- cy.get(choiceinputAnchor).should("have.value", "");
- cy.get(choiceinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Select correct answer");
- cy.get(choiceinputAnchor).contains(`dog`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
-
- cy.log("Click submit button");
- cy.get(choiceinputSubmitAnchor).click({ force: true });
- cy.get(choiceinputCorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks")).should(
- "contain.text",
- "FeedbackWoof FeedbackGrrr",
- );
-
- cy.log("Select half correct answer");
- cy.get(choiceinputAnchor).contains(`cat`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks")).should(
- "contain.text",
- "FeedbackWoof FeedbackGrrr",
- );
-
- cy.log("Click submit button");
- cy.get(choiceinputSubmitAnchor).click({ force: true });
- cy.get(choiceinputPartialAnchor)
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
- cy.get(cesc("#\\/feedbacks")).should(
- "contain.text",
- "FeedbackMeow",
- );
-
- cy.log("Select incorrect answer");
- cy.get(choiceinputAnchor).contains(`monkey`).click({ force: true });
- cy.get(choiceinputSubmitAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks")).should(
- "contain.text",
- "FeedbackMeow",
- );
-
- cy.log("Click submit button");
- cy.get(choiceinputSubmitAnchor).click({ force: true });
- cy.get(choiceinputIncorrectAnchor).should("be.visible");
- cy.get(cesc("#\\/feedbacks"))
- .invoke("text")
- .then((text) => {
- expect(text.match(/^\s*$/)).not.be.null;
- });
- });
- });
-
- it("feedback updated with target", () => {
- let doenetML = `
- a
-
-
-
- $mi = x
-
-
-
- You typed y!
- `;
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/fback")).should("not.exist");
-
- cy.get(cesc("#\\/mi") + " textarea").type("y{enter}", { force: true });
- cy.get(cesc("#\\/fback")).should("not.exist");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_incorrect")).should("be.visible");
- cy.get(cesc("#\\/fback")).should("have.text", "You typed y!");
-
- cy.get(cesc("#\\/mi") + " textarea").type("{end}{backspace}x{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/fback")).should("have.text", "You typed y!");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_correct")).should("be.visible");
- cy.get(cesc("#\\/fback")).should("not.exist");
-
- cy.get("#testRunner_toggleControls").click();
- cy.get("#testRunner_showFeedback").click();
- cy.wait(100);
- cy.get("#testRunner_toggleControls").click();
- cy.reload();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/fback")).should("not.exist");
-
- cy.get(cesc("#\\/mi") + " textarea").type("y{enter}", { force: true });
- cy.get(cesc("#\\/fback")).should("not.exist");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_incorrect")).should("be.visible");
- cy.get(cesc("#\\/fback")).should("not.exist");
-
- cy.get(cesc("#\\/mi") + " textarea").type("{end}{backspace}x{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/fback")).should("not.exist");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_correct")).should("be.visible");
- cy.get(cesc("#\\/fback")).should("not.exist");
- });
-
- it("feedback based on booleans, updated with target", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- $m1 = x
- $m2 = y
-
-
- $got1 and $got2
-
- $m1 $m2
-
-
- Submitted responses: $ans.submittedResponses{assignNames="r1 r2"}
-
-
- Desired feedback behavior
- You got the first; what about the second?
- You got the second; what about the first?
-
-
- Default feedback behavior
- You got the first; what about the second?
- You got the second; what about the first?
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/fback1")).should("not.exist");
- cy.get(cesc("#\\/fback2")).should("not.exist");
- cy.get(cesc("#\\/fback1b")).should("not.exist");
- cy.get(cesc("#\\/fback2b")).should("not.exist");
- cy.get(cesc("#\\/r1")).should("not.exist");
- cy.get(cesc("#\\/r2")).should("not.exist");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_incorrect")).should("be.visible");
- cy.get(cesc("#\\/fback1")).should("not.exist");
- cy.get(cesc("#\\/fback2")).should("not.exist");
- cy.get(cesc("#\\/fback1b")).should("not.exist");
- cy.get(cesc("#\\/fback2b")).should("not.exist");
- cy.get(cesc("#\\/r1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
- cy.get(cesc("#\\/r2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
-
- cy.get(cesc("#\\/m2") + " textarea").type("y{enter}", { force: true });
- cy.get(cesc("#\\/fback1")).should("not.exist");
- cy.get(cesc("#\\/fback2")).should("not.exist");
- cy.get(cesc("#\\/fback1b")).should("not.exist");
- cy.get(cesc("#\\/fback2b")).should(
- "have.text",
- "You got the second; what about the first?",
- );
- cy.get(cesc("#\\/r1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
- cy.get(cesc("#\\/r2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_incorrect")).should("be.visible");
- cy.get(cesc("#\\/fback1")).should("not.exist");
- cy.get(cesc("#\\/fback2")).should(
- "have.text",
- "You got the second; what about the first?",
- );
- cy.get(cesc("#\\/fback1b")).should("not.exist");
- cy.get(cesc("#\\/fback2b")).should(
- "have.text",
- "You got the second; what about the first?",
- );
- cy.get(cesc("#\\/r1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
- cy.get(cesc("#\\/r2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "y");
-
- cy.get(cesc("#\\/m1") + " textarea").type("x{enter}", { force: true });
- cy.get(cesc("#\\/fback1")).should("not.exist");
- cy.get(cesc("#\\/fback2")).should(
- "have.text",
- "You got the second; what about the first?",
- );
- cy.get(cesc("#\\/fback1b")).should("not.exist");
- cy.get(cesc("#\\/fback2b")).should("not.exist");
- cy.get(cesc("#\\/r1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
- cy.get(cesc("#\\/r2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "y");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_correct")).should("be.visible");
- cy.get(cesc("#\\/fback1")).should("not.exist");
- cy.get(cesc("#\\/fback2")).should("not.exist");
- cy.get(cesc("#\\/fback1b")).should("not.exist");
- cy.get(cesc("#\\/fback2b")).should("not.exist");
- cy.get(cesc("#\\/r1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x");
- cy.get(cesc("#\\/r2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "y");
-
- cy.get(cesc("#\\/m2") + " textarea").type("{end}{backspace}{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/fback1")).should("not.exist");
- cy.get(cesc("#\\/fback2")).should("not.exist");
- cy.get(cesc("#\\/fback1b")).should(
- "have.text",
- "You got the first; what about the second?",
- );
- cy.get(cesc("#\\/fback2b")).should("not.exist");
- cy.get(cesc("#\\/r1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x");
- cy.get(cesc("#\\/r2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "y");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_incorrect")).should("be.visible");
- cy.get(cesc("#\\/fback1")).should(
- "have.text",
- "You got the first; what about the second?",
- );
- cy.get(cesc("#\\/fback2")).should("not.exist");
- cy.get(cesc("#\\/fback1b")).should(
- "have.text",
- "You got the first; what about the second?",
- );
- cy.get(cesc("#\\/fback2b")).should("not.exist");
- cy.get(cesc("#\\/r1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x");
- cy.get(cesc("#\\/r2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "\uff3f");
- });
-
- it("feedback based on fractionSatisfied/creditAchieved of award", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- $mi1 < 1 and $mi2 < 1
- $mi1 < 2 and $mi2 < 2
- $mi1 < 3 and $mi2 < 3
-
-
-
- A number or two is close but not quite.
-
-
- One number is good, the other number is close but not quite.
-
-
- A number or two is starting to get close.
-
-
- A number is close but not quite; the other number is starting to get close.
-
-
- One number is good, the other number is starting to get close.
-
-
- One number is good.
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_incorrect")).should("be.visible");
-
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/mi1") + " textarea").type("2{enter}", { force: true });
- cy.get(cesc("#\\/ans_submit")).should("be.visible");
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_incorrect")).should("be.visible");
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should(
- "contain.text",
- "A number or two is starting to get close.",
- );
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}1{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/ans_submit")).should("be.visible");
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should(
- "contain.text",
- "A number or two is starting to get close.",
- );
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("25% correct");
- });
- cy.get(cesc("#\\/close")).should(
- "contain.text",
- "A number or two is close but not quite.",
- );
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}0{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/ans_submit")).should("be.visible");
- cy.get(cesc("#\\/close")).should(
- "contain.text",
- "A number or two is close but not quite.",
- );
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("contain.text", "One number is good.");
-
- cy.get(cesc("#\\/mi2") + " textarea").type("2{enter}", { force: true });
- cy.get(cesc("#\\/ans_submit")).should("be.visible");
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("contain.text", "One number is good.");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should(
- "have.text",
- "One number is good, the other number is starting to get close.",
- );
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/mi2") + " textarea").type("{end}{backspace}1{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/ans_submit")).should("be.visible");
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should(
- "have.text",
- "One number is good, the other number is starting to get close.",
- );
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should(
- "have.text",
- "One number is good, the other number is close but not quite.",
- );
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/mi2") + " textarea").type("{end}{backspace}0{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/ans_submit")).should("be.visible");
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should(
- "have.text",
- "One number is good, the other number is close but not quite.",
- );
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_correct")).should("be.visible");
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}1{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/mi2") + " textarea").type("{end}{backspace}1{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/ans_submit")).should("be.visible");
- cy.get(cesc("#\\/close")).should("not.exist");
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
- cy.get(cesc("#\\/close")).should(
- "contain.text",
- "A number or two is close but not quite.",
- );
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}2{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/ans_submit")).should("be.visible");
- cy.get(cesc("#\\/close")).should(
- "contain.text",
- "A number or two is close but not quite.",
- );
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should("not.exist");
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
-
- cy.get(cesc("#\\/ans_submit")).click();
- cy.get(cesc("#\\/ans_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("25% correct");
- });
- cy.get(cesc("#\\/close")).should(
- "contain.text",
- "A number or two is close but not quite.",
- );
- cy.get(cesc("#\\/goodAndClose")).should("not.exist");
- cy.get(cesc("#\\/startingClose")).should("not.exist");
- cy.get(cesc("#\\/closeStartingClose")).should(
- "contain.text",
- "A number is close but not quite; the other number is starting to get close.",
- );
- cy.get(cesc("#\\/goodStartingClose")).should("not.exist");
- cy.get(cesc("#\\/good")).should("not.exist");
- });
-
- it("feedback with no condition", () => {
- let doenetML = `
- a
- Good job!
- `;
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/fback")).should("have.text", "Good job!");
-
- cy.get("#testRunner_toggleControls").click();
- cy.get("#testRunner_showFeedback").click();
- cy.wait(100);
- cy.get("#testRunner_toggleControls").click();
- cy.reload();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/fback")).should("not.exist");
- });
-
- it("feedback inside invalid children", () => {
- // The following DoenetML was a minimal working example to trigger a bug
- // where the children of _li1 where not being updated on the second submission
- // (due to being marked stale from invalid children in the middle of the first
- // time that they were being updated)
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- x: x
- You answered at least twice
-
- $ans
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/fb")).should("not.exist");
-
- cy.get(cesc("#\\/mi_submit")).click();
- cy.get(cesc("#\\/mi_incorrect")).should("be.visible");
- cy.get(cesc("#\\/_li2") + " .mjx-mrow").should(
- "contain.text",
- "\uff3f",
- );
-
- cy.get(cesc("#\\/fb")).should("not.exist");
-
- // Note: added 100 ms delay because otherwise when Enter key event was received,
- // the renderer had not yet gotten signal from core that answer blank was unvalidated,
- // which is a necessary condition for Enter to lead to a submitAnswer
- cy.get(cesc("#\\/mi") + " textarea").type("y{enter}", {
- force: true,
- delay: 100,
- });
-
- cy.get(cesc("#\\/_li2") + " .mjx-mrow").should("contain.text", "y");
- cy.get(cesc("#\\/fb")).should(
- "have.text",
- "You answered at least twice",
- );
- });
-
- it("feedback from numSubmissions", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- x
-
- You answered more than once!
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinputName =
- stateVariables["/ans"].stateValues.inputChildren[0]
- .componentName;
- let mathinputAnchor = cesc2("#" + mathinputName) + " textarea";
- let mathinputCorrect = cesc2("#" + mathinputName + "_correct");
- let mathinputIncorrect = cesc2("#" + mathinputName + "_incorrect");
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', '');
- cy.get(cesc2("#/pSub")).should("not.exist");
-
- cy.log("Submit first time");
- cy.get(mathinputAnchor).type(`x{enter}`, { force: true });
- cy.get(mathinputCorrect).should("be.visible");
- cy.get(cesc2("#/pSub")).should("not.exist");
-
- cy.log("Submit second time");
- cy.get(mathinputAnchor).type(`{end}{backspace}y{enter}`, {
- force: true,
- });
- cy.get(mathinputIncorrect).should("be.visible");
- cy.get(cesc2("#/pSub")).should(
- "have.text",
- "You answered more than once!",
- );
-
- cy.log("Submit third time");
- cy.get(mathinputAnchor).type(`{end}{backspace}x{enter}`, {
- force: true,
- });
- cy.get(mathinputCorrect).should("be.visible");
- cy.get(cesc2("#/pSub")).should(
- "have.text",
- "You answered more than once!",
- );
- });
- });
-
- it("feedback with deprecation shim for nSubmissions", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- x
-
- You answered more than once!
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let mathinputName =
- stateVariables["/ans"].stateValues.inputChildren[0]
- .componentName;
- let mathinputAnchor = cesc2("#" + mathinputName) + " textarea";
- let mathinputCorrect = cesc2("#" + mathinputName + "_correct");
- let mathinputIncorrect = cesc2("#" + mathinputName + "_incorrect");
-
- cy.log("Test value displayed in browser");
- // cy.get(mathinputAnchor).should('have.value', '');
- cy.get(cesc2("#/pSub")).should("not.exist");
-
- cy.log("Submit first time");
- cy.get(mathinputAnchor).type(`x{enter}`, { force: true });
- cy.get(mathinputCorrect).should("be.visible");
- cy.get(cesc2("#/pSub")).should("not.exist");
-
- cy.log("Submit second time");
- cy.get(mathinputAnchor).type(`{end}{backspace}y{enter}`, {
- force: true,
- });
- cy.get(mathinputIncorrect).should("be.visible");
- cy.get(cesc2("#/pSub")).should(
- "have.text",
- "You answered more than once!",
- );
-
- cy.log("Submit third time");
- cy.get(mathinputAnchor).type(`{end}{backspace}x{enter}`, {
- force: true,
- });
- cy.get(mathinputCorrect).should("be.visible");
- cy.get(cesc2("#/pSub")).should(
- "have.text",
- "You answered more than once!",
- );
- });
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/group.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/group.cy.js
deleted file mode 100644
index 3f1b44923..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/group.cy.js
+++ /dev/null
@@ -1,705 +0,0 @@
-import { cesc, cesc2 } from "@doenet/utils";
-
-describe("Group Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("nested groups, copied", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Animal:
- Plant:
-
-
- The animal is a $animal.value.
-
- The plant is a $plant.value.
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get(cesc("#\\/_text1")).should("have.text", "a");
-
- let animal = "fox";
- let plant = "tree";
- let animalSentence = "The animal is a " + animal + ".";
- let plantSentence = "The plant is a " + plant + ".";
- cy.get(cesc("#\\/animalp")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp")).should("have.text", plantSentence);
- cy.get(cesc("#\\/animalp2")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp2")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp3")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp4")).should("have.text", plantSentence);
- cy.get(cesc("#\\/animalp3")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp5")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp6")).should("have.text", plantSentence);
- cy.get(cesc("#\\/animalp4")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp7")).should("have.text", plantSentence);
- cy.get(cesc("#\\/animalp5")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp8")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp9")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp10")).should("have.text", plantSentence);
- cy.get(cesc("#\\/animalp6")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp11")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp12")).should("have.text", plantSentence);
-
- cy.get(cesc("#\\/animal_input")).clear().type("beetle{enter}");
- cy.get(cesc("#\\/plant_input")).clear().type("dandelion{enter}");
- let animal2 = "beetle";
- let plant2 = "dandelion";
- let animalSentence2 = "The animal is a " + animal2 + ".";
- let plantSentence2 = "The plant is a " + plant2 + ".";
- cy.get(cesc("#\\/animalp")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/animalp2")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp2")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp3")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp4")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/animalp3")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp5")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp6")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/animalp4")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp7")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/animalp5")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp8")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp9")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp10")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/animalp6")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp11")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp12")).should("have.text", plantSentence2);
- });
-
- it("nested groups, initially unresolved, reffed", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- $g1
-
- The animal $animalphrase.
-
- The plant $plantphrase.
-
-
-
-
-
-
-
-
-
-
- $verb1{name="verb"}
- $animalphrase1{name="animalphrase"}
- $verb $animal1
- $article $animal.value
- $verb2{name="verb1"}
- is
- $article1
- $article2{name="article1"}
- a
- $plantphrase1{name="plantphrase"}
- $verb $plant1
- $article $plant.value
-
- Animal:
- Plant:
-
- `,
- },
- "*",
- );
- });
-
- let animal = "fox";
- let plant = "tree";
- let animalSentence = "The animal is a " + animal + ".";
- let plantSentence = "The plant is a " + plant + ".";
- cy.get(cesc("#\\/animalp")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp")).should("have.text", plantSentence);
- cy.get(cesc("#\\/animalp2")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp2")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp3")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp4")).should("have.text", plantSentence);
- cy.get(cesc("#\\/animalp3")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp5")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp6")).should("have.text", plantSentence);
- cy.get(cesc("#\\/animalp4")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp7")).should("have.text", plantSentence);
- cy.get(cesc("#\\/animalp5")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp8")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp9")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp10")).should("have.text", plantSentence);
- cy.get(cesc("#\\/animalp6")).should("have.text", animalSentence);
- cy.get(cesc("#\\/plantp11")).should("have.text", plantSentence);
- cy.get(cesc("#\\/plantp12")).should("have.text", plantSentence);
-
- cy.get(cesc("#\\/animal_input")).clear().type("beetle{enter}");
- cy.get(cesc("#\\/plant_input")).clear().type("dandelion{enter}");
- let animal2 = "beetle";
- let plant2 = "dandelion";
- let animalSentence2 = "The animal is a " + animal2 + ".";
- let plantSentence2 = "The plant is a " + plant2 + ".";
- cy.get(cesc("#\\/animalp")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/animalp2")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp2")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp3")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp4")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/animalp3")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp5")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp6")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/animalp4")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp7")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/animalp5")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp8")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp9")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp10")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/animalp6")).should("have.text", animalSentence2);
- cy.get(cesc("#\\/plantp11")).should("have.text", plantSentence2);
- cy.get(cesc("#\\/plantp12")).should("have.text", plantSentence2);
- });
-
- it("group with a map that begins zero length, copied multiple times", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- $x^2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $count.value{assignNames="count2"}
- $to.value{assignNames="to2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.log("At beginning, nothing shown");
- for (let i = 1; i <= 6; i++) {
- cy.get(cesc(`#\\/p${i}`)).should("have.text", "");
- }
-
- cy.log("make sequence length 1");
- cy.get(cesc("#\\/count") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/count2")).should("contain.text", "1");
-
- for (let i = 1; i <= 6; i++) {
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("1");
- });
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(1)
- .should("not.exist");
- }
-
- cy.log("make sequence length 0 again");
- cy.get(cesc("#\\/count") + " textarea").type(
- "{end}{backspace}0{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/count2")).should("contain.text", "0");
- for (let i = 1; i <= 6; i++) {
- cy.get(cesc(`#\\/p${i}`)).should("have.text", "");
- }
-
- cy.log("make sequence length 2");
- cy.get(cesc("#\\/count") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/count2")).should("contain.text", "2");
-
- for (let i = 1; i <= 6; i++) {
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("1");
- });
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("4");
- });
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(2)
- .should("not.exist");
- }
-
- cy.log("change limits");
- cy.get(cesc("#\\/from") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/to") + " textarea").type("{end}{backspace}5{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/to2")).should("contain.text", "5");
-
- for (let i = 1; i <= 6; i++) {
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("9");
- });
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("25");
- });
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(2)
- .should("not.exist");
- }
-
- cy.log("make sequence length 0 once again");
- cy.get(cesc("#\\/count") + " textarea").type(
- "{end}{backspace}0{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/count2")).should("contain.text", "0");
- for (let i = 1; i <= 6; i++) {
- cy.get(cesc(`#\\/p${i}`)).should("have.text", "");
- }
-
- cy.log("make sequence length 3");
- cy.get(cesc("#\\/count") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/count2")).should("contain.text", "3");
-
- for (let i = 1; i <= 6; i++) {
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("9");
- });
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("16");
- });
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(2)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("25");
- });
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(3)
- .should("not.exist");
- }
- });
-
- it("group with mutual references", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- $var1.value + $y
- $var2.value + $x
-
-
-
-
-
-
- $_group1$_group2
- $_aslist1
-
-
-
-
-
-
-
-
-
- $var2.value{assignNames="var2b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- for (let i = 1; i <= 9; i++) {
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("x+y");
- });
-
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("x+y");
- });
- }
-
- cy.log("change variables");
- cy.get(cesc("#\\/var1") + " textarea").type(
- "{end}{backspace}u{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/var2") + " textarea").type(
- "{end}{backspace}v{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/var2b")).should("contain.text", "v");
-
- for (let i = 1; i <= 9; i++) {
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("u+v");
- });
-
- cy.get(cesc(`#\\/p${i}`))
- .find(".mjx-mrow")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("u+v");
- });
- }
- });
-
- it("fixed propagated when copy group", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- (1,2)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.log("Initial values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/g"].stateValues.fixed).eq(false);
- expect(stateVariables["/g/A"].stateValues.fixed).eq(false);
- expect(stateVariables["/g/A"].stateValues.xs).eqls([1, 2]);
- expect(stateVariables["/g2"].stateValues.fixed).eq(true);
- expect(stateVariables["/g2/A"].stateValues.fixed).eq(true);
- expect(stateVariables["/g2/A"].stateValues.xs).eqls([1, 2]);
- expect(stateVariables["/g3"].stateValues.fixed).eq(false);
- expect(stateVariables["/g3/A"].stateValues.fixed).eq(false);
- expect(stateVariables["/g3/A"].stateValues.xs).eqls([1, 2]);
- expect(stateVariables["/g4"].stateValues.fixed).eq(false);
- expect(stateVariables["/g4/A"].stateValues.fixed).eq(false);
- expect(stateVariables["/g4/A"].stateValues.xs).eqls([1, 2]);
- });
-
- cy.log("move first point");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/g/A",
- args: { x: 3, y: 4 },
- });
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/g/A"].stateValues.xs).eqls([3, 4]);
- expect(stateVariables["/g2/A"].stateValues.xs).eqls([3, 4]);
- expect(stateVariables["/g3/A"].stateValues.xs).eqls([3, 4]);
- expect(stateVariables["/g4/A"].stateValues.xs).eqls([1, 2]);
- });
-
- cy.log(`can't move second point as fixed`);
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/g2/A",
- args: { x: 5, y: 6 },
- });
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/g/A"].stateValues.xs).eqls([3, 4]);
- expect(stateVariables["/g2/A"].stateValues.xs).eqls([3, 4]);
- expect(stateVariables["/g3/A"].stateValues.xs).eqls([3, 4]);
- expect(stateVariables["/g4/A"].stateValues.xs).eqls([1, 2]);
- });
-
- // TODO: this used to be immobile but not it is
- // Do we need to figure out how to make third point immobile again?
- // cy.log(`can't move third point as depends on fixed second point`)
- cy.log(
- `for now, can move third point as depends on directly on xs of first point`,
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/g3/A",
- args: { x: 7, y: 8 },
- });
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/g/A"].stateValues.xs).eqls([7, 8]);
- expect(stateVariables["/g2/A"].stateValues.xs).eqls([7, 8]);
- expect(stateVariables["/g3/A"].stateValues.xs).eqls([7, 8]);
- expect(stateVariables["/g4/A"].stateValues.xs).eqls([1, 2]);
- });
-
- cy.log(`can move fourth point`);
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/g4/A",
- args: { x: 9, y: 0 },
- });
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/g/A"].stateValues.xs).eqls([7, 8]);
- expect(stateVariables["/g2/A"].stateValues.xs).eqls([7, 8]);
- expect(stateVariables["/g3/A"].stateValues.xs).eqls([7, 8]);
- expect(stateVariables["/g4/A"].stateValues.xs).eqls([9, 0]);
- });
- });
-
- it("disabled propagated when copy group", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- $ti.value{assignNames="t"}
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.log("Initial values");
-
- cy.get(cesc("#\\/g\\/ti_input")).should("not.be.disabled");
- cy.get(cesc("#\\/g2\\/ti_input")).should("be.disabled");
- cy.get(cesc("#\\/g3\\/ti_input")).should("not.be.disabled");
- cy.get(cesc("#\\/g4\\/ti_input")).should("not.be.disabled");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/g"].stateValues.disabled).eq(false);
- expect(stateVariables["/g/ti"].stateValues.disabled).eq(false);
- expect(stateVariables["/g/ti"].stateValues.value).eq("hello");
- expect(stateVariables["/g2"].stateValues.disabled).eq(true);
- expect(stateVariables["/g2/ti"].stateValues.disabled).eq(true);
- expect(stateVariables["/g2/ti"].stateValues.value).eq("hello");
- expect(stateVariables["/g3"].stateValues.disabled).eq(false);
- expect(stateVariables["/g3/ti"].stateValues.disabled).eq(false);
- expect(stateVariables["/g3/ti"].stateValues.value).eq("hello");
- expect(stateVariables["/g4"].stateValues.disabled).eq(false);
- expect(stateVariables["/g4/ti"].stateValues.disabled).eq(false);
- expect(stateVariables["/g4/ti"].stateValues.value).eq("hello");
- });
-
- cy.log("type in first textinput");
- cy.get(cesc("#\\/g\\/ti_input")).clear().type("bye{enter}");
- cy.get(cesc("#\\/g\\/t")).should("contain.text", "bye");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/g/ti"].stateValues.value).eq("bye");
- expect(stateVariables["/g2/ti"].stateValues.value).eq("bye");
- expect(stateVariables["/g3/ti"].stateValues.value).eq("bye");
- expect(stateVariables["/g4/ti"].stateValues.value).eq("hello");
- });
-
- cy.log("type in third textinput");
- cy.get(cesc("#\\/g3\\/ti_input")).clear().type("this{enter}");
- cy.get(cesc("#\\/g3\\/t")).should("contain.text", "this");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/g/ti"].stateValues.value).eq("this");
- expect(stateVariables["/g2/ti"].stateValues.value).eq("this");
- expect(stateVariables["/g3/ti"].stateValues.value).eq("this");
- expect(stateVariables["/g4/ti"].stateValues.value).eq("hello");
- });
-
- cy.log("type in fourth textinput");
- cy.get(cesc("#\\/g4\\/ti_input")).clear().type("that{enter}");
- cy.get(cesc("#\\/g4\\/t")).should("contain.text", "that");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/g/ti"].stateValues.value).eq("this");
- expect(stateVariables["/g2/ti"].stateValues.value).eq("this");
- expect(stateVariables["/g3/ti"].stateValues.value).eq("this");
- expect(stateVariables["/g4/ti"].stateValues.value).eq("that");
- });
- });
-
- it("change rendered", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- rendereed 1
-
- Hello
-
-
- rendereed 2
-
- Bye
-
-
-
- $g1{name="g1a"}
- $g2{name="g2a"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/g2/_p1")).should("have.text", "Bye");
- cy.get(cesc2("#/g2a/_p1")).should("have.text", "Bye");
- cy.get(cesc2("#/g1/_p1")).should("not.exist");
- cy.get(cesc2("#/g1a/_p1")).should("not.exist");
-
- cy.get(cesc2("#/ren1")).click();
- cy.get(cesc2("#/g1/_p1")).should("have.text", "Hello");
- cy.get(cesc2("#/g1a/_p1")).should("have.text", "Hello");
- cy.get(cesc2("#/g2/_p1")).should("have.text", "Bye");
- cy.get(cesc2("#/g2a/_p1")).should("have.text", "Bye");
-
- cy.get(cesc2("#/ren2")).click();
- cy.get(cesc2("#/g2/_p1")).should("not.exist");
- cy.get(cesc2("#/g2a/_p1")).should("not.exist");
- cy.get(cesc2("#/g1/_p1")).should("have.text", "Hello");
- cy.get(cesc2("#/g1a/_p1")).should("have.text", "Hello");
-
- cy.get(cesc2("#/ren1")).click();
- cy.get(cesc2("#/g1/_p1")).should("not.exist");
- cy.get(cesc2("#/g1a/_p1")).should("not.exist");
- cy.get(cesc2("#/g2/_p1")).should("not.exist");
- cy.get(cesc2("#/g2a/_p1")).should("not.exist");
-
- cy.get(cesc2("#/ren2")).click();
- cy.get(cesc2("#/g2/_p1")).should("have.text", "Bye");
- cy.get(cesc2("#/g2a/_p1")).should("have.text", "Bye");
- cy.get(cesc2("#/g1/_p1")).should("not.exist");
- cy.get(cesc2("#/g1a/_p1")).should("not.exist");
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/image.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/image.cy.js
index 5c5d8be08..de40b3425 100644
--- a/packages/test-cypress/cypress/e2e/tagSpecific/image.cy.js
+++ b/packages/test-cypress/cypress/e2e/tagSpecific/image.cy.js
@@ -30,191 +30,6 @@ describe("Image Tag Tests", function () {
.then((alt) => expect(alt).eq("A giant anteater"));
});
- it("image sizes", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- let expectedSizes = {
- i: "medium",
- itiny: "tiny",
- ismall: "small",
- imedium: "medium",
- ilarge: "large",
- ifull: "full",
- iinvalid: "medium",
- ia10: "tiny",
- ia100: "tiny",
- ia200: "small",
- ia300: "small",
- ia400: "medium",
- ia500: "medium",
- ia600: "large",
- ia700: "large",
- ia800: "full",
- ia900: "full",
- ia10000: "full",
- ip1: "tiny",
- ip10: "tiny",
- ip20: "small",
- ip30: "small",
- ip40: "small",
- ip50: "medium",
- ip60: "medium",
- ip70: "large",
- ip80: "large",
- ip90: "full",
- ip100: "full",
- ip1000: "full",
- ibadwidth: "medium",
- };
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let name in expectedSizes) {
- console.log(stateVariables);
- console.log("/" + name);
- expect(stateVariables["/" + name].stateValues.size).eq(
- expectedSizes[name],
- );
- }
- });
-
- for (let name in expectedSizes) {
- cy.get(cesc2("#/" + name))
- .invoke("css", "width")
- .then((width) => parseInt(width))
- .should("be.gte", widthsBySize[expectedSizes[name]] - 4)
- .and("be.lte", widthsBySize[expectedSizes[name]] + 1);
- }
- });
-
- it("horizontal align", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/i"].stateValues.horizontalAlign).eq(
- "center",
- );
- expect(stateVariables["/ileft"].stateValues.horizontalAlign).eq(
- "left",
- );
- expect(stateVariables["/iright"].stateValues.horizontalAlign).eq(
- "right",
- );
- expect(stateVariables["/icenter"].stateValues.horizontalAlign).eq(
- "center",
- );
- expect(stateVariables["/iinvalid"].stateValues.horizontalAlign).eq(
- "center",
- );
- });
-
- // TODO: anything to check in the DOM?
- });
-
- it("displayMode", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/i"].stateValues.displayMode).eq("block");
- expect(stateVariables["/iinline"].stateValues.displayMode).eq(
- "inline",
- );
- expect(stateVariables["/iblock"].stateValues.displayMode).eq(
- "block",
- );
- expect(stateVariables["/iinvalid"].stateValues.displayMode).eq(
- "block",
- );
- });
-
- // TODO: anything to check in the DOM?
- });
-
it("image in graph", () => {
cy.window().then(async (win) => {
win.postMessage(
@@ -227,39 +42,6 @@ describe("Image Tag Tests", function () {
- Anchor 1 coordinates: $image1.anchor
- Anchor 2 coordinates: $image2.anchor
- Change anchor 1 coordinates:
- Change anchor 1 coordinates a:
- Change anchor 2 coordinates:
- Position from anchor 1: $image1.positionFromAnchor
- Position from anchor 2: $image2.positionFromAnchor
- Change position from anchor 1
-
- upperRight
- upperLeft
- lowerRight
- lowerLeft
- left
- right
- top
- bottom
- center
-
-
- Change position from anchor 2
-
- upperRight
- upperLeft
- lowerRight
- lowerLeft
- left
- right
- top
- bottom
- center
-
-
Width 1: $image1.width
Width 2: $image2.width
Change width 1
@@ -270,11 +52,6 @@ describe("Image Tag Tests", function () {
Change aspect ratio 1
Change aspect ratio 1a
Change aspect ratio 2
- Draggable 1: $draggable1
- Draggable 2: $draggable2
- Change draggable 1
- Change draggable 2
-
@@ -288,23 +65,6 @@ describe("Image Tag Tests", function () {
cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(1,3)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
-
- cy.get(cesc("#\\/pPositionFromAnchor1")).should(
- "have.text",
- "Position from anchor 1: upperright",
- );
- cy.get(cesc("#\\/pPositionFromAnchor2")).should(
- "have.text",
- "Position from anchor 2: center",
- );
- cy.get(cesc("#\\/positionFromAnchor1")).should("have.value", "1");
- cy.get(cesc("#\\/positionFromAnchor2")).should("have.value", "9");
cy.get(cesc("#\\/pWidth1")).should("have.text", "Width 1: 40%");
cy.get(cesc("#\\/pWidth2")).should("have.text", "Width 2: 50%");
cy.get(cesc("#\\/pAspectRatio1")).should(
@@ -315,15 +75,6 @@ describe("Image Tag Tests", function () {
"have.text",
"Aspect Ratio 2: NaN",
);
- cy.get(cesc("#\\/pDraggable1")).should(
- "have.text",
- "Draggable 1: true",
- );
- cy.get(cesc("#\\/pDraggable2")).should(
- "have.text",
- "Draggable 2: true",
- );
-
cy.get(cesc("#\\/image1a"))
.invoke("css", "width")
.then((str) => parseInt(str))
@@ -352,119 +103,6 @@ describe("Image Tag Tests", function () {
});
});
- cy.log("move images by dragging");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "moveImage",
- componentName: "/image1",
- args: { x: -2, y: 3 },
- });
- win.callAction1({
- actionName: "moveImage",
- componentName: "/image2",
- args: { x: 4, y: -5 },
- });
- });
-
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow").should(
- "contain.text",
- "(4,−5)",
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,3)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,−5)");
-
- cy.log("move images by entering coordinates");
-
- cy.get(cesc("#\\/anchorCoords1") + " textarea").type(
- "{home}{shift+end}{backspace}(6,7){enter}",
- { force: true },
- );
- cy.get(cesc("#\\/anchorCoords2") + " textarea").type(
- "{home}{shift+end}{backspace}(8,9){enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow").should(
- "contain.text",
- "(8,9)",
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(6,7)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(8,9)");
-
- cy.get(cesc("#\\/anchorCoords1a") + " textarea").type(
- "{home}{shift+end}{backspace}(7,6){enter}",
- { force: true },
- );
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow").should(
- "contain.text",
- "(7,6)",
- );
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(7,6)");
-
- cy.log("change position from anchor");
- cy.get(cesc("#\\/positionFromAnchor1")).select("lowerLeft");
- cy.get(cesc("#\\/positionFromAnchor2")).select("lowerRight");
-
- cy.get(cesc("#\\/pPositionFromAnchor1")).should(
- "have.text",
- "Position from anchor 1: lowerleft",
- );
- cy.get(cesc("#\\/pPositionFromAnchor2")).should(
- "have.text",
- "Position from anchor 2: lowerright",
- );
-
- cy.log("make not draggable");
-
- cy.get(cesc("#\\/draggable1")).click();
- cy.get(cesc("#\\/draggable2")).click();
- cy.get(cesc("#\\/pDraggable1")).should(
- "have.text",
- "Draggable 1: false",
- );
- cy.get(cesc("#\\/pDraggable2")).should(
- "have.text",
- "Draggable 2: false",
- );
-
- cy.log("cannot move images by dragging");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "moveImage",
- componentName: "/image1",
- args: { x: -10, y: -9 },
- });
- win.callAction1({
- actionName: "moveImage",
- componentName: "/image2",
- args: { x: -8, y: -7 },
- });
- });
-
- // since nothing will change, wait for boolean input to change to know core has responded
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(7,6)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(8,9)");
-
cy.log("change widths");
cy.get(cesc("#\\/width1") + " textarea").type(
@@ -693,130 +331,4 @@ describe("Image Tag Tests", function () {
.invoke("css", "aspectRatio")
.should("equal", "auto");
});
-
- it("rotate image in graph", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
- Rotate 1: $image1.rotate{displayDigits="8"}
- Change rotate 1
- Change rotate 1a
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- // Is there a way to test the rotation of the image in the graph?
-
- cy.get(cesc("#\\/pRotate1")).should("contain.text", "Rotate 1: 0.785");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/image1"].stateValues.rotate).eq(
- Math.PI / 4,
- );
- });
-
- cy.log("change rotate");
-
- cy.get(cesc("#\\/rotate1") + " textarea").type(
- "{end}{shift+home}{backspace}3pi/4{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/pRotate1")).should("contain.text", "Rotate 1: 2.356");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/image1"].stateValues.rotate).eq(
- (3 * Math.PI) / 4,
- );
- });
-
- cy.get(cesc("#\\/rotate1a") + " textarea").type(
- "{end}{shift+home}{backspace}-pi{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/pRotate1")).should(
- "contain.text",
- "Rotate 1: -3.14159",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/image1"].stateValues.rotate).eq(-Math.PI);
- });
- });
-
- it("image in graph, handle bad anchor coordinates", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
- Anchor 1 coordinates: $image1.anchor
- Change anchor 1 coordinates:
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x");
-
- cy.log("give good anchor coords");
-
- cy.get(cesc("#\\/anchorCoords1") + " textarea").type(
- "{home}{shift+end}{backspace}(6,7){enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow").should(
- "contain.text",
- "(6,7)",
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(6,7)");
-
- cy.log("give bad anchor coords again");
-
- cy.get(cesc("#\\/anchorCoords1") + " textarea").type(
- "{home}{shift+end}{backspace}q{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow").should("contain.text", "q");
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "q");
- });
});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/intersection.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/intersection.cy.js
deleted file mode 100644
index 4a48eb2e0..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/intersection.cy.js
+++ /dev/null
@@ -1,2081 +0,0 @@
-import { cesc, cesc2 } from "@doenet/utils";
-
-describe("Integer Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("intersections between two lines", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- (1,2)
- (2,2)
- (3,2)
- (4,2)
-
-
-
- $_line1$_line2
-
-
-
-
-
-
-
- a
- `,
- },
- "*",
- );
- });
-
- // use this to wait for page to load
- cy.get(cesc("#\\/_text1")).should("have.text", "a");
-
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(1,2)",
- );
-
- cy.log(`no intersection when lines coincide`);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log(`make first line vertical`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 3, y: 5 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 3, y: -5 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(3,5)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(3,−5)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].componentType).eq("point");
- expect(stateVariables["/int1"].stateValues.xs[0]).eq(3);
- expect(stateVariables["/int1"].stateValues.xs[1]).eq(2);
- });
-
- cy.log(`make second line vertical`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: -4, y: 5 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point4",
- args: { x: -4, y: -5 },
- });
- });
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(−4,5)",
- );
- cy.get(cesc("#\\/coords4") + " .mjx-mrow").should(
- "contain.text",
- "(−4,−5)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log(`make lines intersect again`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: -8, y: -7 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 8, y: 9 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: 4, y: 6 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point4",
- args: { x: -4, y: -6 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(−8,−7)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(8,9)",
- );
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(4,6)",
- );
- cy.get(cesc("#\\/coords4") + " .mjx-mrow").should(
- "contain.text",
- "(−4,−6)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].componentType).eq("point");
- expect(stateVariables["/int1"].stateValues.xs[0]).eq(2);
- expect(stateVariables["/int1"].stateValues.xs[1]).eq(3);
- });
-
- cy.log(`make lines equal again`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 6, y: 9 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: -6, y: -9 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(6,9)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(−6,−9)",
- );
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
- });
-
- it("intersections between three lines gives warning", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
-
- $_line1$_line2$_line3
-
-
-
- a
- `,
- },
- "*",
- );
- });
-
- // use this to wait for page to load
- cy.get(cesc("#\\/_text1")).should("have.text", "a");
-
- cy.window().then(async (win) => {
- let errorWarnings = await win.returnErrorWarnings1();
-
- expect(errorWarnings.errors.length).eq(0);
- expect(errorWarnings.warnings.length).eq(1);
-
- expect(errorWarnings.warnings[0].message).contain(
- `Haven't implemented intersection for more than two items`,
- );
- expect(errorWarnings.warnings[0].level).eq(1);
- expect(errorWarnings.warnings[0].doenetMLrange.lineBegin).eq(7);
- expect(errorWarnings.warnings[0].doenetMLrange.charBegin).eq(3);
- expect(errorWarnings.warnings[0].doenetMLrange.lineEnd).eq(7);
- expect(errorWarnings.warnings[0].doenetMLrange.charEnd).eq(52);
- });
- });
-
- it("intersection of two lines hides dynamically", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- (1,2)
- (2,2)
- (3,2)
- (4,2)
-
-
-
-
-
- Hide first intersection
-
-
- Hide second intersection
-
-
- Intersection 1: $_line1$_line2
- Intersection 2: $_line1$_line2
-
- $h1.value{assignNames="h1Val"}
- $h2.value{assignNames="h2Val"}
-
-
-
-
- a
- `,
- },
- "*",
- );
- });
-
- // use this to wait for page to load
- cy.get(cesc("#\\/_text1")).should("have.text", "a");
-
- cy.get(cesc("#\\/h1Val")).should("have.text", "false");
- cy.get(cesc("#\\/h2Val")).should("have.text", "true");
- cy.get(cesc("#\\/i1")).find(".mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/i2")).find(".mjx-mrow").should("not.exist");
-
- cy.get(cesc("#\\/h1")).click();
- cy.get(cesc("#\\/h2")).click();
- cy.get(cesc("#\\/h1Val")).should("have.text", "true");
- cy.get(cesc("#\\/h2Val")).should("have.text", "false");
- cy.get(cesc("#\\/i1")).find(".mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/i2")).find(".mjx-mrow").should("not.exist");
-
- cy.log(`make first line vertical`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 3, y: 5 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 3, y: -5 },
- });
- });
-
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(3,5)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(3,−5)",
- );
-
- cy.get(cesc("#\\/i1") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/i2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("(3,2)");
- });
-
- cy.get(cesc("#\\/h1")).click();
- cy.get(cesc("#\\/h2")).click();
- cy.get(cesc("#\\/h1Val")).should("have.text", "false");
- cy.get(cesc("#\\/h2Val")).should("have.text", "true");
- cy.get(cesc("#\\/i2") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/i1") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("(3,2)");
- });
-
- cy.log(`make second line vertical`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: -4, y: 5 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point4",
- args: { x: -4, y: -5 },
- });
- });
-
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(−4,5)",
- );
- cy.get(cesc("#\\/coords4") + " .mjx-mrow").should(
- "contain.text",
- "(−4,−5)",
- );
-
- cy.get(cesc("#\\/i1") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/i2") + " .mjx-mrow").should("not.exist");
-
- cy.get(cesc("#\\/h1")).click();
- cy.get(cesc("#\\/h2")).click();
-
- cy.get(cesc("#\\/h1Val")).should("have.text", "true");
- cy.get(cesc("#\\/h2Val")).should("have.text", "false");
- cy.get(cesc("#\\/i1") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/i2") + " .mjx-mrow").should("not.exist");
-
- cy.log(`make lines intersect again`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: -8, y: -7 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 8, y: 9 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: 4, y: 6 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point4",
- args: { x: -4, y: -6 },
- });
- });
-
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(−8,−7)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(8,9)",
- );
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(4,6)",
- );
- cy.get(cesc("#\\/coords4") + " .mjx-mrow").should(
- "contain.text",
- "(−4,−6)",
- );
-
- cy.get(cesc("#\\/i1") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/i2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("(2,3)");
- });
-
- cy.get(cesc("#\\/h1")).click();
- cy.get(cesc("#\\/h2")).click();
-
- cy.get(cesc("#\\/h1Val")).should("have.text", "false");
- cy.get(cesc("#\\/h2Val")).should("have.text", "true");
- cy.get(cesc("#\\/i1") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("(2,3)");
- });
- cy.get(cesc("#\\/i2") + " .mjx-mrow").should("not.exist");
-
- cy.log(`make lines equal again`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 6, y: 9 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: -6, y: -9 },
- });
- });
-
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(6,9)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(−6,−9)",
- );
-
- cy.get(cesc("#\\/i1") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/i2") + " .mjx-mrow").should("not.exist");
- });
-
- it("intersections between two circles", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- (3,4)
-
- (3,6)
-
-
- $c1 $c2
-
-
-
-
- $r1{name="r1a"}
- $r2{name="r2a"}
- $P1{name="P1a"}
- $P2{name="P2a"}
- $int1{name="int1a"}
- $int2{name="int2a"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.log("start with single intersection");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([3, 5]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("move first circle up");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/P1",
- args: { x: 3, y: 5 },
- });
- });
-
- cy.get(cesc2("#/int1a") + " .mjx-mrow").should("contain.text", "5.5");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs[0]).closeTo(
- 3 + Math.sqrt(3) / 2,
- 1e-12,
- );
- expect(stateVariables["/int1"].stateValues.xs[1]).eq(5.5);
- expect(stateVariables["/int2"].stateValues.xs[0]).closeTo(
- 3 - Math.sqrt(3) / 2,
- 1e-12,
- );
- expect(stateVariables["/int2"].stateValues.xs[1]).eq(5.5);
- });
-
- cy.log("increase radius of second circle");
-
- cy.get(cesc2("#/r2") + " textarea").type("{end}{backspace}2{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/int2a")).should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([3, 4]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("increase radius of second circle further");
-
- cy.get(cesc2("#/r2") + " textarea").type("{end}{backspace}4{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/int1a")).should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("increase radius of first circle");
-
- cy.get(cesc2("#/r1") + " textarea").type("{end}{backspace}2{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/r1a") + " .mjx-mrow").should("contain.text", "2");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("make 30-60-90 triangle");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/P2",
- args: { x: 3 - 2 * Math.sqrt(3), y: 5 },
- });
- });
-
- cy.get(cesc2("#/int1a") + " .mjx-mrow").should("contain.text", "(3,7)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs[0]).closeTo(3, 1e-12);
- expect(stateVariables["/int1"].stateValues.xs[1]).closeTo(7, 1e-12);
- expect(stateVariables["/int2"].stateValues.xs[0]).closeTo(3, 1e-12);
- expect(stateVariables["/int2"].stateValues.xs[1]).closeTo(3, 1e-12);
- });
-
- cy.log("increase radius of first circle");
-
- cy.get(cesc2("#/r1") + " textarea").type("{end}{backspace}4{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/r1a") + " .mjx-mrow").should("contain.text", "4");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let h = Math.sqrt(16 - 3);
-
- expect(stateVariables["/int1"].stateValues.xs[0]).closeTo(
- 3 - Math.sqrt(3),
- 1e-12,
- );
- expect(stateVariables["/int1"].stateValues.xs[1]).closeTo(
- 5 + h,
- 1e-12,
- );
- expect(stateVariables["/int2"].stateValues.xs[0]).closeTo(
- 3 - Math.sqrt(3),
- 1e-12,
- );
- expect(stateVariables["/int2"].stateValues.xs[1]).closeTo(
- 5 - h,
- 1e-12,
- );
- });
-
- cy.log("make circles identical");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/P1",
- args: { x: 3 - 2 * Math.sqrt(3), y: 5 },
- });
- });
-
- cy.get(cesc2("#/int1a")).should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- expect(stateVariables["/int2"]).eq(undefined);
- });
- });
-
- it("intersections between line and circle", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
- (3,4)
-
- (4,1)
- (4,-4)
-
-
- $l $c
-
-
-
-
- $r{name="ra"}
- $P{name="Pa"}
- $A{name="Aa"}
- $B{name="Ba"}
- $int1{name="int1a"}
- $int2{name="int2a"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.log("start with single intersection");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 4]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("move circle up and to right");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/P",
- args: { x: 4, y: 5 },
- });
- });
-
- cy.get(cesc2("#/int2a") + " .mjx-mrow").should("contain.text", "(4,4)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 6]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([4, 4]);
- });
-
- cy.log("increase radius of circle");
-
- cy.get(cesc2("#/r") + " textarea").type("{end}{backspace}2{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/int2a") + " .mjx-mrow").should("contain.text", "(4,3)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 7]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([4, 3]);
- });
-
- cy.log("move line point 1");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/A",
- args: { x: -2, y: 2 },
- });
- });
-
- cy.get(cesc2("#/int1a")).should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("increase radius of circle to make it tangent to line");
-
- cy.get(cesc2("#/r") + " textarea").type(
- "{end}{backspace}9/\\sqrt{2}{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc2("#/int1a") + " .mjx-mrow").should(
- "contain.text",
- "(−0.5,0.5)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([-0.5, 0.5]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("increase radius of circle further");
-
- cy.get(cesc2("#/r") + " textarea").type(
- "{end}{backspace}{backspace}{backspace}{backspace}9{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc2("#/int1a") + " .mjx-mrow").should(
- "contain.text",
- "(−5,5)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([-5, 5]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([4, -4]);
- });
- });
-
- it("intersection involving zero or one object returns nothing", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
- $l
- $c
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.log("start with single intersection");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_intersection1"].replacements.length).eq(0);
- expect(stateVariables["/_intersection2"].replacements.length).eq(0);
- expect(stateVariables["/_intersection3"].replacements.length).eq(0);
- expect(stateVariables["/int1"]).eq(undefined);
- expect(stateVariables["/int2"]).eq(undefined);
- expect(stateVariables["/int3"]).eq(undefined);
- });
- });
-
- it("intersections between two line segments", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- (1,2)
- (2,2)
- (3,2)
- (4,2)
-
-
-
- $l1$l2
-
-
-
-
-
-
- $int1
-
- a
- `,
- },
- "*",
- );
- });
-
- // use this to wait for page to load
- cy.get(cesc("#\\/_text1")).should("have.text", "a");
-
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(1,2)",
- );
-
- cy.log(`no intersection when line segments coincide`);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log(`make first line segment vertical`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 3, y: 5 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 3, y: -5 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(3,5)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(3,−5)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].componentType).eq("point");
- expect(stateVariables["/int1"].stateValues.xs).eqls([3, 2]);
- });
-
- cy.log("move second line segment to just miss intersection");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: 3.01, y: 2 },
- });
- });
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(3.01,2)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log("shift line segment one to intersect again");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 4, y: 5 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 4, y: -5 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(4,5)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(4,−5)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].componentType).eq("point");
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 2]);
- });
-
- cy.log("move second line segment to make it just miss again");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point4",
- args: { x: 3.99, y: 2 },
- });
- });
- cy.get(cesc("#\\/coords4") + " .mjx-mrow").should(
- "contain.text",
- "(3.99,2)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log("flip second line segment to make it intersect again");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: 6, y: 2 },
- });
- });
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(6,2)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 2]);
- });
-
- cy.log("move second line segment to make it just miss again");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point4",
- args: { x: 4.01, y: 2 },
- });
- });
- cy.get(cesc("#\\/coords4") + " .mjx-mrow").should(
- "contain.text",
- "(4.01,2)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log("shift line segment one to intersect again");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 5, y: 3 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 5, y: 1 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(5,3)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(5,1)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].componentType).eq("point");
- expect(stateVariables["/int1"].stateValues.xs).eqls([5, 2]);
- });
-
- cy.log("move second line segment to just miss intersection again");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: 4.99, y: 2 },
- });
- });
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(4.99,2)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log(`make lines intersect again`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: -8, y: -7 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 8, y: 9 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: 4, y: 6 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point4",
- args: { x: -4, y: -6 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(−8,−7)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(8,9)",
- );
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(4,6)",
- );
- cy.get(cesc("#\\/coords4") + " .mjx-mrow").should(
- "contain.text",
- "(−4,−6)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].componentType).eq("point");
- expect(stateVariables["/int1"].stateValues.xs).eqls([2, 3]);
- });
-
- cy.log("move first line segment to make it just miss again");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 2.01, y: 3 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(2.01,3)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
- });
-
- it("intersections between line and line segment", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- (1,2)
- (2,2)
- (3,2)
- (4,2)
-
-
-
- $l1$l2
-
-
-
-
-
-
- $int1
-
- a
- `,
- },
- "*",
- );
- });
-
- // use this to wait for page to load
- cy.get(cesc("#\\/_text1")).should("have.text", "a");
-
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(1,2)",
- );
-
- cy.log(`no intersection when line and line segment coincide`);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log(`make first line vertical`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 3, y: 5 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 3, y: -5 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(3,5)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(3,−5)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].componentType).eq("point");
- expect(stateVariables["/int1"].stateValues.xs).eqls([3, 2]);
- });
-
- cy.log("move second line segment to just miss intersection");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: 3.01, y: 2 },
- });
- });
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(3.01,2)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log("shift line one to intersect again");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 4, y: 5 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 4, y: -5 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(4,5)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(4,−5)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].componentType).eq("point");
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 2]);
- });
-
- cy.log("move second line segment to make it just miss again");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point4",
- args: { x: 3.99, y: 2 },
- });
- });
- cy.get(cesc("#\\/coords4") + " .mjx-mrow").should(
- "contain.text",
- "(3.99,2)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log("flip second line segment to make it intersect again");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: 6, y: 2 },
- });
- });
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(6,2)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 2]);
- });
-
- cy.log("move second line segment to make it just miss again");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point4",
- args: { x: 4.01, y: 2 },
- });
- });
- cy.get(cesc("#\\/coords4") + " .mjx-mrow").should(
- "contain.text",
- "(4.01,2)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log("shift line one to intersect again");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 5, y: 3 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 5, y: 1 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(5,3)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(5,1)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].componentType).eq("point");
- expect(stateVariables["/int1"].stateValues.xs).eqls([5, 2]);
- });
-
- cy.log("move second line segment to just miss intersection again");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: 4.99, y: 2 },
- });
- });
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(4.99,2)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log(`make lines intersect again`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: -8, y: -7 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point2",
- args: { x: 8, y: 9 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point3",
- args: { x: 4, y: 6 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point4",
- args: { x: -4, y: -6 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(−8,−7)",
- );
- cy.get(cesc("#\\/coords2") + " .mjx-mrow").should(
- "contain.text",
- "(8,9)",
- );
- cy.get(cesc("#\\/coords3") + " .mjx-mrow").should(
- "contain.text",
- "(4,6)",
- );
- cy.get(cesc("#\\/coords4") + " .mjx-mrow").should(
- "contain.text",
- "(−4,−6)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].componentType).eq("point");
- expect(stateVariables["/int1"].stateValues.xs).eqls([2, 3]);
- });
-
- cy.log("move first line and still intersects");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/_point1",
- args: { x: 2.01, y: 3 },
- });
- });
- cy.get(cesc("#\\/coords1") + " .mjx-mrow").should(
- "contain.text",
- "(2.01,3)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs[0]).closeTo(2, 0.1);
- expect(stateVariables["/int1"].stateValues.xs[1]).closeTo(3, 0.1);
- });
- });
-
- it("intersections between line segment and circle", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
- (3,4)
-
- (4,3.99)
- (4,-4)
-
-
- $l $c
-
-
-
-
- $r{name="ra"}
- $P{name="Pa"}
- $A{name="Aa"}
- $B{name="Ba"}
- $int1{name="int1a"}
- $int2{name="int2a"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.log("start with no intersection");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("move line point 1 to intersect");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/A",
- args: { x: 4, y: 4 },
- });
- });
-
- cy.get(cesc2("#/int1a") + " .mjx-mrow").should("contain.text", "(4,4)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 4]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("move circle up and to right");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/P",
- args: { x: 4, y: 5 },
- });
- });
-
- cy.get(cesc2("#/Pa") + " .mjx-mrow").should("contain.text", "(4,5)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 4]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("extend line segment to intersect twice");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/A",
- args: { x: 4, y: 6 },
- });
- });
-
- cy.get(cesc2("#/int2a") + " .mjx-mrow").should("contain.text", "(4,4)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 6]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([4, 4]);
- });
-
- cy.log("increase radius of circle");
-
- cy.get(cesc2("#/r") + " textarea").type("{end}{backspace}2{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/int1a") + " .mjx-mrow").should("contain.text", "(4,3)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 3]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("flip line segment to intersect at top");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/B",
- args: { x: 4, y: 7 },
- });
- });
-
- cy.get(cesc2("#/int1a") + " .mjx-mrow").should("contain.text", "(4,7)");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 7]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("extend line segment to intersect twice");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/A",
- args: { x: 4, y: 3 },
- });
- });
-
- cy.get(cesc2("#/int2a") + " .mjx-mrow").should("contain.text", "(4,3)");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 7]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([4, 3]);
- });
-
- cy.log("move line segment");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/A",
- args: { x: -0.5, y: 0.5 },
- });
- win.callAction1({
- actionName: "movePoint",
- componentName: "/B",
- args: { x: 3, y: -3 },
- });
- });
-
- cy.get(cesc2("#/int1a")).should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("increase radius of circle to make it tangent to line");
-
- cy.get(cesc2("#/r") + " textarea").type(
- "{end}{backspace}9/\\sqrt{2}{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc2("#/int1a") + " .mjx-mrow").should(
- "contain.text",
- "(−0.5,0.5)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([-0.5, 0.5]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("increase radius of circle further");
-
- cy.get(cesc2("#/r") + " textarea").type(
- "{end}{backspace}{backspace}{backspace}{backspace}9{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc2("#/int1a") + " .mjx-mrow").should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("extend bottom of line segment");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/B",
- args: { x: 4, y: -4 },
- });
- });
-
- cy.get(cesc2("#/int1a") + " .mjx-mrow").should(
- "contain.text",
- "(4,−4)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, -4]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("extend top of line segment");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: "/A",
- args: { x: -5, y: 5 },
- });
- });
-
- cy.get(cesc2("#/int1a") + " .mjx-mrow").should(
- "contain.text",
- "(−5,5)",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([-5, 5]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([4, -4]);
- });
- });
-
- it("intersections between two polygons", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
-
- $p1$p2
-
-
-
-
- $int1 $int2 $int3 $int4
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/p11") + " .mjx-mrow").should("contain.text", "(0,1)");
-
- cy.log(`all three triangle vertices are intersections`);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([1, 0]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([0, 1]);
- expect(stateVariables["/int3"].stateValues.xs).eqls([0, 0]);
- expect(stateVariables["/int4"]).eq(undefined);
- });
-
- cy.log(
- `extending rectangle to upper right does not change intersections`,
- );
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolygon",
- componentName: "/p2",
- args: {
- pointCoords: { 2: [4, 2] },
- },
- });
- });
-
- cy.get(cesc2("#/p23") + " .mjx-mrow").should("contain.text", "(4,2)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([1, 0]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([0, 1]);
- expect(stateVariables["/int3"].stateValues.xs).eqls([0, 0]);
- expect(stateVariables["/int4"]).eq(undefined);
- });
-
- cy.log(`moving bottom of rectangle down removes one intersection`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolygon",
- componentName: "/p2",
- args: {
- pointCoords: { 0: [0, -1] },
- },
- });
- });
-
- cy.get(cesc2("#/p21") + " .mjx-mrow").should("contain.text", "(0,−1)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([0, 1]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([0, 0]);
- expect(stateVariables["/int3"]).eq(undefined);
- });
-
- cy.log(`moving left of rectangle left removes all intersections`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolygon",
- componentName: "/p2",
- args: {
- pointCoords: { 0: [-1, -1] },
- },
- });
- });
-
- cy.get(cesc2("#/p21") + " .mjx-mrow").should("contain.text", "(−1,−1)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log(`move top of triangle upward`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolygon",
- componentName: "/p1",
- args: {
- pointCoords: { 0: [0, 4] },
- },
- });
- });
-
- cy.get(cesc2("#/p11") + " .mjx-mrow").should("contain.text", "(0,4)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([0.5, 2]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([0, 2]);
- expect(stateVariables["/int3"]).eq(undefined);
- });
-
- cy.log(`move right of triangle rightward`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolygon",
- componentName: "/p1",
- args: {
- pointCoords: { 1: [6, 0] },
- },
- });
- });
-
- cy.get(cesc2("#/p12") + " .mjx-mrow").should("contain.text", "(6,0)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([4, 4 / 3]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([3, 2]);
- expect(stateVariables["/int3"].stateValues.xs).eqls([4, 0]);
- expect(stateVariables["/int4"].stateValues.xs).eqls([0, 2]);
- expect(stateVariables["/int5"]).eq(undefined);
- });
- });
-
- it("intersections between two polylines", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
-
- $p1$p2
-
-
-
-
- $int1 $int2 $int3 $int4
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/p11") + " .mjx-mrow").should("contain.text", "(0,1)");
-
- cy.log(`all three triangle vertices are intersections`);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([1, 0]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([0, 1]);
- expect(stateVariables["/int3"]).eq(undefined);
- });
-
- cy.log(`extending polyline2 to right does not change intersections`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolyline",
- componentName: "/p2",
- args: {
- pointCoords: { 1: [4, 0] },
- },
- });
- });
-
- cy.get(cesc2("#/p22") + " .mjx-mrow").should("contain.text", "(4,0)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([1, 0]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([0, 1]);
- expect(stateVariables["/int3"]).eq(undefined);
- });
-
- cy.log(`extending top of polyline2 up removes one intersection`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolyline",
- componentName: "/p2",
- args: {
- pointCoords: { 3: [0, 4] },
- },
- });
- });
-
- cy.get(cesc2("#/p24") + " .mjx-mrow").should("contain.text", "(0,4)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([1, 0]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log(`extending bottom polygone 2 removes all intersections`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolyline",
- componentName: "/p2",
- args: {
- pointCoords: { 0: [0, -2] },
- },
- });
- });
-
- cy.get(cesc2("#/p21") + " .mjx-mrow").should("contain.text", "(0,−2)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"]).eq(undefined);
- });
-
- cy.log(`move top of polyline 1 rightward`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolyline",
- componentName: "/p1",
- args: {
- pointCoords: { 0: [4, 1] },
- },
- });
- });
-
- cy.get(cesc2("#/p11") + " .mjx-mrow").should("contain.text", "(4,1)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([2.5, 0.5]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log(`move middle of polyline1 down`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolyline",
- componentName: "/p1",
- args: {
- pointCoords: { 1: [-1, -4] },
- },
- });
- });
-
- cy.get(cesc2("#/p12") + " .mjx-mrow").should("contain.text", "(−1,−4)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([2, -1]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([3.25, 0.25]);
- expect(stateVariables["/int3"]).eq(undefined);
- });
-
- cy.log(`move other end of polyline1 up`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolyline",
- componentName: "/p1",
- args: {
- pointCoords: { 2: [1, 6] },
- },
- });
- });
-
- cy.get(cesc2("#/p13") + " .mjx-mrow").should("contain.text", "(1,6)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([2, -1]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([3.25, 0.25]);
- expect(stateVariables["/int3"].stateValues.xs).eqls([0.375, 2.875]);
- expect(stateVariables["/int4"]).eq(undefined);
- });
- });
-
- it("intersections between polygon and circle", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
- (0,0)
-
-
-
- $p$c
-
-
-
- $P{name="Pa"}
- $r{name="ra"}
- $int1 $int2 $int3 $int4 $int5 $int6
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/p11") + " .mjx-mrow").should("contain.text", "(0,1)");
-
- cy.log(`all three triangle vertices are intersections`);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([0, 1]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([1, 0]);
- expect(stateVariables["/int3"]).eq(undefined);
- });
-
- cy.log(`extend triangle down`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolygon",
- componentName: "/p",
- args: {
- pointCoords: { 2: [0, -10] },
- },
- });
- });
-
- cy.get(cesc2("#/p13") + " .mjx-mrow").should("contain.text", "(0,−10)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([0, 1]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([1, 0]);
- expect(stateVariables["/int3"].stateValues.xs[0]).closeTo(1, 0.1);
- expect(stateVariables["/int3"].stateValues.xs[1]).closeTo(
- -0.1,
- 0.1,
- );
- expect(stateVariables["/int4"].stateValues.xs).eqls([0, -1]);
- expect(stateVariables["/int5"]).eq(undefined);
- });
-
- cy.log(`extend triangle right`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolygon",
- componentName: "/p",
- args: {
- pointCoords: { 1: [6, 1] },
- },
- });
- });
-
- cy.get(cesc2("#/p12") + " .mjx-mrow").should("contain.text", "(6,1)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([0, 1]);
- expect(stateVariables["/int2"].stateValues.xs).eqls([0, -1]);
- expect(stateVariables["/int3"]).eq(undefined);
- });
-
- cy.log(`extend triangle left`);
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePolygon",
- componentName: "/p",
- args: {
- pointCoords: { 0: [-6, 1] },
- },
- });
- });
-
- cy.get(cesc2("#/p11") + " .mjx-mrow").should("contain.text", "(−6,1)");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([0, 1]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
-
- cy.log("Increase readius of circle to 6");
- cy.get(cesc2("#/r") + " textarea").type("{end}{backspace}6{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/ra") + " .mjx-mrow").should("contain.text", "6");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs[0]).closeTo(6, 0.1);
- expect(stateVariables["/int1"].stateValues.xs[1]).eq(1);
- expect(stateVariables["/int2"].stateValues.xs[0]).closeTo(-6, 0.1);
- expect(stateVariables["/int2"].stateValues.xs[1]).eq(1);
- expect(stateVariables["/int3"].stateValues.xs[0]).closeTo(6, 0.1);
- expect(stateVariables["/int3"].stateValues.xs[1]).closeTo(0.9, 0.1);
- expect(stateVariables["/int4"].stateValues.xs[0]).closeTo(2.5, 0.1);
- expect(stateVariables["/int4"].stateValues.xs[1]).closeTo(
- -5.5,
- 0.1,
- );
- expect(stateVariables["/int5"].stateValues.xs[0]).closeTo(-6, 0.1);
- expect(stateVariables["/int5"].stateValues.xs[1]).closeTo(0.9, 0.1);
- expect(stateVariables["/int6"].stateValues.xs[0]).closeTo(
- -2.5,
- 0.1,
- );
- expect(stateVariables["/int6"].stateValues.xs[1]).closeTo(
- -5.5,
- 0.1,
- );
- expect(stateVariables["/int7"]).eq(undefined);
- });
-
- cy.log("Increase readius of circle to 10");
- cy.get(cesc2("#/r") + " textarea").type("{end}{backspace}10{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/ra") + " .mjx-mrow").should("contain.text", "10");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/int1"].stateValues.xs).eqls([0, -10]);
- expect(stateVariables["/int2"]).eq(undefined);
- });
- });
-
- it("aslist", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- $p$c
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/pdefault") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,1)");
- cy.get(cesc2("#/pdefault") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(1,0)");
-
- cy.get(cesc2("#/pdefault")).should("contain.text", "), (");
-
- cy.get(cesc2("#/pnolist") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,1)");
- cy.get(cesc2("#/pnolist") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(1,0)");
- cy.get(cesc2("#/pnolist")).should("not.contain.text", "), (");
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/label.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/label.cy.js
deleted file mode 100644
index eafabfbee..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/label.cy.js
+++ /dev/null
@@ -1,845 +0,0 @@
-import { cesc, cesc2 } from "@doenet/utils";
-
-describe("Label Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("label in graph, text and math", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Hello \\frac{\\partial f}{\\partial x}
- Bye \\int_a^b f(x) dx
-
-
- Anchor 1 coordinates: $label1.anchor
- Anchor 2 coordinates: $label2.anchor
- Change anchor 1 coordinates:
- Change anchor 2 coordinates:
- Position from anchor 1: $label1.positionFromAnchor
- Position from anchor 2: $label2.positionFromAnchor
- Change position from anchor 1
-
- upperRight
- upperLeft
- lowerRight
- lowerLeft
- left
- right
- top
- bottom
- center
-
-
- Change position from anchor 2
-
- upperRight
- upperLeft
- lowerRight
- lowerLeft
- left
- right
- top
- bottom
- center
-
-
- Draggable 1: $draggable1
- Draggable 2: $draggable2
- Change draggable 1
- Change draggable 2
- Content 1: $label1
- Content 2: $label2
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(1,3)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
-
- cy.get(cesc("#\\/pPositionFromAnchor1")).should(
- "have.text",
- "Position from anchor 1: upperright",
- );
- cy.get(cesc("#\\/pPositionFromAnchor2")).should(
- "have.text",
- "Position from anchor 2: center",
- );
- cy.get(cesc("#\\/positionFromAnchor1")).should("have.value", "1");
- cy.get(cesc("#\\/positionFromAnchor2")).should("have.value", "9");
- cy.get(cesc("#\\/pDraggable1")).should(
- "have.text",
- "Draggable 1: true",
- );
- cy.get(cesc("#\\/pDraggable2")).should(
- "have.text",
- "Draggable 2: true",
- );
- cy.get(cesc("#\\/pContent1")).should(
- "contain.text",
- "Content 1: Hello ∂f∂x",
- );
- cy.get(cesc("#\\/pContent1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∂f∂x");
- cy.get(cesc("#\\/pContent2")).should(
- "contain.text",
- "Content 2: Bye ∫baf(x)dx",
- );
- cy.get(cesc("#\\/pContent2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∫baf(x)dx");
-
- cy.log("move labels by dragging");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "moveLabel",
- componentName: "/label1",
- args: { x: -2, y: 3 },
- });
- win.callAction1({
- actionName: "moveLabel",
- componentName: "/label2",
- args: { x: 4, y: -5 },
- });
- });
-
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow").should(
- "contain.text",
- "(4,−5)",
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,3)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,−5)");
-
- cy.log("move labels by entering coordinates");
-
- cy.get(cesc("#\\/anchorCoords1") + " textarea").type(
- "{home}{shift+end}{backspace}(6,7){enter}",
- { force: true },
- );
- cy.get(cesc("#\\/anchorCoords2") + " textarea").type(
- "{home}{shift+end}{backspace}(8,9){enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow").should(
- "contain.text",
- "(8,9)",
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(6,7)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(8,9)");
-
- cy.log("change position from anchor");
- cy.get(cesc("#\\/positionFromAnchor1")).select("lowerLeft");
- cy.get(cesc("#\\/positionFromAnchor2")).select("lowerRight");
-
- cy.get(cesc("#\\/pPositionFromAnchor1")).should(
- "have.text",
- "Position from anchor 1: lowerleft",
- );
- cy.get(cesc("#\\/pPositionFromAnchor2")).should(
- "have.text",
- "Position from anchor 2: lowerright",
- );
-
- cy.log("make not draggable");
-
- cy.get(cesc("#\\/draggable1")).click();
- cy.get(cesc("#\\/draggable2")).click();
- cy.get(cesc("#\\/pDraggable1")).should(
- "have.text",
- "Draggable 1: false",
- );
- cy.get(cesc("#\\/pDraggable2")).should(
- "have.text",
- "Draggable 2: false",
- );
-
- cy.log("cannot move labels by dragging");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "moveLabel",
- componentName: "/label1",
- args: { x: -10, y: -9 },
- });
- win.callAction1({
- actionName: "moveLabel",
- componentName: "/label2",
- args: { x: -8, y: -7 },
- });
- });
-
- // since nothing will change, wait for boolean input to change to know core has responded
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(6,7)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(8,9)");
- });
-
- it("label in graph, just text", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Hello
- Bye
-
-
- Anchor 1 coordinates: $label1.anchor
- Anchor 2 coordinates: $label2.anchor
- Change anchor 1 coordinates:
- Change anchor 2 coordinates:
- Position from anchor 1: $label1.positionFromAnchor
- Position from anchor 2: $label2.positionFromAnchor
- Change position from anchor 1
-
- upperRight
- upperLeft
- lowerRight
- lowerLeft
- left
- right
- top
- bottom
- center
-
-
- Change position from anchor 2
-
- upperRight
- upperLeft
- lowerRight
- lowerLeft
- left
- right
- top
- bottom
- center
-
-
- Draggable 1: $draggable1
- Draggable 2: $draggable2
- Change draggable 1
- Change draggable 2
- Content 1: $label1
- Content 2: $label2
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(1,3)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
-
- cy.get(cesc("#\\/pPositionFromAnchor1")).should(
- "have.text",
- "Position from anchor 1: upperright",
- );
- cy.get(cesc("#\\/pPositionFromAnchor2")).should(
- "have.text",
- "Position from anchor 2: center",
- );
- cy.get(cesc("#\\/positionFromAnchor1")).should("have.value", "1");
- cy.get(cesc("#\\/positionFromAnchor2")).should("have.value", "9");
- cy.get(cesc("#\\/pDraggable1")).should(
- "have.text",
- "Draggable 1: true",
- );
- cy.get(cesc("#\\/pDraggable2")).should(
- "have.text",
- "Draggable 2: true",
- );
- cy.get(cesc("#\\/pContent1")).should("have.text", "Content 1: Hello");
- cy.get(cesc("#\\/pContent2")).should("have.text", "Content 2: Bye");
-
- cy.log("move labels by dragging");
-
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "moveLabel",
- componentName: "/label1",
- args: { x: -2, y: 3 },
- });
- win.callAction1({
- actionName: "moveLabel",
- componentName: "/label2",
- args: { x: 4, y: -5 },
- });
- });
-
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow").should(
- "contain.text",
- "(4,−5)",
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,3)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,−5)");
-
- cy.log("move labels by entering coordinates");
-
- cy.get(cesc("#\\/anchorCoords1") + " textarea").type(
- "{home}{shift+end}{backspace}(6,7){enter}",
- { force: true },
- );
- cy.get(cesc("#\\/anchorCoords2") + " textarea").type(
- "{home}{shift+end}{backspace}(8,9){enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow").should(
- "contain.text",
- "(8,9)",
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(6,7)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(8,9)");
-
- cy.log("change position from anchor");
- cy.get(cesc("#\\/positionFromAnchor1")).select("lowerLeft");
- cy.get(cesc("#\\/positionFromAnchor2")).select("lowerRight");
-
- cy.get(cesc("#\\/pPositionFromAnchor1")).should(
- "have.text",
- "Position from anchor 1: lowerleft",
- );
- cy.get(cesc("#\\/pPositionFromAnchor2")).should(
- "have.text",
- "Position from anchor 2: lowerright",
- );
-
- cy.log("make not draggable");
-
- cy.get(cesc("#\\/draggable1")).click();
- cy.get(cesc("#\\/draggable2")).click();
- cy.get(cesc("#\\/pDraggable1")).should(
- "have.text",
- "Draggable 1: false",
- );
- cy.get(cesc("#\\/pDraggable2")).should(
- "have.text",
- "Draggable 2: false",
- );
-
- cy.log("cannot move labels by dragging");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "moveLabel",
- componentName: "/label1",
- args: { x: -10, y: -9 },
- });
- win.callAction1({
- actionName: "moveLabel",
- componentName: "/label2",
- args: { x: -8, y: -7 },
- });
- });
-
- // since nothing will change, wait for boolean input to change to know core has responded
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(6,7)");
- cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(8,9)");
- });
-
- it("label in graph, handle bad anchor coordinates", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- Hello
-
-
-
- Anchor 1 coordinates: $label1.anchor
- Change anchor 1 coordinates:
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x");
-
- cy.log("give good anchor coords");
-
- cy.get(cesc("#\\/anchorCoords1") + " textarea").type(
- "{home}{shift+end}{backspace}(6,7){enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow").should(
- "contain.text",
- "(6,7)",
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(6,7)");
-
- cy.log("give bad anchor coords again");
-
- cy.get(cesc("#\\/anchorCoords1") + " textarea").type(
- "{home}{shift+end}{backspace}q{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow").should("contain.text", "q");
-
- cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "q");
- });
-
- it("color label via style", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
-
-
-
- Style number:
-
- one: x^2 is $no_style.textStyleDescription , i.e., the text color is $no_style.textColor and the background color is $no_style.backgroundColor .
- two: x^3 is $fixed_style.textStyleDescription , i.e., the text color is $fixed_style.textColor and the background color is $fixed_style.backgroundColor .
- three: x^4 is $variable_style.textStyleDescription , i.e., the text color is $variable_style.textColor and the background color is $variable_style.backgroundColor .
-
-
- $no_style{anchor="(1,2)"}
- $fixed_style{anchor="(3,4)"}
- $variable_style
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/tsd_no_style")).should("have.text", "black");
- cy.get(cesc("#\\/tc_no_style")).should("have.text", "black");
- cy.get(cesc("#\\/bc_no_style")).should("have.text", "none");
-
- cy.get(cesc("#\\/tsd_fixed_style")).should("have.text", "green");
- cy.get(cesc("#\\/tc_fixed_style")).should("have.text", "green");
- cy.get(cesc("#\\/bc_fixed_style")).should("have.text", "none");
-
- cy.get(cesc("#\\/tsd_variable_style")).should("have.text", "black");
- cy.get(cesc("#\\/tc_variable_style")).should("have.text", "black");
- cy.get(cesc("#\\/bc_variable_style")).should("have.text", "none");
-
- cy.get(cesc("#\\/no_style")).should(
- "have.css",
- "color",
- "rgb(0, 0, 0)",
- );
- cy.get(cesc("#\\/no_style")).should(
- "have.css",
- "background-color",
- "rgba(0, 0, 0, 0)",
- );
-
- cy.get(cesc("#\\/fixed_style")).should(
- "have.css",
- "color",
- "rgb(0, 128, 0)",
- );
- cy.get(cesc("#\\/fixed_style")).should(
- "have.css",
- "background-color",
- "rgba(0, 0, 0, 0)",
- );
-
- cy.get(cesc("#\\/variable_style")).should(
- "have.css",
- "color",
- "rgb(0, 0, 0)",
- );
- cy.get(cesc("#\\/variable_style")).should(
- "have.css",
- "background-color",
- "rgba(0, 0, 0, 0)",
- );
-
- // TODO: how to test color in graph
-
- cy.get(cesc("#\\/sn") + " textarea").type("{end}{backspace}2{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/tsd_variable_style")).should("have.text", "green");
- cy.get(cesc("#\\/tc_variable_style")).should("have.text", "green");
- cy.get(cesc("#\\/bc_variable_style")).should("have.text", "none");
-
- cy.get(cesc("#\\/tsd_no_style")).should("have.text", "black");
- cy.get(cesc("#\\/tc_no_style")).should("have.text", "black");
- cy.get(cesc("#\\/bc_no_style")).should("have.text", "none");
-
- cy.get(cesc("#\\/tsd_fixed_style")).should("have.text", "green");
- cy.get(cesc("#\\/tc_fixed_style")).should("have.text", "green");
- cy.get(cesc("#\\/bc_fixed_style")).should("have.text", "none");
-
- cy.get(cesc("#\\/no_style")).should(
- "have.css",
- "color",
- "rgb(0, 0, 0)",
- );
- cy.get(cesc("#\\/no_style")).should(
- "have.css",
- "background-color",
- "rgba(0, 0, 0, 0)",
- );
-
- cy.get(cesc("#\\/fixed_style")).should(
- "have.css",
- "color",
- "rgb(0, 128, 0)",
- );
- cy.get(cesc("#\\/fixed_style")).should(
- "have.css",
- "background-color",
- "rgba(0, 0, 0, 0)",
- );
-
- cy.get(cesc("#\\/variable_style")).should(
- "have.css",
- "color",
- "rgb(0, 128, 0)",
- );
- cy.get(cesc("#\\/variable_style")).should(
- "have.css",
- "background-color",
- "rgba(0, 0, 0, 0)",
- );
-
- cy.get(cesc("#\\/sn") + " textarea").type("{end}{backspace}3{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/tsd_variable_style")).should(
- "have.text",
- "red with a blue background",
- );
- cy.get(cesc("#\\/tc_variable_style")).should("have.text", "red");
- cy.get(cesc("#\\/bc_variable_style")).should("have.text", "blue");
-
- cy.get(cesc("#\\/tsd_no_style")).should("have.text", "black");
- cy.get(cesc("#\\/tc_no_style")).should("have.text", "black");
- cy.get(cesc("#\\/bc_no_style")).should("have.text", "none");
-
- cy.get(cesc("#\\/tsd_fixed_style")).should("have.text", "green");
- cy.get(cesc("#\\/tc_fixed_style")).should("have.text", "green");
- cy.get(cesc("#\\/bc_fixed_style")).should("have.text", "none");
-
- cy.get(cesc("#\\/no_style")).should(
- "have.css",
- "color",
- "rgb(0, 0, 0)",
- );
- cy.get(cesc("#\\/no_style")).should(
- "have.css",
- "background-color",
- "rgba(0, 0, 0, 0)",
- );
-
- cy.get(cesc("#\\/fixed_style")).should(
- "have.css",
- "color",
- "rgb(0, 128, 0)",
- );
- cy.get(cesc("#\\/fixed_style")).should(
- "have.css",
- "background-color",
- "rgba(0, 0, 0, 0)",
- );
-
- cy.get(cesc("#\\/variable_style")).should(
- "have.css",
- "color",
- "rgb(255, 0, 0)",
- );
- cy.get(cesc("#\\/variable_style")).should(
- "have.css",
- "background-color",
- "rgb(0, 0, 255)",
- );
- });
-
- it("label copied by plain macro, but not value, reflects style and anchor position", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
-
-
-
- a
-
-
- one: x^2
- two: x^3
-
-
-
-
-
-
- $m1
- $m2
-
-
-
-
-
- $m1.value
- $m2.value
-
-
-
-
- $m1 $m2
-
- $m1.value $m2.value
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let m1aName = stateVariables["/g2"].activeChildren[0].componentName;
- let m2aName = stateVariables["/g2"].activeChildren[1].componentName;
- let m1bName = stateVariables["/g3"].activeChildren[0].componentName;
- let m2bName = stateVariables["/g3"].activeChildren[1].componentName;
- let m1cName = stateVariables["/p1"].activeChildren[0].componentName;
- let m2cName = stateVariables["/p1"].activeChildren[2].componentName;
- let m1dName = stateVariables["/p2"].activeChildren[0].componentName;
- let m2dName = stateVariables["/p2"].activeChildren[2].componentName;
-
- let m1cAnchor = "#" + cesc2(m1cName) + " .mjx-mrow";
- let m2cAnchor = "#" + cesc2(m2cName) + " .mjx-mrow";
- let m1dAnchor = "#" + cesc2(m1dName) + " .mjx-mrow";
- let m2dAnchor = "#" + cesc2(m2dName) + " .mjx-mrow";
-
- cy.get(m1cAnchor).eq(0).should("have.text", "x2");
- cy.get(m1dAnchor).eq(0).should("have.text", "x2");
- cy.get(m2cAnchor).eq(0).should("have.text", "x3");
- cy.get(m2dAnchor).eq(0).should("have.text", "x3");
-
- cy.get(m1cAnchor).should("have.css", "color", "rgb(0, 128, 0)");
- cy.get(m1dAnchor).should("have.css", "color", "rgb(0, 0, 0)");
- cy.get(m2cAnchor).should("have.css", "color", "rgb(255, 0, 0)");
- cy.get(m2dAnchor).should("have.css", "color", "rgb(0, 0, 0)");
-
- cy.get(cesc("#\\/m1coords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/m2coords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(3,4)");
- cy.get(cesc("#\\/m1acoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/m2acoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(3,4)");
- cy.get(cesc("#\\/m1bcoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/m2bcoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
-
- cy.log("move first labels");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "moveLabel",
- componentName: "/m1",
- args: { x: -2, y: 3 },
- });
- win.callAction1({
- actionName: "moveLabel",
- componentName: "/m2",
- args: { x: 4, y: -5 },
- });
- });
-
- cy.get(cesc("#\\/m2coords") + " .mjx-mrow").should(
- "contain.text",
- "(4,−5)",
- );
-
- cy.get(cesc("#\\/m1coords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,3)");
- cy.get(cesc("#\\/m2coords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,−5)");
- cy.get(cesc("#\\/m1acoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,3)");
- cy.get(cesc("#\\/m2acoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,−5)");
- cy.get(cesc("#\\/m1bcoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/m2bcoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
-
- cy.log("move second labels");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "moveLabel",
- componentName: m1aName,
- args: { x: 7, y: 1 },
- });
- win.callAction1({
- actionName: "moveLabel",
- componentName: m2aName,
- args: { x: -8, y: 2 },
- });
- });
-
- cy.get(cesc("#\\/m2coords") + " .mjx-mrow").should(
- "contain.text",
- "(−8,2)",
- );
-
- cy.get(cesc("#\\/m1coords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(7,1)");
- cy.get(cesc("#\\/m2coords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−8,2)");
- cy.get(cesc("#\\/m1acoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(7,1)");
- cy.get(cesc("#\\/m2acoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−8,2)");
- cy.get(cesc("#\\/m1bcoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/m2bcoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
-
- cy.log("move third labels");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "moveLabel",
- componentName: m1bName,
- args: { x: -6, y: 3 },
- });
- win.callAction1({
- actionName: "moveLabel",
- componentName: m2bName,
- args: { x: -5, y: -4 },
- });
- });
-
- cy.get(cesc("#\\/m2bcoords") + " .mjx-mrow").should(
- "contain.text",
- "(−5,−4)",
- );
-
- cy.get(cesc("#\\/m1coords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(7,1)");
- cy.get(cesc("#\\/m2coords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−8,2)");
- cy.get(cesc("#\\/m1acoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(7,1)");
- cy.get(cesc("#\\/m2acoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−8,2)");
- cy.get(cesc("#\\/m1bcoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−6,3)");
- cy.get(cesc("#\\/m2bcoords") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−5,−4)");
- });
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/legend.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/legend.cy.js
deleted file mode 100644
index 5ce58a3f2..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/legend.cy.js
+++ /dev/null
@@ -1,1171 +0,0 @@
-import { cesc } from "@doenet/utils";
-
-describe("Legend Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("legend includes unique styles, points separate, closed path not separate", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- (x+5)^2
- (-3,2)
-
-
- (-5,6)
- (0,-6)
-
-
- parabola and circle
- $_point1 and $_point2
- vector
- r^2
- This will be unused
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "upperright",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(4);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("parabola and circle");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .value,
- ).eq(
- "\\(\\left( -3, 2 \\right)\\) and \\(\\left( -5, 6 \\right)\\)",
- );
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .hasLatex,
- ).eq(true);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .value,
- ).eq("vector");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .value,
- ).eq("\\(r^2\\)");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .hasLatex,
- ).eq(true);
- });
- });
-
- it("displayClosedSwatches separates closed path", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- (x+5)^2
- (-3,2)
-
-
- (-5,6)
- (0,-6)
-
-
- parabola
- $_point1 and $_point2
- circle
- vector
- r^2
- This will be unused
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "upperright",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(5);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("parabola");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .value,
- ).eq(
- "\\(\\left( -3, 2 \\right)\\) and \\(\\left( -5, 6 \\right)\\)",
- );
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .hasLatex,
- ).eq(true);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .swatchType,
- ).eq("rectangle");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .value,
- ).eq("circle");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .value,
- ).eq("vector");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4].label
- .value,
- ).eq("\\(r^2\\)");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4].label
- .hasLatex,
- ).eq(true);
- });
- });
-
- it("legend with dynamical functions", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
- sin(x)+$v
-
-
-
-
- hi
- \\int_a^b f(x) \\,dx is it!
- only this
- x^2
-
-
-
- $n.value{assignNames="n2"}
- $pos.value{assignNames="pos2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "upperright",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(1);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("hi");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
- });
-
- cy.get(cesc("#\\/pos_input")).type("upperLeft{enter}");
-
- cy.get(cesc("#\\/pos2")).should("have.text", "upperLeft");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "upperleft",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(1);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("hi");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
- });
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}3{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/n2") + " .mjx-mrow").should("contain.text", "3");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "upperleft",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(2);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("hi");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .value,
- ).eq("\\(\\int_a^b f(x) \\,dx\\) is it!");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .hasLatex,
- ).eq(true);
- });
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}4{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/n2") + " .mjx-mrow").should("contain.text", "4");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "upperleft",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(2);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("hi");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .value,
- ).eq("\\(\\int_a^b f(x) \\,dx\\) is it!");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .hasLatex,
- ).eq(true);
- });
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}5{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/n2") + " .mjx-mrow").should("contain.text", "5");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "upperleft",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(3);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("hi");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .value,
- ).eq("\\(\\int_a^b f(x) \\,dx\\) is it!");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .hasLatex,
- ).eq(true);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .value,
- ).eq("only this");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .hasLatex,
- ).eq(false);
- });
-
- cy.get(cesc("#\\/pos_input")).clear().type("LowerRight{enter}");
-
- cy.get(cesc("#\\/pos2")).should("have.text", "LowerRight");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "lowerright",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(3);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("hi");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .value,
- ).eq("\\(\\int_a^b f(x) \\,dx\\) is it!");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .hasLatex,
- ).eq(true);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .value,
- ).eq("only this");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .hasLatex,
- ).eq(false);
- });
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}8{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/n2") + " .mjx-mrow").should("contain.text", "8");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "lowerright",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(4);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("hi");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .value,
- ).eq("\\(\\int_a^b f(x) \\,dx\\) is it!");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .hasLatex,
- ).eq(true);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .value,
- ).eq("only this");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .value,
- ).eq("\\(x^2\\)");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .hasLatex,
- ).eq(true);
- });
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}1{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/n2") + " .mjx-mrow").should("contain.text", "1");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "lowerright",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(1);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("hi");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
- });
-
- cy.get(cesc("#\\/pos_input")).clear().type("lowerleft{enter}");
-
- cy.get(cesc("#\\/pos2")).should("have.text", "lowerleft");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "lowerleft",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(1);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("hi");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
- });
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}10{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/n2") + " .mjx-mrow").should("contain.text", "10");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "lowerleft",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(4);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("hi");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .value,
- ).eq("\\(\\int_a^b f(x) \\,dx\\) is it!");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .hasLatex,
- ).eq(true);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .value,
- ).eq("only this");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .hasLatex,
- ).eq(false);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .value,
- ).eq("\\(x^2\\)");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .hasLatex,
- ).eq(true);
- });
- });
-
- it("legend with forObject", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
- display closed swatches:
-
-
-
- (-3,2)
-
-
- (-5,6)
- (0,-6)
- (x+5)^2
-
-
-
-
- targeted function
- first one
- second one x^2
- targeted point B
- third one
- This will be unused
- fourth one
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "upperright",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(5);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("targeted function");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .lineStyle,
- ).eq("dashed");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .lineColor,
- ).eq("blue");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .lineWidth,
- ).eq(2);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .lineOpacity,
- ).eq(0.8);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .value,
- ).eq("first one");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .hasLatex,
- ).eq(false);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .lineStyle,
- ).eq("solid");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .lineColor,
- ).eq("cyan");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .lineWidth,
- ).eq(3);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .lineOpacity,
- ).eq(0.7);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .value,
- ).eq("second one \\(x^2\\)");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .hasLatex,
- ).eq(true);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .markerStyle,
- ).eq("square");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .markerColor,
- ).eq("blue");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .markerSize,
- ).eq(4);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .value,
- ).eq("targeted point \\(B\\)");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .hasLatex,
- ).eq(true);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .markerStyle,
- ).eq("triangle");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .markerColor,
- ).eq("green");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .markerSize,
- ).eq(5);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4].label
- .value,
- ).eq("third one");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4].label
- .hasLatex,
- ).eq(false);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4]
- .lineStyle,
- ).eq("dotted");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4]
- .lineColor,
- ).eq("black");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4]
- .lineWidth,
- ).eq(4);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4]
- .lineOpacity,
- ).eq(0.6);
- });
-
- cy.log("change displayClosedSwatches to true");
- cy.get(cesc("#\\/closedSwatches")).click();
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- expect(stateVariables["/_legend1"].stateValues.position).eq(
- "upperright",
- );
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements.length,
- ).eq(6);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("targeted function");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .hasLatex,
- ).eq(false);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .lineStyle,
- ).eq("dashed");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .lineColor,
- ).eq("blue");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .lineWidth,
- ).eq(2);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .lineOpacity,
- ).eq(0.8);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .swatchType,
- ).eq("line");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .value,
- ).eq("first one");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .hasLatex,
- ).eq(false);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .lineStyle,
- ).eq("solid");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .lineColor,
- ).eq("cyan");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .lineWidth,
- ).eq(3);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .lineOpacity,
- ).eq(0.7);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .swatchType,
- ).eq("rectangle");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .value,
- ).eq("second one \\(x^2\\)");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2].label
- .hasLatex,
- ).eq(true);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .lineStyle,
- ).eq("solid");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .lineColor,
- ).eq("cyan");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .lineWidth,
- ).eq(3);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .lineOpacity,
- ).eq(0.7);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .fillColor,
- ).eq("magenta");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .filled,
- ).eq(true);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[2]
- .fillOpacity,
- ).eq(0.5);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .value,
- ).eq("targeted point \\(B\\)");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3].label
- .hasLatex,
- ).eq(true);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .markerStyle,
- ).eq("triangle");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .markerColor,
- ).eq("green");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[3]
- .markerSize,
- ).eq(5);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4].label
- .value,
- ).eq("third one");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4].label
- .hasLatex,
- ).eq(false);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4]
- .markerStyle,
- ).eq("square");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4]
- .markerColor,
- ).eq("blue");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[4]
- .markerSize,
- ).eq(4);
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[5]
- .swatchType,
- ).eq("rectangle");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[5].label
- .value,
- ).eq("fourth one");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[5].label
- .hasLatex,
- ).eq(false);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[5]
- .lineStyle,
- ).eq("dashed");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[5]
- .lineColor,
- ).eq("blue");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[5]
- .lineWidth,
- ).eq(2);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[5]
- .lineOpacity,
- ).eq(0.8);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[5]
- .fillColor,
- ).eq("orange");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[5]
- .filled,
- ).eq(true);
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[5]
- .fillOpacity,
- ).eq(0.4);
- });
- });
-
- it("legend with forObject, use names of shadow sources", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- (3,4)
- (4,5)
-
- point p
- point Q
-
-
-
-
-
- $p
- $Q
-
- point Q
- point p
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[0].label
- .value,
- ).eq("point p");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend1"].stateValues.legendElements[1].label
- .value,
- ).eq("point Q");
- expect(
- stateVariables["/_legend2"].stateValues.legendElements[0]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend2"].stateValues.legendElements[0].label
- .value,
- ).eq("point Q");
- expect(
- stateVariables["/_legend2"].stateValues.legendElements[1]
- .swatchType,
- ).eq("marker");
- expect(
- stateVariables["/_legend2"].stateValues.legendElements[1].label
- .value,
- ).eq("point p");
- });
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/matrix.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/matrix.cy.js
deleted file mode 100644
index 16750ce49..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/matrix.cy.js
+++ /dev/null
@@ -1,9610 +0,0 @@
-import { cesc, cesc2 } from "@doenet/utils";
-
-describe("Matrix Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("no arguments, 0x0 matrix", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- A:
- Copy 1:
- Copy 2:
- Copy 3: $A{name="A3"}
- Copy 4:
- Copy 5: $A
- Copy 6: $A.value
- Copy 7:
- Copy 8:
- Modify:
- Modify copy 1:
- Modify copy 2:
- Modify copy 3:
- Modify copy 4:
- Modify copy 5:
- Modify copy 6:
- Modify copy 7:
- Modify copy 8:
- Size: ,
- numRows: ,
- numColumns:
-
- Size 1: ,
- numRows 1: ,
- numColumns 1:
-
- Size 2: ,
- numRows 2: ,
- numColumns 2:
-
- Size 3: ,
- numRows 3: ,
- numColumns 3:
-
- Size 4: ,
- numRows 4: ,
- numColumns 4:
-
- Size 5: ,
- numRows 5: ,
- numColumns 5:
-
- Size 6: ,
- numRows 6: ,
- numColumns 6:
-
- Size 7: ,
- numRows 7: ,
- numColumns 7:
-
- Size 8: ,
- numRows 8: ,
- numColumns 8:
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "not.exist",
- );
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "0, 0");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "0, 0");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "0, 0");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "0, 0");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "0, 0");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "0, 0");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "0, 0");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "0, 0");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "0, 0");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "0");
- cy.get(cesc("#\\/numRows1")).should("have.text", "0");
- cy.get(cesc("#\\/numRows2")).should("have.text", "0");
- cy.get(cesc("#\\/numRows3")).should("have.text", "0");
- cy.get(cesc("#\\/numRows4")).should("have.text", "0");
- cy.get(cesc("#\\/numRows5")).should("have.text", "0");
- cy.get(cesc("#\\/numRows6")).should("have.text", "0");
- cy.get(cesc("#\\/numRows7")).should("have.text", "0");
- cy.get(cesc("#\\/numRows8")).should("have.text", "0");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "0");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "0");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "0");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "0");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "0");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "0");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "0");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "0");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = ["matrix", ["tuple", 0, 0], ["tuple"]];
- let matrixValue = [];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([0, 0]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
- });
-
- it("specify numRows, get 1 column, 2x1 matrix of 0s", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- A:
- Copy 1:
- Copy 2:
- Copy 3: $A{name="A3"}
- Copy 4:
- Copy 5: $A
- Copy 6: $A.value
- Copy 7:
- Copy 8:
- Modify:
- Modify copy 1:
- Modify copy 2:
- Modify copy 3:
- Modify copy 4:
- Modify copy 5:
- Modify copy 6:
- Modify copy 7:
- Modify copy 8:
- Size: ,
- numRows: ,
- numColumns:
-
- Size 1: ,
- numRows 1: ,
- numColumns 1:
-
- Size 2: ,
- numRows 2: ,
- numColumns 2:
-
- Size 3: ,
- numRows 3: ,
- numColumns 3:
-
- Size 4: ,
- numRows 4: ,
- numColumns 4:
-
- Size 5: ,
- numRows 5: ,
- numColumns 5:
-
- Size 6: ,
- numRows 6: ,
- numColumns 6:
-
- Size 7: ,
- numRows 7: ,
- numColumns 7:
-
- Size 8: ,
- numRows 8: ,
- numColumns 8:
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "2, 1");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "2");
- cy.get(cesc("#\\/numRows1")).should("have.text", "2");
- cy.get(cesc("#\\/numRows2")).should("have.text", "2");
- cy.get(cesc("#\\/numRows3")).should("have.text", "2");
- cy.get(cesc("#\\/numRows4")).should("have.text", "2");
- cy.get(cesc("#\\/numRows5")).should("have.text", "2");
- cy.get(cesc("#\\/numRows6")).should("have.text", "2");
- cy.get(cesc("#\\/numRows7")).should("have.text", "2");
- cy.get(cesc("#\\/numRows8")).should("have.text", "2");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "1");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", 0], ["tuple", 0]],
- ];
- let matrixValue = [[0], [0]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 1]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value");
-
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}x{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea")
- .type("{end}{backspace}y{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[xy]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "x"], ["tuple", "y"]],
- ];
- let matrixValue = [["x"], ["y"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 1]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("cannot add rows or columns");
-
- cy.get(cesc("#\\/mi_rowIncrement")).click();
- cy.get(cesc("#\\/mi_columnIncrement")).click();
-
- cy.log("change value so know that core has responded");
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}1{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[1y]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "2, 1");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "2, 1");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "2");
- cy.get(cesc("#\\/numRows1")).should("have.text", "2");
- cy.get(cesc("#\\/numRows2")).should("have.text", "2");
- cy.get(cesc("#\\/numRows3")).should("have.text", "2");
- cy.get(cesc("#\\/numRows4")).should("have.text", "2");
- cy.get(cesc("#\\/numRows5")).should("have.text", "2");
- cy.get(cesc("#\\/numRows6")).should("have.text", "2");
- cy.get(cesc("#\\/numRows7")).should("have.text", "2");
- cy.get(cesc("#\\/numRows8")).should("have.text", "2");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "1");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", 1], ["tuple", "y"]],
- ];
- let matrixValue = [[1], ["y"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 1]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value 2,3");
-
- cy.get(cesc("#\\/mi2_component_0_0") + " textarea")
- .type("{end}{backspace}a{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_1_0") + " textarea")
- .type("{end}{backspace}b{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[ab]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "a"], ["tuple", "b"]],
- ];
- let matrixValue = [["a"], ["b"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 1]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value 4,5");
-
- cy.get(cesc("#\\/mi4_component_0_0") + " textarea")
- .type("{end}{backspace}c{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_1_0") + " textarea")
- .type("{end}{backspace}d{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[cd]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "c"], ["tuple", "d"]],
- ];
- let matrixValue = [["c"], ["d"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 1]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value 6,7");
-
- cy.get(cesc("#\\/mi6_component_0_0") + " textarea")
- .type("{end}{backspace}e{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi7_component_1_0") + " textarea")
- .type("{end}{backspace}f{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- let matrixValue = [["e"], ["f"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 1]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value 8, orig");
-
- cy.get(cesc("#\\/mi8_component_0_0") + " textarea")
- .type("{end}{backspace}g{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_1_0") + " textarea")
- .type("{end}{backspace}h{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[gh]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "g"], ["tuple", "h"]],
- ];
- let matrixValue = [["g"], ["h"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 1]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
- });
-
- it("specify numColumns, get 1 row, 1x2 matrix of zeros", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- A:
- Copy 1:
- Copy 2:
- Copy 3: $A{name="A3"}
- Copy 4:
- Copy 5: $A
- Copy 6: $A.value
- Copy 7:
- Copy 8:
- Modify:
- Modify copy 1:
- Modify copy 2:
- Modify copy 3:
- Modify copy 4:
- Modify copy 5:
- Modify copy 6:
- Modify copy 7:
- Modify copy 8:
- Size: ,
- numRows: ,
- numColumns:
-
- Size 1: ,
- numRows 1: ,
- numColumns 1:
-
- Size 2: ,
- numRows 2: ,
- numColumns 2:
-
- Size 3: ,
- numRows 3: ,
- numColumns 3:
-
- Size 4: ,
- numRows 4: ,
- numColumns 4:
-
- Size 5: ,
- numRows 5: ,
- numColumns 5:
-
- Size 6: ,
- numRows 6: ,
- numColumns 6:
-
- Size 7: ,
- numRows 7: ,
- numColumns 7:
-
- Size 8: ,
- numRows 8: ,
- numColumns 8:
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00]");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "1, 2");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "1");
- cy.get(cesc("#\\/numRows1")).should("have.text", "1");
- cy.get(cesc("#\\/numRows2")).should("have.text", "1");
- cy.get(cesc("#\\/numRows3")).should("have.text", "1");
- cy.get(cesc("#\\/numRows4")).should("have.text", "1");
- cy.get(cesc("#\\/numRows5")).should("have.text", "1");
- cy.get(cesc("#\\/numRows6")).should("have.text", "1");
- cy.get(cesc("#\\/numRows7")).should("have.text", "1");
- cy.get(cesc("#\\/numRows8")).should("have.text", "1");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "2");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", 0, 0]],
- ];
- let matrixValue = [[0, 0]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value");
-
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}x{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea")
- .type("{end}{backspace}y{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[xy]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "x", "y"]],
- ];
- let matrixValue = [["x", "y"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("cannot add rows or columns");
-
- cy.get(cesc("#\\/mi_rowIncrement")).click();
- cy.get(cesc("#\\/mi_columnIncrement")).click();
-
- cy.log("change value so know that core has responded");
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}1{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[1y]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1y]");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "1, 2");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "1, 2");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "1");
- cy.get(cesc("#\\/numRows1")).should("have.text", "1");
- cy.get(cesc("#\\/numRows2")).should("have.text", "1");
- cy.get(cesc("#\\/numRows3")).should("have.text", "1");
- cy.get(cesc("#\\/numRows4")).should("have.text", "1");
- cy.get(cesc("#\\/numRows5")).should("have.text", "1");
- cy.get(cesc("#\\/numRows6")).should("have.text", "1");
- cy.get(cesc("#\\/numRows7")).should("have.text", "1");
- cy.get(cesc("#\\/numRows8")).should("have.text", "1");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "2");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", 1, "y"]],
- ];
- let matrixValue = [[1, "y"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value 2,3");
-
- cy.get(cesc("#\\/mi2_component_0_0") + " textarea")
- .type("{end}{backspace}a{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_0_1") + " textarea")
- .type("{end}{backspace}b{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[ab]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "a", "b"]],
- ];
- let matrixValue = [["a", "b"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value 4,5");
-
- cy.get(cesc("#\\/mi4_component_0_0") + " textarea")
- .type("{end}{backspace}c{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_0_1") + " textarea")
- .type("{end}{backspace}d{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[cd]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "c", "d"]],
- ];
- let matrixValue = [["c", "d"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value 6,7");
-
- cy.get(cesc("#\\/mi6_component_0_0") + " textarea")
- .type("{end}{backspace}e{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi7_component_0_1") + " textarea")
- .type("{end}{backspace}f{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "f"]],
- ];
- let matrixValue = [["e", "f"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value 8, orig");
-
- cy.get(cesc("#\\/mi8_component_0_0") + " textarea")
- .type("{end}{backspace}g{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_0_1") + " textarea")
- .type("{end}{backspace}h{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[gh]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[gh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "g", "h"]],
- ];
- let matrixValue = [["g", "h"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
- });
-
- it("with string/math children get 1x1 matrix", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- A: 2x
- Copy 1:
- Copy 2:
- Copy 3: $A{name="A3"}
- Copy 4:
- Copy 5: $A
- Copy 6: $A.value
- Copy 7:
- Copy 8:
- Modify:
- Modify copy 1:
- Modify copy 2:
- Modify copy 3:
- Modify copy 4:
- Modify copy 5:
- Modify copy 6:
- Modify copy 7:
- Modify copy 8:
- Size: ,
- numRows: ,
- numColumns:
-
- Size 1: ,
- numRows 1: ,
- numColumns 1:
-
- Size 2: ,
- numRows 2: ,
- numColumns 2:
-
- Size 3: ,
- numRows 3: ,
- numColumns 3:
-
- Size 4: ,
- numRows 4: ,
- numColumns 4:
-
- Size 5: ,
- numRows 5: ,
- numColumns 5:
-
- Size 6: ,
- numRows 6: ,
- numColumns 6:
-
- Size 7: ,
- numRows 7: ,
- numColumns 7:
-
- Size 8: ,
- numRows 8: ,
- numColumns 8:
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2x]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2x]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2x]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2x]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2x]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2x]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2x]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2x]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2x]");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "1, 1");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "1");
- cy.get(cesc("#\\/numRows1")).should("have.text", "1");
- cy.get(cesc("#\\/numRows2")).should("have.text", "1");
- cy.get(cesc("#\\/numRows3")).should("have.text", "1");
- cy.get(cesc("#\\/numRows4")).should("have.text", "1");
- cy.get(cesc("#\\/numRows5")).should("have.text", "1");
- cy.get(cesc("#\\/numRows6")).should("have.text", "1");
- cy.get(cesc("#\\/numRows7")).should("have.text", "1");
- cy.get(cesc("#\\/numRows8")).should("have.text", "1");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "1");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", ["*", 2, "x"]]],
- ];
- let matrixValue = [[["*", 2, "x"]]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 1]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value");
-
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}y{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[2y]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2y]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2y]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2y]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2y]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2y]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2y]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2y]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2y]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2y]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", ["*", 2, "y"]]],
- ];
- let matrixValue = [[["*", 2, "y"]]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 1]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("cannot add rows or columns");
-
- cy.get(cesc("#\\/mi_rowIncrement")).click();
- cy.get(cesc("#\\/mi_columnIncrement")).click();
-
- cy.log("change value so know that core has responded");
- cy.get(cesc("#\\/mi3_component_0_0") + " textarea")
- .type("{end}{backspace}z{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[2z]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2z]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2z]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2z]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2z]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2z]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2z]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2z]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2z]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2z]");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "1, 1");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "1, 1");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "1");
- cy.get(cesc("#\\/numRows1")).should("have.text", "1");
- cy.get(cesc("#\\/numRows2")).should("have.text", "1");
- cy.get(cesc("#\\/numRows3")).should("have.text", "1");
- cy.get(cesc("#\\/numRows4")).should("have.text", "1");
- cy.get(cesc("#\\/numRows5")).should("have.text", "1");
- cy.get(cesc("#\\/numRows6")).should("have.text", "1");
- cy.get(cesc("#\\/numRows7")).should("have.text", "1");
- cy.get(cesc("#\\/numRows8")).should("have.text", "1");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "1");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "1");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", ["*", 2, "z"]]],
- ];
- let matrixValue = [[["*", 2, "z"]]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 1]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
- });
-
- it("functionSymbols", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- f(x) g(x)
- h(x) a(x)
-
-
-
- f(x) g(x)
- h(x) a(x)
-
-
-
- h(x) g(x) a(x)
- h(x) a(x) b(x)
-
-
-
- h(x) g(x) a(x)
- h(x) a(x) b(x)
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/Adef") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[f(x)g(x)hxax]");
- cy.get(cesc2("#/Ah") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[fxgxh(x)ax]");
- cy.get(cesc2("#/Amixedbyrow") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[hxg(x)a(x)h(x)axb(x)]");
- cy.get(cesc2("#/Amixedbycolumn") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣hxh(x)g(x)axa(x)b(x)⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixdefAst = [
- "matrix",
- ["tuple", 2, 2],
- [
- "tuple",
- ["tuple", ["apply", "f", "x"], ["apply", "g", "x"]],
- ["tuple", ["*", "h", "x"], ["*", "a", "x"]],
- ],
- ];
- let matrixhAst = [
- "matrix",
- ["tuple", 2, 2],
- [
- "tuple",
- ["tuple", ["*", "f", "x"], ["*", "g", "x"]],
- ["tuple", ["apply", "h", "x"], ["*", "a", "x"]],
- ],
- ];
- let matrixmixedbyrowAst = [
- "matrix",
- ["tuple", 2, 3],
- [
- "tuple",
- [
- "tuple",
- ["*", "h", "x"],
- ["apply", "g", "x"],
- ["apply", "a", "x"],
- ],
- [
- "tuple",
- ["apply", "h", "x"],
- ["*", "a", "x"],
- ["apply", "b", "x"],
- ],
- ],
- ];
- let matrixmixedbycolumnAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", ["*", "h", "x"], ["apply", "h", "x"]],
- ["tuple", ["apply", "g", "x"], ["*", "a", "x"]],
- ["tuple", ["apply", "a", "x"], ["apply", "b", "x"]],
- ],
- ];
- expect(stateVariables["/Adef"].stateValues.value).eqls(
- matrixdefAst,
- );
- expect(stateVariables["/Ah"].stateValues.value).eqls(matrixhAst);
- expect(stateVariables["/Amixedbyrow"].stateValues.value).eqls(
- matrixmixedbyrowAst,
- );
- expect(stateVariables["/Amixedbycolumn"].stateValues.value).eqls(
- matrixmixedbycolumnAst,
- );
- });
- });
-
- it("sourcesAreFunctionSymbols", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- f
- g
- h
- a
- b
-
-
- $fun1(x) $fun2(x)
- $fun3(x) $fun4(x)
-
-
-
- $fun1(x) $fun2(x)
- $fun3(x) $fun4(x)
-
-
-
- $fun3(x) $fun2(x) $fun4(x)
- $fun3(x) $fun4(x) $fun5(x)
-
-
-
- h(x) $fun2(x) $fun4(x)
- $fun3(x) $fun4(x) $fun5(x)
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/Adef") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[fxgxhxax]");
- cy.get(cesc2("#/Ah") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[f(x)gxhxa(x)]");
- cy.get(cesc2("#/Amixedbyrow") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[hxg(x)a(x)h(x)axb(x)]");
- cy.get(cesc2("#/Amixedbycolumn") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣hxh(x)g(x)axa(x)b(x)⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixdefAst = [
- "matrix",
- ["tuple", 2, 2],
- [
- "tuple",
- ["tuple", ["*", "f", "x"], ["*", "g", "x"]],
- ["tuple", ["*", "h", "x"], ["*", "a", "x"]],
- ],
- ];
- let matrixhAst = [
- "matrix",
- ["tuple", 2, 2],
- [
- "tuple",
- ["tuple", ["apply", "f", "x"], ["*", "g", "x"]],
- ["tuple", ["*", "h", "x"], ["apply", "a", "x"]],
- ],
- ];
- let matrixmixedbyrowAst = [
- "matrix",
- ["tuple", 2, 3],
- [
- "tuple",
- [
- "tuple",
- ["*", "h", "x"],
- ["apply", "g", "x"],
- ["apply", "a", "x"],
- ],
- [
- "tuple",
- ["apply", "h", "x"],
- ["*", "a", "x"],
- ["apply", "b", "x"],
- ],
- ],
- ];
- let matrixmixedbycolumnAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", ["*", "h", "x"], ["apply", "h", "x"]],
- ["tuple", ["apply", "g", "x"], ["*", "a", "x"]],
- ["tuple", ["apply", "a", "x"], ["apply", "b", "x"]],
- ],
- ];
- expect(stateVariables["/Adef"].stateValues.value).eqls(
- matrixdefAst,
- );
- expect(stateVariables["/Ah"].stateValues.value).eqls(matrixhAst);
- expect(stateVariables["/Amixedbyrow"].stateValues.value).eqls(
- matrixmixedbyrowAst,
- );
- expect(stateVariables["/Amixedbycolumn"].stateValues.value).eqls(
- matrixmixedbycolumnAst,
- );
- });
- });
-
- it("splitsymbols", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- xy yz
- ab bc
-
-
-
- xy yz
- ab bc
-
-
-
- xy yz zx
- ab bc ca
-
-
-
- xy yz zx
- ab bc ca
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/Adef") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyyzabbc]");
- cy.get(cesc2("#/Ah") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyyzabbc]");
- cy.get(cesc2("#/Amixedbyrow") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyyzzxabbcca]");
- cy.get(cesc2("#/Amixedbycolumn") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyabyzbczxca⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixdefAst = [
- "matrix",
- ["tuple", 2, 2],
- [
- "tuple",
- ["tuple", ["*", "x", "y"], ["*", "y", "z"]],
- ["tuple", ["*", "a", "b"], ["*", "b", "c"]],
- ],
- ];
- let matrixnAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "xy", "yz"], ["tuple", "ab", "bc"]],
- ];
- let matrixmixedbyrowAst = [
- "matrix",
- ["tuple", 2, 3],
- [
- "tuple",
- ["tuple", "xy", ["*", "y", "z"], "zx"],
- ["tuple", ["*", "a", "b"], "bc", ["*", "c", "a"]],
- ],
- ];
- let matrixmixedbycolumnAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "xy", ["*", "a", "b"]],
- ["tuple", ["*", "y", "z"], "bc"],
- ["tuple", "zx", ["*", "c", "a"]],
- ],
- ];
- expect(stateVariables["/Adef"].stateValues.value).eqls(
- matrixdefAst,
- );
- expect(stateVariables["/Ah"].stateValues.value).eqls(matrixnAst);
- expect(stateVariables["/Amixedbyrow"].stateValues.value).eqls(
- matrixmixedbyrowAst,
- );
- expect(stateVariables["/Amixedbycolumn"].stateValues.value).eqls(
- matrixmixedbycolumnAst,
- );
- });
- });
-
- it("displayBlanks", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- x_ y_
- a_ b_
-
-
-
- x_ y_
- a_ b_
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/Adef") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[x_y_a_b_]");
- cy.get(cesc2("#/Ah") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyab]");
- });
-
- it("2x3 matrix by rows", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- A:
- a b c
- d e f
-
-
- Copy 1:
- Copy 2:
- Copy 3: $A{name="A3"}
- Copy 4:
- Copy 5: $A
- Copy 6: $A.value
- Copy 7:
- Copy 8:
- Modify:
- Modify copy 1:
- Modify copy 2:
- Modify copy 3:
- Modify copy 4:
- Modify copy 5:
- Modify copy 6:
- Modify copy 7:
- Modify copy 8:
- Size: ,
- numRows: ,
- numColumns:
-
- Size 1: ,
- numRows 1: ,
- numColumns 1:
-
- Size 2: ,
- numRows 2: ,
- numColumns 2:
-
- Size 3: ,
- numRows 3: ,
- numColumns 3:
-
- Size 4: ,
- numRows 4: ,
- numColumns 4:
-
- Size 5: ,
- numRows 5: ,
- numColumns 5:
-
- Size 6: ,
- numRows 6: ,
- numColumns 6:
-
- Size 7: ,
- numRows 7: ,
- numColumns 7:
-
- Size 8: ,
- numRows 8: ,
- numColumns 8:
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi3_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi3_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi4_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi4_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi5_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi5_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi6_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi6_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi7_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi7_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi8_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi8_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "2, 3");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "2");
- cy.get(cesc("#\\/numRows1")).should("have.text", "2");
- cy.get(cesc("#\\/numRows2")).should("have.text", "2");
- cy.get(cesc("#\\/numRows3")).should("have.text", "2");
- cy.get(cesc("#\\/numRows4")).should("have.text", "2");
- cy.get(cesc("#\\/numRows5")).should("have.text", "2");
- cy.get(cesc("#\\/numRows6")).should("have.text", "2");
- cy.get(cesc("#\\/numRows7")).should("have.text", "2");
- cy.get(cesc("#\\/numRows8")).should("have.text", "2");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "3");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", "a", "b", "c"], ["tuple", "d", "e", "f"]],
- ];
- let matrixValue = [
- ["a", "b", "c"],
- ["d", "e", "f"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value");
-
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}x{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_0_1") + " textarea")
- .type("{end}{backspace}y{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_0_2") + " textarea")
- .type("{end}{backspace}z{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_1_0") + " textarea")
- .type("{end}{backspace}u{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_1_1") + " textarea")
- .type("{end}{backspace}v{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_1_2") + " textarea")
- .type("{end}{backspace}w{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[xyzuvw]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi3_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi3_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi4_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi4_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi5_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi5_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi6_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi6_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi7_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi7_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi8_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi8_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", "x", "y", "z"], ["tuple", "u", "v", "w"]],
- ];
- let matrixValue = [
- ["x", "y", "z"],
- ["u", "v", "w"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("cannot remove rows or columns");
-
- cy.get(cesc("#\\/mi_rowDecrement")).click();
- cy.get(cesc("#\\/mi_columnDecrement")).click();
-
- cy.log("change value so know that core has responded");
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}1{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[1yzuvw]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi3_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi3_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi4_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi4_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi5_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi5_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi6_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi6_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi7_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi7_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi8_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi8_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "2, 3");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "2");
- cy.get(cesc("#\\/numRows1")).should("have.text", "2");
- cy.get(cesc("#\\/numRows2")).should("have.text", "2");
- cy.get(cesc("#\\/numRows3")).should("have.text", "2");
- cy.get(cesc("#\\/numRows4")).should("have.text", "2");
- cy.get(cesc("#\\/numRows5")).should("have.text", "2");
- cy.get(cesc("#\\/numRows6")).should("have.text", "2");
- cy.get(cesc("#\\/numRows7")).should("have.text", "2");
- cy.get(cesc("#\\/numRows8")).should("have.text", "2");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "3");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", 1, "y", "z"], ["tuple", "u", "v", "w"]],
- ];
- let matrixValue = [
- [1, "y", "z"],
- ["u", "v", "w"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value, 1-4");
-
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea")
- .type("{end}{backspace}m{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_0_1") + " textarea")
- .type("{end}{backspace}n{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_0_2") + " textarea")
- .type("{end}{backspace}o{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_1_0") + " textarea")
- .type("{end}{backspace}p{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea")
- .type("{end}{backspace}q{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_1_2") + " textarea")
- .type("{end}{backspace}r{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[mnopqr]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi3_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi3_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi4_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi4_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi5_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi5_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi6_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi6_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi7_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi7_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi8_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi8_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", "m", "n", "o"], ["tuple", "p", "q", "r"]],
- ];
- let matrixValue = [
- ["m", "n", "o"],
- ["p", "q", "r"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value, 5-8");
-
- cy.get(cesc("#\\/mi5_component_0_0") + " textarea")
- .type("{end}{backspace}s{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_0_1") + " textarea")
- .type("{end}{backspace}t{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi7_component_0_2") + " textarea")
- .type("{end}{backspace}u{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi8_component_1_0") + " textarea")
- .type("{end}{backspace}v{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_1_1") + " textarea")
- .type("{end}{backspace}w{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_1_2") + " textarea")
- .type("{end}{backspace}x{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[stuvwx]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi3_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi3_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi4_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi4_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi5_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi5_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi6_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi6_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi7_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi7_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi8_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi8_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", "s", "t", "u"], ["tuple", "v", "w", "x"]],
- ];
- let matrixValue = [
- ["s", "t", "u"],
- ["v", "w", "x"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
- });
-
- it("2x3 matrix by columns", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- A:
- a d
- b e
- c f
-
-
- Copy 1:
- Copy 2:
- Copy 3: $A{name="A3"}
- Copy 4:
- Copy 5: $A
- Copy 6: $A.value
- Copy 7:
- Copy 8:
- Modify:
- Modify copy 1:
- Modify copy 2:
- Modify copy 3:
- Modify copy 4:
- Modify copy 5:
- Modify copy 6:
- Modify copy 7:
- Modify copy 8:
- Size: ,
- numRows: ,
- numColumns:
-
- Size 1: ,
- numRows 1: ,
- numColumns 1:
-
- Size 2: ,
- numRows 2: ,
- numColumns 2:
-
- Size 3: ,
- numRows 3: ,
- numColumns 3:
-
- Size 4: ,
- numRows 4: ,
- numColumns 4:
-
- Size 5: ,
- numRows 5: ,
- numColumns 5:
-
- Size 6: ,
- numRows 6: ,
- numColumns 6:
-
- Size 7: ,
- numRows 7: ,
- numColumns 7:
-
- Size 8: ,
- numRows 8: ,
- numColumns 8:
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcdef]");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi3_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi3_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi4_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi4_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi5_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi5_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi6_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi6_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi7_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi7_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi8_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "c",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi8_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "f",
- );
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "2, 3");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "2");
- cy.get(cesc("#\\/numRows1")).should("have.text", "2");
- cy.get(cesc("#\\/numRows2")).should("have.text", "2");
- cy.get(cesc("#\\/numRows3")).should("have.text", "2");
- cy.get(cesc("#\\/numRows4")).should("have.text", "2");
- cy.get(cesc("#\\/numRows5")).should("have.text", "2");
- cy.get(cesc("#\\/numRows6")).should("have.text", "2");
- cy.get(cesc("#\\/numRows7")).should("have.text", "2");
- cy.get(cesc("#\\/numRows8")).should("have.text", "2");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "3");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", "a", "b", "c"], ["tuple", "d", "e", "f"]],
- ];
- let matrixValue = [
- ["a", "b", "c"],
- ["d", "e", "f"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value");
-
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}x{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_0_1") + " textarea")
- .type("{end}{backspace}y{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_0_2") + " textarea")
- .type("{end}{backspace}z{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_1_0") + " textarea")
- .type("{end}{backspace}u{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_1_1") + " textarea")
- .type("{end}{backspace}v{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_1_2") + " textarea")
- .type("{end}{backspace}w{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[xyzuvw]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xyzuvw]");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi3_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi3_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi4_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi4_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi5_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi5_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi6_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi6_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi7_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi7_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi8_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi8_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", "x", "y", "z"], ["tuple", "u", "v", "w"]],
- ];
- let matrixValue = [
- ["x", "y", "z"],
- ["u", "v", "w"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("cannot remove rows or columns");
-
- cy.get(cesc("#\\/mi_rowDecrement")).click();
- cy.get(cesc("#\\/mi_columnDecrement")).click();
-
- cy.log("change value so know that core has responded");
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}1{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[1yzuvw]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1yzuvw]");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi3_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi3_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi4_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi4_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi5_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi5_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi6_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi6_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi7_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi7_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi8_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi8_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "2, 3");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "2, 3");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "2");
- cy.get(cesc("#\\/numRows1")).should("have.text", "2");
- cy.get(cesc("#\\/numRows2")).should("have.text", "2");
- cy.get(cesc("#\\/numRows3")).should("have.text", "2");
- cy.get(cesc("#\\/numRows4")).should("have.text", "2");
- cy.get(cesc("#\\/numRows5")).should("have.text", "2");
- cy.get(cesc("#\\/numRows6")).should("have.text", "2");
- cy.get(cesc("#\\/numRows7")).should("have.text", "2");
- cy.get(cesc("#\\/numRows8")).should("have.text", "2");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "3");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", 1, "y", "z"], ["tuple", "u", "v", "w"]],
- ];
- let matrixValue = [
- [1, "y", "z"],
- ["u", "v", "w"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value, 1-4");
-
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea")
- .type("{end}{backspace}m{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_0_1") + " textarea")
- .type("{end}{backspace}n{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_0_2") + " textarea")
- .type("{end}{backspace}o{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_1_0") + " textarea")
- .type("{end}{backspace}p{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea")
- .type("{end}{backspace}q{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_1_2") + " textarea")
- .type("{end}{backspace}r{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[mnopqr]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[mnopqr]");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi3_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi3_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi4_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi4_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi5_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi5_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi6_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi6_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi7_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi7_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "m",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "n",
- );
- cy.get(cesc(`#\\/mi8_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "o",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "p",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "q",
- );
- cy.get(cesc(`#\\/mi8_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "r",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", "m", "n", "o"], ["tuple", "p", "q", "r"]],
- ];
- let matrixValue = [
- ["m", "n", "o"],
- ["p", "q", "r"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value, 5-8");
-
- cy.get(cesc("#\\/mi5_component_0_0") + " textarea")
- .type("{end}{backspace}s{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_0_1") + " textarea")
- .type("{end}{backspace}t{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi7_component_0_2") + " textarea")
- .type("{end}{backspace}u{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi8_component_1_0") + " textarea")
- .type("{end}{backspace}v{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_1_1") + " textarea")
- .type("{end}{backspace}w{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_1_2") + " textarea")
- .type("{end}{backspace}x{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[stuvwx]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvwx]");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi3_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi3_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi4_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi4_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi5_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi5_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi6_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi6_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi7_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi7_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "s",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "t",
- );
- cy.get(cesc(`#\\/mi8_component_0_2`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
- cy.get(cesc(`#\\/mi8_component_1_2`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", "s", "t", "u"], ["tuple", "v", "w", "x"]],
- ];
- let matrixValue = [
- ["s", "t", "u"],
- ["v", "w", "x"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi8"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
- });
-
- it("3x2 matrix, rows, change size", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- numRows: ,
- numColumns:
- A:
- a b c
- d e f
-
-
- Copy 1:
- Copy 2:
- Copy 3: $A{name="A3"}
- Copy 4:
- Copy 5: $A
- Copy 6: $A.value
- Copy 7:
- Copy 8:
- Modify:
- Modify copy 1:
- Modify copy 2:
- Modify copy 3:
- Modify copy 4:
- Modify copy 5:
- Modify copy 6:
- Modify copy 7:
- Modify copy 8:
- Size: ,
- numRows: ,
- numColumns:
-
- Size 1: ,
- numRows 1: ,
- numColumns 1:
-
- Size 2: ,
- numRows 2: ,
- numColumns 2:
-
- Size 3: ,
- numRows 3: ,
- numColumns 3:
-
- Size 4: ,
- numRows 4: ,
- numColumns 4:
-
- Size 5: ,
- numRows 5: ,
- numColumns 5:
-
- Size 6: ,
- numRows 6: ,
- numColumns 6:
-
- Size 7: ,
- numRows 7: ,
- numColumns 7:
-
- Size 8: ,
- numRows 8: ,
- numColumns 8:
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi2_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi2_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi3_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi3_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi4_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi4_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi5_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi5_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi6_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi6_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi7_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi7_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi8_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi8_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "3, 2");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "3");
- cy.get(cesc("#\\/numRows1")).should("have.text", "3");
- cy.get(cesc("#\\/numRows2")).should("have.text", "3");
- cy.get(cesc("#\\/numRows3")).should("have.text", "3");
- cy.get(cesc("#\\/numRows4")).should("have.text", "3");
- cy.get(cesc("#\\/numRows5")).should("have.text", "3");
- cy.get(cesc("#\\/numRows6")).should("have.text", "3");
- cy.get(cesc("#\\/numRows7")).should("have.text", "3");
- cy.get(cesc("#\\/numRows8")).should("have.text", "3");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "2");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "a", "b"],
- ["tuple", "d", "e"],
- ["tuple", 0, 0],
- ],
- ];
- let matrixValue = [
- ["a", "b"],
- ["d", "e"],
- [0, 0],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value");
-
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}x{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea")
- .type("{end}{backspace}y{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_1_0") + " textarea")
- .type("{end}{backspace}z{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_1_1") + " textarea")
- .type("{end}{backspace}u{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_2_0") + " textarea")
- .type("{end}{backspace}v{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_2_1") + " textarea")
- .type("{end}{backspace}w{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣xyzuvw⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi2_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi2_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi3_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi3_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi4_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi4_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi5_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi5_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi6_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi6_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi7_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi7_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi8_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi8_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "x", "y"],
- ["tuple", "z", "u"],
- ["tuple", "v", "w"],
- ],
- ];
- let matrixValue = [
- ["x", "y"],
- ["z", "u"],
- ["v", "w"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("cannot remove rows or columns");
-
- cy.get(cesc("#\\/mi_rowDecrement")).click();
- cy.get(cesc("#\\/mi_columnDecrement")).click();
-
- cy.log("change value so know that core has responded");
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}1{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣1yzuvw⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "3, 2");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "3");
- cy.get(cesc("#\\/numRows1")).should("have.text", "3");
- cy.get(cesc("#\\/numRows2")).should("have.text", "3");
- cy.get(cesc("#\\/numRows3")).should("have.text", "3");
- cy.get(cesc("#\\/numRows4")).should("have.text", "3");
- cy.get(cesc("#\\/numRows5")).should("have.text", "3");
- cy.get(cesc("#\\/numRows6")).should("have.text", "3");
- cy.get(cesc("#\\/numRows7")).should("have.text", "3");
- cy.get(cesc("#\\/numRows8")).should("have.text", "3");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "2");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", 1, "y"],
- ["tuple", "z", "u"],
- ["tuple", "v", "w"],
- ],
- ];
- let matrixValue = [
- [1, "y"],
- ["z", "u"],
- ["v", "w"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("increase to 4 columns");
-
- cy.get(cesc("#\\/mi_nColumns") + " textarea")
- .type("{end}{backspace}4{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "3, 4");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "3");
- cy.get(cesc("#\\/numRows1")).should("have.text", "3");
- cy.get(cesc("#\\/numRows2")).should("have.text", "3");
- cy.get(cesc("#\\/numRows3")).should("have.text", "3");
- cy.get(cesc("#\\/numRows4")).should("have.text", "3");
- cy.get(cesc("#\\/numRows5")).should("have.text", "3");
- cy.get(cesc("#\\/numRows6")).should("have.text", "3");
- cy.get(cesc("#\\/numRows7")).should("have.text", "3");
- cy.get(cesc("#\\/numRows8")).should("have.text", "3");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "4");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 4],
- [
- "tuple",
- ["tuple", 1, "y", "c", 0],
- ["tuple", "z", "u", "f", 0],
- ["tuple", "v", "w", 0, 0],
- ],
- ];
- let matrixValue = [
- [1, "y", "c", 0],
- ["z", "u", "f", 0],
- ["v", "w", 0, 0],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 4]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change values");
-
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}g{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea")
- .type("{end}{backspace}h{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_0_2") + " textarea")
- .type("{end}{backspace}i{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_0_3") + " textarea")
- .type("{end}{backspace}j{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_1_0") + " textarea")
- .type("{end}{backspace}k{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_1_1") + " textarea")
- .type("{end}{backspace}l{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_1_2") + " textarea")
- .type("{end}{backspace}m{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi7_component_1_3") + " textarea")
- .type("{end}{backspace}n{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi8_component_2_0") + " textarea")
- .type("{end}{backspace}o{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_2_1") + " textarea")
- .type("{end}{backspace}p{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_2_2") + " textarea")
- .type("{end}{backspace}q{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_2_3") + " textarea")
- .type("{end}{backspace}r{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣ghijklmnopqr⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 4],
- [
- "tuple",
- ["tuple", "g", "h", "i", "j"],
- ["tuple", "k", "l", "m", "n"],
- ["tuple", "o", "p", "q", "r"],
- ],
- ];
- let matrixValue = [
- ["g", "h", "i", "j"],
- ["k", "l", "m", "n"],
- ["o", "p", "q", "r"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 4]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("decrease to 1 row");
-
- cy.get(cesc("#\\/mi_nRows") + " textarea")
- .type("{end}{backspace}1{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[ghij]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "1, 4");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "1");
- cy.get(cesc("#\\/numRows1")).should("have.text", "1");
- cy.get(cesc("#\\/numRows2")).should("have.text", "1");
- cy.get(cesc("#\\/numRows3")).should("have.text", "1");
- cy.get(cesc("#\\/numRows4")).should("have.text", "1");
- cy.get(cesc("#\\/numRows5")).should("have.text", "1");
- cy.get(cesc("#\\/numRows6")).should("have.text", "1");
- cy.get(cesc("#\\/numRows7")).should("have.text", "1");
- cy.get(cesc("#\\/numRows8")).should("have.text", "1");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "4");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "g", "h", "i", "j"]],
- ];
- let matrixValue = [["g", "h", "i", "j"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 4]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change values");
-
- cy.get(cesc("#\\/mi3_component_0_0") + " textarea")
- .type("{end}{backspace}s{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_0_1") + " textarea")
- .type("{end}{backspace}t{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_0_2") + " textarea")
- .type("{end}{backspace}u{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_0_3") + " textarea")
- .type("{end}{backspace}v{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[stuv]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "s", "t", "u", "v"]],
- ];
- let matrixValue = [["s", "t", "u", "v"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 4]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("up to 2 rows");
-
- cy.get(cesc("#\\/mi_nRows") + " textarea")
- .type("{end}{backspace}2{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "[stuvklmn]",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "2, 4");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "2");
- cy.get(cesc("#\\/numRows1")).should("have.text", "2");
- cy.get(cesc("#\\/numRows2")).should("have.text", "2");
- cy.get(cesc("#\\/numRows3")).should("have.text", "2");
- cy.get(cesc("#\\/numRows4")).should("have.text", "2");
- cy.get(cesc("#\\/numRows5")).should("have.text", "2");
- cy.get(cesc("#\\/numRows6")).should("have.text", "2");
- cy.get(cesc("#\\/numRows7")).should("have.text", "2");
- cy.get(cesc("#\\/numRows8")).should("have.text", "2");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "4");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 4],
- [
- "tuple",
- ["tuple", "s", "t", "u", "v"],
- ["tuple", "k", "l", "m", "n"],
- ],
- ];
- let matrixValue = [
- ["s", "t", "u", "v"],
- ["k", "l", "m", "n"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 4]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
- });
-
- it("3x2 matrix, columns, change size", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- numRows: ,
- numColumns:
- A:
- a d
- b e
- c f
-
-
- Copy 1:
- Copy 2:
- Copy 3: $A{name="A3"}
- Copy 4:
- Copy 5: $A
- Copy 6: $A.value
- Copy 7:
- Copy 8:
- Modify:
- Modify copy 1:
- Modify copy 2:
- Modify copy 3:
- Modify copy 4:
- Modify copy 5:
- Modify copy 6:
- Modify copy 7:
- Modify copy 8:
- Size: ,
- numRows: ,
- numColumns:
-
- Size 1: ,
- numRows 1: ,
- numColumns 1:
-
- Size 2: ,
- numRows 2: ,
- numColumns 2:
-
- Size 3: ,
- numRows 3: ,
- numColumns 3:
-
- Size 4: ,
- numRows 4: ,
- numColumns 4:
-
- Size 5: ,
- numRows 5: ,
- numColumns 5:
-
- Size 6: ,
- numRows 6: ,
- numColumns 6:
-
- Size 7: ,
- numRows 7: ,
- numColumns 7:
-
- Size 8: ,
- numRows 8: ,
- numColumns 8:
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde00⎤⎥⎦");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi2_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi2_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi3_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi3_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi4_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi4_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi5_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi5_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi6_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi6_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi7_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi7_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "a",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "b",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "d",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "e",
- );
- cy.get(cesc(`#\\/mi8_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
- cy.get(cesc(`#\\/mi8_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "0",
- );
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "3, 2");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "3");
- cy.get(cesc("#\\/numRows1")).should("have.text", "3");
- cy.get(cesc("#\\/numRows2")).should("have.text", "3");
- cy.get(cesc("#\\/numRows3")).should("have.text", "3");
- cy.get(cesc("#\\/numRows4")).should("have.text", "3");
- cy.get(cesc("#\\/numRows5")).should("have.text", "3");
- cy.get(cesc("#\\/numRows6")).should("have.text", "3");
- cy.get(cesc("#\\/numRows7")).should("have.text", "3");
- cy.get(cesc("#\\/numRows8")).should("have.text", "3");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "2");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "a", "b"],
- ["tuple", "d", "e"],
- ["tuple", 0, 0],
- ],
- ];
- let matrixValue = [
- ["a", "b"],
- ["d", "e"],
- [0, 0],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change value");
-
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}x{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea")
- .type("{end}{backspace}y{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_1_0") + " textarea")
- .type("{end}{backspace}z{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_1_1") + " textarea")
- .type("{end}{backspace}u{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_2_0") + " textarea")
- .type("{end}{backspace}v{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_2_1") + " textarea")
- .type("{end}{backspace}w{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣xyzuvw⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvw⎤⎥⎦");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi2_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi2_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi3_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi3_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi3_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi3_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi3_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi3_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi4_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi4_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi4_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi4_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi4_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi4_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi5_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi5_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi5_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi5_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi5_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi5_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi6_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi6_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi6_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi6_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi6_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi6_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi7_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi7_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi7_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi7_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi7_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi7_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc(`#\\/mi8_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "x",
- );
- cy.get(cesc(`#\\/mi8_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi8_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi8_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi8_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi8_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "x", "y"],
- ["tuple", "z", "u"],
- ["tuple", "v", "w"],
- ],
- ];
- let matrixValue = [
- ["x", "y"],
- ["z", "u"],
- ["v", "w"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("cannot remove rows or columns");
-
- cy.get(cesc("#\\/mi_rowDecrement")).click();
- cy.get(cesc("#\\/mi_columnDecrement")).click();
-
- cy.log("change value so know that core has responded");
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}1{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣1yzuvw⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvw⎤⎥⎦");
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`).should(
- "have.text",
- "1",
- );
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`).should(
- "have.text",
- "y",
- );
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`).should(
- "have.text",
- "z",
- );
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`).should(
- "have.text",
- "u",
- );
- cy.get(cesc(`#\\/mi_component_2_0`) + ` .mq-editable-field`).should(
- "have.text",
- "v",
- );
- cy.get(cesc(`#\\/mi_component_2_1`) + ` .mq-editable-field`).should(
- "have.text",
- "w",
- );
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "3, 2");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "3");
- cy.get(cesc("#\\/numRows1")).should("have.text", "3");
- cy.get(cesc("#\\/numRows2")).should("have.text", "3");
- cy.get(cesc("#\\/numRows3")).should("have.text", "3");
- cy.get(cesc("#\\/numRows4")).should("have.text", "3");
- cy.get(cesc("#\\/numRows5")).should("have.text", "3");
- cy.get(cesc("#\\/numRows6")).should("have.text", "3");
- cy.get(cesc("#\\/numRows7")).should("have.text", "3");
- cy.get(cesc("#\\/numRows8")).should("have.text", "3");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "2");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", 1, "y"],
- ["tuple", "z", "u"],
- ["tuple", "v", "w"],
- ],
- ];
- let matrixValue = [
- [1, "y"],
- ["z", "u"],
- ["v", "w"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("increase to 4 columns");
-
- cy.get(cesc("#\\/mi_nColumns") + " textarea")
- .type("{end}{backspace}4{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yc0zuf0vw00⎤⎥⎦");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "3, 4");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "3, 4");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "3");
- cy.get(cesc("#\\/numRows1")).should("have.text", "3");
- cy.get(cesc("#\\/numRows2")).should("have.text", "3");
- cy.get(cesc("#\\/numRows3")).should("have.text", "3");
- cy.get(cesc("#\\/numRows4")).should("have.text", "3");
- cy.get(cesc("#\\/numRows5")).should("have.text", "3");
- cy.get(cesc("#\\/numRows6")).should("have.text", "3");
- cy.get(cesc("#\\/numRows7")).should("have.text", "3");
- cy.get(cesc("#\\/numRows8")).should("have.text", "3");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "4");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 4],
- [
- "tuple",
- ["tuple", 1, "y", "c", 0],
- ["tuple", "z", "u", "f", 0],
- ["tuple", "v", "w", 0, 0],
- ],
- ];
- let matrixValue = [
- [1, "y", "c", 0],
- ["z", "u", "f", 0],
- ["v", "w", 0, 0],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 4]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change values");
-
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}g{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea")
- .type("{end}{backspace}h{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_0_2") + " textarea")
- .type("{end}{backspace}i{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_0_3") + " textarea")
- .type("{end}{backspace}j{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_1_0") + " textarea")
- .type("{end}{backspace}k{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_1_1") + " textarea")
- .type("{end}{backspace}l{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_1_2") + " textarea")
- .type("{end}{backspace}m{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi7_component_1_3") + " textarea")
- .type("{end}{backspace}n{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi8_component_2_0") + " textarea")
- .type("{end}{backspace}o{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_2_1") + " textarea")
- .type("{end}{backspace}p{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_2_2") + " textarea")
- .type("{end}{backspace}q{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_2_3") + " textarea")
- .type("{end}{backspace}r{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣ghijklmnopqr⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ghijklmnopqr⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 4],
- [
- "tuple",
- ["tuple", "g", "h", "i", "j"],
- ["tuple", "k", "l", "m", "n"],
- ["tuple", "o", "p", "q", "r"],
- ],
- ];
- let matrixValue = [
- ["g", "h", "i", "j"],
- ["k", "l", "m", "n"],
- ["o", "p", "q", "r"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 4]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("decrease to 1 row");
-
- cy.get(cesc("#\\/mi_nRows") + " textarea")
- .type("{end}{backspace}1{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[ghij]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "1, 4");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "1, 4");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "1");
- cy.get(cesc("#\\/numRows1")).should("have.text", "1");
- cy.get(cesc("#\\/numRows2")).should("have.text", "1");
- cy.get(cesc("#\\/numRows3")).should("have.text", "1");
- cy.get(cesc("#\\/numRows4")).should("have.text", "1");
- cy.get(cesc("#\\/numRows5")).should("have.text", "1");
- cy.get(cesc("#\\/numRows6")).should("have.text", "1");
- cy.get(cesc("#\\/numRows7")).should("have.text", "1");
- cy.get(cesc("#\\/numRows8")).should("have.text", "1");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "4");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "g", "h", "i", "j"]],
- ];
- let matrixValue = [["g", "h", "i", "j"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 4]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change values");
-
- cy.get(cesc("#\\/mi3_component_0_0") + " textarea")
- .type("{end}{backspace}s{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_0_1") + " textarea")
- .type("{end}{backspace}t{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_0_2") + " textarea")
- .type("{end}{backspace}u{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_0_3") + " textarea")
- .type("{end}{backspace}v{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should("contain.text", "[stuv]");
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuv]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "s", "t", "u", "v"]],
- ];
- let matrixValue = [["s", "t", "u", "v"]];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([1, 4]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("up to 2 rows");
-
- cy.get(cesc("#\\/mi_nRows") + " textarea")
- .type("{end}{backspace}2{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "[stuvklmn]",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[stuvklmn]");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "2, 4");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "2, 4");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "2");
- cy.get(cesc("#\\/numRows1")).should("have.text", "2");
- cy.get(cesc("#\\/numRows2")).should("have.text", "2");
- cy.get(cesc("#\\/numRows3")).should("have.text", "2");
- cy.get(cesc("#\\/numRows4")).should("have.text", "2");
- cy.get(cesc("#\\/numRows5")).should("have.text", "2");
- cy.get(cesc("#\\/numRows6")).should("have.text", "2");
- cy.get(cesc("#\\/numRows7")).should("have.text", "2");
- cy.get(cesc("#\\/numRows8")).should("have.text", "2");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "4");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "4");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 4],
- [
- "tuple",
- ["tuple", "s", "t", "u", "v"],
- ["tuple", "k", "l", "m", "n"],
- ],
- ];
- let matrixValue = [
- ["s", "t", "u", "v"],
- ["k", "l", "m", "n"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([2, 4]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
- });
-
- it("3x2 matrix, rows, change size, change default entry", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Default entry:
- numRows: ,
- numColumns:
- A:
- a b c
- d e f
-
-
- Copy 1:
- Copy 2:
- Copy 3: $A{name="A3"}
- Copy 4:
- Copy 5: $A
- Copy 6: $A.value
- Copy 7:
- Copy 8:
- Modify:
- Modify copy 1:
- Modify copy 2:
- Modify copy 3:
- Modify copy 4:
- Modify copy 5:
- Modify copy 6:
- Modify copy 7:
- Modify copy 8:
- Size: ,
- numRows: ,
- numColumns:
-
- Size 1: ,
- numRows 1: ,
- numColumns 1:
-
- Size 2: ,
- numRows 2: ,
- numColumns 2:
-
- Size 3: ,
- numRows 3: ,
- numColumns 3:
-
- Size 4: ,
- numRows 4: ,
- numColumns 4:
-
- Size 5: ,
- numRows 5: ,
- numColumns 5:
-
- Size 6: ,
- numRows 6: ,
- numColumns 6:
-
- Size 7: ,
- numRows 7: ,
- numColumns 7:
-
- Size 8: ,
- numRows 8: ,
- numColumns 8:
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "3, 2");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "3");
- cy.get(cesc("#\\/numRows1")).should("have.text", "3");
- cy.get(cesc("#\\/numRows2")).should("have.text", "3");
- cy.get(cesc("#\\/numRows3")).should("have.text", "3");
- cy.get(cesc("#\\/numRows4")).should("have.text", "3");
- cy.get(cesc("#\\/numRows5")).should("have.text", "3");
- cy.get(cesc("#\\/numRows6")).should("have.text", "3");
- cy.get(cesc("#\\/numRows7")).should("have.text", "3");
- cy.get(cesc("#\\/numRows8")).should("have.text", "3");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "2");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "a", "b"],
- ["tuple", "d", "e"],
- ["tuple", 1, 1],
- ],
- ];
- let matrixValue = [
- ["a", "b"],
- ["d", "e"],
- [1, 1],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change default entry");
-
- cy.get(cesc("#\\/de") + " textarea").type("{end}{backspace}k{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣abdekk⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "a", "b"],
- ["tuple", "d", "e"],
- ["tuple", "k", "k"],
- ],
- ];
- let matrixValue = [
- ["a", "b"],
- ["d", "e"],
- ["k", "k"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change all but last value");
-
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}x{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea")
- .type("{end}{backspace}y{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_1_0") + " textarea")
- .type("{end}{backspace}z{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_1_1") + " textarea")
- .type("{end}{backspace}u{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_2_0") + " textarea")
- .type("{end}{backspace}v{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣xyzuvk⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "x", "y"],
- ["tuple", "z", "u"],
- ["tuple", "v", "k"],
- ],
- ];
- let matrixValue = [
- ["x", "y"],
- ["z", "u"],
- ["v", "k"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log(
- "change default entry again does not work as all modified by matrixinput",
- );
-
- cy.get(cesc("#\\/de") + " textarea").type("{end}{backspace}j{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/mi8_component_0_0") + " textarea")
- .type("{end}{backspace}1{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣1yzuvk⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", 1, "y"],
- ["tuple", "z", "u"],
- ["tuple", "v", "k"],
- ],
- ];
- let matrixValue = [
- [1, "y"],
- ["z", "u"],
- ["v", "k"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("add row and column");
- cy.get(cesc("#\\/mi_nRows") + " textarea")
- .type("{end}{backspace}4{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_nColumns") + " textarea")
- .type("{end}{backspace}3{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "4, 3");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "4");
- cy.get(cesc("#\\/numRows1")).should("have.text", "4");
- cy.get(cesc("#\\/numRows2")).should("have.text", "4");
- cy.get(cesc("#\\/numRows3")).should("have.text", "4");
- cy.get(cesc("#\\/numRows4")).should("have.text", "4");
- cy.get(cesc("#\\/numRows5")).should("have.text", "4");
- cy.get(cesc("#\\/numRows6")).should("have.text", "4");
- cy.get(cesc("#\\/numRows7")).should("have.text", "4");
- cy.get(cesc("#\\/numRows8")).should("have.text", "4");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "3");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 4, 3],
- [
- "tuple",
- ["tuple", 1, "y", "c"],
- ["tuple", "z", "u", "f"],
- ["tuple", "v", "k", "j"],
- ["tuple", "j", "j", "j"],
- ],
- ];
- let matrixValue = [
- [1, "y", "c"],
- ["z", "u", "f"],
- ["v", "k", "j"],
- ["j", "j", "j"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([4, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change all values");
-
- cy.get(cesc("#\\/mi5_component_0_0") + " textarea")
- .type("{end}{backspace}l{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_0_1") + " textarea")
- .type("{end}{backspace}m{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi7_component_0_2") + " textarea")
- .type("{end}{backspace}n{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi8_component_1_0") + " textarea")
- .type("{end}{backspace}o{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_1_1") + " textarea")
- .type("{end}{backspace}p{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_1_2") + " textarea")
- .type("{end}{backspace}q{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_2_0") + " textarea")
- .type("{end}{backspace}r{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_2_1") + " textarea")
- .type("{end}{backspace}s{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_2_2") + " textarea")
- .type("{end}{backspace}t{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_3_0") + " textarea")
- .type("{end}{backspace}w{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_3_1") + " textarea")
- .type("{end}{backspace}a{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi7_component_3_2") + " textarea")
- .type("{end}{backspace}b{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 4, 3],
- [
- "tuple",
- ["tuple", "l", "m", "n"],
- ["tuple", "o", "p", "q"],
- ["tuple", "r", "s", "t"],
- ["tuple", "w", "a", "b"],
- ],
- ];
- let matrixValue = [
- ["l", "m", "n"],
- ["o", "p", "q"],
- ["r", "s", "t"],
- ["w", "a", "b"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([4, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
- });
-
- it("3x2 matrix, columns, change size, change default entry", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Default entry:
- numRows: ,
- numColumns:
- A:
- a d
- b e
- c f
-
-
- Copy 1:
- Copy 2:
- Copy 3: $A{name="A3"}
- Copy 4:
- Copy 5: $A
- Copy 6: $A.value
- Copy 7:
- Copy 8:
- Modify:
- Modify copy 1:
- Modify copy 2:
- Modify copy 3:
- Modify copy 4:
- Modify copy 5:
- Modify copy 6:
- Modify copy 7:
- Modify copy 8:
- Size: ,
- numRows: ,
- numColumns:
-
- Size 1: ,
- numRows 1: ,
- numColumns 1:
-
- Size 2: ,
- numRows 2: ,
- numColumns 2:
-
- Size 3: ,
- numRows 3: ,
- numColumns 3:
-
- Size 4: ,
- numRows 4: ,
- numColumns 4:
-
- Size 5: ,
- numRows 5: ,
- numColumns 5:
-
- Size 6: ,
- numRows 6: ,
- numColumns 6:
-
- Size 7: ,
- numRows 7: ,
- numColumns 7:
-
- Size 8: ,
- numRows 8: ,
- numColumns 8:
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abde11⎤⎥⎦");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "3, 2");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "3, 2");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "3");
- cy.get(cesc("#\\/numRows1")).should("have.text", "3");
- cy.get(cesc("#\\/numRows2")).should("have.text", "3");
- cy.get(cesc("#\\/numRows3")).should("have.text", "3");
- cy.get(cesc("#\\/numRows4")).should("have.text", "3");
- cy.get(cesc("#\\/numRows5")).should("have.text", "3");
- cy.get(cesc("#\\/numRows6")).should("have.text", "3");
- cy.get(cesc("#\\/numRows7")).should("have.text", "3");
- cy.get(cesc("#\\/numRows8")).should("have.text", "3");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "2");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "2");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "a", "b"],
- ["tuple", "d", "e"],
- ["tuple", 1, 1],
- ],
- ];
- let matrixValue = [
- ["a", "b"],
- ["d", "e"],
- [1, 1],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change default entry");
-
- cy.get(cesc("#\\/de") + " textarea").type("{end}{backspace}k{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣abdekk⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abdekk⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "a", "b"],
- ["tuple", "d", "e"],
- ["tuple", "k", "k"],
- ],
- ];
- let matrixValue = [
- ["a", "b"],
- ["d", "e"],
- ["k", "k"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change all but last value");
-
- cy.get(cesc("#\\/mi_component_0_0") + " textarea")
- .type("{end}{backspace}x{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea")
- .type("{end}{backspace}y{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_1_0") + " textarea")
- .type("{end}{backspace}z{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_1_1") + " textarea")
- .type("{end}{backspace}u{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_2_0") + " textarea")
- .type("{end}{backspace}v{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣xyzuvk⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣xyzuvk⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "x", "y"],
- ["tuple", "z", "u"],
- ["tuple", "v", "k"],
- ],
- ];
- let matrixValue = [
- ["x", "y"],
- ["z", "u"],
- ["v", "k"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log(
- "change default entry again does not work as all modified by matrixinput",
- );
-
- cy.get(cesc("#\\/de") + " textarea").type("{end}{backspace}j{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/mi8_component_0_0") + " textarea")
- .type("{end}{backspace}1{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣1yzuvk⎤⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣1yzuvk⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", 1, "y"],
- ["tuple", "z", "u"],
- ["tuple", "v", "k"],
- ],
- ];
- let matrixValue = [
- [1, "y"],
- ["z", "u"],
- ["v", "k"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([3, 2]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("add row and column");
- cy.get(cesc("#\\/mi_nRows") + " textarea")
- .type("{end}{backspace}4{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_nColumns") + " textarea")
- .type("{end}{backspace}3{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣1yczufvkjjjj⎤⎥\n⎥\n⎥\n⎥⎦");
-
- cy.get(cesc("#\\/matrixSize")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize1")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize2")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize3")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize4")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize5")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize6")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize7")).should("have.text", "4, 3");
- cy.get(cesc("#\\/matrixSize8")).should("have.text", "4, 3");
-
- cy.get(cesc("#\\/numRows")).should("have.text", "4");
- cy.get(cesc("#\\/numRows1")).should("have.text", "4");
- cy.get(cesc("#\\/numRows2")).should("have.text", "4");
- cy.get(cesc("#\\/numRows3")).should("have.text", "4");
- cy.get(cesc("#\\/numRows4")).should("have.text", "4");
- cy.get(cesc("#\\/numRows5")).should("have.text", "4");
- cy.get(cesc("#\\/numRows6")).should("have.text", "4");
- cy.get(cesc("#\\/numRows7")).should("have.text", "4");
- cy.get(cesc("#\\/numRows8")).should("have.text", "4");
-
- cy.get(cesc("#\\/numColumns")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns1")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns2")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns3")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns4")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns5")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns6")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns7")).should("have.text", "3");
- cy.get(cesc("#\\/numColumns8")).should("have.text", "3");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 4, 3],
- [
- "tuple",
- ["tuple", 1, "y", "c"],
- ["tuple", "z", "u", "f"],
- ["tuple", "v", "k", "j"],
- ["tuple", "j", "j", "j"],
- ],
- ];
- let matrixValue = [
- [1, "y", "c"],
- ["z", "u", "f"],
- ["v", "k", "j"],
- ["j", "j", "j"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([4, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
-
- cy.log("change all values");
-
- cy.get(cesc("#\\/mi5_component_0_0") + " textarea")
- .type("{end}{backspace}l{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_0_1") + " textarea")
- .type("{end}{backspace}m{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi7_component_0_2") + " textarea")
- .type("{end}{backspace}n{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi8_component_1_0") + " textarea")
- .type("{end}{backspace}o{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi_component_1_1") + " textarea")
- .type("{end}{backspace}p{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi1_component_1_2") + " textarea")
- .type("{end}{backspace}q{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2_component_2_0") + " textarea")
- .type("{end}{backspace}r{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3_component_2_1") + " textarea")
- .type("{end}{backspace}s{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4_component_2_2") + " textarea")
- .type("{end}{backspace}t{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi5_component_3_0") + " textarea")
- .type("{end}{backspace}w{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi6_component_3_1") + " textarea")
- .type("{end}{backspace}a{enter}", { force: true })
- .blur();
- cy.get(cesc("#\\/mi7_component_3_2") + " textarea")
- .type("{end}{backspace}b{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/A") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦",
- );
-
- cy.get(cesc("#\\/A") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
- cy.get(cesc("#\\/A8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢⎣lmnopqrstwab⎤⎥\n⎥\n⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 4, 3],
- [
- "tuple",
- ["tuple", "l", "m", "n"],
- ["tuple", "o", "p", "q"],
- ["tuple", "r", "s", "t"],
- ["tuple", "w", "a", "b"],
- ],
- ];
- let matrixValue = [
- ["l", "m", "n"],
- ["o", "p", "q"],
- ["r", "s", "t"],
- ["w", "a", "b"],
- ];
- expect(stateVariables["/A"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A3"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A4"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A5"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A6"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A7"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/A8"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
-
- expect(stateVariables["/A"].stateValues.matrixSize).eqls([4, 3]);
- expect(stateVariables["/A"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A1"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A2"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A3"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A4"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A5"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A6"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A7"].stateValues.matrix).eqls(matrixValue);
- expect(stateVariables["/A8"].stateValues.matrix).eqls(matrixValue);
- });
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/matrixinput.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/matrixinput.cy.js
index 2e52fe397..0964a1ca6 100644
--- a/packages/test-cypress/cypress/e2e/tagSpecific/matrixinput.cy.js
+++ b/packages/test-cypress/cypress/e2e/tagSpecific/matrixinput.cy.js
@@ -6,17891 +6,18 @@ describe("MatrixInput Tag Tests", function () {
cy.visit("/");
});
- it("no arguments, copy matrixinput", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Matrix 1:
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m1"}
- Matrix 4: $mi1.immediateValue{assignNames="m2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[_]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type a in mi1");
- cy.get(cesc("#\\/mi1") + " textarea").type("a", { force: true });
-
- cy.get(cesc("#\\/m2") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[_]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAstA = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- let matrixAstBlank = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAstA,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(
- matrixAstBlank,
- );
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAstA,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(
- matrixAstBlank,
- );
- expect(stateVariables["/m1"].stateValues.value).eqls(
- matrixAstBlank,
- );
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAstA);
- });
-
- cy.log("blur");
- cy.get(cesc("#\\/mi1") + " textarea").blur();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row to mi1");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a_]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a_]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "a"], ["tuple", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type b in second row of mi2");
- cy.get(cesc("#\\/mi2_component_1_0") + " textarea").type("b", {
- force: true,
- });
-
- cy.get(cesc("#\\/m2") + " .mjx-mrow").should("contain.text", "[ab]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a_]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "a"], ["tuple", "_"]],
- ];
- let matrixAstB = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "a"], ["tuple", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAstB,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAstB,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAstB);
- });
-
- cy.log("type enter");
- cy.get(cesc("#\\/mi2_component_1_0") + " textarea").type("{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ab]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "a"], ["tuple", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column to mi2");
- cy.get(cesc("#\\/mi2_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[a_b_]",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a_b_]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a_b_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "a", "_"], ["tuple", "b", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("c and d in second column");
- cy.get(cesc("#\\/mi2_component_0_1") + " textarea").type("c", {
- force: true,
- });
- cy.get(cesc("#\\/mi2_component_1_1") + " textarea").type("d", {
- force: true,
- });
-
- cy.get(cesc("#\\/m2") + " .mjx-mrow").should("contain.text", "[acbd]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[acb_]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[acbd]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "a", "c"], ["tuple", "b", "_"]],
- ];
- let matrixAstD = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "a", "c"], ["tuple", "b", "d"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAstD,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAstD,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAstD);
- });
-
- cy.log("blur");
- cy.get(cesc("#\\/mi2_component_1_1") + " textarea").blur();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[acbd]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[acbd]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[acbd]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "a", "c"], ["tuple", "b", "d"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove row in mi2");
- cy.get(cesc("#\\/mi2_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ac]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ac]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ac]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "a", "c"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change second value");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ae]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ae]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ae]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "a", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove column in mi1");
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi2_component_0_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[f]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[f]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[f]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "f"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("values remembered when add back row and column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi2_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[febd]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[febd]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[febd]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "f", "e"], ["tuple", "b", "d"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}g",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}h",
- { force: true },
- );
- cy.get(cesc("#\\/mi2_component_1_0") + " textarea").type(
- "{end}{backspace}i",
- { force: true },
- );
- cy.get(cesc("#\\/mi2_component_1_1") + " textarea")
- .type("{end}{backspace}j", { force: true })
- .blur();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ghij]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ghij]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "g", "h"], ["tuple", "i", "j"]],
- ];
- expect(stateVariables["/mi1"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mi2"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with matrix", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[abcd]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "a", "b"], ["tuple", "c", "d"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove column");
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ac]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ac]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "a"], ["tuple", "c"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}z{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[zc]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[zc]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "z"], ["tuple", "c"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column back");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[zbcd]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[zbcd]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "z", "b"], ["tuple", "c", "d"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[kgfh]");
-
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with matrix, start smaller", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = ["matrix", ["tuple", 0, 0], ["tuple"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row and column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}e{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ec]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ec]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "c"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type f in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column via mathinput");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ebfd]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ebfd]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "b"], ["tuple", "f", "d"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("g and h in second column");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with vector", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "a"], ["tuple", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove row");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("restore row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[eb]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type f in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[e_f_]",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "_"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("g and h in second column");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[kgfh]");
-
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with altvector", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "a"], ["tuple", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove row");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("restore row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[eb]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type f in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[e_f_]",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "_"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("g and h in second column");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[kgfh]");
-
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with vector, start smaller", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = ["matrix", ["tuple", 0, 0], ["tuple"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row and column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- console.log(stateVariables["/mi1"].stateValues.value);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}e{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[eb]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type f in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column via mathinput");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[e_f_]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "_"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("g and h in second column");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with altvector, start smaller", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = ["matrix", ["tuple", 0, 0], ["tuple"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row and column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- console.log(stateVariables["/mi1"].stateValues.value);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}e{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[eb]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type f in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column via mathinput");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[e_f_]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "_"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("g and h in second column");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with transpose of vector", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "a", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove column");
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("restore column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[eb]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[eb__]",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb__]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "b"], ["tuple", "_", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[kgfh]");
-
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with transpose of altvector", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "a", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove column");
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("restore column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[eb]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[eb__]",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb__]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "b"], ["tuple", "_", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[kgfh]");
-
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with transpose of vector, start smaller", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = ["matrix", ["tuple", 0, 0], ["tuple"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row and column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- console.log(stateVariables["/mi1"].stateValues.value);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}e{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e_]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type f in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column via mathinput");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ebf_]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ebf_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "b"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("g and h in second column");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with transpose of altvector, start smaller", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = ["matrix", ["tuple", 0, 0], ["tuple"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row and column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- console.log(stateVariables["/mi1"].stateValues.value);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}e{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e_]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type f in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column via mathinput");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ebf_]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ebf_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "b"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("g and h in second column");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with transpose of vector, start smaller, alternative format", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = ["matrix", ["tuple", 0, 0], ["tuple"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row and column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- console.log(stateVariables["/mi1"].stateValues.value);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}e{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e_]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type f in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column via mathinput");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ebf_]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ebf_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "b"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("g and h in second column");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("prefill with transpose of altvector, start smaller, alternative format", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Matrix 1:
- Matrix 2: $mi1.value{assignNames="m1"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = ["matrix", ["tuple", 0, 0], ["tuple"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row and column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[a]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[a]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "a"]],
- ];
- console.log(stateVariables["/mi1"].stateValues.value);
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}e{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e_]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type f in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ef]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column via mathinput");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ebf_]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ebf_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "b"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("g and h in second column");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to matrix", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Matrix 1: \\begin{matrix}a & b\\\\c & d\\end{matrix}
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[abcd]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[abcd]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "a", "b"], ["tuple", "c", "d"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change entries");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to matrix, ignore size via definition", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Matrix 1: \\begin{matrix}a & b\\\\c & d\\end{matrix}
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
-
- $ti.value{assignNames="t"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("7");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("5");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[abcd]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[abcd]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "a", "b"], ["tuple", "c", "d"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[ebcd]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("7");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("5");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ebcd]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ebcd]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "b"], ["tuple", "c", "d"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove row");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[eb]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("5");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("ignore change in numRows");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}9{enter}",
- {
- force: true,
- },
- );
-
- // wait for core to responds to change in textinput, so know have waited long enough
- cy.get(cesc("#\\/ti_input")).type("wait{enter}");
-
- cy.get(cesc("#\\/t")).should("have.text", "wait");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("9");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("5");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eb]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to vector", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Vector 1: (a,b)
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(a,b)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let vectorAst = ["tuple", "a", "b"];
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "a"], ["tuple", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,f)");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- let vectorAst = ["tuple", "e", "f"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row, original stays a vector");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,f,_)",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f,_)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ef_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"], ["tuple", "_"]],
- ];
- let vectorAst = ["tuple", "e", "f", "_"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}z{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,f,z)");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f,z)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣efz⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"], ["tuple", "z"]],
- ];
- let vectorAst = ["tuple", "e", "f", "z"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove row");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,f)");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- let vectorAst = ["tuple", "e", "f"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("get value back when add rows");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}4{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,f,z,_)",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc(`#\\/mi1_component_3_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f,z,_)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣efz_⎤⎥\n⎥\n⎥\n⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 4, 1],
- [
- "tuple",
- ["tuple", "e"],
- ["tuple", "f"],
- ["tuple", "z"],
- ["tuple", "_"],
- ],
- ];
- let vectorAst = ["tuple", "e", "f", "z", "_"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_3_0") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,f,_,y)",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_3_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("y");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f,_,y)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣ef_y⎤⎥\n⎥\n⎥\n⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 4, 1],
- [
- "tuple",
- ["tuple", "e"],
- ["tuple", "f"],
- ["tuple", "_"],
- ["tuple", "y"],
- ],
- ];
- let vectorAst = ["tuple", "e", "f", "_", "y"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("back to 2D vector");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,f)");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- let vectorAst = ["tuple", "e", "f"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column via mathinput");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[e_f_]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "_"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("g and h in second column");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to altvector", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Vector 1: ⟨a,b⟩
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨a,b⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let vectorAst = ["altvector", "a", "b"];
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "a"], ["tuple", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,f⟩");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- let vectorAst = ["altvector", "e", "f"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row, original stays a vector");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,f,_⟩",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f,_⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣ef_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"], ["tuple", "_"]],
- ];
- let vectorAst = ["altvector", "e", "f", "_"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}z{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,f,z⟩");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f,z⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣efz⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"], ["tuple", "z"]],
- ];
- let vectorAst = ["altvector", "e", "f", "z"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove row");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,f⟩");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- let vectorAst = ["altvector", "e", "f"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("get value back when add rows");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}4{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,f,z,_⟩",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc(`#\\/mi1_component_3_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f,z,_⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣efz_⎤⎥\n⎥\n⎥\n⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 4, 1],
- [
- "tuple",
- ["tuple", "e"],
- ["tuple", "f"],
- ["tuple", "z"],
- ["tuple", "_"],
- ],
- ];
- let vectorAst = ["altvector", "e", "f", "z", "_"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_3_0") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,f,_,y⟩",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_3_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("y");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f,_,y⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢\n⎢\n⎢\n⎢⎣ef_y⎤⎥\n⎥\n⎥\n⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 4, 1],
- [
- "tuple",
- ["tuple", "e"],
- ["tuple", "f"],
- ["tuple", "_"],
- ["tuple", "y"],
- ],
- ];
- let vectorAst = ["altvector", "e", "f", "_", "y"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("back to 2D vector");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,f⟩");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- let vectorAst = ["altvector", "e", "f"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column via mathinput");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[e_f_]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "_"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("g and h in second column");
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to vector, ignore size via definition", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Vector 1: (a,b,c)
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
-
- $ti.value{assignNames="t"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("7");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(a,b,c)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abc⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let vectorAst = ["tuple", "a", "b", "c"];
- let matrixAst = [
- "matrix",
- ["tuple", 3, 1],
- ["tuple", ["tuple", "a"], ["tuple", "b"], ["tuple", "c"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,f,c)");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("7");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f,c)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣efc⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"], ["tuple", "c"]],
- ];
- let vectorAst = ["tuple", "e", "f", "c"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("ignore change in numColumns");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- // wait for core to responds to change in textinput, so know have waited long enough
- cy.get(cesc("#\\/ti_input")).type("wait{enter}");
-
- cy.get(cesc("#\\/t")).should("have.text", "wait");
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,f,c)");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f,c)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣efc⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"], ["tuple", "c"]],
- ];
- let vectorAst = ["tuple", "e", "f", "c"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove row");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,f)");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f)");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- let vectorAst = ["tuple", "e", "f"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[e_f_]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "_"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to altvector, ignore size via definition", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Vector 1: ⟨a,b,c⟩
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
-
- $ti.value{assignNames="t"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("7");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨a,b,c⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣abc⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let vectorAst = ["altvector", "a", "b", "c"];
- let matrixAst = [
- "matrix",
- ["tuple", 3, 1],
- ["tuple", ["tuple", "a"], ["tuple", "b"], ["tuple", "c"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,f,c⟩");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("7");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f,c⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣efc⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"], ["tuple", "c"]],
- ];
- let vectorAst = ["altvector", "e", "f", "c"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("ignore change in numColumns");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- // wait for core to responds to change in textinput, so know have waited long enough
- cy.get(cesc("#\\/ti_input")).type("wait{enter}");
-
- cy.get(cesc("#\\/t")).should("have.text", "wait");
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,f,c⟩");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f,c⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣efc⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"], ["tuple", "c"]],
- ];
- let vectorAst = ["altvector", "e", "f", "c"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove row");
- cy.get(cesc("#\\/mi1_rowDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,f⟩");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f⟩");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 1],
- ["tuple", ["tuple", "e"], ["tuple", "f"]],
- ];
- let vectorAst = ["altvector", "e", "f"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[e_f_]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e_f_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "_"], ["tuple", "f", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to transpose of vector", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Vector 1: (a,b)^T
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(a,b)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let vectorAst = ["^", ["tuple", "a", "b"], "T"];
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "a", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,g)T");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["^", ["tuple", "e", "g"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column, original stays a vector");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,g,_)T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g,_)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "g", "_"]],
- ];
- let vectorAst = ["^", ["tuple", "e", "g", "_"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_2") + " textarea").type(
- "{end}{backspace}z{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,g,z)T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g,z)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egz]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "g", "z"]],
- ];
- let vectorAst = ["^", ["tuple", "e", "g", "z"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove column");
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,g)T");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["^", ["tuple", "e", "g"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("get value back when add columns");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}4{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,g,z,_)T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc(`#\\/mi1_component_0_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g,z,_)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egz_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "e", "g", "z", "_"]],
- ];
- let vectorAst = ["^", ["tuple", "e", "g", "z", "_"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_2") + " textarea").type(
- "{end}{backspace}{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_3") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,g,_,y)T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_0_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("y");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g,_,y)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg_y]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "e", "g", "_", "y"]],
- ];
- let vectorAst = ["^", ["tuple", "e", "g", "_", "y"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("back to 2D vector transpose");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,g)T");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["^", ["tuple", "e", "g"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[eg__]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg__]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg__]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "_", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("f and h in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to transpose of altvector", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Vector 1: ⟨a,b⟩^T
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨a,b⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let vectorAst = ["^", ["altvector", "a", "b"], "T"];
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "a", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,g⟩T");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["^", ["altvector", "e", "g"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column, original stays a vector");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,g,_⟩T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g,_⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "g", "_"]],
- ];
- let vectorAst = ["^", ["altvector", "e", "g", "_"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_2") + " textarea").type(
- "{end}{backspace}z{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,g,z⟩T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g,z⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egz]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "g", "z"]],
- ];
- let vectorAst = ["^", ["altvector", "e", "g", "z"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove column");
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,g⟩T");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["^", ["altvector", "e", "g"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("get value back when add columns");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}4{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,g,z,_⟩T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc(`#\\/mi1_component_0_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g,z,_⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egz_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "e", "g", "z", "_"]],
- ];
- let vectorAst = ["^", ["altvector", "e", "g", "z", "_"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_2") + " textarea").type(
- "{end}{backspace}{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_3") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,g,_,y⟩T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_0_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("y");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g,_,y⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg_y]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "e", "g", "_", "y"]],
- ];
- let vectorAst = ["^", ["altvector", "e", "g", "_", "y"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("back to 2D vector transpose");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,g⟩T");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["^", ["altvector", "e", "g"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[eg__]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg__]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg__]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "_", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("f and h in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to transpose of vector, alternative format", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Vector 1: (a,b)'
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(a,b)′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let vectorAst = ["prime", ["tuple", "a", "b"]];
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "a", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,g)′");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g)′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["prime", ["tuple", "e", "g"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column, original stays a vector");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,g,_)′",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g,_)′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "g", "_"]],
- ];
- let vectorAst = ["prime", ["tuple", "e", "g", "_"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_2") + " textarea").type(
- "{end}{backspace}z{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,g,z)′",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g,z)′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egz]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "g", "z"]],
- ];
- let vectorAst = ["prime", ["tuple", "e", "g", "z"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove column");
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,g)′");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g)′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["prime", ["tuple", "e", "g"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("get value back when add columns");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}4{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,g,z,_)′",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc(`#\\/mi1_component_0_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g,z,_)′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egz_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "e", "g", "z", "_"]],
- ];
- let vectorAst = ["prime", ["tuple", "e", "g", "z", "_"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_2") + " textarea").type(
- "{end}{backspace}{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_3") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,g,_,y)′",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_0_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("y");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g,_,y)′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg_y]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "e", "g", "_", "y"]],
- ];
- let vectorAst = ["prime", ["tuple", "e", "g", "_", "y"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("back to 2D vector transpose");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,g)′");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,g)′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["prime", ["tuple", "e", "g"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[eg__]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg__]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg__]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "_", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("f and h in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to transpose of vector, alternative format", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Vector 1: ⟨a,b⟩'
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨a,b⟩′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let vectorAst = ["prime", ["altvector", "a", "b"]];
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "a", "b"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}g{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,g⟩′");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g⟩′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["prime", ["altvector", "e", "g"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column, original stays a vector");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,g,_⟩′",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g,_⟩′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "g", "_"]],
- ];
- let vectorAst = ["prime", ["altvector", "e", "g", "_"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_2") + " textarea").type(
- "{end}{backspace}z{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,g,z⟩′",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g,z⟩′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egz]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "g", "z"]],
- ];
- let vectorAst = ["prime", ["altvector", "e", "g", "z"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove column");
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,g⟩′");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g⟩′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["prime", ["altvector", "e", "g"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("get value back when add columns");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}4{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,g,z,_⟩′",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("z");
- });
- cy.get(cesc(`#\\/mi1_component_0_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g,z,_⟩′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egz_]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "e", "g", "z", "_"]],
- ];
- let vectorAst = ["prime", ["altvector", "e", "g", "z", "_"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_2") + " textarea").type(
- "{end}{backspace}{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_3") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,g,_,y⟩′",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_0_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("y");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g,_,y⟩′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg_y]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 4],
- ["tuple", ["tuple", "e", "g", "_", "y"]],
- ];
- let vectorAst = ["prime", ["altvector", "e", "g", "_", "y"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("back to 2D vector transpose");
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}2{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,g⟩′");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,g⟩′");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "g"]],
- ];
- let vectorAst = ["prime", ["altvector", "e", "g"]];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}2{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[eg__]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg__]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[eg__]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "_", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("f and h in second row");
- cy.get(cesc("#\\/mi1_component_1_0") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_1_1") + " textarea").type(
- "{end}{backspace}h{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[egfh]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[egfh]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "g"], ["tuple", "f", "h"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row via mathinput");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfh__⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfh__⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "_", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change third row values");
- cy.get(cesc("#\\/mi1_component_2_0") + " textarea").type(
- "{end}{backspace}i{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_2_1") + " textarea").type(
- "{end}{backspace}j{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣egfhij⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣egfhij⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 2],
- [
- "tuple",
- ["tuple", "e", "g"],
- ["tuple", "f", "h"],
- ["tuple", "i", "j"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("down to one entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}1{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}1{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[e]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[e]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "e"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change value");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}k{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "[k]");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[k]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "k"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("up to 3x3 entry");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/numColumns") + " textarea").type(
- "{end}{backspace}3{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣kg_fh_ij_⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("k");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("g");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("h");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("i");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("j");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣kg_fh_ij_⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", "k", "g", "_"],
- ["tuple", "f", "h", "_"],
- ["tuple", "i", "j", "_"],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to transpose of vector, ignore size via definition", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Vector 1: (a,b,c)^T
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
-
- $ti.value{assignNames="t"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("7");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(a,b,c)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[abc]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let vectorAst = ["^", ["tuple", "a", "b", "c"], "T"];
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "a", "b", "c"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,f,c)T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("7");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f,c)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[efc]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "f", "c"]],
- ];
- let vectorAst = ["^", ["tuple", "e", "f", "c"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("ignore change in numRows");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- // wait for core to responds to change in textinput, so know have waited long enough
- cy.get(cesc("#\\/ti_input")).type("wait{enter}");
-
- cy.get(cesc("#\\/t")).should("have.text", "wait");
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "(e,f,c)T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f,c)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[efc]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "f", "c"]],
- ];
- let vectorAst = ["^", ["tuple", "e", "f", "c"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove column");
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "(e,f)T");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "(e,f)T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "f"]],
- ];
- let vectorAst = ["^", ["tuple", "e", "f"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[ef__]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef__]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef__]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "f"], ["tuple", "_", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("bind to transpose of vector, ignore size via definition", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Number of rows:
- Number of columns:
-
- Vector 1: ⟨a,b,c⟩^T
- Matrix 2:
- Matrix 3: $mi1.value{assignNames="m2"}
-
- $ti.value{assignNames="t"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("7");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("a");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨a,b,c⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[abc]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let vectorAst = ["^", ["altvector", "a", "b", "c"], "T"];
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "a", "b", "c"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("change values");
- cy.get(cesc("#\\/mi1_component_0_0") + " textarea").type(
- "{end}{backspace}e{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/mi1_component_0_1") + " textarea").type(
- "{end}{backspace}f{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,f,c⟩T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("7");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f,c⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[efc]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "f", "c"]],
- ];
- let vectorAst = ["^", ["altvector", "e", "f", "c"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("ignore change in numRows");
- cy.get(cesc("#\\/numRows") + " textarea").type(
- "{end}{backspace}3{enter}",
- {
- force: true,
- },
- );
-
- // wait for core to responds to change in textinput, so know have waited long enough
- cy.get(cesc("#\\/ti_input")).type("wait{enter}");
-
- cy.get(cesc("#\\/t")).should("have.text", "wait");
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⟨e,f,c⟩T",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f,c⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[efc]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 3],
- ["tuple", ["tuple", "e", "f", "c"]],
- ];
- let vectorAst = ["^", ["altvector", "e", "f", "c"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("remove column");
- cy.get(cesc("#\\/mi1_columnDecrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should("contain.text", "⟨e,f⟩T");
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⟨e,f⟩T");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 1, 2],
- ["tuple", ["tuple", "e", "f"]],
- ];
- let vectorAst = ["^", ["altvector", "e", "f"], "T"];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(vectorAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[ef__]",
- );
-
- cy.get(cesc(`#\\/numRows`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/numColumns`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
- });
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("e");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("f");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef__]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[ef__]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", "e", "f"], ["tuple", "_", "_"]],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("matrixinput eliminates multicharacter symbols", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- x2
- xyz
-
-
- $varWithNum2.value{assignNames="varWithNum3"}
- $noSplit2.value{assignNames="noSplit3"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/varWithNum"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("x2");
- });
- cy.get(cesc(`#\\/varWithNum2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "x2",
- );
- });
- cy.get(cesc("#\\/varWithNum3"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("[x2]");
- });
- cy.get(cesc("#\\/noSplit"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("xyz");
- });
- cy.get(cesc(`#\\/noSplit2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "xyz",
- );
- });
- cy.get(cesc("#\\/noSplit3"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("[xyz]");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/varWithNum"].stateValues.value).eq("x2");
- expect(stateVariables["/varWithNum2"].stateValues.value).eqls([
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "x2"]],
- ]);
- expect(stateVariables["/varWithNum3"].stateValues.value).eqls([
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "x2"]],
- ]);
- expect(stateVariables["/noSplit"].stateValues.value).eq("xyz");
- expect(stateVariables["/noSplit2"].stateValues.value).eqls([
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "xyz"]],
- ]);
- expect(stateVariables["/noSplit3"].stateValues.value).eqls([
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "xyz"]],
- ]);
- });
-
- cy.get(cesc("#\\/varWithNum2") + " textarea").type(
- "{end}{backspace}u9j{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/noSplit2") + " textarea").type(
- "{end}{backspace}uv{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/noSplit") + " .mjx-mrow").should(
- "contain.text",
- "[xyuv]",
- );
-
- cy.get(cesc("#\\/varWithNum"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("[xu9j]");
- });
- cy.get(cesc(`#\\/varWithNum2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "xu9j",
- );
- });
- cy.get(cesc("#\\/varWithNum3"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("[xu9j]");
- });
- cy.get(cesc("#\\/noSplit"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("[xyuv]");
- });
- cy.get(cesc(`#\\/noSplit2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "xyuv",
- );
- });
- cy.get(cesc("#\\/noSplit3"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("[xyuv]");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/varWithNum"].stateValues.value).eqls([
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "xu9j"]],
- ]);
- expect(stateVariables["/varWithNum2"].stateValues.value).eqls([
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "xu9j"]],
- ]);
- expect(stateVariables["/varWithNum3"].stateValues.value).eqls([
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "xu9j"]],
- ]);
- expect(stateVariables["/noSplit"].stateValues.value).eqls([
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "xyuv"]],
- ]);
- expect(stateVariables["/noSplit2"].stateValues.value).eqls([
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "xyuv"]],
- ]);
- expect(stateVariables["/noSplit3"].stateValues.value).eqls([
- "matrix",
- ["tuple", 1, 1],
- ["tuple", ["tuple", "xyuv"]],
- ]);
- });
- });
-
- it("default entry", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- Matrix Input:
- Matrix from value:
- Matrix from immediate value:
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[0000]");
- cy.get(cesc("#\\/mv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[0000]");
-
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", 0, 0], ["tuple", 0, 0]],
- ];
- expect(stateVariables["/mi"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/miv"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mv"].stateValues.value).eqls(matrixAst);
- });
-
- // not sure why have to wait so that MathJax can correctly process
- // change to immediate value
- cy.wait(200);
-
- cy.log("type b in second row of mi");
- cy.get(cesc("#\\/mi_component_1_0") + " textarea").type(
- "{end}{backspace}b",
- {
- force: true,
- delay: 200,
- },
- );
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow").should("contain.text", "[00b0]");
-
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00b0]");
- cy.get(cesc("#\\/mv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[0000]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixivAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", 0, 0], ["tuple", "b", 0]],
- ];
- let matrixvAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", 0, 0], ["tuple", 0, 0]],
- ];
- expect(stateVariables["/mi"].stateValues.immediateValue).eqls(
- matrixivAst,
- );
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixvAst);
- expect(stateVariables["/miv"].stateValues.value).eqls(matrixivAst);
- expect(stateVariables["/mv"].stateValues.value).eqls(matrixvAst);
- });
-
- cy.log("blur");
- cy.get(cesc("#\\/mi_component_1_0") + " textarea").blur();
-
- cy.get(cesc("#\\/mv") + " .mjx-mrow").should("contain.text", "[00b0]");
-
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00b0]");
- cy.get(cesc("#\\/mv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00b0]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", 0, 0], ["tuple", "b", 0]],
- ];
- expect(stateVariables["/mi"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/miv"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mv"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add column");
- cy.get(cesc("#\\/mi_columnIncrement")).click();
-
- cy.get(cesc("#\\/mv") + " .mjx-mrow").should(
- "contain.text",
- "[000b00]",
- );
-
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[000b00]");
- cy.get(cesc("#\\/mv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[000b00]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", 0, 0, 0], ["tuple", "b", 0, 0]],
- ];
- expect(stateVariables["/mi"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/miv"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mv"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type c in third column of mi");
- cy.get(cesc("#\\/mi_component_0_2") + " textarea").type(
- "{end}{backspace}c",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow").should(
- "contain.text",
- "[00cb00]",
- );
-
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00cb00]");
- cy.get(cesc("#\\/mv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[000b00]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixivAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", 0, 0, "c"], ["tuple", "b", 0, 0]],
- ];
- let matrixvAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", 0, 0, 0], ["tuple", "b", 0, 0]],
- ];
- expect(stateVariables["/mi"].stateValues.immediateValue).eqls(
- matrixivAst,
- );
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixvAst);
- expect(stateVariables["/miv"].stateValues.value).eqls(matrixivAst);
- expect(stateVariables["/mv"].stateValues.value).eqls(matrixvAst);
- });
-
- cy.log("type enter");
- cy.get(cesc("#\\/mi_component_0_2") + " textarea").type("{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/mv") + " .mjx-mrow").should(
- "contain.text",
- "[00cb00]",
- );
-
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00cb00]");
- cy.get(cesc("#\\/mv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[00cb00]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 2, 3],
- ["tuple", ["tuple", 0, 0, "c"], ["tuple", "b", 0, 0]],
- ];
- expect(stateVariables["/mi"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/miv"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mv"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("add row");
- cy.get(cesc("#\\/mi_rowIncrement")).click();
-
- cy.get(cesc("#\\/mv") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣00cb00000⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣00cb00000⎤⎥⎦");
- cy.get(cesc("#\\/mv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣00cb00000⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", 0, 0, "c"],
- ["tuple", "b", 0, 0],
- ["tuple", 0, 0, 0],
- ],
- ];
- expect(stateVariables["/mi"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/miv"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mv"].stateValues.value).eqls(matrixAst);
- });
-
- cy.log("type d in third row of mi");
- cy.get(cesc("#\\/mi_component_2_1") + " textarea").type(
- "{end}{backspace}d",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣00cb000d0⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc(`#\\/mi_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣00cb000d0⎤⎥⎦");
- cy.get(cesc("#\\/mv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣00cb00000⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixivAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", 0, 0, "c"],
- ["tuple", "b", 0, 0],
- ["tuple", 0, "d", 0],
- ],
- ];
- let matrixvAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", 0, 0, "c"],
- ["tuple", "b", 0, 0],
- ["tuple", 0, 0, 0],
- ],
- ];
- expect(stateVariables["/mi"].stateValues.immediateValue).eqls(
- matrixivAst,
- );
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixvAst);
- expect(stateVariables["/miv"].stateValues.value).eqls(matrixivAst);
- expect(stateVariables["/mv"].stateValues.value).eqls(matrixvAst);
- });
-
- cy.log("blur");
- cy.get(cesc("#\\/mi_component_2_1") + " textarea").blur();
-
- cy.get(cesc("#\\/mv") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣00cb000d0⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("c");
- });
- cy.get(cesc(`#\\/mi_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("b");
- });
- cy.get(cesc(`#\\/mi_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("d");
- });
- cy.get(cesc(`#\\/mi_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.get(cesc("#\\/miv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣00cb000d0⎤⎥⎦");
- cy.get(cesc("#\\/mv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣00cb000d0⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", 0, 0, "c"],
- ["tuple", "b", 0, 0],
- ["tuple", 0, "d", 0],
- ],
- ];
- expect(stateVariables["/mi"].stateValues.immediateValue).eqls(
- matrixAst,
- );
- expect(stateVariables["/mi"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/miv"].stateValues.value).eqls(matrixAst);
- expect(stateVariables["/mv"].stateValues.value).eqls(matrixAst);
- });
- });
-
- it("default entry, prefill sparse matrix", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Sparse matrix:
- \\begin{matrix}\\\\ & 3\\end{matrix}
-
- Matrix 1:
- Matrix 1A: $mi1.value{assignNames="m1"}
- Matrix 2:
- Matrix 2A: $mi2.value{assignNames="m2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣00_03____⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣000030000⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst1 = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", 0, 0, "_"],
- ["tuple", 0, 3, "_"],
- ["tuple", "_", "_", "_"],
- ],
- ];
- let matrixAst2 = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", 0, 0, 0],
- ["tuple", 0, 3, 0],
- ["tuple", 0, 0, 0],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst1);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst1);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst2);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst2);
- });
-
- cy.log("add column");
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi2_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣00__03______⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_0_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_0_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_1_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_2_3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣00__03______⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣000003000000⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst1 = [
- "matrix",
- ["tuple", 3, 4],
- [
- "tuple",
- ["tuple", 0, 0, "_", "_"],
- ["tuple", 0, 3, "_", "_"],
- ["tuple", "_", "_", "_", "_"],
- ],
- ];
- let matrixAst2 = [
- "matrix",
- ["tuple", 3, 4],
- [
- "tuple",
- ["tuple", 0, 0, 0, 0],
- ["tuple", 0, 3, 0, 0],
- ["tuple", 0, 0, 0, 0],
- ],
- ];
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst1);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst1);
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst2);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst2);
- });
- });
-
- it("default entry, bind value to sparse matrix", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Sparse matrix:
- \\begin{matrix}\\\\ & 3\\end{matrix}
-
- Sparse matrix 2: $sparse1{link="false" name="sparse2"}
- Matrix 1:
- Matrix 1A: $mi1.value{assignNames="m1"}
- Matrix 2:
- Matrix 2A: $mi2.value{assignNames="m2"}
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
-
- cy.get(cesc("#\\/sparse1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[0003]");
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[0003]");
- cy.get(cesc("#\\/sparse2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[0003]");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "[0003]");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst1 = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", 0, 0], ["tuple", 0, 3]],
- ];
- let matrixAst2 = [
- "matrix",
- ["tuple", 2, 2],
- ["tuple", ["tuple", 0, 0], ["tuple", 0, 3]],
- ];
- expect(stateVariables["/sparse1"].stateValues.value).eqls(
- matrixAst1,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst1);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst1);
- expect(stateVariables["/sparse2"].stateValues.value).eqls(
- matrixAst2,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst2);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst2);
- });
-
- cy.log("add row and column");
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
- cy.get(cesc("#\\/mi2_rowIncrement")).click();
- cy.get(cesc("#\\/mi1_columnIncrement")).click();
- cy.get(cesc("#\\/mi2_columnIncrement")).click();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣00_03____⎤⎥⎦",
- );
- cy.get(cesc("#\\/m2") + " .mjx-mrow").should(
- "contain.text",
- "⎡⎢⎣000030000⎤⎥⎦",
- );
-
- cy.get(cesc(`#\\/mi1_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi1_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi1_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc(`#\\/mi1_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
-
- cy.get(cesc(`#\\/mi2_component_0_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_0_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_0_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_1_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_1_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
- });
- cy.get(cesc(`#\\/mi2_component_1_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_2_0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_2_1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
- cy.get(cesc(`#\\/mi2_component_2_2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.get(cesc("#\\/sparse1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣00_03____⎤⎥⎦");
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣00_03____⎤⎥⎦");
- cy.get(cesc("#\\/sparse2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣000030000⎤⎥⎦");
- cy.get(cesc("#\\/m2"))
- .find(".mjx-mrow")
- .eq(0)
- .should("have.text", "⎡⎢⎣000030000⎤⎥⎦");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let matrixAst1 = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", 0, 0, "_"],
- ["tuple", 0, 3, "_"],
- ["tuple", "_", "_", "_"],
- ],
- ];
- let matrixAst2 = [
- "matrix",
- ["tuple", 3, 3],
- [
- "tuple",
- ["tuple", 0, 0, 0],
- ["tuple", 0, 3, 0],
- ["tuple", 0, 0, 0],
- ],
- ];
- expect(stateVariables["/sparse1"].stateValues.value).eqls(
- matrixAst1,
- );
- expect(stateVariables["/mi1"].stateValues.value).eqls(matrixAst1);
- expect(stateVariables["/m1"].stateValues.value).eqls(matrixAst1);
- expect(stateVariables["/sparse2"].stateValues.value).eqls(
- matrixAst2,
- );
- expect(stateVariables["/mi2"].stateValues.value).eqls(matrixAst2);
- expect(stateVariables["/m2"].stateValues.value).eqls(matrixAst2);
- });
- });
-
- it("values from matrix prop using array notation", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- a b
- c d
-
-
- Matrix Input:
- Matrix: $mi.matrix
- Row number:
- Column number:
- Row: $mi.matrix[$rnum]
- Entry: $mi.matrix[$rnum][$cnum]{assignNames="entry"}
- Change entry: $entry
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/pmatrix") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abcd]");
- cy.get(cesc2("#/prow") + " .mjx-mrow").should("not.exist");
- cy.get(cesc2("#/pentry") + " .mjx-mrow").should("not.exist");
-
- cy.log("pick second row");
- cy.get(cesc2("#/rnum") + " textarea").type("2{enter}", { force: true });
- cy.get(cesc2("#/prow") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[cd]");
- cy.get(cesc2("#/pentry") + " .mjx-mrow").should("not.exist");
-
- cy.log("pick first column");
- cy.get(cesc2("#/cnum") + " textarea").type("1{enter}", { force: true });
- cy.get(cesc2("#/pentry") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "c");
-
- cy.log("change entry from bound value");
- cy.get(cesc2("#/mi_entry") + " textarea").type(
- "{end}{backspace}x{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc2("#/pentry") + " .mjx-mrow").should("contain.text", "x");
- cy.get(cesc2("#/pmatrix") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[abxd]");
- cy.get(cesc2("#/prow") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xd]");
- cy.get(cesc2("#/pentry") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x");
-
- cy.log("change row");
- cy.get(cesc2("#/rnum") + " textarea").type("{end}{backspace}1{enter}", {
- force: true,
- });
- cy.get(cesc2("#/prow") + " .mjx-mrow").should("contain.text", "[ab]");
- cy.get(cesc2("#/prow") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ab]");
- cy.get(cesc2("#/pentry") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "a");
-
- cy.log("change value from matrix input");
- cy.get(cesc("#\\/mi_component_0_0") + " textarea").type(
- "{end}{backspace}y{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc2("#/pentry") + " .mjx-mrow").should("contain.text", "y");
- cy.get(cesc2("#/pmatrix") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ybxd]");
- cy.get(cesc2("#/prow") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[yb]");
- cy.get(cesc2("#/pentry") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "y");
- });
-
- it("parse scientific notation", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/mi1") + " .mq-editable-field").should(
- "have.text",
- "5E+1",
- );
- cy.get(cesc("#\\/m1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[5E+1]");
- cy.get(cesc("#\\/mi2") + " .mq-editable-field").should(
- "have.text",
- "50",
- );
- cy.get(cesc("#\\/m2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[50]");
-
- cy.get(cesc("#\\/mi1") + " textarea")
- .type("{end}{shift+home}{backspace}2x−3E+2{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/m1") + " .mjx-mrow").should(
- "contain.text",
- "[2x−3E+2]",
- );
-
- cy.get(cesc("#\\/mi1") + " .mq-editable-field").should(
- "have.text",
- "2x−3E+2",
- );
- cy.get(cesc("#\\/m1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2x−3E+2]");
-
- cy.get(cesc("#\\/mi2") + " textarea")
- .type("{end}{shift+home}{backspace}2x-3E+2{enter}", { force: true })
- .blur();
-
- cy.get(cesc("#\\/m2") + " .mjx-mrow").should(
- "contain.text",
- "[2x−300]",
- );
-
- cy.get(cesc("#\\/mi2") + " .mq-editable-field").should(
- "have.text",
- "2x−3E+2",
- );
- cy.get(cesc("#\\/m2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2x−300]");
- });
-
- it("set value from immediateValue on reload", () => {
- let doenetML = `
-
-
- value: $n
- immediate value: $n.immediateValue
- `;
-
- cy.get("#testRunner_toggleControls").click();
- cy.get("#testRunner_allowLocalState").click();
- cy.wait(100);
- cy.get("#testRunner_toggleControls").click();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/n") + " textarea").type("1", { force: true });
-
- cy.get(cesc("#\\/piv") + " .mjx-mrow").should("contain.text", "[1]");
- cy.get(cesc("#\\/piv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1]");
- cy.get(cesc("#\\/pv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
-
- cy.wait(1500); // wait for debounce
-
- cy.reload();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/pv") + " .mjx-mrow").should("contain.text", "[1]");
- cy.get(cesc("#\\/piv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1]");
- cy.get(cesc("#\\/pv") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[1]");
- });
-
- it("minComponentWidth attribute", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- Specify min component width:
-
- Original:
- Result:
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/mcw") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "50px",
- );
-
- cy.get(
- cesc("#\\/original_component_0_0") + " .mq-editable-field",
- ).should("have.css", "min-width", "0px");
- cy.get(cesc("#\\/result_component_0_0") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "0px",
- );
-
- cy.get(cesc("#\\/mcw") + " textarea").type(
- "{end}{backspace}100{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/result_component_0_0") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "100px",
- );
-
- cy.get(cesc("#\\/original_rowIncrement")).click();
- cy.get(cesc("#\\/original_columnIncrement")).click();
- cy.get(cesc("#\\/result_rowIncrement")).click();
- cy.get(cesc("#\\/result_columnIncrement")).click();
-
- cy.get(cesc("#\\/result_component_1_1") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "100px",
- );
- cy.get(cesc("#\\/result_component_0_0") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "100px",
- );
- cy.get(cesc("#\\/result_component_0_1") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "100px",
- );
- cy.get(cesc("#\\/result_component_1_0") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "100px",
- );
-
- cy.get(
- cesc("#\\/original_component_0_0") + " .mq-editable-field",
- ).should("have.css", "min-width", "0px");
- cy.get(
- cesc("#\\/original_component_0_1") + " .mq-editable-field",
- ).should("have.css", "min-width", "0px");
- cy.get(
- cesc("#\\/original_component_1_0") + " .mq-editable-field",
- ).should("have.css", "min-width", "0px");
- cy.get(
- cesc("#\\/original_component_1_1") + " .mq-editable-field",
- ).should("have.css", "min-width", "0px");
-
- cy.get(cesc("#\\/mcw") + " textarea").type("{end}x{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/result_component_0_0") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "0px",
- );
- cy.get(cesc("#\\/result_component_0_1") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "0px",
- );
- cy.get(cesc("#\\/result_component_1_0") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "0px",
- );
- cy.get(cesc("#\\/result_component_1_1") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "0px",
- );
-
- cy.get(cesc("#\\/mcw") + " textarea").type(
- "{end}{backspace}{backspace}{backspace}7{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/result_component_0_0") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "17px",
- );
- cy.get(cesc("#\\/result_component_0_1") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "17px",
- );
- cy.get(cesc("#\\/result_component_1_0") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "17px",
- );
- cy.get(cesc("#\\/result_component_1_1") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "17px",
- );
-
- cy.get(cesc("#\\/mcw") + " textarea").type(
- "{end}{backspace}{backspace}-20{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/result_component_0_0") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "0px",
- );
- cy.get(cesc("#\\/result_component_0_1") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "0px",
- );
- cy.get(cesc("#\\/result_component_1_0") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "0px",
- );
- cy.get(cesc("#\\/result_component_1_1") + " .mq-editable-field").should(
- "have.css",
- "min-width",
- "0px",
- );
- });
-
- it("valueChanged", () => {
- let doenetML = `
-
-
-
- $mi2.immediateValue
-
- `;
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "false");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log("type in first marks only first immediate value as changed");
-
- cy.get(cesc2("#/mi1_component_0_0") + " textarea").type("z", {
- force: true,
- });
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow").should("contain.text", "[z]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "false");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log("press enter in first marks only first value as changed");
-
- cy.get(cesc2("#/mi1_component_0_0") + " textarea").type("{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow").should("contain.text", "[z]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log("type in second marks only second immediate value as changed");
-
- cy.get(cesc2("#/mi2_component_0_0") + " textarea").type(
- "{end}{backspace}a",
- {
- force: true,
- },
- );
-
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow").should("contain.text", "[ay]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log("press enter in second marks only second value as changed");
-
- cy.get(cesc2("#/mi2_component_0_0") + " textarea").type("{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/mi2a") + " .mjx-mrow").should("contain.text", "[ay]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "true");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log("type in third marks third immediate value as changed");
-
- cy.get(cesc2("#/mi3_component_0_0") + " textarea").type(
- "{end}{backspace}b",
- {
- force: true,
- },
- );
-
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow").should("contain.text", "[b]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "true");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log("press enter in third marks third value as changed");
-
- cy.get(cesc2("#/mi3_component_0_0") + " textarea").type("{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/mi3a") + " .mjx-mrow").should("contain.text", "[b]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "true");
- cy.get(cesc2("#/mi3changed")).should("have.text", "true");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log("type in fourth marks fourth immediate value as changed");
-
- cy.get(cesc2("#/mi4_component_1_0") + " textarea").type(
- "{end}{backspace}c",
- {
- force: true,
- },
- );
-
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow").should("contain.text", "[ac]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ac]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "true");
- cy.get(cesc2("#/mi3changed")).should("have.text", "true");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "true");
-
- cy.log("press enter in fourth marks fourth value as changed");
-
- cy.get(cesc2("#/mi4_component_1_0") + " textarea").type("{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/mi4a") + " .mjx-mrow").should("contain.text", "[ac]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ac]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ac]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ac]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[b]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ac]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "true");
- cy.get(cesc2("#/mi3changed")).should("have.text", "true");
- cy.get(cesc2("#/mi4changed")).should("have.text", "true");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "true");
-
- cy.log("reload");
- cy.reload();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "false");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log("type in third marks only third immediate value as changed");
-
- cy.get(cesc2("#/mi3_component_0_0") + " textarea").type("z", {
- force: true,
- });
-
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow").should("contain.text", "[z]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "false");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log(
- "press enter in third marks first and third value/immediateValue as changed",
- );
-
- cy.get(cesc2("#/mi3_component_0_0") + " textarea").type("{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/mi3a") + " .mjx-mrow").should("contain.text", "[z]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "true");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log("type in fourth marks only fourth immediate value as changed");
-
- cy.get(cesc2("#/mi4_component_0_0") + " textarea").type(
- "{end}{backspace}a",
- {
- force: true,
- },
- );
-
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow").should("contain.text", "[ay]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "true");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "true");
-
- cy.log(
- "press enter in fourth marks third and fourth value/immediateValue as changed",
- );
-
- cy.get(cesc2("#/mi4_component_0_0") + " textarea").type("{enter}", {
- force: true,
- });
-
- cy.get(cesc2("#/mi4a") + " .mjx-mrow").should("contain.text", "[ay]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[z]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[ay]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "true");
- cy.get(cesc2("#/mi3changed")).should("have.text", "true");
- cy.get(cesc2("#/mi4changed")).should("have.text", "true");
+ it("set value from immediateValue on reload", () => {
+ let doenetML = `
+
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "true");
+ value: $n
+ immediate value: $n.immediateValue
+ `;
- cy.log("reload");
- cy.reload();
+ cy.get("#testRunner_toggleControls").click();
+ cy.get("#testRunner_allowLocalState").click();
+ cy.wait(100);
+ cy.get("#testRunner_toggleControls").click();
cy.window().then(async (win) => {
win.postMessage(
@@ -17901,135 +28,18 @@ describe("MatrixInput Tag Tests", function () {
);
});
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
+ cy.get(cesc("#\\/n") + " textarea").type("1", { force: true });
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
+ cy.get(cesc("#\\/piv") + " .mjx-mrow").should("contain.text", "[1]");
+ cy.get(cesc("#\\/piv") + " .mjx-mrow")
.eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
+ .should("have.text", "[1]");
+ cy.get(cesc("#\\/pv") + " .mjx-mrow")
.eq(0)
.should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "false");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log(
- "adding row to first marks first value/immediateValue as changed",
- );
- cy.get(cesc("#\\/mi1_rowIncrement")).click();
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow").should(
- "contain.text",
- "[\uff3f\uff3f]",
- );
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log(
- "adding column to second marks second value/immediateValue as changed",
- );
- cy.get(cesc("#\\/mi2_columnIncrement")).click();
-
- cy.get(cesc2("#/mi2a") + " .mjx-mrow").should(
- "contain.text",
- "[x\uff3fy\uff3f]",
- );
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[x\uff3fy\uff3f]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[x\uff3fy\uff3f]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[x\uff3fy\uff3f]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[x\uff3fy\uff3f]");
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "true");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
+ cy.wait(1500); // wait for debounce
- cy.log("reload");
cy.reload();
cy.window().then(async (win) => {
@@ -18041,129 +51,12 @@ describe("MatrixInput Tag Tests", function () {
);
});
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "false");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "false");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log(
- "adding column to third marks first and third value/immediateValue as changed",
- );
- cy.get(cesc("#\\/mi3_columnIncrement")).click();
-
- cy.get(cesc2("#/mi3a") + " .mjx-mrow").should(
- "contain.text",
- "[\uff3f\uff3f]",
- );
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[xy]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "false");
- cy.get(cesc2("#/mi3changed")).should("have.text", "true");
- cy.get(cesc2("#/mi4changed")).should("have.text", "false");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "false");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "false");
-
- cy.log(
- "subtracting row from fourth marks second and fourth value/immediateValue as changed",
- );
- cy.get(cesc("#\\/mi4_rowDecrement")).click();
-
- cy.get(cesc2("#/mi4a") + " .mjx-mrow").should("contain.text", "[x]");
-
- cy.get(cesc2("#/mi1a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi2a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[x]");
- cy.get(cesc2("#/mi3a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi4a") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[x]");
-
- cy.get(cesc2("#/mi1iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi2iva") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[x]");
- cy.get(cesc2("#/mi3iva") + " .mjx-mrow")
+ cy.get(cesc("#\\/pv") + " .mjx-mrow").should("contain.text", "[1]");
+ cy.get(cesc("#\\/piv") + " .mjx-mrow")
.eq(0)
- .should("have.text", "[\uff3f\uff3f]");
- cy.get(cesc2("#/mi4iva") + " .mjx-mrow")
+ .should("have.text", "[1]");
+ cy.get(cesc("#\\/pv") + " .mjx-mrow")
.eq(0)
- .should("have.text", "[x]");
-
- cy.get(cesc2("#/mi1changed")).should("have.text", "true");
- cy.get(cesc2("#/mi2changed")).should("have.text", "true");
- cy.get(cesc2("#/mi3changed")).should("have.text", "true");
- cy.get(cesc2("#/mi4changed")).should("have.text", "true");
-
- cy.get(cesc2("#/mi1ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi2ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi3ivchanged")).should("have.text", "true");
- cy.get(cesc2("#/mi4ivchanged")).should("have.text", "true");
+ .should("have.text", "[1]");
});
});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/module.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/module.cy.js
index aceb50a20..4ddcc8aa1 100644
--- a/packages/test-cypress/cypress/e2e/tagSpecific/module.cy.js
+++ b/packages/test-cypress/cypress/e2e/tagSpecific/module.cy.js
@@ -6,500 +6,6 @@ describe("Module Tag Tests", function () {
cy.visit("/");
});
- it("module with sentence", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- Hello $item!
-
-
-
- Hello $item!
-
- $m{item="plant"}
-
-
- $m{item="$item2"}
- $m
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc("#\\/p1")).should("contain.text", "Hello who?!");
- cy.get(cesc("#\\/p2")).should("contain.text", "Hello who?!");
- cy.get(cesc("#\\/p3")).should("contain.text", "Hello plant!");
- cy.get(cesc("#\\/p4")).should("contain.text", "Hello animal!");
- cy.get(cesc("#\\/p5")).should("contain.text", "Hello who?!");
-
- cy.get(cesc("#\\/item2_input")).clear().type("rock").blur();
- cy.get(cesc("#\\/p4")).should("contain.text", "Hello rock!");
- cy.get(cesc("#\\/p1")).should("contain.text", "Hello who?!");
- cy.get(cesc("#\\/p2")).should("contain.text", "Hello who?!");
- cy.get(cesc("#\\/p3")).should("contain.text", "Hello plant!");
- cy.get(cesc("#\\/p5")).should("contain.text", "Hello who?!");
- });
-
- it("module with sentence, newnamespace", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- Hello $item!
-
-
- Hello $(m/item)!
-
- $m{item="plant" name="m2"}
-
- $m{item="$item" name="m3"}
- $m{name="m4"}
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/m/_p1")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/p2")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/m2/_p1")).should("have.text", "Hello plant!");
- cy.get(cesc2("#/m3/_p1")).should("have.text", "Hello animal!");
- cy.get(cesc2("#/m4/_p1")).should("have.text", "Hello who?!");
-
- cy.get(cesc("#\\/item_input")).clear().type("rock").blur();
- cy.get(cesc2("#/m3/_p1")).should("have.text", "Hello rock!");
- cy.get(cesc2("#/m/_p1")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/p2")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/m2/_p1")).should("have.text", "Hello plant!");
- cy.get(cesc2("#/m4/_p1")).should("have.text", "Hello who?!");
- });
-
- it("module with sentence, nested newnamespaces", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- Hello $(mads/item)!
-
-
- Hello $(m/mads/item)!
-
- $m{item="plant" name="m2"}
-
- $m{item="$item" name="m3"}
- $m{name="m4"}
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/m/_p1")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/p2")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/m2/_p1")).should("have.text", "Hello plant!");
- cy.get(cesc2("#/m3/_p1")).should("have.text", "Hello animal!");
- cy.get(cesc2("#/m4/_p1")).should("have.text", "Hello who?!");
-
- cy.get(cesc("#\\/item_input")).clear().type("rock").blur();
- cy.get(cesc2("#/m3/_p1")).should("have.text", "Hello rock!");
- cy.get(cesc2("#/m/_p1")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/p2")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/m2/_p1")).should("have.text", "Hello plant!");
- cy.get(cesc2("#/m4/_p1")).should("have.text", "Hello who?!");
- });
-
- it("module with sentence, triple nested newnamespaces", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- Hello $(mads/ma/item)!
-
-
- Hello $(m/mads/ma/item)!
-
- $m{item="plant" name="m2"}
-
- $m{item="$item" name="m3"}
- $m{name="m4"}
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/m/_p1")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/p2")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/m2/_p1")).should("have.text", "Hello plant!");
- cy.get(cesc2("#/m3/_p1")).should("have.text", "Hello animal!");
- cy.get(cesc2("#/m4/_p1")).should("have.text", "Hello who?!");
-
- cy.get(cesc("#\\/item_input")).clear().type("rock").blur();
- cy.get(cesc2("#/m3/_p1")).should("have.text", "Hello rock!");
- cy.get(cesc2("#/m/_p1")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/p2")).should("have.text", "Hello who?!");
- cy.get(cesc2("#/m2/_p1")).should("have.text", "Hello plant!");
- cy.get(cesc2("#/m4/_p1")).should("have.text", "Hello who?!");
- });
-
- it("module with graph, newnamespace", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
- Point coords:
-
-
-
- $y2.value{assignNames="y2a"}
-
-
- Point coords:
- Graph size:
-
- $m{x="$x" y="$y" size="$s" aspectRatio="$ar" name="m2"}
-
- $ar.value{assignNames="ar2"}
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- let smallWidth = 255;
- let mediumWidth = 425;
- let largeWidth = 595;
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/g"].stateValues.size).eq("medium");
- expect(stateVariables["/m/g"].stateValues.width.size).eq(
- mediumWidth,
- );
- expect(stateVariables["/m/g"].stateValues.aspectRatio).eq(1);
- expect(stateVariables["/m/p"].stateValues.xs).eqls([3, 5]);
- expect(stateVariables["/m2/g"].stateValues.size).eq("small");
- expect(stateVariables["/m2/g"].stateValues.width.size).eq(
- smallWidth,
- );
- expect(stateVariables["/m2/g"].stateValues.aspectRatio).eq(0.5);
- expect(stateVariables["/m2/p"].stateValues.xs).eqls([7, -7]);
- });
-
- cy.get(cesc2("#/m/x2") + " textarea").type(
- "{end}{backspace}-6{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/m/y2") + " textarea").type("{end}{backspace}9{enter}", {
- force: true,
- });
- cy.get(cesc2("#/m/y2a")).should("contain.text", "9");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/g"].stateValues.size).eq("medium");
- expect(stateVariables["/m/g"].stateValues.width.size).eq(
- mediumWidth,
- );
- expect(stateVariables["/m/g"].stateValues.aspectRatio).eq(1);
- expect(stateVariables["/m/p"].stateValues.xs).eqls([-6, 9]);
- expect(stateVariables["/m2/g"].stateValues.size).eq("small");
- expect(stateVariables["/m2/g"].stateValues.width.size).eq(
- smallWidth,
- );
- expect(stateVariables["/m2/g"].stateValues.aspectRatio).eq(0.5);
- expect(stateVariables["/m2/p"].stateValues.xs).eqls([7, -7]);
- });
-
- cy.get(cesc2("#/x") + " textarea").type(
- "{end}{backspace}{backspace}1{enter}",
- { force: true },
- );
- cy.get(cesc2("#/y") + " textarea").type(
- "{end}{backspace}{backspace}2{enter}",
- { force: true },
- );
- cy.get(cesc2("#/s") + "_input")
- .clear()
- .type("large{enter}", { force: true });
- cy.get(cesc2("#/ar") + " textarea").type(
- "{ctrl+home}{shift+ctrl+end}{backspace}3/2{enter}",
- { force: true },
- );
- cy.get(cesc2("#/ar2")).should("contain.text", "3");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/g"].stateValues.size).eq("medium");
- expect(stateVariables["/m/g"].stateValues.width.size).eq(
- mediumWidth,
- );
- expect(stateVariables["/m/g"].stateValues.aspectRatio).eq(1);
- expect(stateVariables["/m/p"].stateValues.xs).eqls([-6, 9]);
- expect(stateVariables["/m2/g"].stateValues.size).eq("large");
- expect(stateVariables["/m2/g"].stateValues.width.size).eq(
- largeWidth,
- );
- expect(stateVariables["/m2/g"].stateValues.aspectRatio).eq(1.5);
- expect(stateVariables["/m2/p"].stateValues.xs).eqls([1, 2]);
- });
-
- cy.get(cesc2("#/m2/x2") + " textarea").type(
- "{end}{backspace}-3{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/m2/y2") + " textarea").type(
- "{end}{backspace}-4{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc2("#/m2/y2a")).should("contain.text", "−4");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/g"].stateValues.size).eq("medium");
- expect(stateVariables["/m/g"].stateValues.width.size).eq(
- mediumWidth,
- );
- expect(stateVariables["/m/g"].stateValues.aspectRatio).eq(1);
- expect(stateVariables["/m/p"].stateValues.xs).eqls([-6, 9]);
- expect(stateVariables["/m2/g"].stateValues.size).eq("large");
- expect(stateVariables["/m2/g"].stateValues.width.size).eq(
- largeWidth,
- );
- expect(stateVariables["/m2/g"].stateValues.aspectRatio).eq(1.5);
- expect(stateVariables["/m2/p"].stateValues.xs).eqls([-3, -4]);
- });
-
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/m/p",
- args: { x: -8, y: -9 },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/g"].stateValues.size).eq("medium");
- expect(stateVariables["/m/g"].stateValues.width.size).eq(
- mediumWidth,
- );
- expect(stateVariables["/m/g"].stateValues.aspectRatio).eq(1);
- expect(stateVariables["/m/p"].stateValues.xs).eqls([-8, -9]);
- expect(stateVariables["/m2/g"].stateValues.size).eq("large");
- expect(stateVariables["/m2/g"].stateValues.width.size).eq(
- largeWidth,
- );
- expect(stateVariables["/m2/g"].stateValues.aspectRatio).eq(1.5);
- expect(stateVariables["/m2/p"].stateValues.xs).eqls([-3, -4]);
- });
-
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/m2/p",
- args: { x: 6, y: -10 },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/g"].stateValues.size).eq("medium");
- expect(stateVariables["/m/g"].stateValues.width.size).eq(
- mediumWidth,
- );
- expect(stateVariables["/m/g"].stateValues.aspectRatio).eq(1);
- expect(stateVariables["/m/p"].stateValues.xs).eqls([-8, -9]);
- expect(stateVariables["/m2/g"].stateValues.size).eq("large");
- expect(stateVariables["/m2/g"].stateValues.width.size).eq(
- largeWidth,
- );
- expect(stateVariables["/m2/g"].stateValues.aspectRatio).eq(1.5);
- expect(stateVariables["/m2/p"].stateValues.xs).eqls([6, -10]);
- });
- });
-
- it("module inside a module", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $v
- $(../m{x="$u+$vfixed" y="9" name="m"})
-
-
-
- Point coords:
- $n{u="$x" v="$y" name="n2"}
-
- $y.value{assignNames="y2"}
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/p"].stateValues.xs).eqls([3, 5]);
- expect(stateVariables["/n/p"].stateValues.xs).eqls([1, -2]);
- expect(stateVariables["/n/m/p"].stateValues.xs).eqls([-1, 9]);
- expect(stateVariables["/n2/p"].stateValues.xs).eqls([7, -7]);
- expect(stateVariables["/n2/m/p"].stateValues.xs).eqls([0, 9]);
- });
-
- cy.get(cesc2("#/x") + " textarea").type(
- "{end}{backspace}{backspace}-6{enter}",
- { force: true },
- );
- cy.get(cesc2("#/y") + " textarea").type(
- "{end}{backspace}{backspace}8{enter}",
- { force: true },
- );
- cy.get(cesc2("#/y2")).should("contain.text", "8");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/p"].stateValues.xs).eqls([3, 5]);
- expect(stateVariables["/n/p"].stateValues.xs).eqls([1, -2]);
- expect(stateVariables["/n/m/p"].stateValues.xs).eqls([-1, 9]);
- expect(stateVariables["/n2/p"].stateValues.xs).eqls([-6, 8]);
- expect(stateVariables["/n2/m/p"].stateValues.xs).eqls([2, 9]);
- });
-
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/m/p",
- args: { x: -2, y: -4 },
- });
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/p"].stateValues.xs).eqls([-2, -4]);
- expect(stateVariables["/n/p"].stateValues.xs).eqls([1, -2]);
- expect(stateVariables["/n/m/p"].stateValues.xs).eqls([-1, 9]);
- expect(stateVariables["/n2/p"].stateValues.xs).eqls([-6, 8]);
- expect(stateVariables["/n2/m/p"].stateValues.xs).eqls([2, 9]);
- });
-
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/n/p",
- args: { x: 7, y: -3 },
- });
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/p"].stateValues.xs).eqls([-2, -4]);
- expect(stateVariables["/n/p"].stateValues.xs).eqls([7, -3]);
- expect(stateVariables["/n/m/p"].stateValues.xs).eqls([4, 9]);
- expect(stateVariables["/n2/p"].stateValues.xs).eqls([-6, 8]);
- expect(stateVariables["/n2/m/p"].stateValues.xs).eqls([2, 9]);
- });
-
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/n/m/p",
- args: { x: -5, y: -7 },
- });
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/p"].stateValues.xs).eqls([-2, -4]);
- expect(stateVariables["/n/p"].stateValues.xs).eqls([-2, -3]);
- expect(stateVariables["/n/m/p"].stateValues.xs).eqls([-5, -7]);
- expect(stateVariables["/n2/p"].stateValues.xs).eqls([-6, 8]);
- expect(stateVariables["/n2/m/p"].stateValues.xs).eqls([2, 9]);
- });
-
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/n2/p",
- args: { x: 4, y: 5 },
- });
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/p"].stateValues.xs).eqls([-2, -4]);
- expect(stateVariables["/n/p"].stateValues.xs).eqls([-2, -3]);
- expect(stateVariables["/n/m/p"].stateValues.xs).eqls([-5, -7]);
- expect(stateVariables["/n2/p"].stateValues.xs).eqls([4, 5]);
- expect(stateVariables["/n2/m/p"].stateValues.xs).eqls([9, 9]);
- });
-
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/n2/m/p",
- args: { x: -5, y: -6 },
- });
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m/p"].stateValues.xs).eqls([-2, -4]);
- expect(stateVariables["/n/p"].stateValues.xs).eqls([-2, -3]);
- expect(stateVariables["/n/m/p"].stateValues.xs).eqls([-5, -7]);
- expect(stateVariables["/n2/p"].stateValues.xs).eqls([-10, 5]);
- expect(stateVariables["/n2/m/p"].stateValues.xs).eqls([-5, -6]);
- });
- });
-
it("module from uri", () => {
cy.window().then(async (win) => {
win.postMessage(
@@ -1361,660 +867,4 @@ describe("Module Tag Tests", function () {
});
});
});
-
- it("apply sugar in module attributes", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- Point: $P
-
-
- $m{P="(3,4)" name="m2"}
-
-
- (5,6)
-
- $m{P="$Q" name="m3"}
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/m/_p1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(1,2)");
- });
- cy.get(cesc2("#/m2/_p1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(3,4)");
- });
- cy.get(cesc2("#/m3/_p1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(5,6)");
- });
-
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/Q",
- args: { x: 7, y: 8 },
- });
- });
-
- cy.get(cesc2("#/m3/_p1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(7,8)");
- });
- });
-
- it("invalid attributes ignored in module", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- Disabled? $disabled
-
-
- $m{name="m1"}
- $m{disabled="true" name="m2"}
- $m{disabled="false" name="m3"}
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/m/_p1")).should("have.text", "Disabled? ");
- cy.get(cesc2("#/m1/_p1")).should("have.text", "Disabled? ");
- cy.get(cesc2("#/m2/_p1")).should("have.text", "Disabled? ");
- cy.get(cesc2("#/m3/_p1")).should("have.text", "Disabled? ");
- });
-
- it("handle error in custom attributes", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/_document1")).should(
- "contain.text",
- "Duplicate component name: duplicate",
- );
- cy.get(cesc2("#/_document1")).should("contain.text", "line 7");
-
- cy.window().then(async (win) => {
- let errorWarnings = await win.returnErrorWarnings1();
-
- expect(errorWarnings.errors.length).eq(1);
- expect(errorWarnings.warnings.length).eq(0);
-
- expect(errorWarnings.errors[0].message).contain(
- "Duplicate component name: duplicate",
- );
- expect(errorWarnings.errors[0].doenetMLrange.lineBegin).eq(7);
- expect(errorWarnings.errors[0].doenetMLrange.charBegin).eq(9);
- expect(errorWarnings.errors[0].doenetMLrange.lineEnd).eq(7);
- expect(errorWarnings.errors[0].doenetMLrange.charEnd).eq(106);
- });
- });
-
- it("warnings in custom attributes", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- b: $b
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/m/_p1")).should("have.text", "b: ");
- cy.get(cesc2("#/m1/_p1")).should("have.text", "b: hello");
-
- cy.window().then(async (win) => {
- let errorWarnings = await win.returnErrorWarnings1();
-
- expect(errorWarnings.errors.length).eq(0);
- expect(errorWarnings.warnings.length).eq(9);
-
- expect(errorWarnings.warnings[0].message).contain(
- "Could not create . It must be inside a component that is inside a or similar component",
- );
- expect(errorWarnings.warnings[0].level).eq(1);
- expect(errorWarnings.warnings[0].doenetMLrange.lineBegin).eq(14);
- expect(errorWarnings.warnings[0].doenetMLrange.charBegin).eq(7);
- expect(errorWarnings.warnings[0].doenetMLrange.lineEnd).eq(14);
- expect(errorWarnings.warnings[0].doenetMLrange.charEnd).eq(111);
-
- expect(errorWarnings.warnings[1].message).contain(
- "Could not create . It must be inside a component that is inside a or similar component",
- );
- expect(errorWarnings.warnings[1].level).eq(1);
- expect(errorWarnings.warnings[1].doenetMLrange.lineBegin).eq(14);
- expect(errorWarnings.warnings[1].doenetMLrange.charBegin).eq(7);
- expect(errorWarnings.warnings[1].doenetMLrange.lineEnd).eq(14);
- expect(errorWarnings.warnings[1].doenetMLrange.charEnd).eq(111);
-
- expect(errorWarnings.warnings[2].message).contain(
- `Cannot add attribute "disabled" to a because the component type already has a "disabled" attribute defined`,
- );
- expect(errorWarnings.warnings[2].level).eq(1);
- expect(errorWarnings.warnings[2].doenetMLrange.lineBegin).eq(4);
- expect(errorWarnings.warnings[2].doenetMLrange.charBegin).eq(9);
- expect(errorWarnings.warnings[2].doenetMLrange.lineEnd).eq(4);
- expect(errorWarnings.warnings[2].doenetMLrange.charEnd).eq(115);
-
- expect(errorWarnings.warnings[3].message).contain(
- " contains an invalid component type: ",
- );
- expect(errorWarnings.warnings[3].level).eq(1);
- expect(errorWarnings.warnings[3].doenetMLrange.lineBegin).eq(6);
- expect(errorWarnings.warnings[3].doenetMLrange.charBegin).eq(9);
- expect(errorWarnings.warnings[3].doenetMLrange.lineEnd).eq(6);
- expect(errorWarnings.warnings[3].doenetMLrange.charEnd).eq(96);
-
- expect(errorWarnings.warnings[4].message).contain(
- `Since a default value was not supplied for with attribute="b", it will not be created unless a value is specified`,
- );
- expect(errorWarnings.warnings[4].level).eq(1);
- expect(errorWarnings.warnings[4].doenetMLrange.lineBegin).eq(8);
- expect(errorWarnings.warnings[4].doenetMLrange.charBegin).eq(9);
- expect(errorWarnings.warnings[4].doenetMLrange.lineEnd).eq(8);
- expect(errorWarnings.warnings[4].doenetMLrange.charEnd).eq(78);
-
- expect(errorWarnings.warnings[5].message).contain(
- ` must contain a componentType attribute`,
- );
- expect(errorWarnings.warnings[5].level).eq(1);
- expect(errorWarnings.warnings[5].doenetMLrange.lineBegin).eq(10);
- expect(errorWarnings.warnings[5].doenetMLrange.charBegin).eq(9);
- expect(errorWarnings.warnings[5].doenetMLrange.lineEnd).eq(10);
- expect(errorWarnings.warnings[5].doenetMLrange.charEnd).eq(27);
-
- expect(errorWarnings.warnings[6].message).contain(
- `Cannot add attribute "disabled" to a because the component type already has a "disabled" attribute defined`,
- );
- expect(errorWarnings.warnings[6].level).eq(1);
- expect(errorWarnings.warnings[6].doenetMLrange.lineBegin).eq(4);
- expect(errorWarnings.warnings[6].doenetMLrange.charBegin).eq(9);
- expect(errorWarnings.warnings[6].doenetMLrange.lineEnd).eq(4);
- expect(errorWarnings.warnings[6].doenetMLrange.charEnd).eq(115);
-
- expect(errorWarnings.warnings[7].message).contain(
- " contains an invalid component type: ",
- );
- expect(errorWarnings.warnings[7].level).eq(1);
- expect(errorWarnings.warnings[7].doenetMLrange.lineBegin).eq(6);
- expect(errorWarnings.warnings[7].doenetMLrange.charBegin).eq(9);
- expect(errorWarnings.warnings[7].doenetMLrange.lineEnd).eq(6);
- expect(errorWarnings.warnings[7].doenetMLrange.charEnd).eq(96);
-
- expect(errorWarnings.warnings[8].message).contain(
- ` must contain a componentType attribute`,
- );
- expect(errorWarnings.warnings[8].level).eq(1);
- expect(errorWarnings.warnings[8].doenetMLrange.lineBegin).eq(10);
- expect(errorWarnings.warnings[8].doenetMLrange.charBegin).eq(9);
- expect(errorWarnings.warnings[8].doenetMLrange.lineEnd).eq(10);
- expect(errorWarnings.warnings[8].doenetMLrange.charEnd).eq(27);
- });
- });
-
- it("copy module and overwrite attribute values", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
- The first number is $m; the second number is $n.
- Next value? OK $q it is.
-
-
- $md{name="md1"}
- $md1{n="10" name="md2"}
- $md2{m="100" name="md3"}
- $md3{n="0" name="md4"}
-
- $md{m="13" n="17" name="md5"}
- $md5{m="" n="a" name="md6"}
- $md6{m="3" n="4" name="md7"}
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc("#\\/md\\/_p1")).should(
- "have.text",
- "The first number is 1; the second number is 2.",
- );
- cy.get(cesc("#\\/md1\\/_p1")).should(
- "have.text",
- "The first number is 1; the second number is 2.",
- );
- cy.get(cesc("#\\/md2\\/_p1")).should(
- "have.text",
- "The first number is 1; the second number is 10.",
- );
- cy.get(cesc("#\\/md3\\/_p1")).should(
- "have.text",
- "The first number is 100; the second number is 10.",
- );
- cy.get(cesc("#\\/md4\\/_p1")).should(
- "have.text",
- "The first number is 100; the second number is 0.",
- );
- cy.get(cesc("#\\/md5\\/_p1")).should(
- "have.text",
- "The first number is 13; the second number is 17.",
- );
- cy.get(cesc("#\\/md6\\/_p1")).should(
- "have.text",
- "The first number is NaN; the second number is NaN.",
- );
- cy.get(cesc("#\\/md7\\/_p1")).should(
- "have.text",
- "The first number is 3; the second number is 4.",
- );
-
- cy.get(cesc("#\\/md\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("\uff3f");
- });
- cy.get(cesc("#\\/md1\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("\uff3f");
- });
- cy.get(cesc("#\\/md2\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("\uff3f");
- });
- cy.get(cesc("#\\/md3\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("\uff3f");
- });
- cy.get(cesc("#\\/md4\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("\uff3f");
- });
- cy.get(cesc("#\\/md5\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("\uff3f");
- });
- cy.get(cesc("#\\/md6\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("\uff3f");
- });
- cy.get(cesc("#\\/md7\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("\uff3f");
- });
-
- cy.get(cesc("#\\/md\\/q") + " textarea").type("x{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/md1\\/q") + " textarea").type("y{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/md2\\/q") + " textarea").type("z{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/md3\\/q") + " textarea").type("u{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/md4\\/q") + " textarea").type("v{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/md5\\/q") + " textarea").type("w{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/md6\\/q") + " textarea").type("s{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/md7\\/q") + " textarea").type("t{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/md7\\/_p2") + " .mjx-mrow").should(
- "contain.text",
- "t",
- );
-
- cy.get(cesc("#\\/md\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("x");
- });
- cy.get(cesc("#\\/md1\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("y");
- });
- cy.get(cesc("#\\/md2\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("z");
- });
- cy.get(cesc("#\\/md3\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("u");
- });
- cy.get(cesc("#\\/md4\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("v");
- });
- cy.get(cesc("#\\/md5\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("w");
- });
- cy.get(cesc("#\\/md6\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("s");
- });
- cy.get(cesc("#\\/md7\\/_p2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("t");
- });
- });
-
- it("copy sourcesAreResponses with parent namespace target", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
-
-
- $title
-
- Move the point to ($goalx, $goaly) .
-
-
-
-
-
-
-
-
-
-
-
- $(../P) = ($(../goalx), $(../goaly))
-
-
-
-
-
-
-
-
- First one
- $mod{name="m1"}
-
- Submitted response for problem 1: $(m1/ans.submittedResponse)
- Credit for problem 1: $(m1/prob.creditAchieved{assignNames="ca1"})
-
-
- Second one
-
- Now, let's use initial point (-3 , 3 ) and the goal point (7 , -5 )
-
-
- $mod{title="Find point again" goalX="$xb" GoaLy="$yb" initialX="$xa" initialy="$ya" width="200px" aspectRatio="1" name="m2"}
- Submitted response for problem 2: $(m2/ans.submittedResponse)
- Credit for problem 2: $(m2/prob.creditAchieved{assignNames="ca2"})
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2(`#/m1/_m1`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(3,4)");
- });
- cy.get(cesc(`#\\/coordsa`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(-3,3)");
- });
- cy.get(cesc(`#\\/coordsb`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(7,-5)");
- });
- cy.get(cesc2(`#/m2/_m1`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(7,-5)");
- });
- cy.get(cesc("#\\/sr1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("_");
- });
- cy.get(cesc("#\\/ca1")).should("have.text", "0");
- cy.get(cesc("#\\/sr2"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("_");
- });
- cy.get(cesc("#\\/ca2")).should("have.text", "0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/m1/P"].stateValues.xs).eqls([0, 0]);
- expect(stateVariables["/m2/P"].stateValues.xs).eqls([-3, 3]);
- });
-
- cy.log("submit answers");
-
- cy.get(cesc2("#/m1/ans_submit")).click();
- cy.get(cesc2("#/m2/ans_submit")).click();
- cy.get(cesc("#\\/sr2")).should("contain.text", "(−3,3)");
- cy.get(cesc("#\\/sr1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(0,0)");
- });
- cy.get(cesc("#\\/ca1")).should("have.text", "0");
- cy.get(cesc("#\\/sr2"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(-3,3)");
- });
- cy.get(cesc("#\\/ca2")).should("have.text", "0");
-
- cy.log("move near correct answers");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/m1/P",
- args: { x: 3.2, y: 3.9 },
- });
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/m2/P",
- args: { x: 7.2, y: -4.9 },
- });
- });
-
- cy.get(cesc2(`#/m1/_m1`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(3,4)");
- });
- cy.get(cesc(`#\\/coordsa`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(-3,3)");
- });
- cy.get(cesc(`#\\/coordsb`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(7,-5)");
- });
- cy.get(cesc2(`#/m2/_m1`))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(7,-5)");
- });
-
- cy.log("submit answers");
-
- cy.get(cesc2("#/m1/ans_submit")).click();
- cy.get(cesc2("#/m2/ans_submit")).click();
- cy.get(cesc("#\\/sr2")).should("contain.text", "(7,−5)");
- cy.get(cesc("#\\/sr1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(3,4)");
- });
- cy.get(cesc("#\\/ca1")).should("have.text", "1");
- cy.get(cesc("#\\/sr2"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim().replace(/−/g, "-")).equal("(7,-5)");
- });
- cy.get(cesc("#\\/ca2")).should("have.text", "1");
- });
});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/paginator.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/paginator.cy.js
index e5eba0991..b7817270e 100644
--- a/packages/test-cypress/cypress/e2e/tagSpecific/paginator.cy.js
+++ b/packages/test-cypress/cypress/e2e/tagSpecific/paginator.cy.js
@@ -1119,472 +1119,6 @@ describe("Paginator Tag Tests", function () {
cy.get(cesc2("#/ca")).should("have.text", "0.833");
});
- it.skip("With selects, specify variants", () => {
- let doenetML = `
- a
-
-
-
-
-
-
-
- Problem A
- Enter $n .
-
-
- $n
-
-
- What is 1+$n ?
-
-
- 1+$n
-
-
-
-
-
-
-
-
- Problem B
- Enter $n .
-
-
- $n
-
-
- What is 1-$n ?
-
-
- 1-$n
-
-
-
-
-
-
-
-
-
-
-
- Problem C
- What is 2+$n ?
-
-
- 2+$n
-
-
-
-
-
-
-
- Problem D
-
- What is 2-$n ?
-
-
- 2-$n
-
-
-
-
-
-
-
-
-
-
-
- Problem E
-
-
- 1
- 2
- 3
-
- What is 3+$n ?
-
-
- 3+$n
-
-
-
-
-
-
- Problem F
-
-
- 4
- 5
- 6
-
- What is 3-$n ?
-
-
- 3-$n
-
-
-
-
-
-
-
-
- Problem G
-
- What is 2 \\cdot $n ?
-
-
- 2$n
-
-
-
-
- Problem H
-
-
-
- apple
- banana
- cherry
- date
- elderberry
- fig
- grape
-
- Enter $fruit:
-
-
- $fruit
-
-
-
-
- Credit achieved: $_document1.creditAchieved{assignNames="ca"}
- `;
-
- cy.get("#testRunner_toggleControls").click();
- cy.get("#testRunner_allowLocalState").click();
- cy.wait(100);
- cy.get("#testRunner_toggleControls").click();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- requestedVariant: {
- subvariants: [
- {
- indices: [1],
- subvariants: [
- {
- subvariants: [
- {
- indices: [7],
- },
- ],
- },
- ],
- },
- {
- indices: [2],
- subvariants: [
- {
- indices: [2, 1],
- subvariants: [
- {
- index: 1,
- },
- {
- index: 2,
- },
- ],
- },
- ],
- },
- {
- subvariants: [
- {
- indices: [152],
- },
- ],
- },
- {
- index: 6,
- },
- ],
- },
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/problem1/_title1")).should("have.text", "Problem A");
- cy.get(cesc2("#/ca")).should("have.text", "0");
-
- cy.get(cesc2("#/problem1/input1") + " textarea").type("7{enter}", {
- force: true,
- });
- cy.get(cesc2("#/problem1/input1_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.1");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
- cy.get(cesc2("#/ca")).should("have.text", "0.1");
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- b
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
- cy.get(cesc2("#/ca")).should("have.text", "0.1");
-
- cy.get(cesc2("#/problem2/input") + " textarea").type("-1{enter}", {
- force: true,
- });
- cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- b
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
- cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.get(cesc2("#/pcontrols_previous")).click();
- cy.get(cesc2("#/problem1/_title1")).should("have.text", "Problem A");
- cy.get(cesc2("#/problem1/input1_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.get(cesc2("#/problem1/input1") + " textarea").type(
- "{end}{backspace}8{enter}",
- { force: true },
- );
- cy.get(cesc2("#/problem1/input1_incorrect")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.2");
-
- cy.get(cesc2("#/problem1/input2") + " textarea").type("8{enter}", {
- force: true,
- });
- cy.get(cesc2("#/problem1/input2_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- b
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/problem1/_title1")).should("have.text", "Problem A");
- cy.get(cesc2("#/problem1/input1_incorrect")).should("be.visible");
- cy.get(cesc2("#/problem1/input2_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
- cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/problem3/_title1")).should("have.text", "Problem E");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.get(cesc2("#/problem3/input") + " textarea").type("x^{enter}", {
- force: true,
- });
- cy.get(cesc2("#/problem3/input_incorrect")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- b
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/problem3/_title1")).should("have.text", "Problem E");
- cy.get(cesc2("#/problem3/input_incorrect")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.get(cesc2("#/pcontrols_previous")).click();
- cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
- cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.get(cesc2("#/pcontrols_previous")).click();
- cy.get(cesc2("#/problem1/_title1")).should("have.text", "Problem A");
- cy.get(cesc2("#/problem1/input1_incorrect")).should("be.visible");
- cy.get(cesc2("#/problem1/input2_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
- cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- b
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
- cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/problem3/_title1")).should("have.text", "Problem E");
- cy.get(cesc2("#/problem3/input_incorrect")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/problem4/_title1")).should("have.text", "Problem G");
- cy.get(cesc2("#/ca")).should("have.text", "0.3");
-
- cy.get(cesc2("#/problem4/input") + " textarea").type("504{enter}", {
- force: true,
- });
- cy.get(cesc2("#/problem4/input_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.5");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/problem5/_title1")).should("have.text", "Problem H");
- cy.get(cesc2("#/ca")).should("have.text", "0.5");
-
- cy.get(cesc2("#/problem5/input_input")).type("fig{enter}", {
- force: true,
- });
- cy.get(cesc2("#/problem5/input_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.7");
-
- cy.get(cesc2("#/pcontrols_previous")).click();
- cy.get(cesc2("#/problem4/_title1")).should("have.text", "Problem G");
- cy.get(cesc2("#/problem4/input_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.7");
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- b
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/problem4/_title1")).should("have.text", "Problem G");
- cy.get(cesc2("#/problem4/input_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.7");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/problem5/_title1")).should("have.text", "Problem H");
- cy.get(cesc2("#/ca")).should("have.text", "0.7");
- });
-
it("With external and internal copies", () => {
let doenetML = `
a
@@ -2038,273 +1572,6 @@ describe("Paginator Tag Tests", function () {
});
});
- it("Variantcontrols in document and problem", () => {
- let doenetML = `
- a
-
-
-
-
-
-
- Type a number
-
-
- $a: $a
-
-
- Type a letter
-
- u v w x y z
- $b: $b
-
-
-
- Credit achieved: $_document1.creditAchieved{assignNames="ca"}
- `;
-
- cy.get("#testRunner_toggleControls").click();
- cy.get("#testRunner_allowLocalState").click();
- cy.wait(100);
- cy.get("#testRunner_toggleControls").click();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/_title1")).should("have.text", "Type a number");
- cy.get(cesc2("#/ca")).should("have.text", "0");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let a = stateVariables["/a"].stateValues.value;
-
- let mathinput1Name =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let mathinput1Anchor = cesc2(`#${mathinput1Name}`) + " textarea";
- let mathinput1Correct = cesc2(`#${mathinput1Name}_correct`);
-
- cy.get(mathinput1Anchor).type(`${a}{enter}`, { force: true });
- cy.get(mathinput1Correct).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.5");
- });
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/_title2")).should("have.text", "Type a letter");
- cy.get(cesc2("#/ca")).should("have.text", "0.5");
-
- cy.wait(100);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let b = stateVariables["/b"].stateValues.value;
-
- let mathinput2Name =
- stateVariables["/_answer2"].stateValues.inputChildren[0]
- .componentName;
- let mathinput2Anchor = cesc2(`#${mathinput2Name}`) + " textarea";
- let mathinput2Correct = cesc2(`#${mathinput2Name}_correct`);
-
- cy.get(mathinput2Anchor).type(`${b}{enter}`, { force: true });
- cy.get(mathinput2Correct).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "1");
- });
-
- cy.wait(2000); // wait for 1 second debounce
- cy.reload();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- // wait until core is loaded
- cy.waitUntil(() =>
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- return Boolean(stateVariables["/_answer2"]);
- }),
- );
-
- cy.get(cesc2("#/_title2")).should("have.text", "Type a letter");
- cy.get(cesc2("#/ca")).should("have.text", "1");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let mathinput2Name =
- stateVariables["/_answer2"].stateValues.inputChildren[0]
- .componentName;
- let mathinput2Correct = cesc2(`#${mathinput2Name}_correct`);
-
- cy.get(mathinput2Correct).should("be.visible");
- });
-
- cy.get(cesc2("#/pcontrols_previous")).click();
- cy.get(cesc2("#/_title1")).should("have.text", "Type a number");
- cy.get(cesc2("#/ca")).should("have.text", "1");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let mathinput1Name =
- stateVariables["/_answer1"].stateValues.inputChildren[0]
- .componentName;
- let mathinput1Correct = cesc2(`#${mathinput1Name}_correct`);
-
- cy.get(mathinput1Correct).should("be.visible");
- });
- });
-
- // removed this feature
- it.skip("Submit all answers on page change", () => {
- let doenetML = `
- a
-
-
-
-
- Problem 1
- 1: 1
- 2: 2
-
-
- Problem 2
- 3: 3
- 4: 4
- 5: 5
-
-
- Problem 3
- 6: 6
-
-
- Credit achieved: $_document1.creditAchieved{assignNames="ca"}
- `;
-
- cy.get("#testRunner_toggleControls").click();
- cy.get("#testRunner_allowLocalState").click();
- cy.wait(100);
- cy.get("#testRunner_toggleControls").click();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.get(cesc2("#/_title1")).should("have.text", "Problem 1");
- cy.get(cesc2("#/ca")).should("have.text", "0");
-
- cy.get(cesc("#\\/mi1") + " textarea").type("1", { force: true });
- cy.get(cesc("#\\/mi1_submit")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0");
-
- cy.get(cesc("#\\/mi2") + " textarea").type("2{enter}", { force: true });
- cy.get(cesc("#\\/mi2_correct")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.167");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/_title2")).should("have.text", "Problem 2");
- cy.get(cesc2("#/ca")).should("have.text", "0.333");
-
- cy.get(cesc("#\\/mi3_submit")).should("be.visible");
- cy.get(cesc("#\\/mi4_submit")).should("be.visible");
- cy.get(cesc("#\\/mi5_submit")).should("be.visible");
-
- cy.get(cesc("#\\/mi3") + " textarea").type("3", { force: true });
- cy.get(cesc("#\\/mi3_submit")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.333");
-
- cy.get(cesc("#\\/mi4") + " textarea").type("x", { force: true });
- cy.get(cesc("#\\/mi4_submit")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.333");
-
- cy.get(cesc2("#/pcontrols_previous")).click();
- cy.get(cesc2("#/_title1")).should("have.text", "Problem 1");
- cy.get(cesc2("#/ca")).should("have.text", "0.444");
-
- cy.get(cesc("#\\/mi1_correct")).should("be.visible");
- cy.get(cesc("#\\/mi2_correct")).should("be.visible");
-
- cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}y", {
- force: true,
- });
- cy.get(cesc("#\\/mi1_submit")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.444");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/_title2")).should("have.text", "Problem 2");
- cy.get(cesc2("#/ca")).should("have.text", "0.278");
-
- cy.get(cesc("#\\/mi3_correct")).should("be.visible");
- cy.get(cesc("#\\/mi4_incorrect")).should("be.visible");
- cy.get(cesc("#\\/mi5_incorrect")).should("be.visible");
-
- cy.get(cesc("#\\/mi5") + " textarea").type("5", { force: true });
- cy.get(cesc("#\\/mi5_submit")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.278");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/_title3")).should("have.text", "Problem 3");
- cy.get(cesc2("#/ca")).should("have.text", "0.389");
-
- cy.get(cesc("#\\/mi6_submit")).should("be.visible");
-
- cy.get(cesc("#\\/mi6") + " textarea").type("6", { force: true });
- cy.get(cesc("#\\/mi6_submit")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.389");
-
- cy.get(cesc2("#/pcontrols_previous")).click();
- cy.get(cesc2("#/_title2")).should("have.text", "Problem 2");
- cy.get(cesc2("#/ca")).should("have.text", "0.722");
-
- cy.get(cesc("#\\/mi3_correct")).should("be.visible");
- cy.get(cesc("#\\/mi4_incorrect")).should("be.visible");
- cy.get(cesc("#\\/mi5_correct")).should("be.visible");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc2("#/_title3")).should("have.text", "Problem 3");
- cy.get(cesc2("#/ca")).should("have.text", "0.722");
-
- cy.get(cesc("#\\/mi6_correct")).should("be.visible");
-
- cy.log("answers not submitted when readonly");
- cy.get(cesc("#\\/mi6") + " textarea").type("{end}{backspace}7", {
- force: true,
- });
- cy.get(cesc("#\\/mi6_submit")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.722");
-
- // at least right now, this turns on Read Only
- cy.get("h3 > button").click();
- cy.get(":nth-child(5) > label > input").click();
- cy.get("h3 > button").click();
-
- cy.get(cesc2("#/pcontrols_previous")).click();
- cy.get(cesc2("#/ca")).should("have.text", "0.722");
-
- cy.get(cesc2("#/pcontrols_next")).click();
- cy.get(cesc("#\\/mi6_submit")).should("be.visible");
- cy.get(cesc2("#/ca")).should("have.text", "0.722");
- });
-
it("Paginator controls ignore read only flag", () => {
let doenetML = `
a
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/periodicset.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/periodicset.cy.js
deleted file mode 100644
index 434ef3ed7..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/periodicset.cy.js
+++ /dev/null
@@ -1,1438 +0,0 @@
-import { cesc } from "@doenet/utils";
-
-describe("PeriodicSet Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("match given periodic set", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Offsets:
- Period:
-
-
-
-
- =
-
-
-
-
- Credit achieved: $_answer1.creditAchieved{assignNames="ca"}
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get(cesc("#\\/_text1")).should("have.text", "a");
-
- cy.get(cesc("#\\/ca")).should("have.text", "0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s1"].stateValues.value).eq("\uFF3F");
-
- let s2 = ["periodic_set"];
- s2.push(["tuple", ["/", "pi", 4], "pi", -Infinity, Infinity]);
- s2.push([
- "tuple",
- ["/", ["*", 3, "pi"], 4],
- "pi",
- -Infinity,
- Infinity,
- ]);
- expect(stateVariables["/s2"].stateValues.value).eqls(s2);
- expect(stateVariables["/s2"].stateValues.numOffsets).eq(2);
- expect(stateVariables["/s2"].stateValues.offsets[0]).eqls([
- "/",
- "pi",
- 4,
- ]);
- expect(stateVariables["/s2"].stateValues.offsets[1]).eqls([
- "/",
- ["*", 3, "pi"],
- 4,
- ]);
- expect(stateVariables["/s2"].stateValues.period).eq("pi");
- expect(stateVariables["/s2"].stateValues.redundantOffsets).eq(
- false,
- );
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 0,
- );
- });
-
- cy.log("Type in an offset and submit");
- cy.get(cesc("#\\/o") + " textarea").type(`-pi/4{enter}`, {
- force: true,
- });
- cy.get(cesc("#\\/_answer1_submit")).click();
- cy.get(cesc("#\\/_answer1_incorrect")).should("be.visible");
-
- cy.get(cesc("#\\/ca")).should("have.text", "0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s1"].stateValues.value).eq("\uFF3F");
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 0,
- );
- });
-
- cy.log("Type in a period and submit");
- cy.get(cesc("#\\/p") + " textarea").type(`pi/2{enter}`, {
- force: true,
- });
- cy.get(cesc("#\\/_answer1_submit")).click();
-
- cy.get(cesc("#\\/_answer1_correct")).should("be.visible");
-
- cy.get(cesc("#\\/ca")).should("have.text", "1");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let s1 = ["periodic_set"];
- s1.push([
- "tuple",
- ["-", ["/", "pi", 4]],
- ["/", "pi", 2],
- -Infinity,
- Infinity,
- ]);
- expect(stateVariables["/s1"].stateValues.value).eqls(s1);
- expect(stateVariables["/s1"].stateValues.numOffsets).eq(1);
- expect(stateVariables["/s1"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/s1"].stateValues.period).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/s1"].stateValues.redundantOffsets).eq(
- false,
- );
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 1,
- );
- });
-
- cy.log("Change period to be irrational factor of other period");
- cy.get(cesc("#\\/p") + " textarea").type(
- `{ctrl+home}{shift+end}{backspace}1{enter}`,
- { force: true },
- );
- cy.get(cesc("#\\/_answer1_submit")).click();
-
- cy.get(cesc("#\\/_answer1_incorrect")).should("be.visible");
- cy.get(cesc("#\\/ca")).should("have.text", "0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let s1 = ["periodic_set"];
- s1.push(["tuple", ["-", ["/", "pi", 4]], 1, -Infinity, Infinity]);
- expect(stateVariables["/s1"].stateValues.value).eqls(s1);
- expect(stateVariables["/s1"].stateValues.numOffsets).eq(1);
- expect(stateVariables["/s1"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/s1"].stateValues.period).eqls(1);
- expect(stateVariables["/s1"].stateValues.redundantOffsets).eq(
- false,
- );
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 0,
- );
- });
-
- cy.log("Change period");
- cy.get(cesc("#\\/p") + " textarea").type(
- `{ctrl+home}{shift+end}{backspace}pi{enter}`,
- { force: true },
- );
- cy.get(cesc("#\\/_answer1_submit")).click();
-
- cy.get(cesc("#\\/_answer1_incorrect")).should("be.visible");
- cy.get(cesc("#\\/ca")).should("have.text", "0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let s1 = ["periodic_set"];
- s1.push([
- "tuple",
- ["-", ["/", "pi", 4]],
- "pi",
- -Infinity,
- Infinity,
- ]);
- expect(stateVariables["/s1"].stateValues.value).eqls(s1);
- expect(stateVariables["/s1"].stateValues.numOffsets).eq(1);
- expect(stateVariables["/s1"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/s1"].stateValues.period).eqls("pi");
- expect(stateVariables["/s1"].stateValues.redundantOffsets).eq(
- false,
- );
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 0,
- );
- });
-
- cy.log("add offset");
- cy.get(cesc("#\\/o") + " textarea").type(`{end}, 5pi/4{enter}`, {
- force: true,
- });
- cy.get(cesc("#\\/_answer1_submit")).click();
-
- cy.get(cesc("#\\/_answer1_correct")).should("be.visible");
- cy.get(cesc("#\\/ca")).should("have.text", "1");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let s1 = ["periodic_set"];
- s1.push([
- "tuple",
- ["-", ["/", "pi", 4]],
- "pi",
- -Infinity,
- Infinity,
- ]);
- s1.push([
- "tuple",
- ["/", ["*", 5, "pi"], 4],
- "pi",
- -Infinity,
- Infinity,
- ]);
- expect(stateVariables["/s1"].stateValues.value).eqls(s1);
- expect(stateVariables["/s1"].stateValues.numOffsets).eq(2);
- expect(stateVariables["/s1"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/s1"].stateValues.offsets[1]).eqls([
- "/",
- ["*", 5, "pi"],
- 4,
- ]);
- expect(stateVariables["/s1"].stateValues.period).eqls("pi");
- expect(stateVariables["/s1"].stateValues.redundantOffsets).eq(
- false,
- );
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 1,
- );
- });
-
- cy.log("add redundant offset");
- cy.get(cesc("#\\/o") + " textarea").type(`{end}, pi/4{enter}`, {
- force: true,
- });
- cy.get(cesc("#\\/_answer1_submit")).click();
-
- cy.get(cesc("#\\/_answer1_correct")).should("be.visible");
- cy.get(cesc("#\\/ca")).should("have.text", "1");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let s1 = ["periodic_set"];
- s1.push([
- "tuple",
- ["-", ["/", "pi", 4]],
- "pi",
- -Infinity,
- Infinity,
- ]);
- s1.push([
- "tuple",
- ["/", ["*", 5, "pi"], 4],
- "pi",
- -Infinity,
- Infinity,
- ]);
- s1.push(["tuple", ["/", "pi", 4], "pi", -Infinity, Infinity]);
- expect(stateVariables["/s1"].stateValues.value).eqls(s1);
- expect(stateVariables["/s1"].stateValues.numOffsets).eq(3);
- expect(stateVariables["/s1"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/s1"].stateValues.offsets[1]).eqls([
- "/",
- ["*", 5, "pi"],
- 4,
- ]);
- expect(stateVariables["/s1"].stateValues.offsets[2]).eqls([
- "/",
- "pi",
- 4,
- ]);
- expect(stateVariables["/s1"].stateValues.period).eqls("pi");
- expect(stateVariables["/s1"].stateValues.redundantOffsets).eq(true);
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 1,
- );
- });
-
- cy.log("add incorrect offset");
- cy.get(cesc("#\\/o") + " textarea").type(`{end}, pi/2{enter}`, {
- force: true,
- });
- cy.get(cesc("#\\/_answer1_submit")).click();
-
- cy.get(cesc("#\\/_answer1_incorrect")).should("be.visible");
- cy.get(cesc("#\\/ca")).should("have.text", "0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let s1 = ["periodic_set"];
- s1.push([
- "tuple",
- ["-", ["/", "pi", 4]],
- "pi",
- -Infinity,
- Infinity,
- ]);
- s1.push([
- "tuple",
- ["/", ["*", 5, "pi"], 4],
- "pi",
- -Infinity,
- Infinity,
- ]);
- s1.push(["tuple", ["/", "pi", 4], "pi", -Infinity, Infinity]);
- s1.push(["tuple", ["/", "pi", 2], "pi", -Infinity, Infinity]);
- expect(stateVariables["/s1"].stateValues.value).eqls(s1);
- expect(stateVariables["/s1"].stateValues.numOffsets).eq(4);
- expect(stateVariables["/s1"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/s1"].stateValues.offsets[1]).eqls([
- "/",
- ["*", 5, "pi"],
- 4,
- ]);
- expect(stateVariables["/s1"].stateValues.offsets[2]).eqls([
- "/",
- "pi",
- 4,
- ]);
- expect(stateVariables["/s1"].stateValues.offsets[3]).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/s1"].stateValues.period).eqls("pi");
- expect(stateVariables["/s1"].stateValues.redundantOffsets).eq(true);
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 0,
- );
- });
-
- cy.log("add invalid math");
- cy.get(cesc("#\\/o") + " textarea").type(`{end}, ({enter}`, {
- force: true,
- });
- cy.get(cesc("#\\/_answer1_submit")).click();
-
- cy.get(cesc("#\\/_answer1_incorrect")).should("be.visible");
- cy.get(cesc("#\\/ca")).should("have.text", "0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- // expect((stateVariables['/s1'].stateValues.value)).eq('\uff3f');
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 0,
- );
- });
- });
-
- it("match copied periodic sets", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Offsets:
- Period:
-
- Offsets 2:
- Period 2:
-
-
-
-
-
-
- $a{name="a2"} = $b{name="b2"}
-
-
-
- Credit achieved: $_answer1.creditAchieved{assignNames="ca"}
-
- Redundancies: $a.redundantOffsets, $b.redundantOffsets, $a2.redundantOffsets, $b2.redundantOffsets
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get(cesc("#\\/_text1")).should("have.text", "a");
-
- cy.get(cesc("#\\/_answer1_submit")).click();
- cy.get(cesc("#\\/_answer1_incorrect")).should("be.visible");
-
- cy.get(cesc("#\\/ca")).should("have.text", "0");
- cy.get(cesc("#\\/_p6")).should(
- "have.text",
- "Redundancies: false, false, false, false",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/a"].stateValues.value).eq("\uFF3F");
- expect(stateVariables["/b"].stateValues.value).eq("\uFF3F");
- expect(stateVariables["/a2"].stateValues.value).eq("\uFF3F");
- expect(stateVariables["/b2"].stateValues.value).eq("\uFF3F");
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 0,
- );
- });
-
- cy.log("Submit offset for both");
- cy.get(cesc("#\\/offsets") + " textarea").type(`-pi/4{enter}`, {
- force: true,
- });
- cy.get(cesc("#\\/offsets2") + " textarea").type(`-pi/4{enter}`, {
- force: true,
- });
- cy.get(cesc("#\\/_answer1_submit")).click();
- cy.get(cesc("#\\/_answer1_incorrect")).should("be.visible");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/a"].stateValues.value).eq("\uFF3F");
- expect(stateVariables["/b"].stateValues.value).eq("\uFF3F");
- expect(stateVariables["/a2"].stateValues.value).eq("\uFF3F");
- expect(stateVariables["/b2"].stateValues.value).eq("\uFF3F");
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 0,
- );
- });
-
- cy.log("Submit periods for both");
- cy.get(cesc("#\\/period") + " textarea").type(`pi/2{enter}`, {
- force: true,
- });
- cy.get(cesc("#\\/period2") + " textarea").type(`2pi{enter}`, {
- force: true,
- });
- cy.get(cesc("#\\/_answer1_submit")).click();
- cy.get(cesc("#\\/_answer1_incorrect")).should("be.visible");
-
- cy.get(cesc("#\\/ca")).should("have.text", "0");
- cy.get(cesc("#\\/_p6")).should(
- "have.text",
- "Redundancies: false, false, false, false",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let a = ["periodic_set"];
- a.push([
- "tuple",
- ["-", ["/", "pi", 4]],
- ["/", "pi", 2],
- -Infinity,
- Infinity,
- ]);
- expect(stateVariables["/a"].stateValues.value).eqls(a);
- expect(stateVariables["/a"].stateValues.numOffsets).eq(1);
- expect(stateVariables["/a"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/a"].stateValues.period).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/a"].stateValues.redundantOffsets).eq(false);
- expect(stateVariables["/a2"].stateValues.value).eqls(a);
- expect(stateVariables["/a2"].stateValues.numOffsets).eq(1);
- expect(stateVariables["/a2"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/a2"].stateValues.period).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/a2"].stateValues.redundantOffsets).eq(
- false,
- );
-
- let b = ["periodic_set"];
- b.push([
- "tuple",
- ["-", ["/", "pi", 4]],
- ["*", 2, "pi"],
- -Infinity,
- Infinity,
- ]);
- expect(stateVariables["/b"].stateValues.value).eqls(b);
- expect(stateVariables["/b"].stateValues.numOffsets).eq(1);
- expect(stateVariables["/b"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/b"].stateValues.redundantOffsets).eq(false);
- expect(stateVariables["/b"].stateValues.period).eqls([
- "*",
- 2,
- "pi",
- ]);
- expect(stateVariables["/b2"].stateValues.value).eqls(b);
- expect(stateVariables["/b2"].stateValues.numOffsets).eq(1);
- expect(stateVariables["/b2"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/b2"].stateValues.period).eqls([
- "*",
- 2,
- "pi",
- ]);
- expect(stateVariables["/b2"].stateValues.redundantOffsets).eq(
- false,
- );
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 0,
- );
- });
-
- cy.log("Add offsets to match");
- cy.get(cesc("#\\/offsets2") + " textarea").type(
- `{end}, pi/4{rightArrow}, 11pi/4{rightArrow}, -11pi/4{enter}`,
- { force: true },
- );
- cy.get(cesc("#\\/_answer1_submit")).click();
- cy.get(cesc("#\\/_answer1_correct")).should("be.visible");
-
- cy.get(cesc("#\\/ca")).should("have.text", "1");
-
- cy.get(cesc("#\\/_p6")).should(
- "have.text",
- "Redundancies: false, false, false, false",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let a = ["periodic_set"];
- a.push([
- "tuple",
- ["-", ["/", "pi", 4]],
- ["/", "pi", 2],
- -Infinity,
- Infinity,
- ]);
- expect(stateVariables["/a"].stateValues.value).eqls(a);
- expect(stateVariables["/a"].stateValues.numOffsets).eq(1);
- expect(stateVariables["/a"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/a"].stateValues.period).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/a"].stateValues.redundantOffsets).eq(false);
- expect(stateVariables["/a2"].stateValues.value).eqls(a);
- expect(stateVariables["/a2"].stateValues.numOffsets).eq(1);
- expect(stateVariables["/a2"].stateValues.offsets[0]).eqls([
- "-",
- ["/", "pi", 4],
- ]);
- expect(stateVariables["/a2"].stateValues.period).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/a2"].stateValues.redundantOffsets).eq(
- false,
- );
-
- let b = ["periodic_set"];
-
- let offset0 = ["-", ["/", "pi", 4]];
- let offset1 = ["/", "pi", 4];
- let offset2 = ["/", ["*", 11, "pi"], 4];
- let offset3 = ["-", ["/", ["*", 11, "pi"], 4]];
-
- b.push(["tuple", offset0, ["*", 2, "pi"], -Infinity, Infinity]);
- b.push(["tuple", offset1, ["*", 2, "pi"], -Infinity, Infinity]);
- b.push(["tuple", offset2, ["*", 2, "pi"], -Infinity, Infinity]);
- b.push(["tuple", offset3, ["*", 2, "pi"], -Infinity, Infinity]);
- expect(stateVariables["/b"].stateValues.value).eqls(b);
- expect(stateVariables["/b"].stateValues.numOffsets).eq(4);
- expect(stateVariables["/b"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/b"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/b"].stateValues.offsets[2]).eqls(offset2);
- expect(stateVariables["/b"].stateValues.offsets[3]).eqls(offset3);
- expect(stateVariables["/b"].stateValues.redundantOffsets).eq(false);
- expect(stateVariables["/b"].stateValues.period).eqls([
- "*",
- 2,
- "pi",
- ]);
- expect(stateVariables["/b2"].stateValues.value).eqls(b);
- expect(stateVariables["/b2"].stateValues.numOffsets).eq(4);
- expect(stateVariables["/b2"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/b2"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/b2"].stateValues.offsets[2]).eqls(offset2);
- expect(stateVariables["/b2"].stateValues.offsets[3]).eqls(offset3);
- expect(stateVariables["/b2"].stateValues.period).eqls([
- "*",
- 2,
- "pi",
- ]);
- expect(stateVariables["/b2"].stateValues.redundantOffsets).eq(
- false,
- );
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 1,
- );
- });
-
- cy.log("Add extra offsets");
- cy.get(cesc("#\\/offsets") + " textarea").type(
- `{end}, -17pi/4{enter}`,
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/_answer1_submit")).click();
- cy.get(cesc("#\\/_answer1_correct")).should("be.visible");
-
- cy.get(cesc("#\\/ca")).should("have.text", "1");
-
- cy.get(cesc("#\\/_p6")).should(
- "have.text",
- "Redundancies: true, false, true, false",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let offset0 = ["-", ["/", "pi", 4]];
- let offset1 = ["-", ["/", ["*", 17, "pi"], 4]];
-
- let a = ["periodic_set"];
- a.push(["tuple", offset0, ["/", "pi", 2], -Infinity, Infinity]);
- a.push(["tuple", offset1, ["/", "pi", 2], -Infinity, Infinity]);
- expect(stateVariables["/a"].stateValues.value).eqls(a);
- expect(stateVariables["/a"].stateValues.numOffsets).eq(2);
- expect(stateVariables["/a"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/a"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/a"].stateValues.period).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/a"].stateValues.redundantOffsets).eq(true);
- expect(stateVariables["/a2"].stateValues.value).eqls(a);
- expect(stateVariables["/a2"].stateValues.numOffsets).eq(2);
- expect(stateVariables["/a2"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/a2"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/a2"].stateValues.period).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/a2"].stateValues.redundantOffsets).eq(true);
-
- let b = ["periodic_set"];
-
- offset0 = ["-", ["/", "pi", 4]];
- offset1 = ["/", "pi", 4];
- let offset2 = ["/", ["*", 11, "pi"], 4];
- let offset3 = ["-", ["/", ["*", 11, "pi"], 4]];
-
- b.push(["tuple", offset0, ["*", 2, "pi"], -Infinity, Infinity]);
- b.push(["tuple", offset1, ["*", 2, "pi"], -Infinity, Infinity]);
- b.push(["tuple", offset2, ["*", 2, "pi"], -Infinity, Infinity]);
- b.push(["tuple", offset3, ["*", 2, "pi"], -Infinity, Infinity]);
- expect(stateVariables["/b"].stateValues.value).eqls(b);
- expect(stateVariables["/b"].stateValues.numOffsets).eq(4);
- expect(stateVariables["/b"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/b"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/b"].stateValues.offsets[2]).eqls(offset2);
- expect(stateVariables["/b"].stateValues.offsets[3]).eqls(offset3);
- expect(stateVariables["/b"].stateValues.redundantOffsets).eq(false);
- expect(stateVariables["/b"].stateValues.period).eqls([
- "*",
- 2,
- "pi",
- ]);
- expect(stateVariables["/b2"].stateValues.value).eqls(b);
- expect(stateVariables["/b2"].stateValues.numOffsets).eq(4);
- expect(stateVariables["/b2"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/b2"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/b2"].stateValues.offsets[2]).eqls(offset2);
- expect(stateVariables["/b2"].stateValues.offsets[3]).eqls(offset3);
- expect(stateVariables["/b2"].stateValues.period).eqls([
- "*",
- 2,
- "pi",
- ]);
- expect(stateVariables["/b2"].stateValues.redundantOffsets).eq(
- false,
- );
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 1,
- );
- });
-
- cy.log("reduce period");
- cy.get(cesc("#\\/period2") + " textarea").type(
- `{end}{backspace}{backspace}pi{enter}`,
- { force: true },
- );
- cy.get(cesc("#\\/_answer1_submit")).click();
- cy.get(cesc("#\\/_answer1_correct")).should("be.visible");
-
- cy.get(cesc("#\\/ca")).should("have.text", "1");
-
- cy.get(cesc("#\\/_p6")).should(
- "have.text",
- "Redundancies: true, true, true, true",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let offset0 = ["-", ["/", "pi", 4]];
- let offset1 = ["-", ["/", ["*", 17, "pi"], 4]];
-
- let a = ["periodic_set"];
- a.push(["tuple", offset0, ["/", "pi", 2], -Infinity, Infinity]);
- a.push(["tuple", offset1, ["/", "pi", 2], -Infinity, Infinity]);
- expect(stateVariables["/a"].stateValues.value).eqls(a);
- expect(stateVariables["/a"].stateValues.numOffsets).eq(2);
- expect(stateVariables["/a"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/a"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/a"].stateValues.period).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/a"].stateValues.redundantOffsets).eq(true);
- expect(stateVariables["/a2"].stateValues.value).eqls(a);
- expect(stateVariables["/a2"].stateValues.numOffsets).eq(2);
- expect(stateVariables["/a2"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/a2"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/a2"].stateValues.period).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/a2"].stateValues.redundantOffsets).eq(true);
-
- let b = ["periodic_set"];
-
- offset0 = ["-", ["/", "pi", 4]];
- offset1 = ["/", "pi", 4];
- let offset2 = ["/", ["*", 11, "pi"], 4];
- let offset3 = ["-", ["/", ["*", 11, "pi"], 4]];
-
- b.push(["tuple", offset0, "pi", -Infinity, Infinity]);
- b.push(["tuple", offset1, "pi", -Infinity, Infinity]);
- b.push(["tuple", offset2, "pi", -Infinity, Infinity]);
- b.push(["tuple", offset3, "pi", -Infinity, Infinity]);
- expect(stateVariables["/b"].stateValues.value).eqls(b);
- expect(stateVariables["/b"].stateValues.numOffsets).eq(4);
- expect(stateVariables["/b"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/b"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/b"].stateValues.offsets[2]).eqls(offset2);
- expect(stateVariables["/b"].stateValues.offsets[3]).eqls(offset3);
- expect(stateVariables["/b"].stateValues.redundantOffsets).eq(true);
- expect(stateVariables["/b"].stateValues.period).eqls("pi");
- expect(stateVariables["/b2"].stateValues.value).eqls(b);
- expect(stateVariables["/b2"].stateValues.numOffsets).eq(4);
- expect(stateVariables["/b2"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/b2"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/b2"].stateValues.offsets[2]).eqls(offset2);
- expect(stateVariables["/b2"].stateValues.offsets[3]).eqls(offset3);
- expect(stateVariables["/b2"].stateValues.period).eqls("pi");
- expect(stateVariables["/b2"].stateValues.redundantOffsets).eq(true);
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 1,
- );
- });
-
- cy.log("add incorrect offset");
- cy.get(cesc("#\\/offsets2") + " textarea").type(`{end}, 0{enter}`, {
- force: true,
- });
- cy.get(cesc("#\\/_answer1_submit")).click();
- cy.get(cesc("#\\/_answer1_incorrect")).should("be.visible");
-
- cy.get(cesc("#\\/ca")).should("have.text", "0");
-
- cy.get(cesc("#\\/_p6")).should(
- "have.text",
- "Redundancies: true, true, true, true",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let offset0 = ["-", ["/", "pi", 4]];
- let offset1 = ["-", ["/", ["*", 17, "pi"], 4]];
-
- let a = ["periodic_set"];
- a.push(["tuple", offset0, ["/", "pi", 2], -Infinity, Infinity]);
- a.push(["tuple", offset1, ["/", "pi", 2], -Infinity, Infinity]);
- expect(stateVariables["/a"].stateValues.value).eqls(a);
- expect(stateVariables["/a"].stateValues.numOffsets).eq(2);
- expect(stateVariables["/a"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/a"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/a"].stateValues.period).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/a"].stateValues.redundantOffsets).eq(true);
- expect(stateVariables["/a2"].stateValues.value).eqls(a);
- expect(stateVariables["/a2"].stateValues.numOffsets).eq(2);
- expect(stateVariables["/a2"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/a2"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/a2"].stateValues.period).eqls([
- "/",
- "pi",
- 2,
- ]);
- expect(stateVariables["/a2"].stateValues.redundantOffsets).eq(true);
-
- let b = ["periodic_set"];
-
- offset0 = ["-", ["/", "pi", 4]];
- offset1 = ["/", "pi", 4];
- let offset2 = ["/", ["*", 11, "pi"], 4];
- let offset3 = ["-", ["/", ["*", 11, "pi"], 4]];
- let offset4 = 0;
-
- b.push(["tuple", offset0, "pi", -Infinity, Infinity]);
- b.push(["tuple", offset1, "pi", -Infinity, Infinity]);
- b.push(["tuple", offset2, "pi", -Infinity, Infinity]);
- b.push(["tuple", offset3, "pi", -Infinity, Infinity]);
- b.push(["tuple", offset4, "pi", -Infinity, Infinity]);
- expect(stateVariables["/b"].stateValues.value).eqls(b);
- expect(stateVariables["/b"].stateValues.numOffsets).eq(5);
- expect(stateVariables["/b"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/b"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/b"].stateValues.offsets[2]).eqls(offset2);
- expect(stateVariables["/b"].stateValues.offsets[3]).eqls(offset3);
- expect(stateVariables["/b"].stateValues.offsets[4]).eqls(offset4);
- expect(stateVariables["/b"].stateValues.redundantOffsets).eq(true);
- expect(stateVariables["/b"].stateValues.period).eqls("pi");
- expect(stateVariables["/b2"].stateValues.value).eqls(b);
- expect(stateVariables["/b2"].stateValues.numOffsets).eq(5);
- expect(stateVariables["/b2"].stateValues.offsets[0]).eqls(offset0);
- expect(stateVariables["/b2"].stateValues.offsets[1]).eqls(offset1);
- expect(stateVariables["/b2"].stateValues.offsets[2]).eqls(offset2);
- expect(stateVariables["/b2"].stateValues.offsets[3]).eqls(offset3);
- expect(stateVariables["/b2"].stateValues.offsets[4]).eqls(offset4);
- expect(stateVariables["/b2"].stateValues.period).eqls("pi");
- expect(stateVariables["/b2"].stateValues.redundantOffsets).eq(true);
-
- expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(
- 0,
- );
- });
- });
-
- it("partial credit with periodic set", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- 30,150
- $correct_offsets.numComponents{assignNames="n_correct_offsets"}
- 180
-
-
- What is the period?
-
-
-
- $period_input/$correct_period
-
-
-
-
- How many offsets?
-
-
-
- $number_offsets_input
- and
- $number_offsets_input >= $period/$correct_period*$n_correct_offsets
-
-
-
-
- Enter the offsets:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0.8
-
-
- 1
-
-
-
-
-
-
-
- $userPeriodicSet = $correct
-
-
-
-
-
- Answer when penalizing redundant offsets:
-
-
-
- $userPeriodicSet = $correct
-
-
-
- $userPeriodicSet.redundantOffsets
-
-
- $p$o
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_p1")).should("contain.text", "What is the period?");
-
- cy.log("partially correct answer");
- cy.get(cesc("#\\/period_input") + " textarea").type("360{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/period_input_correct")).should("be.visible");
-
- cy.get(cesc("#\\/number_offsets_input") + " textarea").type(
- "4{enter}",
- {
- force: true,
- },
- );
- cy.get(cesc("#\\/number_offsets_input_correct")).should("be.visible");
-
- cy.get(cesc("#\\/mi1") + " textarea")
- .type("30", { force: true })
- .blur();
- cy.get(cesc("#\\/mi2") + " textarea")
- .type("150", { force: true })
- .blur();
- cy.get(cesc("#\\/mi3") + " textarea")
- .type("210", { force: true })
- .blur();
- cy.get(cesc("#\\/mi4") + " textarea")
- .type("211", { force: true })
- .blur();
-
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_partial")).should("contain.text", "75");
- cy.get(cesc("#\\/_answer3_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("75% correct");
- });
-
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "75");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("75% correct");
- });
-
- cy.log("correct answer");
-
- cy.get(cesc("#\\/mi4") + " textarea")
- .type("{ctrl+home}{shift+end}{backspace}-30", { force: true })
- .blur();
-
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_correct")).should("be.visible");
-
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_correct")).should("be.visible");
-
- cy.log("add extraneous answer blanks");
- cy.get(cesc("#\\/number_offsets_input") + " textarea").type(
- "{end}{backspace}10",
- { force: true },
- );
- cy.get(cesc("#\\/number_offsets_input_submit")).should("be.visible");
- cy.get(cesc("#\\/number_offsets_input") + " textarea").type("{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/number_offsets_input_correct")).should("be.visible");
-
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_partial")).should("contain.text", "40");
- cy.get(cesc("#\\/_answer3_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("40% correct");
- });
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "40");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("40% correct");
- });
-
- cy.log("add in a duplicate");
- cy.get(cesc("#\\/mi5") + " textarea")
- .type("330", { force: true })
- .blur();
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_partial")).should("contain.text", "50");
- cy.get(cesc("#\\/_answer3_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "40");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("40% correct");
- });
-
- cy.log("fill in with duplicates");
- cy.get(cesc("#\\/mi6") + " textarea")
- .type("330", { force: true })
- .blur();
- cy.get(cesc("#\\/mi7") + " textarea")
- .type("330", { force: true })
- .blur();
- cy.get(cesc("#\\/mi8") + " textarea")
- .type("330", { force: true })
- .blur();
- cy.get(cesc("#\\/mi9") + " textarea")
- .type("330", { force: true })
- .blur();
- cy.get(cesc("#\\/mi10") + " textarea")
- .type("330", { force: true })
- .blur();
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_correct")).should("be.visible");
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "80");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("80% correct");
- });
-
- cy.log("too few answer blanks");
- cy.get(cesc("#\\/number_offsets_input") + " textarea").type(
- "{end}{backspace}{backspace}3",
- { force: true },
- );
- cy.get(cesc("#\\/number_offsets_input_submit")).click();
- cy.get(cesc("#\\/number_offsets_input_incorrect")).should("be.visible");
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_partial")).should("contain.text", "75");
- cy.get(cesc("#\\/_answer3_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("75% correct");
- });
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "75");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("75% correct");
- });
-
- cy.get(cesc("#\\/mi3") + " textarea")
- .type("{ctrl+home}{shift+end}{backspace}100", { force: true })
- .blur();
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_partial")).should("contain.text", "50");
- cy.get(cesc("#\\/_answer3_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "50");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
-
- cy.log("even fewer answer blanks");
- cy.get(cesc("#\\/number_offsets_input") + " textarea").type(
- "{end}{backspace}2",
- { force: true },
- );
- cy.get(cesc("#\\/number_offsets_input_submit")).click();
- cy.get(cesc("#\\/number_offsets_input_incorrect")).should("be.visible");
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_partial")).should("contain.text", "50");
- cy.get(cesc("#\\/_answer3_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "50");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
-
- cy.log("change period");
- cy.get(cesc("#\\/period_input") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}180",
- { force: true },
- );
- cy.get(cesc("#\\/period_input_submit")).click();
- cy.get(cesc("#\\/period_input_correct")).should("be.visible");
- cy.get(cesc("#\\/number_offsets_input_submit")).click();
- cy.get(cesc("#\\/number_offsets_input_correct")).should("be.visible");
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_correct")).should("be.visible");
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_correct")).should("be.visible");
-
- cy.log("additional answer blanks");
- cy.get(cesc("#\\/number_offsets_input") + " textarea").type(
- "{end}{backspace}3",
- { force: true },
- );
- cy.get(cesc("#\\/number_offsets_input_submit")).click();
- cy.get(cesc("#\\/number_offsets_input_correct")).should("be.visible");
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_partial")).should("contain.text", "67");
- cy.get(cesc("#\\/_answer3_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("67% correct");
- });
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "67");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("67% correct");
- });
-
- cy.get(cesc("#\\/mi3") + " textarea")
- .type("{ctrl+home}{shift+end}{backspace}330", { force: true })
- .blur();
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_correct")).should("be.visible");
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "80");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("80% correct");
- });
-
- cy.log("change period");
- cy.get(cesc("#\\/period_input") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}90",
- { force: true },
- );
- cy.get(cesc("#\\/period_input_submit")).click();
- cy.get(cesc("#\\/period_input_incorrect")).should("be.visible");
- cy.get(cesc("#\\/number_offsets_input_submit")).click();
- cy.get(cesc("#\\/number_offsets_input_correct")).should("be.visible");
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_partial")).should("contain.text", "50");
- cy.get(cesc("#\\/_answer3_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "40");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("40% correct");
- });
-
- cy.get(cesc("#\\/mi3") + " textarea")
- .type("{ctrl+home}{shift+end}{backspace}100", { force: true })
- .blur();
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_partial")).should("contain.text", "33");
- cy.get(cesc("#\\/_answer3_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("33% correct");
- });
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "33");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("33% correct");
- });
-
- cy.get(cesc("#\\/mi3") + " textarea")
- .type("{ctrl+home}{shift+end}{backspace}150", { force: true })
- .blur();
- cy.get(cesc("#\\/_answer3_submit")).click();
- cy.get(cesc("#\\/_answer3_partial")).should("contain.text", "50");
- cy.get(cesc("#\\/_answer3_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("50% correct");
- });
- cy.get(cesc("#\\/_answer4_submit")).click();
- cy.get(cesc("#\\/_answer4_partial")).should("contain.text", "40");
- cy.get(cesc("#\\/_answer4_partial"))
- .invoke("text")
- .then((text) => {
- expect(text.trim().toLowerCase()).equal("40% correct");
- });
- });
-
- it("display periodic set as list", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Period:
- Offsets:
-
-
-
- As list: $pset.asList{assignNames="l1"}
-
- Min index: ,
-
-
-
- As list with specified min/max: $pset2.asList{assignNames="l2"}
-
- $offsets.value{assignNames="offsets2"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/l1")).should("not.exist");
- cy.get(cesc("#\\/l2")).should("not.exist");
-
- cy.get(cesc("#\\/period") + " textarea").type("7{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/offsets") + " textarea").type("1{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/l1")).should("contain.text", "…,−6,1,8,…");
- cy.get(cesc("#\\/l1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("…,−6,1,8,…");
- });
- cy.get(cesc("#\\/l2"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("…,−6,1,8,…");
- });
-
- cy.get(cesc("#\\/minIndex") + " textarea").type("3{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/l2")).should("contain.text", "…,…");
- cy.get(cesc("#\\/l2"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("…,…");
- });
- cy.get(cesc("#\\/maxIndex") + " textarea").type("6{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/l2")).should("contain.text", "…,22,29,36,43,…");
- cy.get(cesc("#\\/l2"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("…,22,29,36,43,…");
- });
-
- cy.get(cesc("#\\/offsets") + " textarea").type("{end},3{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/offsets2")).should("contain.text", "1,3");
- cy.get(cesc("#\\/l1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("…,−6,−4,1,3,8,10,…");
- });
- cy.get(cesc("#\\/l2"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("…,22,24,29,31,36,38,43,45,…");
- });
-
- cy.get(cesc("#\\/offsets") + " textarea").type(
- "{end}{backspace}{backspace}{leftArrow}3,{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/offsets2")).should("contain.text", "3,1");
- cy.get(cesc("#\\/l1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("…,−6,−4,1,3,8,10,…");
- });
- cy.get(cesc("#\\/l2"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("…,22,24,29,31,36,38,43,45,…");
- });
-
- cy.get(cesc("#\\/offsets") + " textarea").type("{end},8{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/offsets2")).should("contain.text", "3,1,8");
-
- cy.get(cesc("#\\/l1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("…,−6,−4,1,3,8,10,…");
- });
- cy.get(cesc("#\\/l2"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("…,22,24,29,31,36,38,43,45,…");
- });
-
- cy.get(cesc("#\\/offsets") + " textarea").type("{end},79{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/offsets2")).should("contain.text", "3,1,8,79");
- cy.get(cesc("#\\/l1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("…,−6,−5,−4,1,2,3,8,9,10,…");
- });
- cy.get(cesc("#\\/l2"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal(
- "…,22,23,24,29,30,31,36,37,38,43,44,45,…",
- );
- });
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/piecewisefunction.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/piecewisefunction.cy.js
deleted file mode 100644
index 97b28454c..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/piecewisefunction.cy.js
+++ /dev/null
@@ -1,1883 +0,0 @@
-import me from "math-expressions";
-import { cesc, cesc2, createFunctionFromDefinition } from "@doenet/utils";
-
-function nInDOM(n) {
- if (n < 0) {
- return `−${Math.abs(n)}`;
- } else {
- return String(n);
- }
-}
-
-describe("Piecewise Function Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("heaviside function", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- 1
- 0
-
-
- 0
- 1
-
-
- 1
- 0
-
-
- 0
- 1
-
-
- 1/2
- 1
- 0
-
-
- 1
- 0
- 1/2
-
-
- f(x)=$f
- f_2(x)=$f2
- g(x)=$g
- g_2(x)=$g2
- h(x)=$h
- h_2(x)=$h2
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/mef") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "f(x)={1if\u00a0x>00otherwise");
- cy.get(cesc("#\\/mef2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "f2(x)={0if\u00a0x≤01otherwise");
- cy.get(cesc("#\\/meg") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "g(x)={1if\u00a0x≥00otherwise");
- cy.get(cesc("#\\/meg2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "g2(x)={0if\u00a0x<01otherwise");
- cy.get(cesc("#\\/meh") + " .mjx-mrow")
- .eq(0)
- .should(
- "have.text",
- "h(x)=⎧⎪⎨⎪⎩12if\u00a0x=01if\u00a0x>00otherwise",
- );
- cy.get(cesc("#\\/meh2") + " .mjx-mrow")
- .eq(0)
- .should(
- "have.text",
- "h2(x)=⎧⎪⎨⎪⎩1if\u00a0x>00if\u00a0x<012otherwise",
- );
-
- let fs = ["f", "f2"];
- let gs = ["g", "g2"];
- let hs = ["h", "h2"];
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- for (let fsym of fs) {
- let f = createFunctionFromDefinition(
- stateVariables["/" + fsym].stateValues.fDefinitions[0],
- );
- expect(f(-2)).closeTo(0, 1e-12);
- expect(f(-1)).closeTo(0, 1e-12);
- expect(f(-1e-6)).closeTo(0, 1e-12);
- expect(f(0)).closeTo(0, 1e-12);
- expect(f(1e-6)).closeTo(1, 1e-12);
- expect(f(1)).closeTo(1, 1e-12);
- expect(f(2)).closeTo(1, 1e-12);
-
- expect(
- stateVariables["/" + fsym].stateValues.globalMinimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + fsym].stateValues.globalInfimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + fsym].stateValues.globalMaximum[1],
- ).eq(1);
- expect(
- stateVariables["/" + fsym].stateValues.globalSupremum[1],
- ).eq(1);
- }
-
- for (let gsym of gs) {
- let g = createFunctionFromDefinition(
- stateVariables["/" + gsym].stateValues.fDefinitions[0],
- );
- expect(g(-2)).closeTo(0, 1e-12);
- expect(g(-1)).closeTo(0, 1e-12);
- expect(g(-1e-6)).closeTo(0, 1e-12);
- expect(g(0)).closeTo(1, 1e-12);
- expect(g(1e-6)).closeTo(1, 1e-12);
- expect(g(1)).closeTo(1, 1e-12);
- expect(g(2)).closeTo(1, 1e-12);
-
- expect(
- stateVariables["/" + gsym].stateValues.globalMinimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + gsym].stateValues.globalInfimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + gsym].stateValues.globalMaximum[1],
- ).eq(1);
- expect(
- stateVariables["/" + gsym].stateValues.globalSupremum[1],
- ).eq(1);
- }
-
- for (let hsym of hs) {
- let h = createFunctionFromDefinition(
- stateVariables["/" + hsym].stateValues.fDefinitions[0],
- );
- expect(h(-2)).closeTo(0, 1e-12);
- expect(h(-1)).closeTo(0, 1e-12);
- expect(h(-1e-6)).closeTo(0, 1e-12);
- expect(h(0)).closeTo(0.5, 1e-12);
- expect(h(1e-6)).closeTo(1, 1e-12);
- expect(h(1)).closeTo(1, 1e-12);
- expect(h(2)).closeTo(1, 1e-12);
-
- expect(
- stateVariables["/" + hsym].stateValues.globalMinimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + hsym].stateValues.globalInfimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + hsym].stateValues.globalMaximum[1],
- ).eq(1);
- expect(
- stateVariables["/" + hsym].stateValues.globalSupremum[1],
- ).eq(1);
- }
- });
- });
-
- it("heaviside function, ignore extra pieces", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- 1
- 0
- x^2
-
-
- 0
- 1
- x^2
-
-
- 1
- 0
- x^2
-
-
- 0
- 1
- x^2
-
-
- 1/2
- 1
- 0
- x^2
- x^3
-
-
- 1
- 0
- 1/2
- x^2
- x^3
-
-
- f(x)=$f
- f_2(x)=$f2
- g(x)=$g
- g_2(x)=$g2
- h(x)=$h
- h_2(x)=$h2
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/mef") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "f(x)={1if\u00a0x>00otherwise");
- cy.get(cesc("#\\/mef2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "f2(x)={0if\u00a0x≤01otherwise");
- cy.get(cesc("#\\/meg") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "g(x)={1if\u00a0x≥00otherwise");
- cy.get(cesc("#\\/meg2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "g2(x)={0if\u00a0x<01otherwise");
- cy.get(cesc("#\\/meh") + " .mjx-mrow")
- .eq(0)
- .should(
- "have.text",
- "h(x)=⎧⎪⎨⎪⎩12if\u00a0x=01if\u00a0x>00otherwise",
- );
- cy.get(cesc("#\\/meh2") + " .mjx-mrow")
- .eq(0)
- .should(
- "have.text",
- "h2(x)=⎧⎪⎨⎪⎩1if\u00a0x>00if\u00a0x<012otherwise",
- );
-
- let fs = ["f", "f2"];
- let gs = ["g", "g2"];
- let hs = ["h", "h2"];
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- for (let fsym of fs) {
- let f = createFunctionFromDefinition(
- stateVariables["/" + fsym].stateValues.fDefinitions[0],
- );
- expect(f(-2)).closeTo(0, 1e-12);
- expect(f(-1)).closeTo(0, 1e-12);
- expect(f(-1e-6)).closeTo(0, 1e-12);
- expect(f(0)).closeTo(0, 1e-12);
- expect(f(1e-6)).closeTo(1, 1e-12);
- expect(f(1)).closeTo(1, 1e-12);
- expect(f(2)).closeTo(1, 1e-12);
-
- expect(
- stateVariables["/" + fsym].stateValues.globalMinimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + fsym].stateValues.globalInfimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + fsym].stateValues.globalMaximum[1],
- ).eq(1);
- expect(
- stateVariables["/" + fsym].stateValues.globalSupremum[1],
- ).eq(1);
- }
-
- for (let gsym of gs) {
- let g = createFunctionFromDefinition(
- stateVariables["/" + gsym].stateValues.fDefinitions[0],
- );
- expect(g(-2)).closeTo(0, 1e-12);
- expect(g(-1)).closeTo(0, 1e-12);
- expect(g(-1e-6)).closeTo(0, 1e-12);
- expect(g(0)).closeTo(1, 1e-12);
- expect(g(1e-6)).closeTo(1, 1e-12);
- expect(g(1)).closeTo(1, 1e-12);
- expect(g(2)).closeTo(1, 1e-12);
-
- expect(
- stateVariables["/" + gsym].stateValues.globalMinimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + gsym].stateValues.globalInfimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + gsym].stateValues.globalMaximum[1],
- ).eq(1);
- expect(
- stateVariables["/" + gsym].stateValues.globalSupremum[1],
- ).eq(1);
- }
-
- for (let hsym of hs) {
- let h = createFunctionFromDefinition(
- stateVariables["/" + hsym].stateValues.fDefinitions[0],
- );
- expect(h(-2)).closeTo(0, 1e-12);
- expect(h(-1)).closeTo(0, 1e-12);
- expect(h(-1e-6)).closeTo(0, 1e-12);
- expect(h(0)).closeTo(0.5, 1e-12);
- expect(h(1e-6)).closeTo(1, 1e-12);
- expect(h(1)).closeTo(1, 1e-12);
- expect(h(2)).closeTo(1, 1e-12);
-
- expect(
- stateVariables["/" + hsym].stateValues.globalMinimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + hsym].stateValues.globalInfimum[1],
- ).eq(0);
- expect(
- stateVariables["/" + hsym].stateValues.globalMaximum[1],
- ).eq(1);
- expect(
- stateVariables["/" + hsym].stateValues.globalSupremum[1],
- ).eq(1);
- }
- });
- });
-
- it("different variables", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- x
- 2-y
-
-
- q
- 2-y
-
-
- q
- 2-y
-
-
- q
- 2-y
-
-
- f(t)=$f
- g(q)=$g
- h(s)=$h
- k(u)=$k
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/mef") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "f(t)={tif\u00a0t>02−tif\u00a0t≤0");
- cy.get(cesc("#\\/meg") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "g(q)={qif\u00a0q>02−qif\u00a0q<0");
- cy.get(cesc("#\\/meh") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "h(s)={sif\u00a00≤s<102−sif\u00a0−10≤s<0");
- cy.get(cesc("#\\/mek") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "k(u)={uif\u00a0u>02−uif\u00a0u<0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let f = createFunctionFromDefinition(
- stateVariables["/f"].stateValues.fDefinitions[0],
- );
- expect(f(-2)).closeTo(4, 1e-12);
- expect(f(-1)).closeTo(3, 1e-12);
- expect(f(-1e-6)).closeTo(2.000001, 1e-12);
- expect(f(0)).closeTo(2, 1e-12);
- expect(f(1e-6)).closeTo(1e-6, 1e-12);
- expect(f(1)).closeTo(1, 1e-12);
- expect(f(2)).closeTo(2, 1e-12);
-
- expect(stateVariables["/f"].stateValues.globalMinimum).eqls([]);
- expect(stateVariables["/f"].stateValues.globalInfimum).eqls([0, 0]);
- expect(stateVariables["/f"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/f"].stateValues.globalSupremum).eqls([
- -200, 202,
- ]);
-
- let g = createFunctionFromDefinition(
- stateVariables["/g"].stateValues.fDefinitions[0],
- );
- expect(g(-2)).closeTo(4, 1e-12);
- expect(g(-1)).closeTo(3, 1e-12);
- expect(g(-1e-6)).closeTo(2.000001, 1e-12);
- expect(g(0)).eqls(NaN);
- expect(g(1e-6)).closeTo(1e-6, 1e-12);
- expect(g(1)).closeTo(1, 1e-12);
- expect(g(2)).closeTo(2, 1e-12);
-
- expect(stateVariables["/g"].stateValues.globalMinimum).eqls([]);
- expect(stateVariables["/g"].stateValues.globalInfimum).eqls([0, 0]);
- expect(stateVariables["/g"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/g"].stateValues.globalSupremum).eqls([
- -200, 202,
- ]);
-
- let h = createFunctionFromDefinition(
- stateVariables["/h"].stateValues.fDefinitions[0],
- );
- expect(h(-10.000001)).eqls(NaN);
- expect(h(-10)).closeTo(12, 1e-12);
- expect(h(-2)).closeTo(4, 1e-12);
- expect(h(-1)).closeTo(3, 1e-12);
- expect(h(-1e-6)).closeTo(2.000001, 1e-12);
- expect(h(0)).closeTo(0, 1e-12);
- expect(h(1e-6)).closeTo(1e-6, 1e-12);
- expect(h(1)).closeTo(1, 1e-12);
- expect(h(2)).closeTo(2, 1e-12);
- expect(h(9.99999)).closeTo(9.99999, 1e-12);
- expect(h(10)).eqls(NaN);
-
- expect(stateVariables["/h"].stateValues.globalMinimum).eqls([0, 0]);
- expect(stateVariables["/h"].stateValues.globalInfimum).eqls([0, 0]);
- expect(stateVariables["/h"].stateValues.globalMaximum).eqls([
- -10, 12,
- ]);
- expect(stateVariables["/h"].stateValues.globalSupremum).eqls([
- -10, 12,
- ]);
-
- let k = createFunctionFromDefinition(
- stateVariables["/k"].stateValues.fDefinitions[0],
- );
- expect(k(-10)).eqls(NaN);
- expect(k(-9.99999)).closeTo(11.99999, 1e-12);
- expect(k(-2)).closeTo(4, 1e-12);
- expect(k(-1)).closeTo(3, 1e-12);
- expect(k(-1e-6)).closeTo(2.000001, 1e-12);
- expect(k(0)).eqls(NaN);
- expect(k(1e-6)).closeTo(1e-6, 1e-12);
- expect(k(1)).closeTo(1, 1e-12);
- expect(k(2)).closeTo(2, 1e-12);
- expect(k(10)).closeTo(10, 1e-12);
- expect(k(10.0000001)).eqls(NaN);
-
- expect(stateVariables["/k"].stateValues.globalMinimum).eqls([]);
- expect(stateVariables["/k"].stateValues.globalInfimum).eqls([0, 0]);
- expect(stateVariables["/k"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/k"].stateValues.globalSupremum).eqls([
- -10, 12,
- ]);
- });
- });
-
- it("extrema", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- x^2
- -x^2
-
-
- x^2
- -x^2
-
-
- f(x)=$f
- f_2(x)=$f2
- Minima of f: $f.minima
- Maxima of f: $f.maxima
- Minima of f_2: $f2.minima
- Maxima of f_2: $f2.maxima
-
-
-
- x^2
- -x^2
-
-
- x^2
- -x^2
-
-
- g(x)=$g
- g_2(x)=$g2
- Minima of g: $g.minima
- Maxima of g: $g.maxima
- Minima of g_2: $g2.minima
- Maxima of g_2: $g2.maxima
-
-
-
- x^2
- -x^2
-
-
- x^2
- -x^2
-
-
- h(x)=$h
- h_2(x)=$h2
- Minima of h: $h.minima
- Maxima of h: $h.maxima
- Minima of h_2: $h2.minima
- Maxima of h_2: $h2.maxima
-
-
-
- (x-2)^2
- (x+2)^2
- cos(pi*x/2)
-
-
- (x-2)^2
- (x+2)^2
- cos(pi*x/2)
-
-
- k(x)=$k
- k_2(x)=$k2
- Minima of k: $k.minima
- Maxima of k: $k.maxima
- Minima of k_2: $k2.minima
- Maxima of k_2: $k2.maxima
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/mef") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "f(x)={x2if\u00a0x>0−x2otherwise");
- cy.get(cesc("#\\/mef2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "f2(x)={x2if\u00a0x≥0−x2otherwise");
- cy.get(cesc("#\\/pfmin") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/pfmax") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/pf2min") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/pf2max") + " .mjx-mrow").should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/f"].stateValues.minima).eqls([]);
- expect(stateVariables["/f"].stateValues.maxima).eqls([]);
- expect(stateVariables["/f2"].stateValues.minima).eqls([]);
- expect(stateVariables["/f2"].stateValues.maxima).eqls([]);
- expect(stateVariables["/f"].stateValues.globalMinimum).eqls([]);
- expect(stateVariables["/f"].stateValues.globalInfimum).eqls([
- -200,
- -(200 ** 2),
- ]);
- expect(stateVariables["/f"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/f"].stateValues.globalSupremum).eqls([
- 200,
- 200 ** 2,
- ]);
- expect(stateVariables["/f2"].stateValues.globalMinimum).eqls([]);
- expect(stateVariables["/f2"].stateValues.globalInfimum).eqls([
- -200,
- -(200 ** 2),
- ]);
- expect(stateVariables["/f2"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/f2"].stateValues.globalSupremum).eqls([
- 200,
- 200 ** 2,
- ]);
- });
-
- cy.get(cesc("#\\/meg") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "g(x)={x2if\u00a0x>0.1−x2otherwise");
- cy.get(cesc("#\\/meg2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "g2(x)={x2if\u00a0x≥0.1−x2otherwise");
- cy.get(cesc("#\\/pgmin") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0.1,−0.01)");
- cy.get(cesc("#\\/pgmin") + " .mjx-mrow")
- .eq(2)
- .should("not.exist");
- cy.get(cesc("#\\/pgmax") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/pgmax") + " .mjx-mrow")
- .eq(2)
- .should("not.exist");
- cy.get(cesc("#\\/pg2min") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/pg2max") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/pg2max") + " .mjx-mrow")
- .eq(2)
- .should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/g"].stateValues.minima.length).eq(1);
- expect(stateVariables["/g"].stateValues.minima[0][0]).closeTo(
- 0.1,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.minima[0][1]).closeTo(
- -0.01,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.maxima.length).eq(1);
- expect(stateVariables["/g"].stateValues.maxima[0][0]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.maxima[0][1]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/g2"].stateValues.minima).eqls([]);
- expect(stateVariables["/g2"].stateValues.maxima.length).eq(1);
- expect(stateVariables["/g2"].stateValues.maxima[0][0]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/g2"].stateValues.maxima[0][1]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.globalMinimum).eqls([]);
- expect(stateVariables["/g"].stateValues.globalInfimum).eqls([
- -199.9,
- -(199.9 ** 2),
- ]);
- expect(stateVariables["/g"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/g"].stateValues.globalSupremum).eqls([
- 200.1,
- 200.1 ** 2,
- ]);
- expect(stateVariables["/g2"].stateValues.globalMinimum).eqls([]);
- expect(stateVariables["/g2"].stateValues.globalInfimum).eqls([
- -199.9,
- -(199.9 ** 2),
- ]);
- expect(stateVariables["/g2"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/g2"].stateValues.globalSupremum).eqls([
- 200.1,
- 200.1 ** 2,
- ]);
- });
-
- cy.get(cesc("#\\/meh") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "h(x)={x2if\u00a0x>−0.1−x2otherwise");
- cy.get(cesc("#\\/meh2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "h2(x)={x2if\u00a0x≥−0.1−x2otherwise");
- cy.get(cesc("#\\/phmin") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/phmin") + " .mjx-mrow")
- .eq(2)
- .should("not.exist");
- cy.get(cesc("#\\/phmax") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/ph2min") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/ph2min") + " .mjx-mrow")
- .eq(2)
- .should("not.exist");
- cy.get(cesc("#\\/ph2max") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−0.1,0.01)");
- cy.get(cesc("#\\/ph2max") + " .mjx-mrow")
- .eq(2)
- .should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/h"].stateValues.minima.length).eq(1);
- expect(stateVariables["/h"].stateValues.minima[0][0]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/h"].stateValues.minima[0][1]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/h"].stateValues.maxima).eqls([]);
- expect(stateVariables["/h2"].stateValues.minima.length).eq(1);
- expect(stateVariables["/h2"].stateValues.minima[0][0]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/h2"].stateValues.minima[0][1]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/h2"].stateValues.maxima.length).eq(1);
- expect(stateVariables["/h2"].stateValues.maxima[0][0]).closeTo(
- -0.1,
- 1e-14,
- );
- expect(stateVariables["/h2"].stateValues.maxima[0][1]).closeTo(
- 0.01,
- 1e-14,
- );
- expect(stateVariables["/h"].stateValues.globalMinimum).eqls([]);
- expect(stateVariables["/h"].stateValues.globalInfimum).eqls([
- -200.1,
- -(200.1 ** 2),
- ]);
- expect(stateVariables["/h"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/h"].stateValues.globalSupremum).eqls([
- 199.9,
- 199.9 ** 2,
- ]);
- expect(stateVariables["/h2"].stateValues.globalMinimum).eqls([]);
- expect(stateVariables["/h2"].stateValues.globalInfimum).eqls([
- -200.1,
- -(200.1 ** 2),
- ]);
- expect(stateVariables["/h2"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/h2"].stateValues.globalSupremum).eqls([
- 199.9,
- 199.9 ** 2,
- ]);
- });
-
- cy.get(cesc("#\\/mek") + " .mjx-mrow")
- .eq(0)
- .should(
- "have.text",
- "k(x)=⎧⎪\n⎪⎨⎪\n⎪⎩(x−2)2if\u00a0x>1(x+2)2if\u00a0x<−1cos(πx2)otherwise",
- );
- cy.get(cesc("#\\/mek2") + " .mjx-mrow")
- .eq(0)
- .should(
- "have.text",
- "k2(x)=⎧⎪\n⎪⎨⎪\n⎪⎩(x−2)2if\u00a0x≥1(x+2)2if\u00a0x≤−1cos(πx2)otherwise",
- );
- cy.get(cesc("#\\/pkmin") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,0)");
- cy.get(cesc("#\\/pkmin") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(−1,0)");
- cy.get(cesc("#\\/pkmin") + " .mjx-mrow")
- .eq(4)
- .should("have.text", "(1,0)");
- cy.get(cesc("#\\/pkmin") + " .mjx-mrow")
- .eq(6)
- .should("have.text", "(2,0)");
- cy.get(cesc("#\\/pkmin") + " .mjx-mrow")
- .eq(8)
- .should("not.exist");
- cy.get(cesc("#\\/pkmax") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,1)");
- cy.get(cesc("#\\/pkmax") + " .mjx-mrow")
- .eq(2)
- .should("not.exist");
- cy.get(cesc("#\\/pk2min") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,0)");
- cy.get(cesc("#\\/pk2min") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(2,0)");
- cy.get(cesc("#\\/pk2min") + " .mjx-mrow")
- .eq(4)
- .should("not.exist");
- cy.get(cesc("#\\/pk2max") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−1,1)");
- cy.get(cesc("#\\/pk2max") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(0,1)");
- cy.get(cesc("#\\/pk2max") + " .mjx-mrow")
- .eq(4)
- .should("have.text", "(1,1)");
- cy.get(cesc("#\\/pk2max") + " .mjx-mrow")
- .eq(6)
- .should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/k"].stateValues.minima.length).eq(4);
- expect(stateVariables["/k"].stateValues.minima[0][0]).closeTo(
- -2,
- 1e-14,
- );
- expect(stateVariables["/k"].stateValues.minima[0][1]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/k"].stateValues.minima[1][0]).closeTo(
- -1,
- 1e-14,
- );
- expect(stateVariables["/k"].stateValues.minima[1][1]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/k"].stateValues.minima[2][0]).closeTo(
- 1,
- 1e-14,
- );
- expect(stateVariables["/k"].stateValues.minima[2][1]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/k"].stateValues.minima[3][0]).closeTo(
- 2,
- 1e-14,
- );
- expect(stateVariables["/k"].stateValues.minima[3][1]).closeTo(
- 0,
- 1e-14,
- );
-
- expect(stateVariables["/k"].stateValues.maxima.length).eq(1);
- expect(stateVariables["/k"].stateValues.maxima[0][0]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/k"].stateValues.maxima[0][1]).closeTo(
- 1,
- 1e-14,
- );
-
- expect(stateVariables["/k2"].stateValues.minima.length).eq(2);
- expect(stateVariables["/k2"].stateValues.minima[0][0]).closeTo(
- -2,
- 1e-14,
- );
- expect(stateVariables["/k2"].stateValues.minima[0][1]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/k2"].stateValues.minima[1][0]).closeTo(
- 2,
- 1e-14,
- );
- expect(stateVariables["/k2"].stateValues.minima[1][1]).closeTo(
- 0,
- 1e-14,
- );
-
- expect(stateVariables["/k2"].stateValues.maxima.length).eq(3);
- expect(stateVariables["/k2"].stateValues.maxima[0][0]).closeTo(
- -1,
- 1e-14,
- );
- expect(stateVariables["/k2"].stateValues.maxima[0][1]).closeTo(
- 1,
- 1e-14,
- );
- expect(stateVariables["/k2"].stateValues.maxima[1][0]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/k2"].stateValues.maxima[1][1]).closeTo(
- 1,
- 1e-14,
- );
- expect(stateVariables["/k2"].stateValues.maxima[2][0]).closeTo(
- 1,
- 1e-14,
- );
- expect(stateVariables["/k2"].stateValues.maxima[2][1]).closeTo(
- 1,
- 1e-14,
- );
-
- expect(stateVariables["/k"].stateValues.globalMinimum).eqls([2, 0]);
- expect(stateVariables["/k"].stateValues.globalInfimum).eqls([2, 0]);
- expect(stateVariables["/k"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/k"].stateValues.globalSupremum).eqls([
- 201,
- 199 ** 2,
- ]);
- expect(stateVariables["/k2"].stateValues.globalMinimum).eqls([
- 2, 0,
- ]);
- expect(stateVariables["/k2"].stateValues.globalInfimum).eqls([
- 2, 0,
- ]);
- expect(stateVariables["/k2"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/k2"].stateValues.globalSupremum).eqls([
- 201,
- 199 ** 2,
- ]);
- });
- });
-
- it("extrema 2, overlap in domains", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- x^2
- (x-1)^2+1
- (x+1)^2+1
-
-
- x^2
- (x-1)^2+1
- (x+1)^2+1
-
-
- f(x)=$f
- f_2(x)=$f2
- Minima of f: $f.minima
- Maxima of f: $f.maxima
- Minima of f_2: $f2.minima
- Maxima of f_2: $f2.maxima
-
-
-
- x^2
- (x-2)^2+1
- (x+2)^2+1
-
-
- x^2
- (x-2)^2+1
- (x+2)^2+1
-
-
- g(x)=$g
- g_2(x)=$g2
- Minima of g: $g.minima
- Maxima of g: $g.maxima
- Minima of g_2: $g2.minima
- Maxima of g_2: $g2.maxima
-
-
-
-
-
- x^2
- x^4/4-2x^2
- abs(x)
-
-
- x^2
- x^4/4-2x^2
- abs(x)
-
-
- h(x)=$h
- h_2(x)=$h2
- Minima of h: $h.minima
- Maxima of h: $h.maxima
- Minima of h_2: $h2.minima
- Maxima of h_2: $h2.maxima
-
-
-
- x^2
- x^4/4-2x^2+4
- abs(x)
-
-
- x^2
- x^4/4-2x^2+4
- abs(x)
-
-
- k(x)=$k
- k_2(x)=$k2
- Minima of k: $k.minima
- Maxima of k: $k.maxima
- Minima of k_2: $k2.minima
- Maxima of k_2: $k2.maxima
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/pfmin") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/pfmin") + " .mjx-mrow")
- .eq(2)
- .should("not.exist");
- cy.get(cesc("#\\/pfmax") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/pf2min") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/pf2min") + " .mjx-mrow")
- .eq(2)
- .should("not.exist");
- cy.get(cesc("#\\/pf2max") + " .mjx-mrow").should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/f"].stateValues.minima).eqls([[0, 0]]);
- expect(stateVariables["/f"].stateValues.maxima).eqls([]);
- expect(stateVariables["/f2"].stateValues.minima).eqls([[0, 0]]);
- expect(stateVariables["/f2"].stateValues.maxima).eqls([]);
-
- expect(stateVariables["/f"].stateValues.globalMinimum).eqls([0, 0]);
- expect(stateVariables["/f"].stateValues.globalInfimum).eqls([0, 0]);
- expect(stateVariables["/f"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/f"].stateValues.globalSupremum).eqls([
- 201,
- 200 ** 2 + 1,
- ]);
- expect(stateVariables["/f2"].stateValues.globalMinimum).eqls([
- 0, 0,
- ]);
- expect(stateVariables["/f2"].stateValues.globalInfimum).eqls([
- 0, 0,
- ]);
- expect(stateVariables["/f2"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/f2"].stateValues.globalSupremum).eqls([
- 201,
- 200 ** 2 + 1,
- ]);
- });
-
- cy.get(cesc("#\\/pgmin") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,1)");
- cy.get(cesc("#\\/pgmin") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/pgmin") + " .mjx-mrow")
- .eq(4)
- .should("have.text", "(2,1)");
- cy.get(cesc("#\\/pgmin") + " .mjx-mrow")
- .eq(6)
- .should("not.exist");
- cy.get(cesc("#\\/pgmax") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−1,2)");
- cy.get(cesc("#\\/pgmax") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(1,2)");
- cy.get(cesc("#\\/pgmax") + " .mjx-mrow")
- .eq(4)
- .should("not.exist");
- cy.get(cesc("#\\/pg2min") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,1)");
- cy.get(cesc("#\\/pg2min") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/pg2min") + " .mjx-mrow")
- .eq(4)
- .should("have.text", "(2,1)");
- cy.get(cesc("#\\/pg2min") + " .mjx-mrow")
- .eq(6)
- .should("not.exist");
- cy.get(cesc("#\\/pg2max") + " .mjx-mrow").should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/g"].stateValues.minima.length).eq(3);
- expect(stateVariables["/g"].stateValues.minima[0][0]).closeTo(
- -2,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.minima[0][1]).closeTo(
- 1,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.minima[1][0]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.minima[1][1]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.minima[2][0]).closeTo(
- 2,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.minima[2][1]).closeTo(
- 1,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.maxima.length).eq(2);
- expect(stateVariables["/g"].stateValues.maxima[0][0]).closeTo(
- -1,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.maxima[0][1]).closeTo(
- 2,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.maxima[1][0]).closeTo(
- 1,
- 1e-14,
- );
- expect(stateVariables["/g"].stateValues.maxima[1][1]).closeTo(
- 2,
- 1e-14,
- );
- expect(stateVariables["/g2"].stateValues.minima.length).eq(3);
- expect(stateVariables["/g2"].stateValues.minima[0][0]).closeTo(
- -2,
- 1e-14,
- );
- expect(stateVariables["/g2"].stateValues.minima[0][1]).closeTo(
- 1,
- 1e-14,
- );
- expect(stateVariables["/g2"].stateValues.minima[1][0]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/g2"].stateValues.minima[1][1]).closeTo(
- 0,
- 1e-14,
- );
- expect(stateVariables["/g2"].stateValues.minima[2][0]).closeTo(
- 2,
- 1e-14,
- );
- expect(stateVariables["/g2"].stateValues.minima[2][1]).closeTo(
- 1,
- 1e-14,
- );
- expect(stateVariables["/g2"].stateValues.maxima).eqls([]);
-
- expect(stateVariables["/g"].stateValues.globalMinimum).eqls([0, 0]);
- expect(stateVariables["/g"].stateValues.globalInfimum).eqls([0, 0]);
- expect(stateVariables["/g"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/g"].stateValues.globalSupremum).eqls([
- 201,
- 199 ** 2 + 1,
- ]);
- expect(stateVariables["/g2"].stateValues.globalMinimum).eqls([
- 0, 0,
- ]);
- expect(stateVariables["/g2"].stateValues.globalInfimum).eqls([
- 0, 0,
- ]);
- expect(stateVariables["/g2"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/g2"].stateValues.globalSupremum).eqls([
- 201,
- 199 ** 2 + 1,
- ]);
- });
-
- cy.get(cesc("#\\/phmin") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,−4)");
- cy.get(cesc("#\\/phmin") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/phmin") + " .mjx-mrow")
- .eq(4)
- .should("have.text", "(2,−4)");
- cy.get(cesc("#\\/phmin") + " .mjx-mrow")
- .eq(6)
- .should("not.exist");
- cy.get(cesc("#\\/phmax") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/ph2min") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,−4)");
- cy.get(cesc("#\\/ph2min") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/ph2min") + " .mjx-mrow")
- .eq(4)
- .should("have.text", "(2,−4)");
- cy.get(cesc("#\\/ph2min") + " .mjx-mrow")
- .eq(6)
- .should("not.exist");
- cy.get(cesc("#\\/ph2max") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−1,1)");
- cy.get(cesc("#\\/ph2max") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(1,1)");
- cy.get(cesc("#\\/ph2max") + " .mjx-mrow")
- .eq(4)
- .should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/h"].stateValues.minima.length).eq(3);
- expect(stateVariables["/h"].stateValues.minima[0][0]).closeTo(
- -2,
- 1e-8,
- );
- expect(stateVariables["/h"].stateValues.minima[0][1]).closeTo(
- -4,
- 1e-8,
- );
- expect(stateVariables["/h"].stateValues.minima[1][0]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/h"].stateValues.minima[1][1]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/h"].stateValues.minima[2][0]).closeTo(
- 2,
- 1e-8,
- );
- expect(stateVariables["/h"].stateValues.minima[2][1]).closeTo(
- -4,
- 1e-8,
- );
- expect(stateVariables["/h"].stateValues.maxima).eqls([]);
- expect(stateVariables["/h2"].stateValues.minima.length).eq(3);
- expect(stateVariables["/h2"].stateValues.minima[0][0]).closeTo(
- -2,
- 1e-8,
- );
- expect(stateVariables["/h2"].stateValues.minima[0][1]).closeTo(
- -4,
- 1e-8,
- );
- expect(stateVariables["/h2"].stateValues.minima[1][0]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/h2"].stateValues.minima[1][1]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/h2"].stateValues.minima[2][0]).closeTo(
- 2,
- 1e-8,
- );
- expect(stateVariables["/h2"].stateValues.minima[2][1]).closeTo(
- -4,
- 1e-8,
- );
- expect(stateVariables["/h2"].stateValues.maxima.length).eq(2);
- expect(stateVariables["/h2"].stateValues.maxima[0][0]).closeTo(
- -1,
- 1e-8,
- );
- expect(stateVariables["/h2"].stateValues.maxima[0][1]).closeTo(
- 1,
- 1e-8,
- );
- expect(stateVariables["/h2"].stateValues.maxima[1][0]).closeTo(
- 1,
- 1e-8,
- );
- expect(stateVariables["/h2"].stateValues.maxima[1][1]).closeTo(
- 1,
- 1e-8,
- );
-
- expect(stateVariables["/h"].stateValues.globalMinimum).eqls([
- -2, -4,
- ]);
- expect(stateVariables["/h"].stateValues.globalInfimum).eqls([
- -2, -4,
- ]);
- expect(stateVariables["/h"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/h"].stateValues.globalSupremum).eqls([
- -203, 203,
- ]);
- expect(stateVariables["/h2"].stateValues.globalMinimum).eqls([
- -2, -4,
- ]);
- expect(stateVariables["/h2"].stateValues.globalInfimum).eqls([
- -2, -4,
- ]);
- expect(stateVariables["/h2"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/h2"].stateValues.globalSupremum).eqls([
- -203, 203,
- ]);
- });
-
- cy.get(cesc("#\\/pkmin") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−3,3)");
- cy.get(cesc("#\\/pkmin") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(−2,0)");
- cy.get(cesc("#\\/pkmin") + " .mjx-mrow")
- .eq(4)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/pkmin") + " .mjx-mrow")
- .eq(6)
- .should("have.text", "(2,0)");
- cy.get(cesc("#\\/pkmin") + " .mjx-mrow")
- .eq(8)
- .should("have.text", "(3,3)");
- cy.get(cesc("#\\/pkmin") + " .mjx-mrow")
- .eq(10)
- .should("not.exist");
- cy.get(cesc("#\\/pkmax") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−1,2.25)");
- cy.get(cesc("#\\/pkmax") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(1,2.25)");
- cy.get(cesc("#\\/pkmax") + " .mjx-mrow")
- .eq(4)
- .should("not.exist");
- cy.get(cesc("#\\/pk2min") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−2,0)");
- cy.get(cesc("#\\/pk2min") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(0,0)");
- cy.get(cesc("#\\/pk2min") + " .mjx-mrow")
- .eq(4)
- .should("have.text", "(2,0)");
- cy.get(cesc("#\\/pk2min") + " .mjx-mrow")
- .eq(6)
- .should("not.exist");
- cy.get(cesc("#\\/pk2max") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−3,6.25)");
- cy.get(cesc("#\\/pk2max") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(3,6.25)");
- cy.get(cesc("#\\/pk2max") + " .mjx-mrow")
- .eq(4)
- .should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/k"].stateValues.minima.length).eq(5);
- expect(stateVariables["/k"].stateValues.minima[0][0]).closeTo(
- -3,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.minima[0][1]).closeTo(
- 3,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.minima[1][0]).closeTo(
- -2,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.minima[1][1]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.minima[2][0]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.minima[2][1]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.minima[3][0]).closeTo(
- 2,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.minima[3][1]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.minima[4][0]).closeTo(
- 3,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.minima[4][1]).closeTo(
- 3,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.maxima.length).eq(2);
- expect(stateVariables["/k"].stateValues.maxima[0][0]).closeTo(
- -1,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.maxima[0][1]).closeTo(
- 2.25,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.maxima[1][0]).closeTo(
- 1,
- 1e-8,
- );
- expect(stateVariables["/k"].stateValues.maxima[1][1]).closeTo(
- 2.25,
- 1e-8,
- );
- expect(stateVariables["/k2"].stateValues.minima.length).eq(3);
- expect(stateVariables["/k2"].stateValues.minima[0][0]).closeTo(
- -2,
- 1e-8,
- );
- expect(stateVariables["/k2"].stateValues.minima[0][1]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/k2"].stateValues.minima[1][0]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/k2"].stateValues.minima[1][1]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/k2"].stateValues.minima[2][0]).closeTo(
- 2,
- 1e-8,
- );
- expect(stateVariables["/k2"].stateValues.minima[2][1]).closeTo(
- 0,
- 1e-8,
- );
- expect(stateVariables["/k2"].stateValues.maxima.length).eq(2);
- expect(stateVariables["/k2"].stateValues.maxima[0][0]).closeTo(
- -3,
- 1e-8,
- );
- expect(stateVariables["/k2"].stateValues.maxima[0][1]).closeTo(
- 6.25,
- 1e-8,
- );
- expect(stateVariables["/k2"].stateValues.maxima[1][0]).closeTo(
- 3,
- 1e-8,
- );
- expect(stateVariables["/k2"].stateValues.maxima[1][1]).closeTo(
- 6.25,
- 1e-8,
- );
-
- expect(stateVariables["/k"].stateValues.globalMinimum).eqls([0, 0]);
- expect(stateVariables["/k"].stateValues.globalInfimum).eqls([0, 0]);
- expect(stateVariables["/k"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/k"].stateValues.globalSupremum).eqls([
- -203, 203,
- ]);
- expect(stateVariables["/k2"].stateValues.globalMinimum).eqls([
- 0, 0,
- ]);
- expect(stateVariables["/k2"].stateValues.globalInfimum).eqls([
- 0, 0,
- ]);
- expect(stateVariables["/k2"].stateValues.globalMaximum).eqls([]);
- expect(stateVariables["/k2"].stateValues.globalSupremum).eqls([
- -203, 203,
- ]);
- });
- });
-
- it("ignore function pieces with non-numerical domain when evaluating numerically", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- 1
- x
- x^2/10
- x^3/100
- x^4/1000
- x^5/10000
-
-
- f(x)=$f
- $$f(7)
- $$f(8)
- $$f(9)
- $$f(10)
- $$f(11)
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/mef") + " .mjx-mrow")
- .eq(0)
- .should(
- "have.text",
- "f(x)=⎧⎪\n⎪\n⎪\n⎪\n⎪\n⎪\n⎪⎨⎪\n⎪\n⎪\n⎪\n⎪\n⎪\n⎪⎩1if\u00a0x=axif\u00a0s {
- let stateVariables = await win.returnAllStateVariables1();
-
- let f = createFunctionFromDefinition(
- stateVariables["/f"].stateValues.fDefinitions[0],
- );
- for (let i = -10; i <= 15; i++) {
- if (i >= 8 && i <= 10) {
- expect(f(i)).closeTo(i ** 4 / 1000, 1e-14);
- } else {
- expect(f(i)).eqls(NaN);
- }
- }
-
- expect(stateVariables["/f"].stateValues.globalMinimum).eqls([
- 8,
- f(8),
- ]);
- expect(stateVariables["/f"].stateValues.globalInfimum).eqls([
- 8,
- f(8),
- ]);
- expect(stateVariables["/f"].stateValues.globalMaximum).eqls([
- 10,
- f(10),
- ]);
- expect(stateVariables["/f"].stateValues.globalSupremum).eqls([
- 10,
- f(10),
- ]);
- });
- });
-
- it("use single point notation", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- x
- x^2/10
- x^3/100
-
- $f.extrema
- $f.globalMaximum{styleNumber="2"}
- $f.globalInfimum{styleNumber="3"}
-
- f(x)=$f
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/mef") + " .mjx-mrow")
- .eq(0)
- .should(
- "have.text",
- "f(x)=⎧⎪\n⎪⎨⎪\n⎪⎩xif\u00a0x=1x210if\u00a0x=2x3100if\u00a01 {
- let stateVariables = await win.returnAllStateVariables1();
-
- let f = createFunctionFromDefinition(
- stateVariables["/f"].stateValues.fDefinitions[0],
- );
- expect(f(0)).eqls(NaN);
- expect(f(0.999)).eqls(NaN);
- expect(f(1)).eq(1);
- expect(f(1.0001)).closeTo(1.0001 ** 3 / 100, 1e-14);
- expect(f(1.9999)).closeTo(1.9999 ** 3 / 100, 1e-14);
- expect(f(2)).eq(4 / 10);
- expect(f(2.0001)).closeTo(2.0001 ** 3 / 100, 1e-14);
- expect(f(2.9999)).closeTo(2.9999 ** 3 / 100, 1e-14);
- expect(f(3)).eqls(NaN);
- expect(f(4)).eqls(NaN);
-
- expect(stateVariables["/f"].stateValues.maxima).eqls([[2, 4 / 10]]);
- expect(stateVariables["/f"].stateValues.minima).eqls([]);
- expect(stateVariables["/f"].stateValues.globalMaximum).eqls([1, 1]);
- expect(stateVariables["/f"].stateValues.globalSupremum).eqls([
- 1, 1,
- ]);
- expect(stateVariables["/f"].stateValues.globalMinimum).eqls([]);
- expect(stateVariables["/f"].stateValues.globalInfimum).eqls([
- 1,
- 1 / 100,
- ]);
- });
- });
-
- it("global extrema, find single points from gaps", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- 3
- 1/x-1
- 1/x-1
- -2-(x+4)^2
-
- $f.extrema
- $f.globalMaximum{styleNumber="2"}
- $f.globalInfimum{styleNumber="3"}
-
- f(x)=$f
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/mef") + " .mjx-mrow")
- .eq(0)
- .should(
- "have.text",
- "f(x)=⎧⎪⎨⎪⎩3if\u00a0−1 {
- let stateVariables = await win.returnAllStateVariables1();
-
- let f = createFunctionFromDefinition(
- stateVariables["/f"].stateValues.fDefinitions[0],
- );
- expect(f(-5)).eqls(NaN);
- expect(f(-4.999)).closeTo(-2 - 0.999 ** 2, 1e-14);
- expect(f(-1)).eq(-2 - 3 ** 2);
- expect(f(-0.999)).eq(3);
- expect(f(0.0999)).eq(3);
- expect(f(0.1)).eq(-2 - 4.1 ** 2);
- expect(f(3)).eq(-2 - 7 ** 2);
- expect(f(3.001)).eq(1 / 3.001 - 1);
- expect(f(3.999)).eq(1 / 3.999 - 1);
- expect(f(4)).eq(-2 - 8 ** 2);
- expect(f(4.001)).eq(1 / 4.001 - 1);
- expect(f(4.999)).eq(1 / 4.999 - 1);
- expect(f(5)).eqls(NaN);
-
- expect(stateVariables["/f"].stateValues.maxima).eqls([[-4, -2]]);
- expect(stateVariables["/f"].stateValues.minima).eqls([
- [-1, -2 - 3 ** 2],
- [3, -2 - 7 ** 2],
- [4, -2 - 8 ** 2],
- ]);
- expect(stateVariables["/f"].stateValues.globalMaximum[0]).within(
- -1,
- -0.9,
- );
- expect(stateVariables["/f"].stateValues.globalMaximum[1]).eq(3);
- expect(stateVariables["/f"].stateValues.globalSupremum).eqls([
- -1, 3,
- ]);
- expect(stateVariables["/f"].stateValues.globalMinimum).eqls([
- 4,
- -2 - 8 ** 2,
- ]);
- expect(stateVariables["/f"].stateValues.globalInfimum).eqls([
- 4,
- -2 - 8 ** 2,
- ]);
- });
- });
-
- it("latex combines pieces", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- x
- x
- x
- x^2
- x^2
- x^2
- x^2
- x
-
-
- f(x)=$f
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/mef") + " .mjx-mrow")
- .eq(0)
- .should(
- "have.text",
- "f(x)=⎧⎨⎩xif\u00a0s {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
- x^2
- 1-x^2/4
- cos(pi x)
-
-
- $f.extrema
- $f.globalSupremum{styleNumber="2"}
- $f.globalMaximum{styleNumber="3"}
- $f.globalInfimum{styleNumber="4"}
- $f.globalMinimum{styleNumber="5"}
-
- f(x)=$f
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/mef") + " .mjx-mrow")
- .eq(0)
- .should(
- "have.text",
- "f(x)=⎧⎪⎨⎪⎩x2if\u00a0−1 {
- let stateVariables = await win.returnAllStateVariables1();
-
- expect(stateVariables["/f"].stateValues.maxima).eqls([
- [-4, 1],
- [1, 1],
- [6, 1],
- [8, 1],
- ]);
- expect(stateVariables["/f"].stateValues.minima).eqls([
- [0, 0],
- [4, -3],
- [5, -1],
- [7, -1],
- ]);
- expect(stateVariables["/f"].stateValues.globalMaximum).eqls([1, 1]);
- expect(stateVariables["/f"].stateValues.globalSupremum).eqls([
- -1, 1,
- ]);
- expect(stateVariables["/f"].stateValues.globalMinimum).eqls([
- 4, -3,
- ]);
- expect(stateVariables["/f"].stateValues.globalInfimum).eqls([
- -4, -3,
- ]);
- });
- });
-
- it("extrema of piecewise functions with piecewise function children", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- 0
- x^2
-
- $f1.extrema
-
-
-
-
-
- 1/x
-
- $f2.extrema
-
-
-
-
- 9*e^(-(x-3))
- 8-x
- $f1
-
- $f3.extrema
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let f2 = createFunctionFromDefinition(
- stateVariables["/f2"].stateValues.fDefinitions[0],
- );
-
- expect(f2(-4)).eq(-1 / 4);
- expect(f2(-3)).eq(-1 / 3);
- expect(f2(-2)).eq(0);
- expect(f2(-1)).eq(0);
- expect(f2(0)).eq(0);
- expect(f2(1)).eq(1);
- expect(f2(2)).eq(4);
- expect(f2(3)).eq(1 / 3);
- expect(f2(4)).eq(1 / 4);
-
- expect(stateVariables["/f2"].stateValues.maxima).eqls([[2, 4]]);
- expect(stateVariables["/f2"].stateValues.minima).eqls([
- [-3, -1 / 3],
- ]);
- expect(stateVariables["/f2"].stateValues.globalMaximum).eqls([
- 2, 4,
- ]);
- expect(stateVariables["/f2"].stateValues.globalSupremum).eqls([
- 2, 4,
- ]);
- expect(stateVariables["/f2"].stateValues.globalMinimum).eqls([
- -3,
- -1 / 3,
- ]);
- expect(stateVariables["/f2"].stateValues.globalInfimum).eqls([
- -3,
- -1 / 3,
- ]);
-
- let f3 = createFunctionFromDefinition(
- stateVariables["/f3"].stateValues.fDefinitions[0],
- );
-
- expect(f3(-4)).eq(0);
- expect(f3(0)).eq(0);
- expect(f3(0.5)).eq(0.25);
- expect(f3(1)).eq(7);
- expect(f3(1.5)).eq(6.5);
- expect(f3(2)).eq(4);
- expect(f3(3)).eq(9);
- expect(f3(4)).eq(9 * Math.exp(-1));
-
- expect(stateVariables["/f3"].stateValues.maxima).eqls([
- [1, 7],
- [3, 9],
- ]);
- expect(stateVariables["/f3"].stateValues.minima).eqls([[2, 4]]);
- expect(stateVariables["/f3"].stateValues.globalMaximum).eqls([
- 3, 9,
- ]);
- expect(stateVariables["/f3"].stateValues.globalSupremum).eqls([
- 3, 9,
- ]);
- expect(stateVariables["/f3"].stateValues.globalMinimum[1]).eq(0);
- expect(stateVariables["/f3"].stateValues.globalInfimum[1]).eq(0);
- });
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/pluralize.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/pluralize.cy.js
deleted file mode 100644
index 63747505b..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/pluralize.cy.js
+++ /dev/null
@@ -1,274 +0,0 @@
-import { cesc } from "@doenet/utils";
-
-describe("Pluralize Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("number followed by noun", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- one dog
- two dog
- zero dog
- 1 mouse
- 2 mouse
- 0 mouse
- one thousand bus
- 0.5 bus
- 1 bus
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_p1")).should("have.text", "one dog");
- cy.get(cesc("#\\/_p2")).should("have.text", "two dogs");
- cy.get(cesc("#\\/_p3")).should("have.text", "zero dogs");
- cy.get(cesc("#\\/_p4")).should("have.text", "1 mouse");
- cy.get(cesc("#\\/_p5")).should("have.text", "2 mice");
- cy.get(cesc("#\\/_p6")).should("have.text", "0 mice");
- cy.get(cesc("#\\/_p7")).should("have.text", "one thousand buses");
- cy.get(cesc("#\\/_p8")).should("have.text", "0.5 buses");
- cy.get(cesc("#\\/_p9")).should("have.text", "1 bus");
- });
-
- it("single word", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- dog
- mouse
- bus
- goose
- pony
- only
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_p1")).should("have.text", "dogs");
- cy.get(cesc("#\\/_p2")).should("have.text", "mice");
- cy.get(cesc("#\\/_p3")).should("have.text", "buses");
- cy.get(cesc("#\\/_p4")).should("have.text", "geese");
- cy.get(cesc("#\\/_p5")).should("have.text", "ponies");
- cy.get(cesc("#\\/_p6")).should("have.text", "only");
- });
-
- it("number followed by noun with plural form", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- one dog
- two dog
- zero dog
- 1 mouse
- 2 mouse
- 0 mouse
- one thousand bus
- 0.5 bus
- 1 bus
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_p1")).should("have.text", "one dog");
- cy.get(cesc("#\\/_p2")).should("have.text", "two cheetahs");
- cy.get(cesc("#\\/_p3")).should("have.text", "zero cheetahs");
- cy.get(cesc("#\\/_p4")).should("have.text", "1 mouse");
- cy.get(cesc("#\\/_p5")).should("have.text", "2 cheetahs");
- cy.get(cesc("#\\/_p6")).should("have.text", "0 cheetahs");
- cy.get(cesc("#\\/_p7")).should("have.text", "one thousand cheetahs");
- cy.get(cesc("#\\/_p8")).should("have.text", "0.5 cheetahs");
- cy.get(cesc("#\\/_p9")).should("have.text", "1 bus");
- });
-
- it("single word, with plural form", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- dog
- mouse
- bus
- goose
- pony
- only
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_p1")).should("have.text", "cheetahs");
- cy.get(cesc("#\\/_p2")).should("have.text", "cheetahs");
- cy.get(cesc("#\\/_p3")).should("have.text", "cheetahs");
- cy.get(cesc("#\\/_p4")).should("have.text", "cheetahs");
- cy.get(cesc("#\\/_p5")).should("have.text", "cheetahs");
- cy.get(cesc("#\\/_p6")).should("have.text", "cheetahs");
- });
-
- it("number followed by noun, based on number", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- one dog
- two dog
- zero dog
- 1 mouse
- 2 mouse
- 0 mouse
- one thousand bus
- 0.5 bus
- 1 bus
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_p1")).should("have.text", "one dogs");
- cy.get(cesc("#\\/_p2")).should("have.text", "two dog");
- cy.get(cesc("#\\/_p3")).should("have.text", "zero dogs");
- cy.get(cesc("#\\/_p4")).should("have.text", "1 mice");
- cy.get(cesc("#\\/_p5")).should("have.text", "2 mice");
- cy.get(cesc("#\\/_p6")).should("have.text", "0 mouse");
- cy.get(cesc("#\\/_p7")).should("have.text", "one thousand bus");
- cy.get(cesc("#\\/_p8")).should("have.text", "0.5 buses");
- cy.get(cesc("#\\/_p9")).should("have.text", "1 buses");
- });
-
- it("single word, based on number", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- dog
- dog
- mouse
- mouse
- bus
- bus
- goose
- goose
- pony
- pony
- only
- only
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_p1")).should("have.text", "dogs");
- cy.get(cesc("#\\/_p2")).should("have.text", "dog");
- cy.get(cesc("#\\/_p3")).should("have.text", "mice");
- cy.get(cesc("#\\/_p4")).should("have.text", "mouse");
- cy.get(cesc("#\\/_p5")).should("have.text", "buses");
- cy.get(cesc("#\\/_p6")).should("have.text", "bus");
- cy.get(cesc("#\\/_p7")).should("have.text", "geese");
- cy.get(cesc("#\\/_p8")).should("have.text", "goose");
- cy.get(cesc("#\\/_p9")).should("have.text", "ponies");
- cy.get(cesc("#\\/_p10")).should("have.text", "pony");
- cy.get(cesc("#\\/_p11")).should("have.text", "only");
- cy.get(cesc("#\\/_p12")).should("have.text", "only");
- });
-
- it("phrases", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- one dog three cat two squirrel or 1 cat plus 7 goose
- one hundred green plane flew through one big sky, rather than six shiny sky
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_p1")).should(
- "have.text",
- "one dog three cats two squirrels or 1 cat plus 7 geese",
- );
- cy.get(cesc("#\\/_p2")).should(
- "have.text",
- "one hundred green planes flew through one big sky, rather than six shiny skies",
- );
- });
-
- it("dynamic", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- How many geese?
- How many teeth?
-
- I have $ngeese.value goose even if one doesn't have $nteeth.value tooth
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_p3")).should(
- "have.text",
- `I have 1 goose even if one doesn't have 1 tooth`,
- );
-
- cy.get(cesc("#\\/ngeese_input")).clear().type("three{enter}");
- cy.get(cesc("#\\/_p3")).should(
- "have.text",
- `I have three geese even if one doesn't have 1 tooth`,
- );
-
- cy.get(cesc("#\\/nteeth_input")).clear().type("0{enter}");
- cy.get(cesc("#\\/_p3")).should(
- "have.text",
- `I have three geese even if one doesn't have 0 teeth`,
- );
-
- cy.get(cesc("#\\/nteeth_input")).clear().type("one{enter}");
- cy.get(cesc("#\\/_p3")).should(
- "have.text",
- `I have three geese even if one doesn't have one tooth`,
- );
-
- cy.get(cesc("#\\/nteeth_input")).clear().type("one thousand{enter}");
- cy.get(cesc("#\\/_p3")).should(
- "have.text",
- `I have three geese even if one doesn't have one thousand teeth`,
- );
-
- cy.get(cesc("#\\/ngeese_input")).clear().type("-1{enter}");
- cy.get(cesc("#\\/_p3")).should(
- "have.text",
- `I have -1 geese even if one doesn't have one thousand teeth`,
- );
-
- cy.get(cesc("#\\/ngeese_input")).clear().type("-2{enter}");
- cy.get(cesc("#\\/_p3")).should(
- "have.text",
- `I have -2 geese even if one doesn't have one thousand teeth`,
- );
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/regionBetweenCurves.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/regionBetweenCurves.cy.js
deleted file mode 100644
index a0e808308..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/regionBetweenCurves.cy.js
+++ /dev/null
@@ -1,353 +0,0 @@
-import { cesc2 } from "@doenet/utils";
-
-describe("RegionBetweenCurves Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("region between two curves", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- sin(x)
- cos(x)
- $f1 $f2
-
-
-
- $(../g1/r{name="r"})
-
-
- $g2{name="g3"}
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait for page to load
-
- // Not sure what to test until can test jsxgraph output
- });
-
- it("region between two curves, flipped", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- sin(x)
- cos(x)
- $f1 $f2
-
-
-
- $(../g1/r{name="r"})
-
-
- $g2{name="g3"}
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait for page to load
-
- // Not sure what to test until can test jsxgraph output
- });
-
- it("constrain point to region between two curves", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
- sin(pi x/4)
- cos(pi x/4)
- $f1 $f2
-
- (0,5)
-
- $r
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should("contain.text", "(0,1)");
-
- cy.log("move point below");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: `/P`,
- args: { x: -2, y: -6 },
- });
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should(
- "contain.text",
- `(−2,−1)`,
- );
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(-2, 1e-12);
- expect(py).closeTo(-1, 1e-12);
- });
-
- cy.log("move point to upper left");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: `/P`,
- args: { x: -9, y: 3 },
- });
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should(
- "contain.text",
- `(−6,1)`,
- );
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(-6, 1e-12);
- expect(py).closeTo(1, 1e-12);
- });
-
- cy.log("move point to lower left");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: `/P`,
- args: { x: -8, y: -6 },
- });
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should(
- "contain.text",
- `(−6,0)`,
- );
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(-6, 1e-12);
- expect(py).closeTo(0, 1e-12);
- });
-
- cy.log("move point to left");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: `/P`,
- args: { x: -10, y: 0.4 },
- });
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should(
- "contain.text",
- `(−6,0.4)`,
- );
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(-6, 1e-12);
- expect(py).closeTo(0.4, 1e-12);
- });
-
- cy.log("move point to right");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: `/P`,
- args: { x: 10, y: -0.2 },
- });
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should(
- "contain.text",
- `(4,−0.2)`,
- );
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(4, 1e-12);
- expect(py).closeTo(-0.2, 1e-12);
- });
-
- cy.log("move point to upper right");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: `/P`,
- args: { x: 5, y: 4 },
- });
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should(
- "contain.text",
- `(4,0)`,
- );
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(4, 1e-12);
- expect(py).closeTo(0, 1e-12);
- });
-
- cy.log("move point to lower right");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: `/P`,
- args: { x: 6, y: -9 },
- });
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should(
- "contain.text",
- `(4,−1)`,
- );
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(4, 1e-12);
- expect(py).closeTo(-1, 1e-12);
- });
-
- cy.log("change boundaries");
- cy.get(cesc2("#/a") + " textarea").type(`{end}{backspace}8{enter}`, {
- force: true,
- });
- cy.get(cesc2("#/b") + " textarea").type(`{end}{backspace}-2{enter}`, {
- force: true,
- });
-
- cy.get(cesc2("#/b2")).should("have.text", "-2");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(-2, 1e-12);
- expect(py).closeTo(-1, 1e-12);
- });
-
- cy.log("move point to upper right");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: `/P`,
- args: { x: 5, y: 4 },
- });
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should(
- "contain.text",
- `(−2,0)`,
- );
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(-2, 1e-12);
- expect(py).closeTo(0, 1e-12);
- });
-
- cy.log("move point to middle");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: `/P`,
- args: { x: -5.2, y: 0.1 },
- });
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should(
- "contain.text",
- `(−5.2,0.1)`,
- );
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(-5.2, 1e-12);
- expect(py).closeTo(0.1, 1e-12);
- });
-
- cy.log("move point to top");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: `/P`,
- args: { x: -6, y: 3 },
- });
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should(
- "contain.text",
- `(−6,1)`,
- );
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(-6, 1e-12);
- expect(py).closeTo(1, 1e-12);
- });
-
- cy.log("move point to left");
- cy.window().then(async (win) => {
- win.callAction1({
- actionName: "movePoint",
- componentName: `/P`,
- args: { x: -9.2, y: 0.6 },
- });
-
- cy.get(cesc2("#/P2") + " .mjx-mrow").should(
- "contain.text",
- `(−8,0.6)`,
- );
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let px = stateVariables["/P"].stateValues.xs[0];
- let py = stateVariables["/P"].stateValues.xs[1];
- expect(px).closeTo(-8, 1e-12);
- expect(py).closeTo(0.6, 1e-12);
- });
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/sidebyside.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/sidebyside.cy.js
deleted file mode 100644
index 7a4a9cd84..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/sidebyside.cy.js
+++ /dev/null
@@ -1,8075 +0,0 @@
-import { cesc, cesc2 } from "@doenet/utils";
-
-describe("SideBySide Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- let checkSingleColumnSbs = async function ({
- specifiedWidth = null,
- specifiedMargins = [null, null],
- specifiedValign = null,
- sbsWidth,
- sbsName = "/sbs",
- isSbsGroup = false,
- widthValueName = "/w1a",
- leftMarginValueName = "/m1a",
- rightMarginValueName = "/m2a",
- valignValueName = "/v1a",
- ignoreInitialDOMChecks = false,
- }) {
- let actualWidth = specifiedWidth;
- let actualLeftMargin = specifiedMargins[0];
- let actualRightMargin = specifiedMargins[1];
-
- if (actualWidth === null) {
- if (actualLeftMargin === null) {
- if (actualRightMargin === null) {
- actualWidth = 100;
- actualLeftMargin = actualRightMargin = 0;
- } else {
- actualLeftMargin = 0;
- actualWidth = Math.max(0, 100 - actualRightMargin);
- }
- } else {
- if (actualRightMargin === null) {
- actualRightMargin = 0;
- actualWidth = Math.max(0, 100 - actualLeftMargin);
- } else {
- actualWidth = Math.max(
- 0,
- 100 - actualLeftMargin - actualRightMargin,
- );
- }
- }
- } else {
- if (actualLeftMargin === null) {
- if (actualRightMargin === null) {
- actualLeftMargin = actualRightMargin = Math.max(
- 0,
- (100 - actualWidth) / 2,
- );
- } else {
- actualLeftMargin = Math.max(
- 0,
- 100 - actualWidth - actualRightMargin,
- );
- }
- } else {
- if (actualRightMargin === null) {
- actualRightMargin = Math.max(
- 0,
- 100 - actualWidth - actualLeftMargin,
- );
- }
- }
- }
-
- let originalTotal = actualWidth + actualLeftMargin + actualRightMargin;
-
- if (originalTotal > 100) {
- // rescale to 100
- let rescale = 100 / originalTotal;
- actualWidth *= rescale;
- actualLeftMargin *= rescale;
- actualRightMargin *= rescale;
- } else if (originalTotal < 100) {
- // add to right margin
- actualRightMargin += 100 - originalTotal;
- }
-
- let valign = specifiedValign ? specifiedValign : "top";
-
- if (!ignoreInitialDOMChecks) {
- cy.get(cesc2("#" + widthValueName)).should(
- "contain.text",
- Math.trunc(actualWidth),
- );
- cy.get(cesc2("#" + leftMarginValueName)).should(
- "contain.text",
- Math.trunc(actualLeftMargin),
- );
- cy.get(cesc2("#" + rightMarginValueName)).should(
- "contain.text",
- Math.trunc(actualRightMargin),
- );
- cy.get(cesc2("#" + valignValueName)).should("have.text", valign);
- }
-
- if (!isSbsGroup) {
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(1)`)
- .invoke("width")
- .then((width) => {
- expect(Number(width)).closeTo(
- (sbsWidth * actualWidth) / 100,
- 0.1,
- );
- });
-
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(1)`)
- .invoke("css", "margin-left")
- .then((margin) => {
- expect(parseFloat(margin)).closeTo(
- (sbsWidth * actualLeftMargin) / 100,
- 0.1,
- );
- });
-
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(1)`)
- .invoke("css", "margin-right")
- .then((margin) => {
- expect(parseFloat(margin)).closeTo(
- (sbsWidth * actualRightMargin) / 100,
- 0.1,
- );
- });
- }
-
- let specifiedWidthName = isSbsGroup
- ? "specifiedWidths"
- : "allWidthsSpecified";
- let specifiedMarginName = isSbsGroup
- ? "specifiedMargins"
- : "allMarginsSpecified";
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables[sbsName].stateValues.widths.length).eq(1);
- expect(
- stateVariables[sbsName].stateValues[specifiedWidthName],
- ).eqls([specifiedWidth]);
- expect(stateVariables[sbsName].stateValues.widths[0]).closeTo(
- actualWidth,
- 1e-5,
- );
- expect(
- stateVariables[sbsName].stateValues[specifiedMarginName],
- ).eqls(specifiedMargins);
- expect(stateVariables[sbsName].stateValues.margins.length).eq(2);
- expect(stateVariables[sbsName].stateValues.margins[0]).closeTo(
- actualLeftMargin,
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.margins[1]).closeTo(
- actualRightMargin,
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.valigns).eqls([valign]);
- });
- };
-
- let checkTwoColumnSbs = function ({
- specifiedWidths = [null, null],
- specifiedMargins = [null, null],
- specifiedValigns = [null, null],
- sbsWidth,
- sbsName = "/sbs",
- isSbsGroup = false,
- leftWidthValueName = "/w1a",
- rightWidthValueName = "/w2a",
- leftMarginValueName = "/m1a",
- rightMarginValueName = "/m2a",
- leftValignValueName = "/v1a",
- rightValignValueName = "/v2a",
- ignoreInitialDOMChecks = false,
- }) {
- let actualWidth1 = specifiedWidths[0];
- let actualWidth2 = specifiedWidths[1];
- let actualLeftMargin = specifiedMargins[0];
- let actualRightMargin = specifiedMargins[1];
- let actualGap = 0;
-
- if (actualWidth1 === null) {
- if (actualWidth2 === null) {
- if (actualLeftMargin === null) {
- if (actualRightMargin === null) {
- actualWidth1 = actualWidth2 = 50;
- actualLeftMargin = actualRightMargin = 0;
- } else {
- actualWidth1 = actualWidth2 = Math.max(
- 0,
- (100 - 2 * actualRightMargin) / 2,
- );
- actualLeftMargin = 0;
- }
- } else {
- if (actualRightMargin === null) {
- actualWidth1 = actualWidth2 = Math.max(
- 0,
- (100 - 2 * actualLeftMargin) / 2,
- );
- actualRightMargin = 0;
- } else {
- actualWidth1 = actualWidth2 = Math.max(
- 0,
- (100 - 2 * (actualLeftMargin + actualRightMargin)) /
- 2,
- );
- }
- }
- } else {
- if (actualLeftMargin === null) {
- if (actualRightMargin === null) {
- actualWidth1 = Math.max(0, 100 - actualWidth2);
- actualLeftMargin = actualRightMargin = 0;
- } else {
- actualWidth1 = Math.max(
- 0,
- 100 - actualWidth2 - 2 * actualRightMargin,
- );
- actualLeftMargin = 0;
- }
- } else {
- if (actualRightMargin === null) {
- actualWidth1 = Math.max(
- 0,
- 100 - actualWidth2 - 2 * actualLeftMargin,
- );
- actualRightMargin = 0;
- } else {
- actualWidth1 = Math.max(
- 0,
- 100 -
- actualWidth2 -
- 2 * (actualLeftMargin + actualRightMargin),
- );
- }
- }
- }
- } else {
- if (actualWidth2 === null) {
- if (actualLeftMargin === null) {
- if (actualRightMargin === null) {
- actualWidth2 = Math.max(0, 100 - actualWidth1);
- actualLeftMargin = actualRightMargin = 0;
- } else {
- actualWidth2 = Math.max(
- 0,
- 100 - actualWidth1 - 2 * actualRightMargin,
- );
- actualLeftMargin = 0;
- }
- } else {
- if (actualRightMargin === null) {
- actualWidth2 = Math.max(
- 0,
- 100 - actualWidth1 - 2 * actualLeftMargin,
- );
- actualRightMargin = 0;
- } else {
- actualWidth2 = Math.max(
- 0,
- 100 -
- actualWidth1 -
- 2 * (actualLeftMargin + actualRightMargin),
- );
- }
- }
- } else {
- if (actualLeftMargin === null) {
- if (actualRightMargin === null) {
- actualLeftMargin = actualRightMargin = Math.max(
- 0,
- (100 - actualWidth1 - actualWidth2) / 4,
- );
- } else {
- actualLeftMargin = Math.max(
- 0,
- (100 -
- actualWidth1 -
- actualWidth2 -
- 2 * actualRightMargin) /
- 2,
- );
- }
- } else {
- if (actualRightMargin === null) {
- actualRightMargin = Math.max(
- 0,
- (100 -
- actualWidth1 -
- actualWidth2 -
- 2 * actualLeftMargin) /
- 2,
- );
- }
- }
- }
- }
-
- let originalTotal =
- actualWidth1 +
- actualWidth2 +
- 2 * (actualLeftMargin + actualRightMargin);
-
- if (originalTotal > 100) {
- // rescale to 100
- let rescale = 100 / originalTotal;
- actualWidth1 *= rescale;
- actualWidth2 *= rescale;
- actualLeftMargin *= rescale;
- actualRightMargin *= rescale;
- } else if (originalTotal < 100) {
- // add to gap
- actualGap = 100 - originalTotal;
- }
-
- let valigns = [
- specifiedValigns[0] ? specifiedValigns[0] : "top",
- specifiedValigns[1] ? specifiedValigns[1] : "top",
- ];
-
- if (!ignoreInitialDOMChecks) {
- cy.get(cesc2("#" + leftWidthValueName)).should(
- "contain.text",
- Math.trunc(actualWidth1),
- );
- cy.get(cesc2("#" + rightWidthValueName)).should(
- "contain.text",
- Math.trunc(actualWidth2),
- );
- cy.get(cesc2("#" + leftMarginValueName)).should(
- "contain.text",
- Math.trunc(actualLeftMargin),
- );
- cy.get(cesc2("#" + rightMarginValueName)).should(
- "contain.text",
- Math.trunc(actualRightMargin),
- );
- cy.get(cesc2("#" + leftValignValueName)).should(
- "have.text",
- valigns[0],
- );
- cy.get(cesc2("#" + rightValignValueName)).should(
- "have.text",
- valigns[1],
- );
- }
-
- if (!isSbsGroup) {
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(1)`)
- .invoke("width")
- .then((width) => {
- expect(Number(width)).closeTo(
- (sbsWidth * actualWidth1) / 100,
- 0.1,
- );
- });
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(1)`)
- .invoke("css", "margin-left")
- .then((margin) => {
- expect(parseFloat(margin)).closeTo(
- (sbsWidth * actualLeftMargin) / 100,
- 0.1,
- );
- });
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(1)`)
- .invoke("css", "margin-right")
- .then((margin) => {
- expect(parseFloat(margin)).closeTo(
- (sbsWidth * (actualRightMargin + actualGap / 2)) / 100,
- 0.1,
- );
- });
-
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(2)`)
- .invoke("width")
- .then((width) => {
- expect(Number(width)).closeTo(
- (sbsWidth * actualWidth2) / 100,
- 0.1,
- );
- });
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(2)`)
- .invoke("css", "margin-left")
- .then((margin) => {
- expect(parseFloat(margin)).closeTo(
- (sbsWidth * (actualLeftMargin + actualGap / 2)) / 100,
- 0.1,
- );
- });
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(2)`)
- .invoke("css", "margin-right")
- .then((margin) => {
- expect(parseFloat(margin)).closeTo(
- (sbsWidth * actualRightMargin) / 100,
- 0.1,
- );
- });
- }
-
- let specifiedWidthName = isSbsGroup
- ? "specifiedWidths"
- : "allWidthsSpecified";
- let specifiedMarginName = isSbsGroup
- ? "specifiedMargins"
- : "allMarginsSpecified";
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables[sbsName].stateValues[specifiedWidthName],
- ).eqls(specifiedWidths);
- expect(stateVariables[sbsName].stateValues.widths.length).eq(2);
- expect(stateVariables[sbsName].stateValues.widths[0]).closeTo(
- actualWidth1,
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.widths[1]).closeTo(
- actualWidth2,
- 1e-5,
- );
- expect(
- stateVariables[sbsName].stateValues[specifiedMarginName],
- ).eqls(specifiedMargins);
- expect(stateVariables[sbsName].stateValues.margins.length).eq(2);
- expect(stateVariables[sbsName].stateValues.margins[0]).closeTo(
- actualLeftMargin,
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.margins[1]).closeTo(
- actualRightMargin,
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.gapWidth).closeTo(
- actualGap,
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.valigns).eqls(valigns);
- });
- };
-
- let checkFourColumnSbs = function ({
- specifiedWidths = [null, null, null, null],
- specifiedMargins = [null, null],
- specifiedValigns = [null, null, null, null],
- sbsWidth,
- sbsName = "/sbs",
- isSbsGroup = false,
- width1ValueName = "/w1a",
- width2ValueName = "/w2a",
- width3ValueName = "/w3a",
- width4ValueName = "/w4a",
- leftMarginValueName = "/m1a",
- rightMarginValueName = "/m2a",
- valign1ValueName = "/v1a",
- valign2ValueName = "/v2a",
- valign3ValueName = "/v3a",
- valign4ValueName = "/v4a",
- ignoreInitialDOMChecks = false,
- }) {
- let totalWidthSpecified = 0;
- let nWidthsUndefined = 0;
-
- for (let ind = 0; ind < 4; ind++) {
- let width = specifiedWidths[ind];
- if (width === null) {
- nWidthsUndefined++;
- } else {
- totalWidthSpecified += width;
- }
- }
-
- let totalMarginSpecified = 0;
- let nMarginsUndefined = 0;
-
- for (let ind = 0; ind < 2; ind++) {
- let margin = specifiedMargins[ind];
- if (margin === null) {
- nMarginsUndefined++;
- } else {
- totalMarginSpecified += margin;
- }
- }
- totalMarginSpecified *= 4;
-
- let actualWidths = [...specifiedWidths];
- let actualMargins = [...specifiedMargins];
- let actualGap = 0;
-
- if (totalWidthSpecified + totalMarginSpecified >= 100) {
- // we are already over 100%
- // anything null becomes width 0
- // everything else is normalized to add up to 100
-
- let normalization =
- 100 / (totalWidthSpecified + totalMarginSpecified);
- for (let ind = 0; ind < 4; ind++) {
- if (actualWidths[ind] === null) {
- actualWidths[ind] = 0;
- } else {
- actualWidths[ind] *= normalization;
- }
- }
- for (let ind = 0; ind < 2; ind++) {
- if (actualMargins[ind] === null) {
- actualMargins[ind] = 0;
- } else {
- actualMargins[ind] *= normalization;
- }
- }
- } else {
- // since we are under 100%, we try the following to get to 100%
- // 1. if there are any null widths,
- // define them to be the same value that makes the total 100%
- // and make any null margins be zero
- // 2. else, if there are any null margins,
- // define them to be the same value that makes the total 100%
- // 3. else set gapWidth to make the total 100%
-
- if (nWidthsUndefined > 0) {
- let newWidth =
- (100 - (totalWidthSpecified + totalMarginSpecified)) /
- nWidthsUndefined;
- for (let ind = 0; ind < 4; ind++) {
- if (actualWidths[ind] === null) {
- actualWidths[ind] = newWidth;
- }
- }
-
- for (let ind = 0; ind < 2; ind++) {
- let margin = actualMargins[ind];
- if (margin === null) {
- actualMargins[ind] = 0;
- }
- }
- } else if (nMarginsUndefined > 0) {
- let newMargin =
- (100 - (totalWidthSpecified + totalMarginSpecified)) /
- (nMarginsUndefined * 4);
- for (let ind = 0; ind < 2; ind++) {
- if (actualMargins[ind] === null) {
- actualMargins[ind] = newMargin;
- }
- }
- } else {
- actualGap =
- (100 - (totalWidthSpecified + totalMarginSpecified)) / 3;
- }
- }
-
- let actualLeftMargin = actualMargins[0];
- let actualRightMargin = actualMargins[1];
-
- let valigns = specifiedValigns.map((x) => (x ? x : "top"));
-
- if (!ignoreInitialDOMChecks) {
- cy.get(cesc2("#" + width1ValueName)).should(
- "contain.text",
- Math.trunc(actualWidths[0]),
- );
- cy.get(cesc2("#" + width2ValueName)).should(
- "contain.text",
- Math.trunc(actualWidths[1]),
- );
- cy.get(cesc2("#" + width3ValueName)).should(
- "contain.text",
- Math.trunc(actualWidths[2]),
- );
- cy.get(cesc2("#" + width4ValueName)).should(
- "contain.text",
- Math.trunc(actualWidths[3]),
- );
- cy.get(cesc2("#" + leftMarginValueName)).should(
- "contain.text",
- Math.trunc(actualLeftMargin),
- );
- cy.get(cesc2("#" + rightMarginValueName)).should(
- "contain.text",
- Math.trunc(actualRightMargin),
- );
- cy.get(cesc2("#" + valign1ValueName)).should(
- "have.text",
- valigns[0],
- );
- cy.get(cesc2("#" + valign2ValueName)).should(
- "have.text",
- valigns[1],
- );
- cy.get(cesc2("#" + valign3ValueName)).should(
- "have.text",
- valigns[2],
- );
- cy.get(cesc2("#" + valign4ValueName)).should(
- "have.text",
- valigns[3],
- );
- }
-
- if (!isSbsGroup) {
- for (let col = 0; col < 4; col++) {
- let thisLeftMargin = actualLeftMargin;
- let thisRightMargin = actualRightMargin;
-
- if (col > 0) {
- thisLeftMargin += actualGap / 2;
- }
- if (col < 3) {
- thisRightMargin += actualGap / 2;
- }
-
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(${col + 1})`)
- .invoke("width")
- .then((width) => {
- expect(Number(width)).closeTo(
- (sbsWidth * actualWidths[col]) / 100,
- 0.1,
- );
- });
-
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(${col + 1})`)
- .invoke("css", "margin-left")
- .then((margin) => {
- expect(parseFloat(margin)).closeTo(
- (sbsWidth * thisLeftMargin) / 100,
- 0.1,
- );
- });
-
- cy.get(`${cesc2("#" + sbsName)} > span:nth-of-type(${col + 1})`)
- .invoke("css", "margin-right")
- .then((margin) => {
- expect(parseFloat(margin)).closeTo(
- (sbsWidth * thisRightMargin) / 100,
- 0.1,
- );
- });
- }
- }
-
- let specifiedWidthName = isSbsGroup
- ? "specifiedWidths"
- : "allWidthsSpecified";
- let specifiedMarginName = isSbsGroup
- ? "specifiedMargins"
- : "allMarginsSpecified";
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables[sbsName].stateValues[specifiedWidthName],
- ).eqls(specifiedWidths);
- expect(stateVariables[sbsName].stateValues.widths.length).eq(4);
- expect(stateVariables[sbsName].stateValues.widths[0]).closeTo(
- actualWidths[0],
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.widths[1]).closeTo(
- actualWidths[1],
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.widths[2]).closeTo(
- actualWidths[2],
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.widths[3]).closeTo(
- actualWidths[3],
- 1e-5,
- );
- expect(
- stateVariables[sbsName].stateValues[specifiedMarginName],
- ).eqls(specifiedMargins);
- expect(stateVariables[sbsName].stateValues.margins.length).eq(2);
- expect(stateVariables[sbsName].stateValues.margins[0]).closeTo(
- actualLeftMargin,
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.margins[1]).closeTo(
- actualRightMargin,
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.gapWidth).closeTo(
- actualGap,
- 1e-5,
- );
- expect(stateVariables[sbsName].stateValues.valigns).eqls(valigns);
- });
- };
-
- it("sideBySide with no arguments, one panel, change margins first", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- Width:
-
-
-
- Margins:
-
-
-
-
- Valign:
-
-
-
-
- $w1.value{assignNames="w1a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkSingleColumnSbs({
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(`change left margin first, unspecified width adjusts`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedMargins: [10, null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change right margin, unspecified width adjusts`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}20{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedMargins: [10, 20],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change width to be smaller, add extra to right margin`);
- // Note: add to right margin since with one panel, there is not gapWidth to set
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}60{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 60,
- specifiedMargins: [10, 20],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change width to be larger, rescale to 100%`);
- // Note: this rescaling ignores the extra width added to the right margin,
- // as it was an indirect consequence of changing the width.
- // Computations assume the right margin is at the origin 20% specified
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}95{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 95,
- specifiedMargins: [10, 20],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `shrink margins to make specified values add back to 100%`,
- );
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}3{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}2{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/m2a")).should("not.contain.text", "1");
-
- checkSingleColumnSbs({
- specifiedWidth: 95,
- specifiedMargins: [3, 2],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`shrink right margin to 1, gets recreated to make 100%`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}1{enter}",
- { force: true },
- );
- // since value of m2a doesn't get changed, can't use it to determine how long to wait
- // use boolean input to check that core has responded to that
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- checkSingleColumnSbs({
- specifiedWidth: 95,
- specifiedMargins: [3, 1],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increase left margin to make specified total be 100%`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}4{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 95,
- specifiedMargins: [4, 1],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change totals to keep at 100%`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}80{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}15{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedMargins: [15, 5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increasing right margin rescales`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}30{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedMargins: [15, 30],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increasing left margin rescales`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}50{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedMargins: [50, 30],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`shrink width to get specified back to 100%`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}20{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 20,
- specifiedMargins: [50, 30],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("bottom{enter}");
-
- checkSingleColumnSbs({
- specifiedWidth: 20,
- specifiedMargins: [50, 30],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid valign ignored`);
- cy.get(cesc("#\\/v1_input")).clear().type("invalid{enter}");
- // since no change, use booleaninput to wait for core
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "false");
-
- checkSingleColumnSbs({
- specifiedWidth: 20,
- specifiedMargins: [50, 30],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with no arguments, one panel, change width first", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- Width:
-
-
-
- Margins:
-
-
-
-
- Valign:
-
-
-
-
- $w1.value{assignNames="w1a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkSingleColumnSbs({
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs"].stateValues.allWidthsSpecified,
- ).eqls([null]);
- expect(stateVariables["/sbs"].stateValues.widths).eqls([
- 100,
- ]);
- expect(
- stateVariables["/sbs"].stateValues.allMarginsSpecified,
- ).eqls([null, null]);
- expect(stateVariables["/sbs"].stateValues.margins).eqls([
- 0, 0,
- ]);
- expect(stateVariables["/sbs"].stateValues.valigns).eqls([
- "top",
- ]);
- });
-
- cy.log(`change width first, unspecified margins adjusts`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}70{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 70,
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change width larger than 100%, scaled back to 100%`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}170{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 170,
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change width smaller again`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}60{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 60,
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change right margin, unspecified left margin adjusts`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 60,
- specifiedMargins: [null, 10],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `change right margin so total is larger than 100%, rescales`,
- );
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}60{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 60,
- specifiedMargins: [null, 60],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change left margin to be large, rescaling adjusts`);
- // Note: add to right margin since with one panel, there is not gapWidth to set
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}120{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 60,
- specifiedMargins: [120, 60],
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with singular relative arguments, one panel", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- Width:
-
-
-
- Margins:
-
-
-
-
- Valign:
-
-
-
-
- $w1.value{assignNames="w1a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedMargins: [10, 10],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(
- `change left margin, specified margins stay symmetric, get rescaling`,
- );
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}40{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedMargins: [40, 40],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `change right margin, specified margins stay symmetric, extra added to right`,
- );
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedMargins: [5, 5],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`symmetry regained by increasing width`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}90{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 90,
- specifiedMargins: [5, 5],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("bottom{enter}");
-
- checkSingleColumnSbs({
- specifiedWidth: 90,
- specifiedMargins: [5, 5],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`ignore invalid valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("green{enter}");
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- checkSingleColumnSbs({
- specifiedWidth: 90,
- specifiedMargins: [5, 5],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with plural relative arguments, one panel", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- Width:
-
-
-
- Margins:
-
-
-
-
- Valign:
-
-
-
-
- $w1.value{assignNames="w1a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedMargins: [15, 5],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(`decrease left margin, space added to right margin`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedMargins: [10, 5],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increase right margin, get rescaling`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}35{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedMargins: [10, 35],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`decrease width to return to 100%`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}55{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 55,
- specifiedMargins: [10, 35],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("bottom{enter}");
-
- checkSingleColumnSbs({
- specifiedWidth: 55,
- specifiedMargins: [10, 35],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`ignore invalid valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("green{enter}");
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- checkSingleColumnSbs({
- specifiedWidth: 55,
- specifiedMargins: [10, 35],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with singular relative arguments and auto margins, one panel", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
- Width:
-
-
-
- Margins:
-
-
-
-
- Valign:
-
-
-
-
- $w1.value{assignNames="w1a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(
- `change left margin, specified margins stay symmetric, get rescaling`,
- );
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}40{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedMargins: [40, 40],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `change right margin, specified margins stay symmetric, extra added to right`,
- );
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 80,
- specifiedMargins: [5, 5],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`symmetry regained by increasing width`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}90{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 90,
- specifiedMargins: [5, 5],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("bottom{enter}");
-
- checkSingleColumnSbs({
- specifiedWidth: 90,
- specifiedMargins: [5, 5],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`ignore invalid valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("green{enter}");
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- checkSingleColumnSbs({
- specifiedWidth: 90,
- specifiedMargins: [5, 5],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with no arguments, two panels, change margins first", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
- Widths:
-
-
-
-
- Margins:
-
-
-
-
- Valigns:
-
-
-
-
-
- $w1.value{assignNames="w1a"}
- $w2.value{assignNames="w2a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
- $v2.value{assignNames="v2a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(`change left margin first, unspecified widths adjust`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedMargins: [10, null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change right margin, unspecified widths adjust`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedMargins: [10, 5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `change first width to be smaller, add extra to second width`,
- );
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}20{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, null],
- specifiedMargins: [10, 5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `change first width to be larger, second width shrinks to zero, rescale to 100%`,
- );
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}95{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [95, null],
- specifiedMargins: [10, 5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change first width to be smaller again`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, null],
- specifiedMargins: [10, 5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second width to be smaller, extra added to gap`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}50{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 50],
- specifiedMargins: [10, 5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second width to be larger, rescaled to 100%`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}85{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 85],
- specifiedMargins: [10, 5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `shrink margins to make specified values add back to 100%`,
- );
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}1.5{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}1{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 85],
- specifiedMargins: [1.5, 1],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`shrink right margin to 0.5, extra added to gap`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}0.5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 85],
- specifiedMargins: [1.5, 0.5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increase left margin to make specified total be 100%`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}2{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 85],
- specifiedMargins: [2, 0.5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change totals to keep at 100%`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}30{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}50{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}4{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}6{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 50],
- specifiedMargins: [4, 6],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increasing right margin rescales`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}18.5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 50],
- specifiedMargins: [4, 18.5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increasing left margin rescales`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}21.5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 50],
- specifiedMargins: [21.5, 18.5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`shrink widths to get specified below 100%`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}5{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}10{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [5, 10],
- specifiedMargins: [21.5, 18.5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change first valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [5, 10],
- specifiedMargins: [21.5, 18.5],
- specifiedValigns: ["bottom", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second valign`);
- cy.get(cesc("#\\/v2_input")).clear().type("middle{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [5, 10],
- specifiedMargins: [21.5, 18.5],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid valign ignored`);
- cy.get(cesc("#\\/v2_input")).clear().type("invalid{enter}");
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- checkTwoColumnSbs({
- specifiedWidths: [5, 10],
- specifiedMargins: [21.5, 18.5],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with no arguments, two panels, change widths first", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
- Widths:
-
-
-
-
- Margins:
-
-
-
-
- Valigns:
-
-
-
-
-
- $w1.value{assignNames="w1a"}
- $w2.value{assignNames="w2a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
- $v2.value{assignNames="v2a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(
- `change second width past 100%, unspecified first width shrinks to zero, rescales`,
- );
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}130{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [null, 130],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second width, unspecified first width adjusts`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}10{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [null, 10],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change first width, unspecified margins adjust`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}30{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 10],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change right margin, unspecified left margin adjusts`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 10],
- specifiedMargins: [null, 5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `increase second width so total is past 100%, rescaling`,
- );
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}85{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 85],
- specifiedMargins: [null, 5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`decrease second width`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}20{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 20],
- specifiedMargins: [null, 5],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`specify first margin to be smaller, remainder in gap`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 20],
- specifiedMargins: [10, 5],
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with singular relative arguments, two panels", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
- Widths:
-
-
-
-
- Margins:
-
-
-
-
- Valigns:
-
-
-
-
-
- $w1.value{assignNames="w1a"}
- $w2.value{assignNames="w2a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
- $v2.value{assignNames="v2a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(`change first width, second matches`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}30{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second width, first matches, rescaling`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}80{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [80, 80],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`shrink width, rest in gap`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increase left margin, right margin matches`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}20{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [20, 20],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increase right margin, left margin matches, rescaling`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}45{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [45, 45],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change first valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("top{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [45, 45],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second valign`);
- cy.get(cesc("#\\/v2_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [45, 45],
- specifiedValigns: ["bottom", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid valign ignored`);
- cy.get(cesc("#\\/v1_input")).clear().type("invalid{enter}");
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [45, 45],
- specifiedValigns: ["bottom", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with plural relative arguments, two panels", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
- Widths:
-
-
-
-
- Margins:
-
-
-
-
- Valigns:
-
-
-
-
-
- $w1.value{assignNames="w1a"}
- $w2.value{assignNames="w2a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
- $v2.value{assignNames="v2a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- specifiedWidths: [20, 10],
- specifiedMargins: [10, 20],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(`change first width`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}30{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 10],
- specifiedMargins: [10, 20],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second width, rescaling`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}110{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 110],
- specifiedMargins: [10, 20],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`shrink second width`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [10, 20],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`decrease right margin`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [10, 5],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increase left margin, rescaling`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}77.5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [77.5, 5],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change first valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("top{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [77.5, 5],
- specifiedValigns: ["top", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second valign`);
- cy.get(cesc("#\\/v2_input")).clear().type("middle{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [77.5, 5],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid valign ignored`);
- cy.get(cesc("#\\/v2_input")).clear().type("invalid{enter}");
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [77.5, 5],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with half-specified plural relative arguments and auto margins", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
- Widths:
-
-
-
-
- Margins:
-
-
-
-
- Valigns:
-
-
-
-
-
- $w1.value{assignNames="w1a"}
- $w2.value{assignNames="w2a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
- $v2.value{assignNames="v2a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- specifiedWidths: [20, null],
- specifiedMargins: [null, null],
- specifiedValigns: ["middle", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(`change first width, unspecified second width adjusts`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}30{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, null],
- specifiedMargins: [null, null],
- specifiedValigns: ["middle", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `change right margin, left is symmetric, unspecified second width adjusts`,
- );
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, null],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second width, rest in gap`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}20{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change first width, rescaling`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}140{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [140, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`shrink first width`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`decrease right margin, left matches`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 20],
- specifiedMargins: [5, 5],
- specifiedValigns: ["middle", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increase left margin, right matches, rescaling`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}42.5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 20],
- specifiedMargins: [42.5, 42.5],
- specifiedValigns: ["middle", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change first valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("top{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 20],
- specifiedMargins: [42.5, 42.5],
- specifiedValigns: ["top", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second valign`);
- cy.get(cesc("#\\/v2_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 20],
- specifiedMargins: [42.5, 42.5],
- specifiedValigns: ["top", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid valign ignored`);
- cy.get(cesc("#\\/v2_input")).clear().type("invalid{enter}");
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 20],
- specifiedMargins: [42.5, 42.5],
- specifiedValigns: ["top", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with no arguments, four panels", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
- Widths:
-
-
-
-
-
-
- Margins:
-
-
-
-
- Valigns:
-
-
-
-
-
-
-
- $w1.value{assignNames="w1a"}
- $w2.value{assignNames="w2a"}
- $w3.value{assignNames="w3a"}
- $w4.value{assignNames="w4a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
- $v2.value{assignNames="v2a"}
- $v3.value{assignNames="v3a"}
- $v4.value{assignNames="v4a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkFourColumnSbs({
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(`change left margin first, unspecified widths adjust`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}2{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedMargins: [2, null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change right margin, unspecified widths adjust`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}3{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedMargins: [2, 3],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `change 3rd width to be smaller, add extra to other widths`,
- );
- cy.get(cesc("#\\/w3") + " textarea").type(
- "{end}{backspace}{backspace}14{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [null, null, 14, null],
- specifiedMargins: [2, 3],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `change 3rd width to be larger, others widths shrinks to zero, rescale to 100%`,
- );
- cy.get(cesc("#\\/w3") + " textarea").type(
- "{end}{backspace}{backspace}180{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [null, null, 180, null],
- specifiedMargins: [2, 3],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change 3rd width to be smaller again`);
- cy.get(cesc("#\\/w3") + " textarea").type(
- "{end}{backspace}{backspace}11{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [null, null, 11, null],
- specifiedMargins: [2, 3],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change 2nd width to be smaller`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}15{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [null, 15, 11, null],
- specifiedMargins: [2, 3],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change 1st width to be smaller`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}20{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [20, 15, 11, null],
- specifiedMargins: [2, 3],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `change 4th width to be smaller, remainder added to gap`,
- );
- cy.get(cesc("#\\/w4") + " textarea").type(
- "{end}{backspace}{backspace}19{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [20, 15, 11, 19],
- specifiedMargins: [2, 3],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change 2nd width to be larger, rescaled to 100%`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}55{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [20, 55, 11, 19],
- specifiedMargins: [2, 3],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `shrink width 2 to make specified values add back to 100%`,
- );
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}30{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [20, 30, 11, 19],
- specifiedMargins: [2, 3],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`shrink right margin, extra added to gap`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}1{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [20, 30, 11, 19],
- specifiedMargins: [2, 1],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change fourth valign`);
- cy.get(cesc("#\\/v4_input")).clear().type("bottom{enter}");
-
- checkFourColumnSbs({
- specifiedWidths: [20, 30, 11, 19],
- specifiedMargins: [2, 1],
- specifiedValigns: [null, null, null, "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second valign`);
- cy.get(cesc("#\\/v2_input")).clear().type("middle{enter}");
-
- checkFourColumnSbs({
- specifiedWidths: [20, 30, 11, 19],
- specifiedMargins: [2, 1],
- specifiedValigns: [null, "middle", null, "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change first valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("middle{enter}");
-
- checkFourColumnSbs({
- specifiedWidths: [20, 30, 11, 19],
- specifiedMargins: [2, 1],
- specifiedValigns: ["middle", "middle", null, "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change third valign`);
- cy.get(cesc("#\\/v3_input")).clear().type("bottom{enter}");
-
- checkFourColumnSbs({
- specifiedWidths: [20, 30, 11, 19],
- specifiedMargins: [2, 1],
- specifiedValigns: ["middle", "middle", "bottom", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid valign ignored`);
- cy.get(cesc("#\\/v3_input")).clear().type("invalid{enter}");
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- checkFourColumnSbs({
- specifiedWidths: [20, 30, 11, 19],
- specifiedMargins: [2, 1],
- specifiedValigns: ["middle", "middle", "bottom", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with singular relative arguments, four panels", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
- Widths:
-
-
-
-
-
-
- Margins:
-
-
-
-
- Valigns:
-
-
-
-
-
-
-
- $w1.value{assignNames="w1a"}
- $w2.value{assignNames="w2a"}
- $w3.value{assignNames="w3a"}
- $w4.value{assignNames="w4a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
- $v2.value{assignNames="v2a"}
- $v3.value{assignNames="v3a"}
- $v4.value{assignNames="v4a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkFourColumnSbs({
- specifiedWidths: [15, 15, 15, 15],
- specifiedMargins: [5, 5],
- specifiedValigns: ["middle", "middle", "middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(`change 4th width, rest match, remainder added to gap`);
- cy.get(cesc("#\\/w4") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [10, 10, 10, 10],
- specifiedMargins: [5, 5],
- specifiedValigns: ["middle", "middle", "middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change right margin, rescaled`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}20{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [10, 10, 10, 10],
- specifiedMargins: [20, 20],
- specifiedValigns: ["middle", "middle", "middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`shrink left margin`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}2{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [10, 10, 10, 10],
- specifiedMargins: [2, 2],
- specifiedValigns: ["middle", "middle", "middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change fourth valign`);
- cy.get(cesc("#\\/v4_input")).clear().type("bottom{enter}");
-
- checkFourColumnSbs({
- specifiedWidths: [10, 10, 10, 10],
- specifiedMargins: [2, 2],
- specifiedValigns: ["bottom", "bottom", "bottom", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with plural relative arguments, four panels", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
- Widths:
-
-
-
-
-
-
- Margins:
-
-
-
-
- Valigns:
-
-
-
-
-
-
-
- $w1.value{assignNames="w1a"}
- $w2.value{assignNames="w2a"}
- $w3.value{assignNames="w3a"}
- $w4.value{assignNames="w4a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
- $v2.value{assignNames="v2a"}
- $v3.value{assignNames="v3a"}
- $v4.value{assignNames="v4a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkFourColumnSbs({
- specifiedWidths: [5, 10, 15, 20],
- specifiedMargins: [5, 2],
- specifiedValigns: ["middle", null, null, null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(`change 4th width, remainder added to gap`);
- cy.get(cesc("#\\/w4") + " textarea").type(
- "{end}{backspace}{backspace}9{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [5, 10, 15, 9],
- specifiedMargins: [5, 2],
- specifiedValigns: ["middle", null, null, null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change 1st width, rescaled`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}63{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [63, 10, 15, 9],
- specifiedMargins: [5, 2],
- specifiedValigns: ["middle", null, null, null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change more widths, remainder added to gap`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}3{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}8{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/w3") + " textarea").type(
- "{end}{backspace}{backspace}13{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [3, 8, 13, 9],
- specifiedMargins: [5, 2],
- specifiedValigns: ["middle", null, null, null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change margins`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}7{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}6{enter}",
- { force: true },
- );
-
- checkFourColumnSbs({
- specifiedWidths: [3, 8, 13, 9],
- specifiedMargins: [7, 6],
- specifiedValigns: ["middle", null, null, null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change valigns`);
- cy.get(cesc("#\\/v1_input")).clear().type("top{enter}");
- cy.get(cesc("#\\/v2_input")).clear().type("middle{enter}");
- cy.get(cesc("#\\/v3_input")).clear().type("bottom{enter}");
- cy.get(cesc("#\\/v4_input")).clear().type("middle{enter}");
-
- checkFourColumnSbs({
- specifiedWidths: [3, 8, 13, 9],
- specifiedMargins: [7, 6],
- specifiedValigns: ["top", "middle", "bottom", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("copy sideBySide and overwrite parameters", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkFourColumnSbs({
- specifiedWidths: [5, 10, 15, 20],
- specifiedMargins: [5, 2],
- specifiedValigns: ["middle", null, null, null],
- sbsWidth,
- sbsName: "/sbs",
- ignoreInitialDOMChecks: true,
- });
-
- checkFourColumnSbs({
- specifiedWidths: [30, 10, null, null],
- specifiedMargins: [1, 3],
- specifiedValigns: ["bottom", "middle", "top", "bottom"],
- sbsWidth,
- sbsName: "/sbs2",
- ignoreInitialDOMChecks: true,
- });
-
- checkFourColumnSbs({
- specifiedWidths: [7, 8, 11, 12],
- specifiedMargins: [1, 3],
- specifiedValigns: ["top", "bottom", null, null],
- sbsWidth,
- sbsName: "/sbs3",
- ignoreInitialDOMChecks: true,
- });
- });
- });
-
- it("sideBySide absolute measurements turned to absolute with warning", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Hello
- Hello
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_sidebyside1"].stateValues.marginsAbsolute,
- ).eq(false);
- expect(
- stateVariables["/_sidebyside1"].stateValues.widthsAbsolute,
- ).eq(false);
- });
-
- cy.window().then(async (win) => {
- let errorWarnings = await win.returnErrorWarnings1();
-
- expect(errorWarnings.errors.length).eq(0);
- expect(errorWarnings.warnings.length).eq(2);
-
- expect(errorWarnings.warnings[0].message).contain(
- ` is not implemented for absolute measurements. Setting widths to relative`,
- );
- expect(errorWarnings.warnings[0].level).eq(1);
- expect(errorWarnings.warnings[0].doenetMLrange.lineBegin).eq(3);
- expect(errorWarnings.warnings[0].doenetMLrange.charBegin).eq(5);
- expect(errorWarnings.warnings[0].doenetMLrange.lineEnd).eq(6);
- expect(errorWarnings.warnings[0].doenetMLrange.charEnd).eq(17);
-
- expect(errorWarnings.warnings[1].message).contain(
- ` is not implemented for absolute measurements. Setting margins to relative`,
- );
- expect(errorWarnings.warnings[1].level).eq(1);
- expect(errorWarnings.warnings[1].doenetMLrange.lineBegin).eq(3);
- expect(errorWarnings.warnings[1].doenetMLrange.charBegin).eq(5);
- expect(errorWarnings.warnings[1].doenetMLrange.lineEnd).eq(6);
- expect(errorWarnings.warnings[1].doenetMLrange.charEnd).eq(17);
- });
- });
-
- it("sbsGroup with no arguments, one panel", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
- Width for sbsg:
-
-
-
- Margins for sbsg:
-
-
-
-
- Valign for sbsg:
-
-
-
- Width for sbs1:
-
-
-
- Margins for sbs1:
-
-
-
-
- Valign for sbs1:
-
-
-
- Width for sbs2:
-
-
-
- Margins for sbs2:
-
-
-
-
- Valign for sbs2:
-
-
-
-
-
- $w1g.value{assignNames="w1ga"}
- $m1g.value{assignNames="m1ga"}
- $m2g.value{assignNames="m2ga"}
- $v1g.value{assignNames="v1ga"}
- $w11.value{assignNames="w11a"}
- $m11.value{assignNames="m11a"}
- $m21.value{assignNames="m21a"}
- $v11.value{assignNames="v11a"}
- $w12.value{assignNames="w12a"}
- $m12.value{assignNames="m12a"}
- $m22.value{assignNames="m22a"}
- $v12.value{assignNames="v12a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- // Note: including essentialWidths and essentialMargins
- // just so can keep track of which sbs will still be affected by the spsGroup
-
- cy.get(cesc("#\\/sbs1"))
- .invoke("width")
- .then((sbsWidth) => {
- checkSingleColumnSbs({
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbsg"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs1"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(
- `change left margin of sbs1, unspecified width of sbs1 adjusts`,
- );
- cy.get(cesc("#\\/m11") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedMargins: [10, null],
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width of sbsg, unspecified margin(s) adjust`);
- cy.get(cesc("#\\/w1g") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}70{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 70,
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 70,
- specifiedMargins: [10, null],
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 70,
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(
- `change right margin of sbs2, unspecified margin adjusts`,
- );
- cy.get(cesc("#\\/m22") + " textarea").type(
- "{end}{backspace}{backspace}25{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 70,
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 70,
- specifiedMargins: [10, null],
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 70,
- specifiedMargins: [null, 25],
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, 25]);
- });
-
- cy.log(`change left margin of sbsg, affects only sbs2`);
- cy.get(cesc("#\\/m1g") + " textarea").type(
- "{end}{backspace}{backspace}4{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 70,
- specifiedMargins: [4, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 70,
- specifiedMargins: [10, null],
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 70,
- specifiedMargins: [4, 25],
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, 25]);
- });
-
- cy.log(
- `change sbsg width to be smaller, adds to unspecified or right margins`,
- );
- cy.get(cesc("#\\/w1g") + " textarea").type(
- "{end}{backspace}{backspace}60{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 60,
- specifiedMargins: [4, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 60,
- specifiedMargins: [10, null],
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 60,
- specifiedMargins: [4, 25],
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, 25]);
- });
-
- cy.log(
- `change sbs1 width to be smaller, adds to unspecified right margin`,
- );
- cy.get(cesc("#\\/w11") + " textarea").type(
- "{end}{backspace}{backspace}50{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 60,
- specifiedMargins: [4, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 50,
- specifiedMargins: [10, null],
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 60,
- specifiedMargins: [4, 25],
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([50]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, 25]);
- });
-
- cy.log(
- `increase sbsg left margin, cause rescaling just in sbs2`,
- );
- cy.get(cesc("#\\/m1g") + " textarea").type(
- "{end}{backspace}{backspace}20{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 60,
- specifiedMargins: [20, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 50,
- specifiedMargins: [10, null],
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 60,
- specifiedMargins: [20, 25],
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([50]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, 25]);
- });
-
- cy.log(
- `increase sbsg width, causing rescaling in sbsg and a second in sbs2`,
- );
- cy.get(cesc("#\\/w1g") + " textarea").type(
- "{end}{backspace}{backspace}90{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 90,
- specifiedMargins: [20, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 50,
- specifiedMargins: [10, null],
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 90,
- specifiedMargins: [20, 25],
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([50]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, 25]);
- });
-
- cy.log(`shrink sbsg width to remove rescaling`);
- cy.get(cesc("#\\/w1g") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}40{enter}",
- { force: true },
- );
-
- checkSingleColumnSbs({
- specifiedWidth: 40,
- specifiedMargins: [20, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 50,
- specifiedMargins: [10, null],
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 40,
- specifiedMargins: [20, 25],
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([50]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, 25]);
- });
-
- cy.log(`change valign of sbs1`);
- cy.get(cesc("#\\/v11_input")).clear().type("bottom{enter}");
-
- checkSingleColumnSbs({
- specifiedWidth: 40,
- specifiedMargins: [20, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 50,
- specifiedMargins: [10, null],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 40,
- specifiedMargins: [20, 25],
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([50]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, 25]);
- });
-
- cy.log(`change valign of sbsg`);
- cy.get(cesc("#\\/v1g_input")).clear().type("middle{enter}");
-
- checkSingleColumnSbs({
- specifiedWidth: 40,
- specifiedMargins: [20, null],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 50,
- specifiedMargins: [10, null],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 40,
- specifiedMargins: [20, 25],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([50]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, 25]);
- });
-
- cy.log(`change valign of sbs2`);
- cy.get(cesc("#\\/v12_input")).clear().type("top{enter}");
-
- checkSingleColumnSbs({
- specifiedWidth: 40,
- specifiedMargins: [20, null],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 50,
- specifiedMargins: [10, null],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 40,
- specifiedMargins: [20, 25],
- specifiedValign: "top",
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([50]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, 25]);
- });
-
- cy.log(`valign of sbsg ignores invalid`);
- cy.get(cesc("#\\/v1g_input")).clear().type("banana{enter}");
- cy.get(cesc("#\\/bi")).click();
- cy.get(cesc("#\\/b")).should("have.text", "true");
-
- checkSingleColumnSbs({
- specifiedWidth: 40,
- specifiedMargins: [20, null],
- specifiedValign: "middle",
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- widthValueName: "/w1ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- valignValueName: "/v1ga",
- });
- checkSingleColumnSbs({
- specifiedWidth: 50,
- specifiedMargins: [10, null],
- specifiedValign: "bottom",
- sbsWidth,
- sbsName: "/sbs1",
- widthValueName: "/w11a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- valignValueName: "/v11a",
- });
- checkSingleColumnSbs({
- specifiedWidth: 40,
- specifiedMargins: [20, 25],
- specifiedValign: "top",
- sbsWidth,
- sbsName: "/sbs2",
- widthValueName: "/w12a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- valignValueName: "/v12a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([50]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([10, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, 25]);
- });
- });
- });
-
- it("sbsGroup with no arguments, two panels", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
-
- Widths for sbsg:
-
-
-
-
- Margins for sbsg:
-
-
-
-
- Valigns for sbsg:
-
-
-
-
- Widths for sbs1:
-
-
-
-
- Margins for sbs1:
-
-
-
-
- Valigns for sbs1:
-
-
-
-
- Widths for sbs2:
-
-
-
-
- Margins for sbs2:
-
-
-
-
- Valigns for sbs2:
-
-
-
-
-
-
- $w1g.value{assignNames="w1ga"}
- $w2g.value{assignNames="w2ga"}
- $m1g.value{assignNames="m1ga"}
- $m2g.value{assignNames="m2ga"}
- $v1g.value{assignNames="v1ga"}
- $v2g.value{assignNames="v2ga"}
- $w11.value{assignNames="w11a"}
- $w21.value{assignNames="w21a"}
- $m11.value{assignNames="m11a"}
- $m21.value{assignNames="m21a"}
- $v11.value{assignNames="v11a"}
- $v21.value{assignNames="v21a"}
- $w12.value{assignNames="w12a"}
- $w22.value{assignNames="w22a"}
- $m12.value{assignNames="m12a"}
- $m22.value{assignNames="m22a"}
- $v12.value{assignNames="v12a"}
- $v22.value{assignNames="v22a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- // Note: including essentialWidths and essentialMargins
- // just so can keep track of which sbs will still be affected by the spsGroup
-
- cy.get(cesc("#\\/sbs1"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbsg"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs1"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width1 of sbsg`);
- cy.get(cesc("#\\/w1g") + " textarea").type(
- "{end}{backspace}{backspace}40{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [40, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, null],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, null],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`override width1 of sbs1`);
- cy.get(cesc("#\\/w11") + " textarea").type(
- "{end}{backspace}{backspace}30{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [40, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, null],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, null],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`override width2 of sbs2`);
- cy.get(cesc("#\\/w22") + " textarea").type(
- "{end}{backspace}{backspace}50{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [40, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, null],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, 50],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change left margin of sbs1`);
- cy.get(cesc("#\\/m11") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [40, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, null],
- specifiedMargins: [5, null],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, 50],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([5, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change left margin of sbsg`);
- cy.get(cesc("#\\/m1g") + " textarea").type(
- "{end}{backspace}{backspace}3{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [40, null],
- specifiedMargins: [3, null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, null],
- specifiedMargins: [5, null],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, 50],
- specifiedMargins: [3, null],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([5, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.allMarginsSpecified,
- ).eqls([3, null]);
- });
-
- cy.log(`change right margin of sbsg`);
- cy.get(cesc("#\\/m2g") + " textarea").type(
- "{end}{backspace}{backspace}1{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [40, null],
- specifiedMargins: [3, 1],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, null],
- specifiedMargins: [5, 1],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, 50],
- specifiedMargins: [3, 1],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([5, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change second width of sbsg`);
- cy.get(cesc("#\\/w2g") + " textarea").type(
- "{end}{backspace}{backspace}45{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [40, 45],
- specifiedMargins: [3, 1],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 45],
- specifiedMargins: [5, 1],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, 50],
- specifiedMargins: [3, 1],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([5, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`increase second width of sbsg to cause rescaling`);
- cy.get(cesc("#\\/w2g") + " textarea").type(
- "{end}{backspace}{backspace}65{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [40, 65],
- specifiedMargins: [3, 1],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 65],
- specifiedMargins: [5, 1],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, 50],
- specifiedMargins: [3, 1],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([5, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`decrease second width of sbs1 to drop below 100%`);
- cy.get(cesc("#\\/w21") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}55{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [40, 65],
- specifiedMargins: [3, 1],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 55],
- specifiedMargins: [5, 1],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, 50],
- specifiedMargins: [3, 1],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, 55]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([5, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`decrease first width of sbsg to drop below 100%`);
- cy.get(cesc("#\\/w1g") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}25{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [25, 65],
- specifiedMargins: [3, 1],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 55],
- specifiedMargins: [5, 1],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [25, 50],
- specifiedMargins: [3, 1],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, 55]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([5, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change first valign of sbsg`);
- cy.get(cesc("#\\/v1g_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [25, 65],
- specifiedMargins: [3, 1],
- specifiedValigns: ["bottom", null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 55],
- specifiedMargins: [5, 1],
- specifiedValigns: ["bottom", null],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [25, 50],
- specifiedMargins: [3, 1],
- specifiedValigns: ["bottom", null],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, 55]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([5, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change first valign of sbs2`);
- cy.get(cesc("#\\/v12_input")).clear().type("middle{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [25, 65],
- specifiedMargins: [3, 1],
- specifiedValigns: ["bottom", null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 55],
- specifiedMargins: [5, 1],
- specifiedValigns: ["bottom", null],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [25, 50],
- specifiedMargins: [3, 1],
- specifiedValigns: ["middle", null],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, 55]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([5, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change second valign of sbs1`);
- cy.get(cesc("#\\/v21_input")).clear().type("middle{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [25, 65],
- specifiedMargins: [3, 1],
- specifiedValigns: ["bottom", null],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 55],
- specifiedMargins: [5, 1],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [25, 50],
- specifiedMargins: [3, 1],
- specifiedValigns: ["middle", null],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, 55]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([5, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change second valign of sbsg`);
- cy.get(cesc("#\\/v2g_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [25, 65],
- specifiedMargins: [3, 1],
- specifiedValigns: ["bottom", "bottom"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 55],
- specifiedMargins: [5, 1],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [25, 50],
- specifiedMargins: [3, 1],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([30, 55]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([5, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 50]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
- });
- });
-
- it("sbsGroup with singular arguments, sidebysides with plural or no arguments, two panels", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
-
- Widths for sbsg:
-
-
-
-
- Margins for sbsg:
-
-
-
-
- Valigns for sbsg:
-
-
-
-
- Widths for sbs1:
-
-
-
-
- Margins for sbs1:
-
-
-
-
- Valigns for sbs1:
-
-
-
-
- Widths for sbs2:
-
-
-
-
- Margins for sbs2:
-
-
-
-
- Valigns for sbs2:
-
-
-
-
-
- $w1g.value{assignNames="w1ga"}
- $w2g.value{assignNames="w2ga"}
- $m1g.value{assignNames="m1ga"}
- $m2g.value{assignNames="m2ga"}
- $v1g.value{assignNames="v1ga"}
- $v2g.value{assignNames="v2ga"}
- $w11.value{assignNames="w11a"}
- $w21.value{assignNames="w21a"}
- $m11.value{assignNames="m11a"}
- $m21.value{assignNames="m21a"}
- $v11.value{assignNames="v11a"}
- $v21.value{assignNames="v21a"}
- $w12.value{assignNames="w12a"}
- $w22.value{assignNames="w22a"}
- $m12.value{assignNames="m12a"}
- $m22.value{assignNames="m22a"}
- $v12.value{assignNames="v12a"}
- $v22.value{assignNames="v22a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs1"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- specifiedWidths: [25, 25],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [25, 25],
- specifiedMargins: [15, 5],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbsg"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs1"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width1 of sbsg`);
- cy.get(cesc("#\\/w1g") + " textarea").type(
- "{end}{backspace}{backspace}20{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [15, 5],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width2 of sbs2`);
- cy.get(cesc("#\\/w22") + " textarea").type(
- "{end}{backspace}{backspace}15{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [20, 15],
- specifiedMargins: [15, 5],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width2 of sbsg`);
- cy.get(cesc("#\\/w2g") + " textarea").type(
- "{end}{backspace}{backspace}12{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [40, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [15, 5],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width1 of sbs1`);
- cy.get(cesc("#\\/w11") + " textarea").type(
- "{end}{backspace}{backspace}35{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [15, 5],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change margins of sbs2`);
- cy.get(cesc("#\\/m12") + " textarea").type(
- "{end}{backspace}{backspace}22{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/m22") + " textarea").type(
- "{end}{backspace}{backspace}11{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [22, 11],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change right margin of sbsg`);
- cy.get(cesc("#\\/m2g") + " textarea").type(
- "{end}{backspace}{backspace}8{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 20],
- specifiedMargins: [8, 8],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [22, 11],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change right margin of sbs1`);
- cy.get(cesc("#\\/m21") + " textarea").type(
- "{end}{backspace}{backspace}7{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 20],
- specifiedMargins: [8, 7],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [22, 11],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change left margin of sbsg`);
- cy.get(cesc("#\\/m1g") + " textarea").type(
- "{end}{backspace}{backspace}9{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [9, 9],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 20],
- specifiedMargins: [9, 7],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [22, 11],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change left margin of sbs1`);
- cy.get(cesc("#\\/m11") + " textarea").type(
- "{end}{backspace}{backspace}6{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [9, 9],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 20],
- specifiedMargins: [6, 7],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [22, 11],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change valign1 of sbsg`);
- cy.get(cesc("#\\/v1g_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [9, 9],
- specifiedValigns: ["bottom", "bottom"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 20],
- specifiedMargins: [6, 7],
- specifiedValigns: ["top", "bottom"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [22, 11],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change valign2 of sbs1`);
- cy.get(cesc("#\\/v21_input")).clear().type("middle{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [9, 9],
- specifiedValigns: ["bottom", "bottom"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 20],
- specifiedMargins: [6, 7],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [22, 11],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change valign2 of sbsg`);
- cy.get(cesc("#\\/v2g_input")).clear().type("top{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [9, 9],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 20],
- specifiedMargins: [6, 7],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [22, 11],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change valign1 of sbs1`);
- cy.get(cesc("#\\/v11_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [9, 9],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 20],
- specifiedMargins: [6, 7],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [22, 11],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change valigns of sbs2`);
- cy.get(cesc("#\\/v12_input")).clear().type("middle{enter}");
- cy.get(cesc("#\\/v22_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [12, 12],
- specifiedMargins: [9, 9],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 20],
- specifiedMargins: [6, 7],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [12, 15],
- specifiedMargins: [22, 11],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 15]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
- });
- });
-
- it("sbsGroup with plural arguments, sidebysides with singular or no arguments, two panels", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
-
- Widths for sbsg:
-
-
-
-
- Margins for sbsg:
-
-
-
-
- Valigns for sbsg:
-
-
-
-
- Widths for sbs1:
-
-
-
-
- Margins for sbs1:
-
-
-
-
- Valigns for sbs1:
-
-
-
-
- Widths for sbs2:
-
-
-
-
- Margins for sbs2:
-
-
-
-
- Valigns for sbs2:
-
-
-
-
-
- $w1g.value{assignNames="w1ga"}
- $w2g.value{assignNames="w2ga"}
- $m1g.value{assignNames="m1ga"}
- $m2g.value{assignNames="m2ga"}
- $v1g.value{assignNames="v1ga"}
- $v2g.value{assignNames="v2ga"}
- $w11.value{assignNames="w11a"}
- $w21.value{assignNames="w21a"}
- $m11.value{assignNames="m11a"}
- $m21.value{assignNames="m21a"}
- $v11.value{assignNames="v11a"}
- $v21.value{assignNames="v21a"}
- $w12.value{assignNames="w12a"}
- $w22.value{assignNames="w22a"}
- $m12.value{assignNames="m12a"}
- $m22.value{assignNames="m22a"}
- $v12.value{assignNames="v12a"}
- $v22.value{assignNames="v22a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs1"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- specifiedWidths: [25, 15],
- specifiedMargins: [5, 10],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [5, 10],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [25, 15],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbsg"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs1"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues
- .absoluteMeasurements,
- ).eq(false);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width1 of sbsg`);
- cy.get(cesc("#\\/w1g") + " textarea").type(
- "{end}{backspace}{backspace}20{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 15],
- specifiedMargins: [5, 10],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [5, 10],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [20, 15],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width2 of sbs2`);
- cy.get(cesc("#\\/w22") + " textarea").type(
- "{end}{backspace}{backspace}25{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 15],
- specifiedMargins: [5, 10],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [5, 10],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [20, 25],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width2 of sbsg`);
- cy.get(cesc("#\\/w2g") + " textarea").type(
- "{end}{backspace}{backspace}12{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [5, 10],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [5, 10],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [20, 25],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width1 of sbs1`);
- cy.get(cesc("#\\/w11") + " textarea").type(
- "{end}{backspace}{backspace}35{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [5, 10],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [35, 35],
- specifiedMargins: [5, 10],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [20, 25],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width2 of sbs1`);
- cy.get(cesc("#\\/w21") + " textarea").type(
- "{end}{backspace}{backspace}30{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [5, 10],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [5, 10],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [20, 25],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([null, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change width1 of sbs2`);
- cy.get(cesc("#\\/w12") + " textarea").type(
- "{end}{backspace}{backspace}22{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [5, 10],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [5, 10],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change right margin of sbsg`);
- cy.get(cesc("#\\/m2g") + " textarea").type(
- "{end}{backspace}{backspace}8{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [5, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [5, 8],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change right margin of sbs1`);
- cy.get(cesc("#\\/m21") + " textarea").type(
- "{end}{backspace}{backspace}7{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [5, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [5, 7],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change left margin of sbsg`);
- cy.get(cesc("#\\/m1g") + " textarea").type(
- "{end}{backspace}{backspace}9{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [9, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [9, 7],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([null, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change left margin of sbs1`);
- cy.get(cesc("#\\/m11") + " textarea").type(
- "{end}{backspace}{backspace}6{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [9, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [6, 7],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change right margin of sbs2`);
- cy.get(cesc("#\\/m22") + " textarea").type(
- "{end}{backspace}{backspace}3{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [9, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [6, 7],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [3, 3],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change left margin of sbs2`);
- cy.get(cesc("#\\/m12") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [9, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [6, 7],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change valign1 of sbsg`);
- cy.get(cesc("#\\/v1g_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [9, 8],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [6, 7],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [10, 10],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change valign2 of sbs1`);
- cy.get(cesc("#\\/v21_input")).clear().type("middle{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [9, 8],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [6, 7],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [10, 10],
- specifiedValigns: ["bottom", "top"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change valign2 of sbsg`);
- cy.get(cesc("#\\/v2g_input")).clear().type("middle{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [9, 8],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [6, 7],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [10, 10],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change valign1 of sbs1`);
- cy.get(cesc("#\\/v11_input")).clear().type("top{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [9, 8],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [6, 7],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [10, 10],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
-
- cy.log(`change valigns of sbs2`);
- cy.get(cesc("#\\/v12_input")).clear().type("middle{enter}");
- cy.get(cesc("#\\/v22_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 12],
- specifiedMargins: [9, 8],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- leftWidthValueName: "/w1ga",
- rightWidthValueName: "/w2ga",
- leftMarginValueName: "/m1ga",
- rightMarginValueName: "/m2ga",
- leftValignValueName: "/v1ga",
- rightValignValueName: "/v2ga",
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [6, 7],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs1",
- leftWidthValueName: "/w11a",
- rightWidthValueName: "/w21a",
- leftMarginValueName: "/m11a",
- rightMarginValueName: "/m21a",
- leftValignValueName: "/v11a",
- rightValignValueName: "/v21a",
- });
- checkTwoColumnSbs({
- specifiedWidths: [22, 25],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs2",
- leftWidthValueName: "/w12a",
- rightWidthValueName: "/w22a",
- leftMarginValueName: "/m12a",
- rightMarginValueName: "/m22a",
- leftValignValueName: "/v12a",
- rightValignValueName: "/v22a",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs1"].stateValues.essentialWidths,
- ).eqls([null, null]);
- expect(
- stateVariables["/sbs1"].stateValues.essentialMargins,
- ).eqls([6, 7]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialWidths,
- ).eqls([22, 25]);
- expect(
- stateVariables["/sbs2"].stateValues.essentialMargins,
- ).eqls([null, null]);
- });
- });
- });
-
- it("copy sbsGroup and overwrite parameters", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbsg\\/sbs1"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- specifiedWidths: [25, 15],
- specifiedMargins: [5, 10],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg",
- isSbsGroup: true,
- ignoreInitialDOMChecks: true,
- });
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [5, 10],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbsg/sbs1",
- ignoreInitialDOMChecks: true,
- });
- checkTwoColumnSbs({
- specifiedWidths: [25, 15],
- specifiedMargins: [8, 8],
- specifiedValigns: ["middle", "top"],
- sbsWidth,
- sbsName: "/sbsg/sbs2",
- ignoreInitialDOMChecks: true,
- });
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 10],
- specifiedMargins: [1, 3],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbsg2",
- isSbsGroup: true,
- ignoreInitialDOMChecks: true,
- });
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [1, 3],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbsg2/sbs1",
- ignoreInitialDOMChecks: true,
- });
- checkTwoColumnSbs({
- specifiedWidths: [30, 10],
- specifiedMargins: [8, 8],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbsg2/sbs2",
- ignoreInitialDOMChecks: true,
- });
-
- checkTwoColumnSbs({
- specifiedWidths: [7, null],
- specifiedMargins: [1, 3],
- specifiedValigns: ["top", "bottom"],
- sbsWidth,
- sbsName: "/sbsg3",
- isSbsGroup: true,
- ignoreInitialDOMChecks: true,
- });
-
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [1, 3],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbsg3/sbs1",
- ignoreInitialDOMChecks: true,
- });
- checkTwoColumnSbs({
- specifiedWidths: [7, null],
- specifiedMargins: [8, 8],
- specifiedValigns: ["top", "bottom"],
- sbsWidth,
- sbsName: "/sbsg3/sbs2",
- ignoreInitialDOMChecks: true,
- });
- });
- });
-
- it("sbsGroup absolute measurements turned to absolute with warning", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- Hello
- Hello
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/_sbsgroup1"].stateValues.marginsAbsolute,
- ).eq(false);
- expect(stateVariables["/_sbsgroup1"].stateValues.widthsAbsolute).eq(
- false,
- );
- });
-
- cy.window().then(async (win) => {
- let errorWarnings = await win.returnErrorWarnings1();
-
- expect(errorWarnings.errors.length).eq(0);
- expect(errorWarnings.warnings.length).eq(2);
-
- expect(errorWarnings.warnings[0].message).contain(
- ` is not implemented for absolute measurements. Setting widths to relative`,
- );
- expect(errorWarnings.warnings[0].level).eq(1);
- expect(errorWarnings.warnings[0].doenetMLrange.lineBegin).eq(3);
- expect(errorWarnings.warnings[0].doenetMLrange.charBegin).eq(5);
- expect(errorWarnings.warnings[0].doenetMLrange.lineEnd).eq(8);
- expect(errorWarnings.warnings[0].doenetMLrange.charEnd).eq(15);
-
- expect(errorWarnings.warnings[1].message).contain(
- ` is not implemented for absolute measurements. Setting margins to relative`,
- );
- expect(errorWarnings.warnings[1].level).eq(1);
- expect(errorWarnings.warnings[1].doenetMLrange.lineBegin).eq(3);
- expect(errorWarnings.warnings[1].doenetMLrange.charBegin).eq(5);
- expect(errorWarnings.warnings[1].doenetMLrange.lineEnd).eq(8);
- expect(errorWarnings.warnings[1].doenetMLrange.charEnd).eq(15);
- });
- });
-
- it("sideBySide with a stack", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
- Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
- Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-
- Fringilla ut morbi tincidunt augue interdum velit euismod in. Mattis molestie a iaculis at erat. Pharetra magna ac placerat vestibulum lectus mauris ultrices. Nisl rhoncus mattis rhoncus urna neque viverra justo nec ultrices. Congue quisque egestas diam in arcu cursus euismod quis viverra. Et leo duis ut diam quam nulla porttitor massa. Dolor sit amet consectetur adipiscing elit. Ullamcorper malesuada proin libero nunc consequat interdum varius. Nunc lobortis mattis aliquam faucibus purus. Amet commodo nulla facilisi nullam vehicula. Massa placerat duis ultricies lacus sed turpis.
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- specifiedWidths: [49, 49],
- specifiedMargins: [0, 0],
- sbsWidth,
- sbsName: "/sbs",
- ignoreInitialDOMChecks: true,
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
- });
- });
-
- it("sideBySide with singular relative arguments from inputs, two panels", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Width:
- Margin:
- Valign:
-
-
-
-
-
-
- Widths:
-
-
-
-
- Margins:
-
-
-
-
- Valigns:
-
-
-
-
-
- $w1.value{assignNames="w1a"}
- $w2.value{assignNames="w2a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
- $v2.value{assignNames="v2a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- specifiedWidths: [20, 20],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(`change first width, second matches`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}30{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 30],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second width, first matches, rescaling`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}80{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [80, 80],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change defining width`);
- cy.get(cesc("#\\/w") + " textarea").type(
- "{end}{backspace}{backspace}25{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [25, 25],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid defining width treated as null`);
- cy.get(cesc("#\\/w") + " textarea").type(
- "{end}{backspace}{backspace}x{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [null, null],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`reset width by changing second width`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}10{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [10, 10],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`decrease defining margin`);
- cy.get(cesc("#\\/m") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [5, 5],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid defining margin treated as null`);
- cy.get(cesc("#\\/m") + " textarea").type(
- "{end}{backspace}{backspace}none{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [null, null],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`reset from left margin, right margin matches`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{end}{backspace}{backspace}15{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [15, 15],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increase right margin, left margin matches, rescaling`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}45{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [45, 45],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change first valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("top{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [45, 45],
- specifiedValigns: ["top", "top"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change defining valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [45, 45],
- specifiedValigns: ["bottom", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second valign`);
- cy.get(cesc("#\\/v2_input")).clear().type("middle{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [45, 45],
- specifiedValigns: ["middle", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid defining valign becomes top`);
- cy.get(cesc("#\\/v_input")).clear().type("invalid{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [45, 45],
- specifiedValigns: [null, null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`reset from first valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [10, 10],
- specifiedMargins: [45, 45],
- specifiedValigns: ["bottom", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-
- it("sideBySide with plural relative arguments from inputs, two panels", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Defining widths:
-
-
-
- Defining margins:
-
-
-
- Defining valigns:
-
-
-
-
-
-
-
-
-
- Widths:
-
-
-
-
- Margins:
-
-
-
-
- Valigns:
-
-
-
-
-
- $w1.value{assignNames="w1a"}
- $w2.value{assignNames="w2a"}
- $m1.value{assignNames="m1a"}
- $m2.value{assignNames="m2a"}
- $v1.value{assignNames="v1a"}
- $v2.value{assignNames="v2a"}
-
-
-
- $bi.value{assignNames="b"}
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sbs"))
- .invoke("width")
- .then((sbsWidth) => {
- checkTwoColumnSbs({
- specifiedWidths: [20, 10],
- specifiedMargins: [10, 20],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables["/sbs"].stateValues.absoluteMeasurements,
- ).eq(false);
- });
-
- cy.log(`change first width`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}30{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 10],
- specifiedMargins: [10, 20],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second defining width, rescaling`);
- cy.get(cesc("#\\/dw2") + " textarea").type(
- "{end}{backspace}{backspace}110{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 110],
- specifiedMargins: [10, 20],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(
- `make second defining width be invalid, treated as null`,
- );
- cy.get(cesc("#\\/dw2") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}hello{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, null],
- specifiedMargins: [10, 20],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`make first defining width be invalid, treated as null`);
- cy.get(cesc("#\\/dw1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}bye{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [null, null],
- specifiedMargins: [10, 20],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`reset second width`);
- cy.get(cesc("#\\/w2") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [null, 5],
- specifiedMargins: [10, 20],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`reset first width`);
- cy.get(cesc("#\\/w1") + " textarea").type(
- "{end}{backspace}{backspace}30{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [10, 20],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`decrease right margin`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{end}{backspace}{backspace}5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [10, 5],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`increase left defining margin, rescaling`);
- cy.get(cesc("#\\/dm1") + " textarea").type(
- "{end}{backspace}{backspace}77.5{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [77.5, 5],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`decrease left margin`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}7{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [7, 5],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid left defining margin, treated as null`);
- cy.get(cesc("#\\/dm1") + " textarea").type(
- "{end}{backspace}{backspace}hello{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [null, 5],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid right defining margin, treated as null`);
- cy.get(cesc("#\\/dm2") + " textarea").type(
- "{end}{backspace}{backspace}bye{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [null, null],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`reset left margin`);
- cy.get(cesc("#\\/m1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}12{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [12, null],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`reset right margin`);
- cy.get(cesc("#\\/m2") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}8{enter}",
- { force: true },
- );
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [12, 8],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change first valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("top{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [12, 8],
- specifiedValigns: ["top", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second valign`);
- cy.get(cesc("#\\/v2_input")).clear().type("middle{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [12, 8],
- specifiedValigns: ["top", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change first defining valign`);
- cy.get(cesc("#\\/dv1_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [12, 8],
- specifiedValigns: ["bottom", "middle"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`change second defining valign`);
- cy.get(cesc("#\\/dv2_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [12, 8],
- specifiedValigns: ["bottom", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid second defining valign treated as null`);
- cy.get(cesc("#\\/dv2_input")).clear().type("banana{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [12, 8],
- specifiedValigns: ["bottom", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`invalid first defining valign treated as null`);
- cy.get(cesc("#\\/dv1_input")).clear().type("apple{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [12, 8],
- specifiedValigns: [null, null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`reset first valign`);
- cy.get(cesc("#\\/v1_input")).clear().type("middle{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [12, 8],
- specifiedValigns: ["middle", null],
- sbsWidth,
- sbsName: "/sbs",
- });
-
- cy.log(`reset second valign`);
- cy.get(cesc("#\\/v2_input")).clear().type("bottom{enter}");
-
- checkTwoColumnSbs({
- specifiedWidths: [30, 5],
- specifiedMargins: [12, 8],
- specifiedValigns: ["middle", "bottom"],
- sbsWidth,
- sbsName: "/sbs",
- });
- });
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/slider.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/slider.cy.js
index 514763ef0..25339aa5d 100644
--- a/packages/test-cypress/cypress/e2e/tagSpecific/slider.cy.js
+++ b/packages/test-cypress/cypress/e2e/tagSpecific/slider.cy.js
@@ -346,564 +346,6 @@ describe("Slider Tag Tests", function () {
});
});
- it("change step to 0.1", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Value: $s
- Change value:
- `,
- },
- "*",
- );
- });
-
- let numberToPx = (x) => 20 + 30 * x;
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sv")).should("have.text", "0");
-
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(0);
- expect(stateVariables["/sv"].stateValues.value).eq(0);
- expect(stateVariables["/mi"].stateValues.value).eq(0);
- });
-
- cy.log("move handle to 1");
- cy.get(cesc("#\\/s-handle"))
- .trigger("mousedown")
- .trigger("mousemove", { clientX: numberToPx(1), clientY: 0 })
- .trigger("mouseup");
-
- cy.get(cesc("#\\/sv")).should("have.text", "1");
- cy.get(cesc("#\\/mi") + " .mq-editable-field").should("have.text", "1");
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(1);
- expect(stateVariables["/sv"].stateValues.value).eq(1);
- expect(stateVariables["/mi"].stateValues.value).eq(1);
- });
-
- cy.log("move handle to 9.4");
- cy.get(cesc("#\\/s-handle"))
- .trigger("mousedown")
- .trigger("mousemove", { clientX: numberToPx(9.4), clientY: 0 })
- .trigger("mouseup");
-
- cy.get(cesc("#\\/sv")).should("have.text", "9.4");
- cy.get(cesc("#\\/mi") + " .mq-editable-field").should(
- "have.text",
- "9.4",
- );
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "9.4",
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(9.4);
- expect(stateVariables["/sv"].stateValues.value).eq(9.4);
- expect(stateVariables["/mi"].stateValues.value).eq(9.4);
- });
-
- cy.log("enter 2.5");
-
- cy.get(cesc("#\\/mi") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}2.5{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/sv")).should("have.text", "2.5");
- // cy.get(cesc("#\\/mi") + " .mq-editable-field").should('have.text', '2.5')
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "2.5",
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(2.5);
- expect(stateVariables["/sv"].stateValues.value).eq(2.5);
- expect(stateVariables["/mi"].stateValues.value).eq(2.5);
- });
- });
-
- it("from 100 to 200", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Value: $s
- Change value:
- `,
- },
- "*",
- );
- });
-
- let numberToPx = (x) => 20 + (30 * (x - 100)) / 10;
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sv")).should("have.text", "100");
-
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "100",
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(100);
- expect(stateVariables["/sv"].stateValues.value).eq(100);
- expect(stateVariables["/mi"].stateValues.value).eq(100);
- });
-
- cy.log("move handle to 137");
- cy.get(cesc("#\\/s-handle"))
- .trigger("mousedown")
- .trigger("mousemove", { clientX: numberToPx(137), clientY: 0 })
- .trigger("mouseup");
-
- cy.get(cesc("#\\/sv")).should("have.text", "137");
- cy.get(cesc("#\\/mi") + " .mq-editable-field").should(
- "have.text",
- "137",
- );
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "137",
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(137);
- expect(stateVariables["/sv"].stateValues.value).eq(137);
- expect(stateVariables["/mi"].stateValues.value).eq(137);
- });
-
- cy.log("move handle to 199");
- cy.get(cesc("#\\/s-handle"))
- .trigger("mousedown")
- .trigger("mousemove", { clientX: numberToPx(199), clientY: 0 })
- .trigger("mouseup");
-
- cy.get(cesc("#\\/sv")).should("have.text", "199");
- cy.get(cesc("#\\/mi") + " .mq-editable-field").should(
- "have.text",
- "199",
- );
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "199",
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(199);
- expect(stateVariables["/sv"].stateValues.value).eq(199);
- expect(stateVariables["/mi"].stateValues.value).eq(199);
- });
-
- cy.log("enter 2.5");
-
- cy.get(cesc("#\\/mi") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}2.5{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/sv")).should("have.text", "100");
- // cy.get(cesc("#\\/mi") + " .mq-editable-field").should('have.text', '100')
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "100",
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(100);
- expect(stateVariables["/sv"].stateValues.value).eq(100);
- expect(stateVariables["/mi"].stateValues.value).eq(100);
- });
-
- cy.log("enter 357");
-
- cy.get(cesc("#\\/mi") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}357{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/sv")).should("have.text", "200");
- // cy.get(cesc("#\\/mi") + " .mq-editable-field").should('have.text', '200')
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "200",
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(200);
- expect(stateVariables["/sv"].stateValues.value).eq(200);
- expect(stateVariables["/mi"].stateValues.value).eq(200);
- });
-
- cy.log("enter 171");
-
- cy.get(cesc("#\\/mi") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}171{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/sv")).should("have.text", "171");
- // cy.get(cesc("#\\/mi") + " .mq-editable-field").should('have.text', '171')
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "171",
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(171);
- expect(stateVariables["/sv"].stateValues.value).eq(171);
- expect(stateVariables["/mi"].stateValues.value).eq(171);
- });
- });
-
- it("initial value", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Value: $s
- Change value:
- `,
- },
- "*",
- );
- });
-
- let numberToPx = (x) => 20 + 30 * x;
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sv")).should("have.text", "7");
-
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("7");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(7);
- expect(stateVariables["/sv"].stateValues.value).eq(7);
- expect(stateVariables["/mi"].stateValues.value).eq(7);
- });
-
- cy.log("move handle to 1");
- cy.get(cesc("#\\/s-handle"))
- .trigger("mousedown")
- .trigger("mousemove", { clientX: numberToPx(1), clientY: 0 })
- .trigger("mouseup");
-
- cy.get(cesc("#\\/sv")).should("have.text", "1");
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(1);
- expect(stateVariables["/sv"].stateValues.value).eq(1);
- expect(stateVariables["/mi"].stateValues.value).eq(1);
- });
-
- cy.log("enter 4.2");
-
- cy.get(cesc("#\\/mi") + " textarea").type(
- "{end}{backspace}4.2{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/sv")).should("have.text", "4");
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(4);
- expect(stateVariables["/sv"].stateValues.value).eq(4);
- expect(stateVariables["/mi"].stateValues.value).eq(4);
- });
- });
-
- it("bind value to", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Original value:
-
- Value: $s
- Change value:
- `,
- },
- "*",
- );
- });
-
- let numberToPx = (x) => 20 + 30 * x;
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sv")).should("have.text", "0");
- cy.get(cesc("#\\/mi0") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("");
- });
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(0);
- expect(stateVariables["/sv"].stateValues.value).eq(0);
- expect(stateVariables["/mi0"].stateValues.value).eq("\uff3f");
- expect(stateVariables["/mi"].stateValues.value).eq(0);
- });
-
- cy.log("move handle to 1");
- cy.get(cesc("#\\/s-handle"))
- .trigger("mousedown")
- .trigger("mousemove", { clientX: numberToPx(1), clientY: 0 })
- .trigger("mouseup");
-
- cy.get(cesc("#\\/sv")).should("have.text", "1");
- cy.get(cesc("#\\/mi0") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(1);
- expect(stateVariables["/sv"].stateValues.value).eq(1);
- expect(stateVariables["/mi0"].stateValues.value).eq(1);
- expect(stateVariables["/mi"].stateValues.value).eq(1);
- });
-
- cy.log("enter 4.2 in post math input");
-
- cy.get(cesc("#\\/mi") + " textarea").type(
- "{end}{backspace}4.2{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/sv")).should("have.text", "4");
- cy.get(cesc("#\\/mi0") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(4);
- expect(stateVariables["/sv"].stateValues.value).eq(4);
- expect(stateVariables["/mi0"].stateValues.value).eq(4);
- expect(stateVariables["/mi"].stateValues.value).eq(4);
- });
-
- cy.log("enter 8.7 in pre math input");
-
- cy.get(cesc("#\\/mi0") + " textarea").type(
- "{end}{backspace}8.7{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/sv")).should("have.text", "9");
- cy.get(cesc("#\\/mi0") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "8.7",
- );
- });
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("9");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(9);
- expect(stateVariables["/sv"].stateValues.value).eq(9);
- expect(stateVariables["/mi0"].stateValues.value).eq(8.7);
- expect(stateVariables["/mi"].stateValues.value).eq(9);
- });
-
- cy.log("enter x in pre math input");
-
- cy.get(cesc("#\\/mi0") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}x{enter}",
- { force: true },
- );
-
- cy.get(cesc("#\\/sv")).should("have.text", "0");
- cy.get(cesc("#\\/mi0") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("x");
- });
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("0");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(0);
- expect(stateVariables["/sv"].stateValues.value).eq(0);
- expect(stateVariables["/mi0"].stateValues.value).eq("x");
- expect(stateVariables["/mi"].stateValues.value).eq(0);
- });
-
- cy.log("move handle to 5");
- cy.get(cesc("#\\/s-handle"))
- .trigger("mousedown")
- .trigger("mousemove", { clientX: numberToPx(5), clientY: 0 })
- .trigger("mouseup");
-
- cy.get(cesc("#\\/sv")).should("have.text", "5");
- cy.get(cesc("#\\/mi0") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("5");
- });
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("5");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(5);
- expect(stateVariables["/sv"].stateValues.value).eq(5);
- expect(stateVariables["/mi0"].stateValues.value).eq(5);
- expect(stateVariables["/mi"].stateValues.value).eq(5);
- });
-
- cy.log("enter 999 in pre math input");
-
- cy.get(cesc("#\\/mi0") + " textarea").type(
- "{end}{backspace}999{enter}",
- {
- force: true,
- },
- );
-
- cy.get(cesc("#\\/sv")).should("have.text", "10");
- cy.get(cesc("#\\/mi0") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "999",
- );
- });
- cy.get(cesc("#\\/mi") + " .mq-editable-field")
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- "10",
- );
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/s"].stateValues.value).eq(10);
- expect(stateVariables["/sv"].stateValues.value).eq(10);
- expect(stateVariables["/mi0"].stateValues.value).eq(999);
- expect(stateVariables["/mi"].stateValues.value).eq(10);
- });
- });
-
it("label with math", () => {
cy.window().then(async (win) => {
win.postMessage(
@@ -957,59 +399,4 @@ describe("Slider Tag Tests", function () {
expect(stateVariables["/sv"].stateValues.value).eq(1);
});
});
-
- it("label is name", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- Value: $mySlider
- `,
- },
- "*",
- );
- });
-
- let numberToPx = (x) => 20 + 30 * x;
- let numberToPx2 = (x) => 30 * x;
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/sv")).should("have.text", "0");
-
- cy.get(cesc("#\\/mySlider-label")).should("have.text", "my slider = 0");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/mySlider"].stateValues.value).eq(0);
- expect(stateVariables["/mySlider"].stateValues.label).eq(
- "my slider",
- );
- expect(stateVariables["/sv"].stateValues.value).eq(0);
- });
-
- cy.log("drag handle to 1");
- cy.get(cesc("#\\/mySlider-handle"))
- .trigger("mousedown")
- .trigger("mousemove", { clientX: numberToPx(1), clientY: 0 })
- .trigger("mouseup");
-
- cy.get(cesc("#\\/sv")).should("have.text", "1");
-
- cy.get(cesc("#\\/mySlider-label")).should(
- "contain.text",
- "my slider = 1",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/mySlider"].stateValues.value).eq(1);
- expect(stateVariables["/mySlider"].stateValues.label).eq(
- "my slider",
- );
- expect(stateVariables["/sv"].stateValues.value).eq(1);
- });
- });
});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/solution.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/solution.cy.js
deleted file mode 100644
index 0856bb889..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/solution.cy.js
+++ /dev/null
@@ -1,109 +0,0 @@
-import { cesc } from "@doenet/utils";
-
-describe("Solution Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("solution isn't created before opening", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
- This is the text of the solution.
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/solutionText")).should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solutionText"]).be.undefined;
- });
-
- cy.get(cesc("#\\/sol_button")).click();
-
- cy.get(cesc("#\\/solutionText")).should(
- "have.text",
- "This is the text of the solution.",
- );
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solutionText"].stateValues.text).eq(
- "This is the text of the solution.",
- );
- });
- });
-
- it("Can open solution in read only mode", () => {
- cy.get("#testRunner_toggleControls").click();
- cy.get("#testRunner_readOnly").click();
- cy.wait(100);
- cy.get("#testRunner_toggleControls").click();
-
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- Hello
- Content
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/solution1_button")).should("contain.text", "Solution");
-
- cy.get(cesc("#\\/_title1")).should("not.exist");
- cy.get(cesc("#\\/_p1")).should("not.exist");
- cy.get(cesc("#\\/ti_input")).should("be.disabled");
-
- cy.get(cesc("#\\/solution1_button")).click();
- cy.get(cesc("#\\/_title1")).should("have.text", "Hello");
- cy.get(cesc("#\\/_p1")).should("have.text", "Content");
-
- cy.get(cesc("#\\/solution1_button")).click();
- cy.get(cesc("#\\/_title1")).should("not.exist");
- cy.get(cesc("#\\/_p1")).should("not.exist");
- });
-
- it("empty solution", () => {
- // an empty solution was creating an infinite loop
- // as the zero replacements were always treated as uninitialized
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/solOpen")).should("have.text", "false");
-
- cy.get(cesc("#\\/sol_button")).click();
- cy.get(cesc("#\\/solOpen")).should("have.text", "true");
-
- cy.get(cesc("#\\/sol_button")).click();
- cy.get(cesc("#\\/solOpen")).should("have.text", "false");
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/solveequations.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/solveequations.cy.js
deleted file mode 100644
index 78bd0ae49..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/solveequations.cy.js
+++ /dev/null
@@ -1,1061 +0,0 @@
-import { cesc } from "@doenet/utils";
-
-describe("SolveEquations Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it.skip("solve single equation", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- variable:
- equation:
- $equation
- Number of solutions: $solve.numSolutions{assignNames="num"}
- Solutions:
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("i");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("−i");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([
- "i",
- ["-", "i"],
- ]);
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{end}{leftArrow}{leftArrow}{backspace}a{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("√−a");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("−√−a");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([
- ["apply", "sqrt", ["-", "a"]],
- ["-", ["apply", "sqrt", ["-", "a"]]],
- ]);
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{backspace}{backspace}-a^2{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("a");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("−a");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([
- "a",
- ["-", "a"],
- ]);
- });
-
- cy.get(cesc("#\\/var") + " textarea").type("{end}{backspace}a{enter}", {
- force: true,
- delay: 5,
- });
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("x");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("−x");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([
- "x",
- ["-", "x"],
- ]);
- });
-
- cy.get(cesc("#\\/var") + " textarea").type(
- "{end}{backspace}x_1{enter}",
- {
- force: true,
- delay: 5,
- },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 0);
-
- cy.get(cesc("#\\/sols")).find(".mjx-math").should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(0);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([]);
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}x_1{rightArrow}- 0.1exp(x_1{rightArrow})=0{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.111833");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("3.57715");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- 0.111833,
- 1e-6,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- 3.57715,
- 1e-5,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}ab=0{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 0);
-
- cy.get(cesc("#\\/sols")).find(".mjx-math").should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(0);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([]);
- });
-
- cy.get(cesc("#\\/var") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}b{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 1);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(1);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([0]);
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}sin(10b) = b^3{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 7);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("−0.870457");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("−0.657084");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(2)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("−0.311147");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(3)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(4)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.311147");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(5)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.657084");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(6)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.870457");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(7);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- -0.870457,
- 1e-6,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- -0.657084,
- 1e-6,
- );
- expect(stateVariables["/solve"].stateValues.solutions[2]).closeTo(
- -0.311147,
- 1e-6,
- );
- expect(stateVariables["/solve"].stateValues.solutions[3]).closeTo(
- 0,
- 1e-6,
- );
- expect(stateVariables["/solve"].stateValues.solutions[4]).closeTo(
- 0.311147,
- 1e-6,
- );
- expect(stateVariables["/solve"].stateValues.solutions[5]).closeTo(
- 0.657084,
- 1e-6,
- );
- expect(stateVariables["/solve"].stateValues.solutions[6]).closeTo(
- 0.870457,
- 1e-6,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}b^2{rightArrow}+0.1b=0{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("−0.1");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- -0.1,
- 1e-6,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- 0,
- 1e-6,
- );
- });
- });
-
- it("solve single equation, minvar and maxvar", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- variable:
- minvar:
- maxvar:
- equation:
- $equation
- Number of solutions: $solve.numSolutions{assignNames="num"}
- Solutions:
-
- $equation.value{assignNames="equation2"}
- $var.value{assignNames="var2"}
- $maxvar.value{assignNames="maxvar2"}
- $minvar.value{assignNames="minvar2"}
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/num")).should("have.text", 0);
-
- cy.get(cesc("#\\/sols")).find(".mjx-math").should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(0);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([]);
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{end}{leftArrow}{leftArrow}{backspace}{backspace}-a{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/equation2")).should("contain.text", "a");
-
- cy.get(cesc("#\\/num")).should("have.text", 0);
-
- cy.get(cesc("#\\/sols")).find(".mjx-math").should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(0);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([]);
- });
-
- cy.get(cesc("#\\/var") + " textarea").type(
- "{end}{backspace}x_1{enter}",
- {
- force: true,
- delay: 5,
- },
- );
- cy.get(cesc("#\\/var2")).should("contain.text", "x1");
-
- cy.get(cesc("#\\/num")).should("have.text", 0);
-
- cy.get(cesc("#\\/sols")).find(".mjx-math").should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(0);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([]);
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}x_1{rightArrow}- 0.1exp(x_1{rightArrow})=0{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 1);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0.111833");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(1);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- 0.111833,
- 1e-6,
- );
- });
-
- cy.get(cesc("#\\/maxvar") + " textarea").type(
- "{end}{backspace}100{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(Number(text)).closeTo(0.111833, 1e-5);
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(Number(text)).closeTo(3.57715, 1e-4);
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- 0.111833,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- 3.57715,
- 1e-4,
- );
- });
-
- cy.get(cesc("#\\/minvar") + " textarea").type(
- "{end}{backspace}{backspace}1{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 1);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(Number(text)).closeTo(3.57715, 1e-4);
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(1);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- 3.57715,
- 1e-4,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}ab=0{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/var") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}b{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/var2")).should("contain.text", "b");
-
- cy.get(cesc("#\\/num")).should("have.text", 0);
-
- cy.get(cesc("#\\/sols")).find(".mjx-math").should("not.exist");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(0);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([]);
- });
-
- cy.get(cesc("#\\/minvar") + " textarea").type(
- "{end}{backspace}{backspace}0{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 1);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(1);
- expect(stateVariables["/solve"].stateValues.solutions).eqls([0]);
- });
-
- cy.get(cesc("#\\/maxvar") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}10{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}sin(10b) = b^3{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/equation2")).should("contain.text", "sin(10b)");
-
- cy.get(cesc("#\\/num")).should("have.text", 4);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(Number(text)).closeTo(0.311147, 1e-5);
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(2)
- .invoke("text")
- .then((text) => {
- expect(Number(text)).closeTo(0.657084, 1e-5);
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(3)
- .invoke("text")
- .then((text) => {
- expect(Number(text)).closeTo(0.870457, 1e-5);
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(4);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- 0,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- 0.311147,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[2]).closeTo(
- 0.657084,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[3]).closeTo(
- 0.870457,
- 1e-5,
- );
- });
-
- cy.get(cesc("#\\/minvar") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}-10{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 7);
-
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(Number(text.replace(/−/, "-"))).closeTo(-0.870457, 1e-5);
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(1)
- .invoke("text")
- .then((text) => {
- expect(Number(text.replace(/−/, "-"))).closeTo(-0.657084, 1e-5);
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(2)
- .invoke("text")
- .then((text) => {
- expect(Number(text.replace(/−/, "-"))).closeTo(-0.311147, 1e-5);
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(3)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("0");
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(4)
- .invoke("text")
- .then((text) => {
- expect(Number(text)).closeTo(0.311147, 1e-5);
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(5)
- .invoke("text")
- .then((text) => {
- expect(Number(text)).closeTo(0.657084, 1e-5);
- });
- cy.get(cesc("#\\/sols"))
- .find(".mjx-math")
- .eq(6)
- .invoke("text")
- .then((text) => {
- expect(Number(text)).closeTo(0.870457, 1e-5);
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(7);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- -0.870457,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- -0.657084,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[2]).closeTo(
- -0.311147,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[3]).closeTo(
- 0,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[4]).closeTo(
- 0.311147,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[5]).closeTo(
- 0.657084,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[6]).closeTo(
- 0.870457,
- 1e-5,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}sin(pi b) = 0{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/minvar") + " textarea").type("{end}.1{enter}", {
- force: true,
- delay: 5,
- });
- cy.get(cesc("#\\/maxvar") + " textarea").type("{end}.1{enter}", {
- force: true,
- delay: 5,
- });
- cy.get(cesc("#\\/maxvar2")).should("contain.text", ".1");
-
- cy.get(cesc("#\\/num")).should("have.text", 21);
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(21);
- for (let i = 0; i < 21; i++) {
- expect(
- stateVariables["/solve"].stateValues.solutions[i],
- ).closeTo(i - 10, 1e-3);
- }
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}b^2{rightArrow}-0.001b = 0{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/equation2")).should("contain.text", "0.001b=0");
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- 0,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- 0.001,
- 1e-5,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}(b+0.03)(b+0.0301) = 0{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/equation2")).should(
- "contain.text",
- "(b+0.03)(b+0.0301)=0",
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- -0.0301,
- 1e-5,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- -0.03,
- 1e-5,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{end}{backspace}-0.1{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/equation2")).should("contain.text", "=−0.1");
-
- cy.get(cesc("#\\/num")).should("have.text", 0);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(0);
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}43.241(b+4.52352)(b+4.52365)(b-8.58230)(b-8.58263) = 0{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/equation2")).should(
- "contain.text",
- "43.241(b+4.52352)(b+4.52365)",
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 4);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(4);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- -4.52365,
- 1e-4,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- -4.52352,
- 1e-4,
- );
- expect(stateVariables["/solve"].stateValues.solutions[2]).closeTo(
- 8.5823,
- 1e-4,
- );
- expect(stateVariables["/solve"].stateValues.solutions[3]).closeTo(
- 8.58263,
- 1e-4,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{home}exp({end}{backspace}{backspace}{backspace})=1{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/equation2")).should("contain.text", "=1");
-
- cy.get(cesc("#\\/num")).should("have.text", 4);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(4);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- -4.52365,
- 1e-4,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- -4.52352,
- 1e-4,
- );
- expect(stateVariables["/solve"].stateValues.solutions[2]).closeTo(
- 8.5823,
- 1e-4,
- );
- expect(stateVariables["/solve"].stateValues.solutions[3]).closeTo(
- 8.58263,
- 1e-4,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}cos(pi b) + 1=0{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 10);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(10);
- for (let i = 0; i < 10; i++) {
- expect(
- stateVariables["/solve"].stateValues.solutions[i],
- ).closeTo(2 * i - 9, 1e-3);
- }
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}cos(pib) = 1{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 11);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(11);
- for (let i = 0; i < 11; i++) {
- expect(
- stateVariables["/solve"].stateValues.solutions[i],
- ).closeTo(2 * i - 10, 1e-3);
- }
- });
-
- cy.get(cesc("#\\/minvar") + " textarea").type(
- "{end}{backspace}{backspace}{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/minvar2")).should("not.contain.text", ".1");
-
- cy.get(cesc("#\\/num")).should("have.text", 11);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(11);
- for (let i = 0; i < 11; i++) {
- expect(
- stateVariables["/solve"].stateValues.solutions[i],
- ).closeTo(2 * i - 10, 1e-3);
- }
- });
-
- cy.get(cesc("#\\/maxvar") + " textarea").type(
- "{end}{backspace}{backspace}{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/maxvar2")).should("not.contain.text", ".1");
-
- cy.get(cesc("#\\/num")).should("have.text", 11);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(11);
- for (let i = 0; i < 11; i++) {
- expect(
- stateVariables["/solve"].stateValues.solutions[i],
- ).closeTo(2 * i - 10, 1e-3);
- }
- });
-
- cy.get(cesc("#\\/minvar") + " textarea").type("{end}.0001{enter}", {
- force: true,
- delay: 5,
- });
- cy.get(cesc("#\\/minvar2")).should("contain.text", ".0001");
-
- cy.get(cesc("#\\/num")).should("have.text", 11);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(11);
- for (let i = 0; i < 11; i++) {
- expect(
- stateVariables["/solve"].stateValues.solutions[i],
- ).closeTo(2 * i - 10, 1e-3);
- }
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}sqrtb-pi{rightArrow}=0{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 1);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(1);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- Math.PI,
- 1e-3,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}sqrtb^2{rightArrow}-pi^2{rightArrow}{rightArrow}=0{enter}",
- { force: true, delay: 5 },
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- -Math.PI,
- 1e-3,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- Math.PI,
- 1e-3,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}sqrtpi^2{rightArrow}-b^2{rightArrow}{rightArrow}=0{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/equation2")).should("contain.text", "√π2−b2=0");
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- -Math.PI,
- 1e-3,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- Math.PI,
- 1e-3,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}10000000000sqrtpi^2{rightArrow}-b^2{rightArrow}{rightArrow}=0{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/equation2")).should(
- "contain.text",
- "10000000000√π2−b2=0",
- );
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- -Math.PI,
- 1e-3,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- Math.PI,
- 1e-3,
- );
- });
-
- cy.get(cesc("#\\/equation") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}0.00000000000000000001sqrtpi^2{rightArrow}-b^2{rightArrow}{rightArrow}=0{enter}",
- { force: true, delay: 5 },
- );
- cy.get(cesc("#\\/equation2")).should("contain.text", "1⋅10−20√π2−b2=0");
-
- cy.get(cesc("#\\/num")).should("have.text", 2);
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/solve"].stateValues.numSolutions).eq(2);
- expect(stateVariables["/solve"].stateValues.solutions[0]).closeTo(
- -Math.PI,
- 1e-3,
- );
- expect(stateVariables["/solve"].stateValues.solutions[1]).closeTo(
- Math.PI,
- 1e-3,
- );
- });
- });
-
- it("handle bad equation", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- x_(2t)=1
- Number of solutions:
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/num")).should("have.text", 0);
-
- cy.window().then(async (win) => {
- let errorWarnings = await win.returnErrorWarnings1();
-
- expect(errorWarnings.errors.length).eq(0);
- expect(errorWarnings.warnings.length).eq(1);
-
- expect(errorWarnings.warnings[0].message).contain(
- `Cannot solve equation`,
- );
- expect(errorWarnings.warnings[0].level).eq(1);
- expect(errorWarnings.warnings[0].doenetMLrange.lineBegin).eq(2);
- expect(errorWarnings.warnings[0].doenetMLrange.charBegin).eq(3);
- expect(errorWarnings.warnings[0].doenetMLrange.lineEnd).eq(2);
- expect(errorWarnings.warnings[0].doenetMLrange.charEnd).eq(56);
- });
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/spreadsheet.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/spreadsheet.cy.js
index 3d80bd515..600f70178 100644
--- a/packages/test-cypress/cypress/e2e/tagSpecific/spreadsheet.cy.js
+++ b/packages/test-cypress/cypress/e2e/tagSpecific/spreadsheet.cy.js
@@ -33,18 +33,42 @@ describe("Spreadsheet Tag Tests", function () {
}
};
- it("empty spreadsheet", () => {
+ it("copy extracted points from spreadsheet", () => {
cy.window().then(async (win) => {
win.postMessage(
{
doenetML: `
-
- a
-
- $_spreadsheet1.cellA1{assignNames="A1a"}
- $_spreadsheet1.cellB3{assignNames="B3a"}
- $_spreadsheet1.cellD2{assignNames="D2a"}
-
+
+
+
+
+
+
+ (1,2) |
+ hello |
+ 5 |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
`,
},
"*",
@@ -52,5550 +76,588 @@ describe("Spreadsheet Tag Tests", function () {
});
// to wait for page to load
- cy.get(cesc("#\\/_text1")).should("have.text", "a");
-
- cy.log("check have spreadsheet cells");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- Array.isArray(
- stateVariables["/_spreadsheet1"].stateValues.cells,
- ),
- ).eq(true);
- });
- cy.log("enter text in B3");
- enterSpreadsheetText({ row: 3, column: 2, text: "hello" });
- cy.get(cesc("#\\/B3a")).should("have.text", "hello");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "hello",
- );
- });
-
- cy.log("delete text in B3");
- enterSpreadsheetText({ row: 3, column: 2, clear: true });
- cy.get(cesc("#\\/B3a")).should("have.text", "");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "",
- );
- });
-
- cy.log("enter text in A1");
- enterSpreadsheetText({ row: 1, column: 1, text: "first" });
- cy.get(cesc("#\\/A1a")).should("have.text", "first");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "first",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "",
- );
- });
+ cy.get(cesc("#\\/t1")).should("have.text", "(1,2)");
- cy.log("enter text in D2");
- enterSpreadsheetText({ row: 2, column: 4, text: "right" });
- cy.get(cesc("#\\/D2a")).should("have.text", "right");
+ cy.log("check initial cell values");
cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "first",
+ "(1,2)",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
+ "hello",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][3]).eq(
- "right",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
+ "5",
);
+ expect(stateVariables["/inAllCells"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([1, 2]);
+ expect(stateVariables["/inCellB3"].activeChildren.length).eq(0);
+ expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
+ expect(stateVariables["/inColumn1"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inColumn1"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([1, 2]);
+ expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(0);
});
- });
- it("spreadsheet with cell children", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- first |
- hello |
- bye |
- before |
- above |
-
- `,
- },
- "*",
- );
- });
+ // cy.log('move point');
+ // cy.window().then(async (win) => {
+ // let stateVariables = await win.returnAllStateVariables1();
+ // stateVariables['/inAllCells'].activeChildren[0].movePoint({ x: -3, y: 7 })
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][0]).eq('( -3, 7 )');
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][1]).eq('hello');
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][2]).eq('5');
+ // expect(stateVariables['/inAllCells'].activeChildren.length).eq(1);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[0]).eqls(['-', 3]);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[1]).eq(7);
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "first");
- cy.get(cesc("#\\/t2")).should("have.text", "");
- cy.get(cesc("#\\/t3")).should("have.text", "hello");
+ // })
- cy.log("check initial cell values");
+ cy.log("type in different coordinates");
+ enterSpreadsheetText({
+ id: cesc("\\/_spreadsheet1"),
+ row: 1,
+ column: 1,
+ text: "(4,9)",
+ clear: true,
+ });
+ cy.get(cesc("#\\/t1")).should("have.text", "(4,9)");
cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "first",
+ "(4,9)",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][2]).eq(
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
"hello",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][3]).eq(
- "bye",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "before",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][1]).eq(
- "above",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
+ "5",
);
- expect(stateVariables["/_cell1"].stateValues.text).eq("first");
- expect(stateVariables["/_cell2"].stateValues.text).eq("hello");
- expect(stateVariables["/_cell3"].stateValues.text).eq("bye");
- expect(stateVariables["/_cell4"].stateValues.text).eq("before");
- expect(stateVariables["/_cell5"].stateValues.text).eq("above");
+ expect(stateVariables["/inAllCells"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([4, 9]);
+ expect(stateVariables["/inCellB3"].activeChildren.length).eq(0);
+ expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
+ expect(stateVariables["/inColumn1"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inColumn1"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([4, 9]);
+ expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(0);
});
- cy.log("overwrite text in A1");
- enterSpreadsheetText({ row: 1, column: 1, text: "new" });
- cy.get(cesc("#\\/t1")).should("have.text", "new");
- cy.get(cesc("#\\/t2")).should("have.text", "");
- cy.get(cesc("#\\/t3")).should("have.text", "hello");
+ cy.log("enter new point B3");
+ enterSpreadsheetText({
+ id: cesc("\\/_spreadsheet1"),
+ row: 3,
+ column: 2,
+ text: "(5,4)",
+ clear: true,
+ });
+ cy.get(cesc("#\\/t2")).should("have.text", "(5,4)");
cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "new",
+ "(4,9)",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][2]).eq(
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
"hello",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][3]).eq(
- "bye",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
+ "5",
);
expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "before",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][1]).eq(
- "above",
+ "(5,4)",
);
- expect(stateVariables["/_cell1"].stateValues.text).eq("new");
- expect(stateVariables["/_cell2"].stateValues.text).eq("hello");
- expect(stateVariables["/_cell3"].stateValues.text).eq("bye");
- expect(stateVariables["/_cell4"].stateValues.text).eq("before");
- expect(stateVariables["/_cell5"].stateValues.text).eq("above");
+ expect(stateVariables["/inAllCells"].activeChildren.length).eq(2);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([4, 9]);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[1]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inCellB3"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
+ expect(stateVariables["/inColumn1"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inColumn1"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([4, 9]);
+ expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inRangeA2B4"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
});
- cy.log("enter text in new cell C1");
- enterSpreadsheetText({ row: 1, column: 3, text: "third" });
- cy.get(cesc("#\\/t2")).should("have.text", "third");
- cy.get(cesc("#\\/t1")).should("have.text", "new");
- cy.get(cesc("#\\/t3")).should("have.text", "hello");
+ // cy.log('move new point');
+ // cy.window().then(async (win) => {
+ // let stateVariables = await win.returnAllStateVariables1();
+ // stateVariables['/inAllCells'].activeChildren[1].movePoint({ x: 0, y: 1 })
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][0]).eq('(4,9)');
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][1]).eq('hello');
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][2]).eq('5');
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[2][1]).eq('( 0, 1 )');
+ // expect(stateVariables['/inAllCells'].activeChildren.length).eq(2);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[0]).eq(4);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[1]).eq(9);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[1].componentName].stateValues.xs[0]).eq(0);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[1].componentName].stateValues.xs[1]).eq(1);
+ // })
+
+ cy.log("enter random text on top of point in A1");
+ enterSpreadsheetText({
+ id: cesc("\\/_spreadsheet1"),
+ row: 1,
+ column: 1,
+ text: ")x,-",
+ clear: true,
+ });
+ cy.get(cesc("#\\/t1")).should("have.text", ")x,-");
cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "new",
+ ")x,-",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][2]).eq(
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
"hello",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][3]).eq(
- "bye",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
+ "5",
);
expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "before",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][1]).eq(
- "above",
- );
- expect(stateVariables["/_cell1"].stateValues.text).eq("new");
- expect(stateVariables["/_cell2"].stateValues.text).eq("hello");
- expect(stateVariables["/_cell3"].stateValues.text).eq("bye");
- expect(stateVariables["/_cell4"].stateValues.text).eq("before");
- expect(stateVariables["/_cell5"].stateValues.text).eq("above");
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "third",
+ "(5,4)",
);
+ expect(stateVariables["/inAllCells"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inCellB3"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
+ expect(stateVariables["/inColumn1"].activeChildren.length).eq(0);
+ expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inRangeA2B4"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
});
- cy.log("delete text in C3");
- enterSpreadsheetText({ row: 3, column: 3, clear: true });
- cy.get(cesc("#\\/t3")).should("have.text", "");
- cy.get(cesc("#\\/t1")).should("have.text", "new");
- cy.get(cesc("#\\/t2")).should("have.text", "third");
+ cy.log("enter new point in A4");
+ enterSpreadsheetText({
+ id: cesc("\\/_spreadsheet1"),
+ row: 4,
+ column: 1,
+ text: "(3,2)",
+ clear: true,
+ });
+ cy.get(cesc("#\\/t3")).should("have.text", "(3,2)");
cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "new",
+ ")x,-",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][2]).eq(
- "",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
+ "hello",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][3]).eq(
- "bye",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
+ "5",
);
expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "before",
+ "(5,4)",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][1]).eq(
- "above",
- );
- expect(stateVariables["/_cell1"].stateValues.text).eq("new");
- expect(stateVariables["/_cell2"].stateValues.text).eq("");
- expect(stateVariables["/_cell3"].stateValues.text).eq("bye");
- expect(stateVariables["/_cell4"].stateValues.text).eq("before");
- expect(stateVariables["/_cell5"].stateValues.text).eq("above");
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "third",
- );
- });
- });
-
- it("copy individual cells into new spreadsheet", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- $_spreadsheet1.cellA1
- $_spreadsheet2.cellA3
- $ss1a.cellD3
- $ss2a.cellD4
- $ss1b.cellB1
-
-
- first |
- hello |
- bye |
- last |
- mid |
-
-
-
- $_cell4{name="c4a"}
- |
- $_cell3{name="c3a"}
- |
- |
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_spreadsheet1")); //wait for window to load
-
- let cellLocations = {
- 1: [
- [1, 1],
- [4, 2],
- ],
- 2: [
- [3, 3],
- [3, 1],
- ],
- 3: [
- [3, 4],
- [3, 2],
- ],
- 4: [
- [4, 4],
- [4, 4],
- ],
- 5: [
- [1, 2],
- [2, 2],
- ],
- 6: [
- [2, 2],
- [1, 3],
- ],
- };
-
- let cellNames = {
- 1: ["/_cell1", "/c1a"],
- 2: ["/_cell2", "/c2a"],
- 3: ["/_cell3", "/c3a"],
- 4: ["/_cell4", "/c4a"],
- 5: ["/_cell5", "/c5a"],
- };
-
- let spreadsheetNames = {
- 0: ["/_spreadsheet1", "/ss1a", "/ss1b"],
- 1: ["/_spreadsheet2", "/ss2a", "/ss2b"],
- };
-
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "first");
- cy.get(cesc("#\\/t2")).should("have.text", "hello");
- cy.get(cesc("#\\/t3")).should("have.text", "bye");
- cy.get(cesc("#\\/t4")).should("have.text", "last");
- cy.get(cesc("#\\/t5")).should("have.text", "mid");
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let cellValues = {
- 1: "first",
- 2: "hello",
- 3: "bye",
- 4: "last",
- 5: "mid",
- 6: "",
- };
-
- for (let cellNum in cellNames) {
- for (let ind in cellNames[cellNum]) {
- expect(
- stateVariables[cellNames[cellNum][ind]].stateValues
- .text,
- ).eq(cellValues[cellNum]);
- }
- }
-
- for (let ssNum in spreadsheetNames) {
- for (let ssInd in spreadsheetNames[ssNum]) {
- let ssName = spreadsheetNames[ssNum][ssInd];
- for (let cellNum in cellLocations) {
- let cLoc = cellLocations[cellNum][ssNum];
- expect(
- stateVariables[ssName].stateValues.cells[
- cLoc[0] - 1
- ][cLoc[1] - 1],
- ).eq(cellValues[cellNum]);
- }
- }
- }
- });
-
- let allCellValues = {
- 1: ["apple", "red", "up", "soft", "happy", "monday"],
- 2: ["banana", "purple", "down", "hard", "sad", "tuesday"],
- 3: ["grape", "black", "left", "smooth", "serious", "wednesday"],
- 4: [
- "orange",
- "green",
- "right",
- "prickly",
- "determined",
- "thursday",
- ],
- 5: ["melon", "yellow", "middle", "rough", "impulsive", "friday"],
- 6: ["pear", "brown", "back", "dimpled", "passive", "saturday"],
- };
-
- let valueInd = -1;
- let valueInd2 = -1;
- for (let ssNumChange in spreadsheetNames) {
- for (let ssIndChange in spreadsheetNames[ssNumChange]) {
- let ssNameChange = spreadsheetNames[ssNumChange][ssIndChange];
- valueInd++;
-
- if (ssNameChange[0] === "/") {
- ssNameChange = "\\" + ssNameChange;
- }
-
- for (let cellNum in allCellValues) {
- let cLoc = cellLocations[cellNum][ssNumChange];
- enterSpreadsheetText({
- id: cesc(ssNameChange),
- row: cLoc[0],
- column: cLoc[1],
- text: allCellValues[cellNum][valueInd],
- });
- }
-
- cy.window().then(async (win) => {
- // have to use a different valueInd variable
- // since the code is run asynchronously
- valueInd2++;
- cy.get(cesc("#\\/t1")).should(
- "have.text",
- allCellValues[1][valueInd2],
- );
- cy.get(cesc("#\\/t2")).should(
- "have.text",
- allCellValues[2][valueInd2],
- );
- cy.get(cesc("#\\/t3")).should(
- "have.text",
- allCellValues[3][valueInd2],
- );
- cy.get(cesc("#\\/t4")).should(
- "have.text",
- allCellValues[4][valueInd2],
- );
- cy.get(cesc("#\\/t5")).should(
- "have.text",
- allCellValues[5][valueInd2],
- );
-
- cy.window().then(async (win) => {
- let stateVariables =
- await win.returnAllStateVariables1();
-
- for (let cellNum in cellNames) {
- for (let ind in cellNames[cellNum]) {
- expect(
- stateVariables[cellNames[cellNum][ind]]
- .stateValues.text,
- ).eq(allCellValues[cellNum][valueInd2]);
- }
- }
-
- cy.waitUntil(
- () =>
- cy.window().then(async (win) => {
- let stateVariables =
- await win.returnAllStateVariables1();
- for (let ssNum in spreadsheetNames) {
- for (let ssInd in spreadsheetNames[
- ssNum
- ]) {
- let ssName =
- spreadsheetNames[ssNum][ssInd];
- for (let cellNum in cellLocations) {
- let cLoc =
- cellLocations[cellNum][
- ssNum
- ];
- if (
- cellNum < 6 ||
- ssNum == valueInd2 > 2
- ) {
- if (
- stateVariables[ssName]
- .stateValues.cells[
- cLoc[0] - 1
- ][cLoc[1] - 1] !==
- allCellValues[cellNum][
- valueInd2
- ]
- ) {
- return false;
- }
-
- // expect(stateVariables[ssName].stateValues.cells[cLoc[0] - 1][cLoc[1] - 1]).eq(allCellValues[cellNum][valueInd2]);
- } else {
- if (ssNum === "1") {
- if (
- stateVariables[
- ssName
- ].stateValues.cells[
- cLoc[0] - 1
- ][cLoc[1] - 1] !==
- ""
- ) {
- return false;
- }
- } else {
- if (
- stateVariables[
- ssName
- ].stateValues.cells[
- cLoc[0] - 1
- ][cLoc[1] - 1] !==
- allCellValues[
- cellNum
- ][2]
- ) {
- return false;
- }
- }
- // if (ssNum === '1') {
- // expect(stateVariables[ssName].stateValues.cells[cLoc[0] - 1][cLoc[1] - 1]).eq("");
- // } else {
- // expect(stateVariables[ssName].stateValues.cells[cLoc[0] - 1][cLoc[1] - 1]).eq(allCellValues[cellNum][2]);
- // }
- }
- }
- }
- }
- return true;
- }),
- {
- errorMsg:
- "Time out waiting for spreadsheet to have correct content.",
- },
- );
- });
- });
- }
- }
- });
-
- it("copy spreadsheet cells into new spreadsheet", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- $_spreadsheet1.cellA1
- $_spreadsheet2.cellA3
- $ss1a.cellD3
- $ss2a.cellD4
- $ss1b.cellB1
-
-
- first |
- hello |
- bye |
- last |
- mid |
-
-
-
- |
- |
- |
- |
- |
-
-
-
-
-
-
- `,
- },
- "*",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][0]).eq(
+ "(3,2)",
);
+ expect(stateVariables["/inAllCells"].activeChildren.length).eq(2);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[1]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
+ expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inCellB3"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
+ expect(stateVariables["/inColumn1"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inColumn1"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
+ expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(2);
+ expect(
+ stateVariables[
+ stateVariables["/inRangeA2B4"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(
+ stateVariables[
+ stateVariables["/inRangeA2B4"].activeChildren[1]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
});
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "first");
- cy.get(cesc("#\\/t2")).should("have.text", "hello");
- cy.get(cesc("#\\/t3")).should("have.text", "bye");
- cy.get(cesc("#\\/t4")).should("have.text", "last");
- cy.get(cesc("#\\/t5")).should("have.text", "mid");
-
- let cellLocations = {
- 1: [
- [1, 1],
- [4, 2],
- ],
- 2: [
- [3, 3],
- [3, 1],
- ],
- 3: [
- [3, 4],
- [3, 2],
- ],
- 4: [
- [4, 4],
- [4, 4],
- ],
- 5: [
- [1, 2],
- [2, 2],
- ],
- 6: [
- [2, 2],
- [1, 3],
- ],
- };
-
- let cellNames = {
- 1: ["/_cell1", "/c1a"],
- 2: ["/_cell2", "/c2a"],
- 3: ["/_cell3", "/c3a"],
- 4: ["/_cell4", "/c4a"],
- 5: ["/_cell5", "/c5a"],
- };
-
- let spreadsheetNames = {
- 0: ["/_spreadsheet1", "/ss1a", "/ss1b"],
- 1: ["/_spreadsheet2", "/ss2a", "/ss2b"],
- };
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let cellValues = {
- 1: "first",
- 2: "hello",
- 3: "bye",
- 4: "last",
- 5: "mid",
- 6: "",
- };
-
- for (let cellNum in cellNames) {
- for (let ind in cellNames[cellNum]) {
- expect(
- stateVariables[cellNames[cellNum][ind]].stateValues
- .text,
- ).eq(cellValues[cellNum]);
- }
- }
-
- for (let ssNum in spreadsheetNames) {
- for (let ssInd in spreadsheetNames[ssNum]) {
- let ssName = spreadsheetNames[ssNum][ssInd];
- for (let cellNum in cellLocations) {
- let cLoc = cellLocations[cellNum][ssNum];
- expect(
- stateVariables[ssName].stateValues.cells[
- cLoc[0] - 1
- ][cLoc[1] - 1],
- ).eq(cellValues[cellNum]);
- }
- }
- }
- });
-
- let allCellValues = {
- 1: ["apple", "red", "up", "soft", "happy", "monday"],
- 2: ["banana", "purple", "down", "hard", "sad", "tuesday"],
- 3: ["grape", "black", "left", "smooth", "serious", "wednesday"],
- 4: [
- "orange",
- "green",
- "right",
- "prickly",
- "determined",
- "thursday",
- ],
- 5: ["melon", "yellow", "middle", "rough", "impulsive", "friday"],
- 6: ["pear", "brown", "back", "dimpled", "passive", "saturday"],
- };
-
- let valueInd = -1;
- let valueInd2 = -1;
- for (let ssNumChange in spreadsheetNames) {
- for (let ssIndChange in spreadsheetNames[ssNumChange]) {
- let ssNameChange = spreadsheetNames[ssNumChange][ssIndChange];
- valueInd++;
-
- if (ssNameChange[0] === "/") {
- ssNameChange = "\\" + ssNameChange;
- }
-
- for (let cellNum in allCellValues) {
- let cLoc = cellLocations[cellNum][ssNumChange];
- enterSpreadsheetText({
- id: cesc(ssNameChange),
- row: cLoc[0],
- column: cLoc[1],
- text: allCellValues[cellNum][valueInd],
- });
- }
-
- cy.window().then(async (win) => {
- // have to use a different valueInd variable
- // since the code is run asynchronously
- valueInd2++;
- cy.get(cesc("#\\/t1")).should(
- "have.text",
- allCellValues[1][valueInd2],
- );
- cy.get(cesc("#\\/t2")).should(
- "have.text",
- allCellValues[2][valueInd2],
- );
- cy.get(cesc("#\\/t3")).should(
- "have.text",
- allCellValues[3][valueInd2],
- );
- cy.get(cesc("#\\/t4")).should(
- "have.text",
- allCellValues[4][valueInd2],
- );
- cy.get(cesc("#\\/t5")).should(
- "have.text",
- allCellValues[5][valueInd2],
- );
-
- cy.window().then(async (win) => {
- let stateVariables =
- await win.returnAllStateVariables1();
-
- for (let cellNum in cellNames) {
- for (let ind in cellNames[cellNum]) {
- expect(
- stateVariables[cellNames[cellNum][ind]]
- .stateValues.text,
- ).eq(allCellValues[cellNum][valueInd2]);
- }
- }
-
- cy.waitUntil(
- () =>
- cy.window().then(async (win) => {
- let stateVariables =
- await win.returnAllStateVariables1();
- for (let ssNum in spreadsheetNames) {
- for (let ssInd in spreadsheetNames[
- ssNum
- ]) {
- let ssName =
- spreadsheetNames[ssNum][ssInd];
- for (let cellNum in cellLocations) {
- let cLoc =
- cellLocations[cellNum][
- ssNum
- ];
- if (
- cellNum < 6 ||
- ssNum == valueInd2 > 2
- ) {
- if (
- stateVariables[ssName]
- .stateValues.cells[
- cLoc[0] - 1
- ][cLoc[1] - 1] !==
- allCellValues[cellNum][
- valueInd2
- ]
- ) {
- return false;
- }
- } else {
- if (ssNum === "1") {
- if (
- stateVariables[
- ssName
- ].stateValues.cells[
- cLoc[0] - 1
- ][cLoc[1] - 1] !==
- ""
- ) {
- return false;
- }
- } else {
- if (
- stateVariables[
- ssName
- ].stateValues.cells[
- cLoc[0] - 1
- ][cLoc[1] - 1] !==
- allCellValues[
- cellNum
- ][2]
- ) {
- return false;
- }
- }
- }
- }
- }
- }
-
- return true;
- }),
- {
- errorMsg:
- "Time out waiting for spreadsheet to have correct content.",
- },
- );
- });
- });
- }
- }
- });
-
- it("build spreadsheet from cells and rows", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
- A1 | B1 | D1 |
- B2 | C2 |
- A5 | F5 |
- C6 | D6 |
- A7 |
-
- `,
- },
- "*",
- );
+ cy.log("enter point on top of text in A1");
+ enterSpreadsheetText({
+ id: cesc("\\/_spreadsheet1"),
+ row: 1,
+ column: 1,
+ text: "(7,3)",
+ clear: true,
});
-
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "A1");
-
- cy.log("check initial cell values");
+ cy.get(cesc("#\\/t1")).should("have.text", "(7,3)");
cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(7);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 6,
- );
expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "A1",
+ "(7,3)",
);
expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "B1",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][3]).eq(
- "D1",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][1]).eq(
- "B2",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][2]).eq(
- "C2",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[4][0]).eq(
- "A5",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[4][5]).eq(
- "F5",
+ "hello",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[5][2]).eq(
- "C6",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
+ "5",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[5][3]).eq(
- "D6",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
+ "(5,4)",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[6][0]).eq(
- "A7",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][0]).eq(
+ "(3,2)",
);
- expect(stateVariables["/_cell1"].stateValues.text).eq("A1");
- expect(stateVariables["/_cell2"].stateValues.text).eq("B1");
- expect(stateVariables["/_cell3"].stateValues.text).eq("D1");
- expect(stateVariables["/_cell4"].stateValues.text).eq("B2");
- expect(stateVariables["/_cell5"].stateValues.text).eq("C2");
- expect(stateVariables["/_cell6"].stateValues.text).eq("A5");
- expect(stateVariables["/_cell7"].stateValues.text).eq("F5");
- expect(stateVariables["/_cell8"].stateValues.text).eq("C6");
- expect(stateVariables["/_cell9"].stateValues.text).eq("D6");
- expect(stateVariables["/_cell10"].stateValues.text).eq("A7");
- });
-
- cy.log("enter text into first column");
- for (let ind = 1; ind <= 7; ind++) {
- enterSpreadsheetText({ row: ind, column: 1, text: `row${ind}` });
- }
- cy.get(cesc("#\\/t7")).should("have.text", "row7");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let ind = 1; ind <= 7; ind++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- ind - 1
- ][0],
- ).eq(`row${ind}`);
- }
- expect(stateVariables["/_cell1"].stateValues.text).eq("row1");
- expect(stateVariables["/_cell6"].stateValues.text).eq("row5");
- expect(stateVariables["/_cell10"].stateValues.text).eq("row7");
+ expect(stateVariables["/inAllCells"].activeChildren.length).eq(3);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([7, 3]);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[1]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[2]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
+ expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inCellB3"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
+ expect(stateVariables["/inColumn1"].activeChildren.length).eq(2);
+ expect(
+ stateVariables[
+ stateVariables["/inColumn1"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([7, 3]);
+ expect(
+ stateVariables[
+ stateVariables["/inColumn1"].activeChildren[1].componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
+ expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(2);
+ expect(
+ stateVariables[
+ stateVariables["/inRangeA2B4"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(
+ stateVariables[
+ stateVariables["/inRangeA2B4"].activeChildren[1]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
});
- });
- it("build spreadsheet from cells and columns", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
- A1 | A2 | A4 |
- B2 | B3 |
- E1 | E6 |
- F3 | F4 |
- G1 |
-
- `,
- },
- "*",
- );
+ cy.log("non-numerical point added (but not graphed) in D2");
+ enterSpreadsheetText({
+ id: cesc("\\/_spreadsheet1"),
+ row: 2,
+ column: 4,
+ text: "(x,q)",
+ clear: true,
});
-
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "A1");
-
- cy.log("check initial cell values");
+ cy.get(cesc("#\\/t4")).should("have.text", "(x,q)");
cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(6);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 7,
- );
expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "A1",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][0]).eq(
- "A2",
+ "(7,3)",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][0]).eq(
- "A4",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
+ "hello",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][1]).eq(
- "B2",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
+ "5",
);
expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "B3",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][4]).eq(
- "E1",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[5][4]).eq(
- "E6",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][5]).eq(
- "F3",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][5]).eq(
- "F4",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][6]).eq(
- "G1",
- );
- expect(stateVariables["/_cell1"].stateValues.text).eq("A1");
- expect(stateVariables["/_cell2"].stateValues.text).eq("A2");
- expect(stateVariables["/_cell3"].stateValues.text).eq("A4");
- expect(stateVariables["/_cell4"].stateValues.text).eq("B2");
- expect(stateVariables["/_cell5"].stateValues.text).eq("B3");
- expect(stateVariables["/_cell6"].stateValues.text).eq("E1");
- expect(stateVariables["/_cell7"].stateValues.text).eq("E6");
- expect(stateVariables["/_cell8"].stateValues.text).eq("F3");
- expect(stateVariables["/_cell9"].stateValues.text).eq("F4");
- expect(stateVariables["/_cell10"].stateValues.text).eq("G1");
- });
-
- cy.log("enter text into first row");
- for (let ind = 1; ind <= 7; ind++) {
- enterSpreadsheetText({ row: 1, column: ind, text: `column${ind}` });
- }
- cy.get(cesc("#\\/t7")).should("have.text", "column7");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let ind = 1; ind <= 7; ind++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[0][
- ind - 1
- ],
- ).eq(`column${ind}`);
- }
- expect(stateVariables["/_cell1"].stateValues.text).eq("column1");
- expect(stateVariables["/_cell6"].stateValues.text).eq("column5");
- expect(stateVariables["/_cell10"].stateValues.text).eq("column7");
- });
- });
-
- it("build spreadsheet with cellblocks", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- C3 | D3 |
- E2 | E3 |
-
- F2 |
-
- G2 |
- G4 |
-
-
- G5 | H5 |
-
-
- A5 |
- B6 |
-
- C5 |
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "C3");
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(6);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 8,
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][2]).eq(
- "C3",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][3]).eq(
- "D3",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][4]).eq(
- "E2",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][4]).eq(
- "E3",
+ "(5,4)",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][5]).eq(
- "F2",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][0]).eq(
+ "(3,2)",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][6]).eq(
- "G2",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][6]).eq(
- "G4",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[4][6]).eq(
- "G5",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[4][7]).eq(
- "H5",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[4][0]).eq(
- "A5",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[5][1]).eq(
- "B6",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[4][2]).eq(
- "C5",
- );
- expect(stateVariables["/_cell1"].stateValues.text).eq("C3");
- expect(stateVariables["/_cell2"].stateValues.text).eq("D3");
- expect(stateVariables["/_cell3"].stateValues.text).eq("E2");
- expect(stateVariables["/_cell4"].stateValues.text).eq("E3");
- expect(stateVariables["/_cell5"].stateValues.text).eq("F2");
- expect(stateVariables["/_cell6"].stateValues.text).eq("G2");
- expect(stateVariables["/_cell7"].stateValues.text).eq("G4");
- expect(stateVariables["/_cell8"].stateValues.text).eq("G5");
- expect(stateVariables["/_cell9"].stateValues.text).eq("H5");
- expect(stateVariables["/_cell10"].stateValues.text).eq("A5");
- expect(stateVariables["/_cell11"].stateValues.text).eq("B6");
- expect(stateVariables["/_cell12"].stateValues.text).eq("C5");
- });
-
- cy.log("enter text into fifth row");
- for (let ind = 1; ind <= 8; ind++) {
- enterSpreadsheetText({ row: 5, column: ind, text: `column${ind}` });
- }
- cy.get(cesc("#\\/t8")).should("have.text", "column8");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let ind = 1; ind <= 8; ind++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[4][
- ind - 1
- ],
- ).eq(`column${ind}`);
- }
- expect(stateVariables["/_cell8"].stateValues.text).eq("column7");
- expect(stateVariables["/_cell9"].stateValues.text).eq("column8");
- expect(stateVariables["/_cell10"].stateValues.text).eq("column1");
- expect(stateVariables["/_cell12"].stateValues.text).eq("column3");
- });
- });
-
- it("copy spreadsheet with cellblocks", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- A1 | B1 | C1 |
- A2 | A3 | A4 |
-
- B2 | C2 | D2 |
- B3 | C3 | D3 |
-
- B4 | C4 | D4 |
- D1 |
-
-
-
-
-
-
-
- `,
- },
- "*",
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][3]).eq(
+ "(x,q)",
);
+ expect(stateVariables["/inAllCells"].activeChildren.length).eq(4);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([7, 3]);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[1]
+ .componentName
+ ].stateValues.xs,
+ ).eqls(["x", "q"]);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[2]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[3]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
+ expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inCellB3"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(stateVariables["/inRow2"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inRow2"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls(["x", "q"]);
+ expect(stateVariables["/inColumn1"].activeChildren.length).eq(2);
+ expect(
+ stateVariables[
+ stateVariables["/inColumn1"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([7, 3]);
+ expect(
+ stateVariables[
+ stateVariables["/inColumn1"].activeChildren[1].componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
+ expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(2);
+ expect(
+ stateVariables[
+ stateVariables["/inRangeA2B4"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(
+ stateVariables[
+ stateVariables["/inRangeA2B4"].activeChildren[1]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
});
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "A1");
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(4);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 4,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.numRows).eq(4);
- expect(stateVariables["/_spreadsheet2"].stateValues.numColumns).eq(
- 4,
- );
- for (let row = 1; row <= 4; row++) {
- for (let col = 1; col <= 4; col++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- row - 1
- ][col - 1],
- ).eq(`${String.fromCharCode(64 + col)}${row}`);
- }
- }
- for (let row = 3; row <= 4; row++) {
- for (let col = 3; col <= 4; col++) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- row - 3
- ][col - 3],
- ).eq(`${String.fromCharCode(64 + col)}${row}`);
- }
- }
- for (let row = 1; row <= 4; row++) {
- for (let col = 1; col <= 2; col++) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- row - 1
- ][col + 1],
- ).eq(`${String.fromCharCode(64 + col)}${row}`);
- }
- }
- for (let row = 1; row <= 2; row++) {
- for (let col = 3; col <= 4; col++) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- row + 1
- ][col - 3],
- ).eq(`${String.fromCharCode(64 + col)}${row}`);
- }
- }
+ cy.log("3D point added (but not graphed) in A2");
+ enterSpreadsheetText({
+ id: cesc("\\/_spreadsheet1"),
+ row: 2,
+ column: 1,
+ text: "(1,2,3)",
+ clear: true,
});
-
- cy.log("enter text into third row of first spreadsheet");
- for (let ind = 1; ind <= 4; ind++) {
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 3,
- column: ind,
- text: `column${ind}`,
- });
- }
- cy.get(cesc("#\\/t2")).should("have.text", "column4");
-
+ cy.get(cesc("#\\/t5")).should("have.text", "(1,2,3)");
cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
- for (let ind = 1; ind <= 4; ind++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[2][
- ind - 1
- ],
- ).eq(`column${ind}`);
- }
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[2][2]).eq(
- `column1`,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[2][3]).eq(
- `column2`,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[0][0]).eq(
- `column3`,
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
+ "(7,3)",
);
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[0][1]).eq(
- `column4`,
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
+ "hello",
);
- });
-
- cy.log("enter text into second column of second spreadsheet");
- for (let ind = 1; ind <= 4; ind++) {
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: ind,
- column: 2,
- text: `row${ind}`,
- });
- }
- cy.get(cesc("#\\/t3")).should("have.text", "row4");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let ind = 1; ind <= 4; ind++) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- ind - 1
- ][1],
- ).eq(`row${ind}`);
- }
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][3]).eq(
- `row1`,
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
+ "5",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][3]).eq(
- `row2`,
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
+ "(5,4)",
);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][3]).eq(
- `row3`,
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][0]).eq(
+ "(3,2)",
);
expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][3]).eq(
- `row4`,
- );
- });
- });
-
- it("copy spreadsheet with rows and columns", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- A1 | B1 | C1 |
- A2 | A3 | A4 |
-
- B2 | C2 | D2 |
- B3 | C3 | D3 |
-
- B4 | C4 | D4 |
- D1 |
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "A1");
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(4);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 4,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.numRows).eq(4);
- expect(stateVariables["/_spreadsheet2"].stateValues.numColumns).eq(
- 6,
- );
- for (let row = 1; row <= 4; row++) {
- for (let col = 1; col <= 4; col++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- row - 1
- ][col - 1],
- ).eq(`${String.fromCharCode(64 + col)}${row}`);
- }
- }
- for (let row = 1; row <= 2; row++) {
- for (let col = 1; col <= 4; col++) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- row - 1
- ][col - 1],
- ).eq("");
- }
- }
- for (let col = 1; col <= 4; col++) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[2][
- col - 1
- ],
- ).eq(`${String.fromCharCode(64 + col)}2`);
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[3][
- col - 1
- ],
- ).eq(`${String.fromCharCode(64 + col)}1`);
- }
- for (let row = 1; row <= 4; row++) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- row - 1
- ][4],
- ).eq(`C${row}`);
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- row - 1
- ][5],
- ).eq(`B${row}`);
- }
- });
-
- cy.log("enter text into second row of first spreadsheet");
- for (let ind = 1; ind <= 4; ind++) {
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 2,
- column: ind,
- text: `column${ind}`,
- });
- }
- cy.get(cesc("#\\/t2")).should("have.text", "column4");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let ind = 1; ind <= 4; ind++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[1][
- ind - 1
- ],
- ).eq(`column${ind}`);
- }
- // becomes third row of second spreadsheet
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[2][0]).eq(
- `column1`,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[2][1]).eq(
- `column2`,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[2][2]).eq(
- `column3`,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[2][3]).eq(
- `column4`,
- );
-
- // fifth and sixth column ref third and second column
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[1][4]).eq(
- `column3`,
+ "(x,q)",
);
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[1][5]).eq(
- `column2`,
+ expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][0]).eq(
+ "(1,2,3)",
);
+ expect(stateVariables["/inAllCells"].activeChildren.length).eq(5);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([7, 3]);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[1]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([1, 2, 3]);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[2]
+ .componentName
+ ].stateValues.xs,
+ ).eqls(["x", "q"]);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[3]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(
+ stateVariables[
+ stateVariables["/inAllCells"].activeChildren[4]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
+ expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
+ expect(
+ stateVariables[
+ stateVariables["/inCellB3"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(stateVariables["/inRow2"].activeChildren.length).eq(2);
+ expect(
+ stateVariables[
+ stateVariables["/inRow2"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([1, 2, 3]);
+ expect(
+ stateVariables[
+ stateVariables["/inRow2"].activeChildren[1].componentName
+ ].stateValues.xs,
+ ).eqls(["x", "q"]);
+ expect(stateVariables["/inColumn1"].activeChildren.length).eq(3);
+ expect(
+ stateVariables[
+ stateVariables["/inColumn1"].activeChildren[0].componentName
+ ].stateValues.xs,
+ ).eqls([7, 3]);
+ expect(
+ stateVariables[
+ stateVariables["/inColumn1"].activeChildren[1].componentName
+ ].stateValues.xs,
+ ).eqls([1, 2, 3]);
+ expect(
+ stateVariables[
+ stateVariables["/inColumn1"].activeChildren[2].componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
+ expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(3);
+ expect(
+ stateVariables[
+ stateVariables["/inRangeA2B4"].activeChildren[0]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([1, 2, 3]);
+ expect(
+ stateVariables[
+ stateVariables["/inRangeA2B4"].activeChildren[1]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([5, 4]);
+ expect(
+ stateVariables[
+ stateVariables["/inRangeA2B4"].activeChildren[2]
+ .componentName
+ ].stateValues.xs,
+ ).eqls([3, 2]);
});
- cy.log("enter text into fifth column of second spreadsheet");
- for (let ind = 1; ind <= 4; ind++) {
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: ind,
- column: 5,
- text: `row${ind}`,
- });
- }
- cy.get(cesc("#\\/t3")).should("have.text", "row4");
+ // cy.log('move point');
+ // cy.window().then(async (win) => {
+ // let stateVariables = await win.returnAllStateVariables1();
+ // stateVariables['/inAllCells'].activeChildren[2].movePoint({ x: 8, y: 5 });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let ind = 1; ind <= 4; ind++) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- ind - 1
- ][4],
- ).eq(`row${ind}`);
- }
-
- //comes third column of first spreadsheet
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- `row1`,
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][2]).eq(
- `row2`,
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][2]).eq(
- `row3`,
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][2]).eq(
- `row4`,
- );
-
- // third and fourth row of second spreadsheet also change due
- // changes in second and first row of first spreadsheet
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[2][2]).eq(
- `row2`,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.cells[3][2]).eq(
- `row1`,
- );
- });
- });
-
- it("copy all spreadsheet cells shifted", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- A1 | B1 | C1 |
- A2 | B2 | C2 |
- A3 | B3 | C3 |
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "A1");
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(3);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 3,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.numRows).eq(5);
- expect(stateVariables["/_spreadsheet2"].stateValues.numColumns).eq(
- 4,
- );
- for (let row = 1; row <= 3; row++) {
- for (let col = 1; col <= 3; col++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- row - 1
- ][col - 1],
- ).eq(`${String.fromCharCode(64 + col)}${row}`);
- }
- }
- for (let row = 1; row <= 3; row++) {
- for (let col = 1; col <= 3; col++) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- row + 1
- ][col],
- ).eq(`${String.fromCharCode(64 + col)}${row}`);
- }
- }
- });
-
- cy.log("enter text into second row of first spreadsheet");
- for (let ind = 1; ind <= 3; ind++) {
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 2,
- column: ind,
- text: `column${ind}`,
- });
- }
- cy.get(cesc("#\\/t2")).should("have.text", "column3");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let ind = 1; ind <= 3; ind++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[1][
- ind - 1
- ],
- ).eq(`column${ind}`);
- }
- for (let ind = 1; ind <= 3; ind++) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[3][ind],
- ).eq(`column${ind}`);
- }
- });
-
- cy.log("enter text into fourth column of second spreadsheet");
- for (let ind = 1; ind <= 5; ind++) {
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: ind,
- column: 4,
- text: `row${ind}`,
- });
- }
- cy.get(cesc("#\\/t3")).should("have.text", "row5");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let ind = 1; ind <= 5; ind++) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- ind - 1
- ][3],
- ).eq(`row${ind}`);
- }
-
- //becomes third column of first spreadsheet
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- `row3`,
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][2]).eq(
- `row4`,
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][2]).eq(
- `row5`,
- );
- });
- });
-
- it("copy spreadsheet cells ignores cell col/row num", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- alpha |
- beta |
- gamma |
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "alpha");
-
- let cellBlockUpperLefts = [
- [0, 0],
- [0, 3],
- [2, 3],
- ];
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][4]).eq(
- "alpha",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][5]).eq(
- "beta",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][5]).eq(
- "gamma",
- );
- for (let inds of cellBlockUpperLefts) {
- let row = inds[0];
- let col = inds[1];
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[row][
- col
- ],
- ).eq("alpha");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[row][
- col + 1
- ],
- ).eq("beta");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[row + 1][
- col + 1
- ],
- ).eq("gamma");
- }
- });
-
- cy.log("enter text in first spreadsheet block");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 1,
- column: 5,
- text: `a`,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 1,
- column: 6,
- text: `b`,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 2,
- column: 5,
- text: `c`,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 2,
- column: 6,
- text: `d`,
- });
-
- cy.get(cesc("#\\/t2")).should("have.text", "d");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][4]).eq(
- "a",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][5]).eq(
- "b",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][4]).eq(
- "c",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][5]).eq(
- "d",
- );
- for (let inds of cellBlockUpperLefts) {
- let row = inds[0];
- let col = inds[1];
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[row][
- col
- ],
- ).eq("a");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[row][
- col + 1
- ],
- ).eq("b");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[row + 1][
- col
- ],
- ).eq("c");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[row + 1][
- col + 1
- ],
- ).eq("d");
- }
- });
-
- cy.log("enter text in other spreadsheet blocks");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: 1,
- column: 1,
- text: `first`,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: 1,
- column: 5,
- text: `second`,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: 4,
- column: 4,
- text: `third`,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: 4,
- column: 5,
- text: `fourth`,
- });
-
- cy.get(cesc("#\\/t3")).should("have.text", "fourth");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][4]).eq(
- "first",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][5]).eq(
- "second",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][4]).eq(
- "third",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][5]).eq(
- "fourth",
- );
- for (let inds of cellBlockUpperLefts) {
- let row = inds[0];
- let col = inds[1];
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[row][
- col
- ],
- ).eq("first");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[row][
- col + 1
- ],
- ).eq("second");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[row + 1][
- col
- ],
- ).eq("third");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[row + 1][
- col + 1
- ],
- ).eq("fourth");
- }
- });
- });
-
- it("copy extracted points from spreadsheet", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
-
-
- (1,2) |
- hello |
- 5 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "(1,2)");
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "(1,2)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "hello",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "5",
- );
- expect(stateVariables["/inAllCells"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([1, 2]);
- expect(stateVariables["/inCellB3"].activeChildren.length).eq(0);
- expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
- expect(stateVariables["/inColumn1"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inColumn1"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([1, 2]);
- expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(0);
- });
-
- // cy.log('move point');
- // cy.window().then(async (win) => {
- // let stateVariables = await win.returnAllStateVariables1();
- // stateVariables['/inAllCells'].activeChildren[0].movePoint({ x: -3, y: 7 })
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][0]).eq('( -3, 7 )');
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][0]).eq('(7,3)');
// expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][1]).eq('hello');
// expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][2]).eq('5');
- // expect(stateVariables['/inAllCells'].activeChildren.length).eq(1);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[0]).eqls(['-', 3]);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[1]).eq(7);
-
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[2][1]).eq('( 0, 1 )');
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[3][0]).eq('( 8, 5 )');
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[1][3]).eq('(x,q)');
+ // expect(stateVariables['/_spreadsheet1'].stateValues.cells[1][0]).eq('(1,2,3)');
+ // expect(stateVariables['/inAllCells'].activeChildren.length).eq(5);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[0]).eq(7);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[1]).eq(3);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[1].componentName].stateValues.xs[0]).eq(1);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[1].componentName].stateValues.xs[1]).eq(2);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[1].componentName].stateValues.xs[2]).eq(3);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[2].componentName].stateValues.xs[0]).eq(8);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[2].componentName].stateValues.xs[1]).eq(5);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[3].componentName].stateValues.xs[0]).eq(0);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[3].componentName].stateValues.xs[1]).eq(1);
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[4].componentName].stateValues.xs[0]).eq('x');
+ // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[4].componentName].stateValues.xs[1]).eq('q');
// })
-
- cy.log("type in different coordinates");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 1,
- column: 1,
- text: "(4,9)",
- clear: true,
- });
- cy.get(cesc("#\\/t1")).should("have.text", "(4,9)");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "(4,9)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "hello",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "5",
- );
- expect(stateVariables["/inAllCells"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([4, 9]);
- expect(stateVariables["/inCellB3"].activeChildren.length).eq(0);
- expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
- expect(stateVariables["/inColumn1"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inColumn1"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([4, 9]);
- expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(0);
- });
-
- cy.log("enter new point B3");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 3,
- column: 2,
- text: "(5,4)",
- clear: true,
- });
- cy.get(cesc("#\\/t2")).should("have.text", "(5,4)");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "(4,9)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "hello",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "5",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "(5,4)",
- );
- expect(stateVariables["/inAllCells"].activeChildren.length).eq(2);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([4, 9]);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[1]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inCellB3"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
- expect(stateVariables["/inColumn1"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inColumn1"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([4, 9]);
- expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inRangeA2B4"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- });
-
- // cy.log('move new point');
- // cy.window().then(async (win) => {
- // let stateVariables = await win.returnAllStateVariables1();
- // stateVariables['/inAllCells'].activeChildren[1].movePoint({ x: 0, y: 1 })
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][0]).eq('(4,9)');
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][1]).eq('hello');
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][2]).eq('5');
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[2][1]).eq('( 0, 1 )');
- // expect(stateVariables['/inAllCells'].activeChildren.length).eq(2);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[0]).eq(4);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[1]).eq(9);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[1].componentName].stateValues.xs[0]).eq(0);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[1].componentName].stateValues.xs[1]).eq(1);
- // })
-
- cy.log("enter random text on top of point in A1");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 1,
- column: 1,
- text: ")x,-",
- clear: true,
- });
- cy.get(cesc("#\\/t1")).should("have.text", ")x,-");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- ")x,-",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "hello",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "5",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "(5,4)",
- );
- expect(stateVariables["/inAllCells"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inCellB3"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
- expect(stateVariables["/inColumn1"].activeChildren.length).eq(0);
- expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inRangeA2B4"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- });
-
- cy.log("enter new point in A4");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 4,
- column: 1,
- text: "(3,2)",
- clear: true,
- });
- cy.get(cesc("#\\/t3")).should("have.text", "(3,2)");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- ")x,-",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "hello",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "5",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "(5,4)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][0]).eq(
- "(3,2)",
- );
- expect(stateVariables["/inAllCells"].activeChildren.length).eq(2);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[1]
- .componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inCellB3"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
- expect(stateVariables["/inColumn1"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inColumn1"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(2);
- expect(
- stateVariables[
- stateVariables["/inRangeA2B4"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(
- stateVariables[
- stateVariables["/inRangeA2B4"].activeChildren[1]
- .componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- });
-
- cy.log("enter point on top of text in A1");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 1,
- column: 1,
- text: "(7,3)",
- clear: true,
- });
- cy.get(cesc("#\\/t1")).should("have.text", "(7,3)");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "(7,3)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "hello",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "5",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "(5,4)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][0]).eq(
- "(3,2)",
- );
- expect(stateVariables["/inAllCells"].activeChildren.length).eq(3);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([7, 3]);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[1]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[2]
- .componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inCellB3"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(stateVariables["/inRow2"].activeChildren.length).eq(0);
- expect(stateVariables["/inColumn1"].activeChildren.length).eq(2);
- expect(
- stateVariables[
- stateVariables["/inColumn1"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([7, 3]);
- expect(
- stateVariables[
- stateVariables["/inColumn1"].activeChildren[1].componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(2);
- expect(
- stateVariables[
- stateVariables["/inRangeA2B4"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(
- stateVariables[
- stateVariables["/inRangeA2B4"].activeChildren[1]
- .componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- });
-
- cy.log("non-numerical point added (but not graphed) in D2");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 2,
- column: 4,
- text: "(x,q)",
- clear: true,
- });
- cy.get(cesc("#\\/t4")).should("have.text", "(x,q)");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "(7,3)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "hello",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "5",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "(5,4)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][0]).eq(
- "(3,2)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][3]).eq(
- "(x,q)",
- );
- expect(stateVariables["/inAllCells"].activeChildren.length).eq(4);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([7, 3]);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[1]
- .componentName
- ].stateValues.xs,
- ).eqls(["x", "q"]);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[2]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[3]
- .componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inCellB3"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(stateVariables["/inRow2"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inRow2"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls(["x", "q"]);
- expect(stateVariables["/inColumn1"].activeChildren.length).eq(2);
- expect(
- stateVariables[
- stateVariables["/inColumn1"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([7, 3]);
- expect(
- stateVariables[
- stateVariables["/inColumn1"].activeChildren[1].componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(2);
- expect(
- stateVariables[
- stateVariables["/inRangeA2B4"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(
- stateVariables[
- stateVariables["/inRangeA2B4"].activeChildren[1]
- .componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- });
-
- cy.log("3D point added (but not graphed) in A2");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 2,
- column: 1,
- text: "(1,2,3)",
- clear: true,
- });
- cy.get(cesc("#\\/t5")).should("have.text", "(1,2,3)");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "(7,3)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "hello",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "5",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[2][1]).eq(
- "(5,4)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[3][0]).eq(
- "(3,2)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][3]).eq(
- "(x,q)",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][0]).eq(
- "(1,2,3)",
- );
- expect(stateVariables["/inAllCells"].activeChildren.length).eq(5);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([7, 3]);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[1]
- .componentName
- ].stateValues.xs,
- ).eqls([1, 2, 3]);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[2]
- .componentName
- ].stateValues.xs,
- ).eqls(["x", "q"]);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[3]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(
- stateVariables[
- stateVariables["/inAllCells"].activeChildren[4]
- .componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- expect(stateVariables["/inCellB3"].activeChildren.length).eq(1);
- expect(
- stateVariables[
- stateVariables["/inCellB3"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(stateVariables["/inRow2"].activeChildren.length).eq(2);
- expect(
- stateVariables[
- stateVariables["/inRow2"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([1, 2, 3]);
- expect(
- stateVariables[
- stateVariables["/inRow2"].activeChildren[1].componentName
- ].stateValues.xs,
- ).eqls(["x", "q"]);
- expect(stateVariables["/inColumn1"].activeChildren.length).eq(3);
- expect(
- stateVariables[
- stateVariables["/inColumn1"].activeChildren[0].componentName
- ].stateValues.xs,
- ).eqls([7, 3]);
- expect(
- stateVariables[
- stateVariables["/inColumn1"].activeChildren[1].componentName
- ].stateValues.xs,
- ).eqls([1, 2, 3]);
- expect(
- stateVariables[
- stateVariables["/inColumn1"].activeChildren[2].componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- expect(stateVariables["/inRangeA2B4"].activeChildren.length).eq(3);
- expect(
- stateVariables[
- stateVariables["/inRangeA2B4"].activeChildren[0]
- .componentName
- ].stateValues.xs,
- ).eqls([1, 2, 3]);
- expect(
- stateVariables[
- stateVariables["/inRangeA2B4"].activeChildren[1]
- .componentName
- ].stateValues.xs,
- ).eqls([5, 4]);
- expect(
- stateVariables[
- stateVariables["/inRangeA2B4"].activeChildren[2]
- .componentName
- ].stateValues.xs,
- ).eqls([3, 2]);
- });
-
- // cy.log('move point');
- // cy.window().then(async (win) => {
- // let stateVariables = await win.returnAllStateVariables1();
- // stateVariables['/inAllCells'].activeChildren[2].movePoint({ x: 8, y: 5 });
-
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][0]).eq('(7,3)');
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][1]).eq('hello');
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[0][2]).eq('5');
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[2][1]).eq('( 0, 1 )');
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[3][0]).eq('( 8, 5 )');
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[1][3]).eq('(x,q)');
- // expect(stateVariables['/_spreadsheet1'].stateValues.cells[1][0]).eq('(1,2,3)');
- // expect(stateVariables['/inAllCells'].activeChildren.length).eq(5);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[0]).eq(7);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[0].componentName].stateValues.xs[1]).eq(3);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[1].componentName].stateValues.xs[0]).eq(1);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[1].componentName].stateValues.xs[1]).eq(2);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[1].componentName].stateValues.xs[2]).eq(3);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[2].componentName].stateValues.xs[0]).eq(8);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[2].componentName].stateValues.xs[1]).eq(5);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[3].componentName].stateValues.xs[0]).eq(0);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[3].componentName].stateValues.xs[1]).eq(1);
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[4].componentName].stateValues.xs[0]).eq('x');
- // expect(stateVariables[stateVariables['/inAllCells'].activeChildren[4].componentName].stateValues.xs[1]).eq('q');
- // })
- });
-
- it("spreadsheet prefill", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- x^2
- hello
- 5
- true
-
-
-
- |
- |
- |
- |
-
-
-
-
- $_spreadsheet1.cellD1{assignNames="D1a"}
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.log("initial values");
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("x2");
- });
- cy.get(cesc("#\\/t1")).should("have.text", "hello");
- cy.get(cesc("#\\/n1")).should("have.text", "5");
- cy.get(cesc("#\\/b1")).should("have.text", "true");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "x²",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "hello",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "5",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][3]).eq(
- "true",
- );
- });
-
- cy.log("changing spreadsheet doesn't change prefill sources");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 1,
- column: 1,
- text: "3(-",
- clear: true,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 1,
- column: 2,
- text: "bye",
- clear: true,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 1,
- column: 3,
- text: "ab",
- clear: true,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: 1,
- column: 4,
- text: "1+q",
- clear: true,
- });
- cy.get(cesc("#\\/D1a")).should("have.text", "1+q");
-
- cy.get(cesc("#\\/m1"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text).eq("x2");
- });
- cy.get(cesc("#\\/t1")).should("have.text", "hello");
- cy.get(cesc("#\\/n1")).should("have.text", "5");
- cy.get(cesc("#\\/b1")).should("have.text", "true");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "3(-",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "bye",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][2]).eq(
- "ab",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][3]).eq(
- "1+q",
- );
- });
- });
-
- it.skip("internal references within spreadsheet", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- first |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "first");
-
- let firstInds = [
- [0, 0],
- [0, 1],
- [0, 2],
- [0, 3],
- [0, 4],
- ];
- let secondInds = [
- [1, 1],
- [1, 2],
- [1, 3],
- [1, 4],
- [1, 5],
- [2, 0],
- ];
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(4);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 6,
- );
- expect(stateVariables["/s2"].stateValues.numRows).eq(4);
- expect(stateVariables["/s2"].stateValues.numColumns).eq(6);
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(`first`);
- expect(
- stateVariables["/s2"].stateValues.cells[inds[0]][inds[1]],
- ).eq(`first`);
- }
- for (let inds of secondInds) {
- expect(
- ["", undefined].includes(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ),
- ).eq(true);
- expect(
- ["", undefined].includes(
- stateVariables["/s2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ),
- ).eq(true);
- }
- });
-
- cy.log("change text of second group in first spreadsheet");
- for (let indsChange of secondInds) {
- let newText = `a${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("first");
- expect(
- stateVariables["/s2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq("first");
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/s2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(newText);
- }
- });
- }
-
- cy.log("change text of first group in first spreadsheet");
- for (let indsChange of firstInds) {
- let newText = `b${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/s2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(newText);
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("a20");
- expect(
- stateVariables["/s2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq("a20");
- }
- });
- }
-
- cy.log("change text of second group in second spreadsheet");
- for (let indsChange of secondInds) {
- let newText = `c${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: "__spreadsheet1",
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("b04");
- expect(
- stateVariables["/s2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq("b04");
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/s2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(newText);
- }
- });
- }
-
- cy.log("change text of first group in second spreadsheet");
- for (let indsChange of firstInds) {
- let newText = `d${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: "__spreadsheet1",
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/s2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(newText);
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("c20");
- expect(
- stateVariables["/s2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq("c20");
- }
- });
- }
- });
-
- it.skip("internal references within spreadsheet 2", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
- first |
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get("#__text1").should("have.text", "");
-
- let firstInds = [
- [2, 1],
- [2, 2],
- [1, 0],
- [6, 2],
- [6, 3],
- [5, 1],
- [2, 4],
- [5, 4],
- ];
- let secondInds = [
- [0, 0],
- [2, 3],
- [4, 1],
- [4, 4],
- ];
-
- let block1Inds = [
- [0, 1],
- [0, 2],
- [1, 1],
- [1, 2],
- [2, 0],
- ];
- let block2Inds = [
- [4, 2],
- [4, 3],
- [5, 2],
- [5, 3],
- [6, 1],
- ];
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(7);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 5,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(7);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(5);
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(`first`);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(`first`);
- }
- for (let inds of secondInds) {
- expect(
- ["", undefined].includes(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ),
- ).eq(true);
- expect(
- ["", undefined].includes(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ),
- ).eq(true);
- }
- });
-
- cy.log("change text of second group in first spreadsheet");
- for (let indsChange of secondInds) {
- let newText = `a${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.get(cesc("#\\/_spreadsheet1") + " ");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("first");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("first");
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- }
- });
- }
-
- cy.log("change text of first group in first spreadsheet");
- for (let indsChange of firstInds) {
- let newText = `b${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("a44");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("a44");
- }
- });
- }
-
- cy.log("change text of second group in second spreadsheet");
- for (let indsChange of secondInds) {
- let newText = `c${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: "__spreadsheet1",
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("b54");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("b54");
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- }
- });
- }
-
- cy.log("change text of first group in second spreadsheet");
- for (let indsChange of firstInds) {
- let newText = `d${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: "__spreadsheet1",
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("c44");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("c44");
- }
- });
- }
-
- cy.log("change text of first block in first spreadsheet");
-
- let blockTexts1 = [];
- for (let indsChange of block1Inds) {
- let newText = `e${indsChange[0]}${indsChange[1]}`;
- blockTexts1.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let [i, inds] of block1Inds.entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts1[i]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(blockTexts1[i]);
- }
- for (let [i, inds] of block2Inds.entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts1[i]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(blockTexts1[i]);
- }
- });
-
- cy.log("change text of second block in first spreadsheet");
-
- let blockTexts2 = [];
- for (let indsChange of block2Inds) {
- let newText = `f${indsChange[0]}${indsChange[1]}`;
- blockTexts2.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let [i, inds] of block1Inds.entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts2[i]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(blockTexts2[i]);
- }
- for (let [i, inds] of block2Inds.entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts2[i]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(blockTexts2[i]);
- }
- });
-
- cy.log("change text of first block in second spreadsheet");
-
- let blockTexts3 = [];
- for (let indsChange of block1Inds) {
- let newText = `g${indsChange[0]}${indsChange[1]}`;
- blockTexts3.push(newText);
- enterSpreadsheetText({
- id: "__spreadsheet1",
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let [i, inds] of block1Inds.entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts3[i]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(blockTexts3[i]);
- }
- for (let [i, inds] of block2Inds.entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts3[i]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(blockTexts3[i]);
- }
- });
-
- cy.log("change text of second block in second spreadsheet");
-
- let blockTexts4 = [];
- for (let indsChange of block2Inds) {
- let newText = `h${indsChange[0]}${indsChange[1]}`;
- blockTexts4.push(newText);
- enterSpreadsheetText({
- id: "__spreadsheet1",
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let [i, inds] of block1Inds.entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts4[i]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(blockTexts4[i]);
- }
- for (let [i, inds] of block2Inds.entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts4[i]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(blockTexts4[i]);
- }
- });
- });
-
- it.skip("internal references to rows", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- first | second | sixth |
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get("#__text1").should("have.text", "first");
-
- let numRows = 5;
- let numcols = 6;
-
- let rowTexts = ["first", "second", , , , "sixth"];
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(
- numRows,
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- numcols,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(numRows);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(numcols);
- for (let row = 0; row < numRows; row++) {
- for (let col of [0, 1, 5]) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[row][
- col
- ],
- ).eq(rowTexts[col]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- row
- ][col],
- ).eq(rowTexts[col]);
- }
- }
- });
-
- cy.log("change text of each row in first spreadsheet");
-
- let newRowTexts = [];
- for (let rowChange = 0; rowChange < numRows; rowChange++) {
- newRowTexts.push([]);
- let thisNew = newRowTexts[rowChange];
- for (let colChange = 0; colChange < numcols; colChange++) {
- let newText = `a${rowChange}${colChange}`;
- thisNew.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: rowChange + 1,
- column: colChange + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let row = 0; row < numRows; row++) {
- for (let col = 0; col < numcols; col++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- row
- ][col],
- ).eq(thisNew[col]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues
- .cells[row][col],
- ).eq(thisNew[col]);
- }
- }
- });
- }
-
- cy.log("change text of each row in second spreadsheet");
-
- let newRowTextsB = [];
- for (let rowChange = 0; rowChange < numRows; rowChange++) {
- newRowTextsB.push([]);
- let thisNew = newRowTextsB[rowChange];
- for (let colChange = 0; colChange < numcols; colChange++) {
- let newText = `b${rowChange}${colChange}`;
- thisNew.push(newText);
- enterSpreadsheetText({
- id: "__spreadsheet1",
- row: rowChange + 1,
- column: colChange + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let row = 0; row < numRows; row++) {
- for (let col = 0; col < numcols; col++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- row
- ][col],
- ).eq(thisNew[col]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues
- .cells[row][col],
- ).eq(thisNew[col]);
- }
- }
- });
- }
- });
-
- it.skip("internal references to columns", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- first | second | sixth |
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get("#__text1").should("have.text", "first");
-
- let numRows = 6;
- let numcols = 5;
-
- let colTexts = ["first", "second", , , , "sixth"];
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(
- numRows,
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- numcols,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(numRows);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(numcols);
- for (let col = 0; col < numcols; col++) {
- for (let row of [0, 1, 5]) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[row][
- col
- ],
- ).eq(colTexts[row]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- row
- ][col],
- ).eq(colTexts[row]);
- }
- }
- });
-
- cy.log("change text of each column in first spreadsheet");
-
- let newcolTexts = [];
- for (let colChange = 0; colChange < numcols; colChange++) {
- newcolTexts.push([]);
- let thisNew = newcolTexts[colChange];
- for (let rowChange = 0; rowChange < numRows; rowChange++) {
- let newText = `a${colChange}${rowChange}`;
- thisNew.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: colChange + 1,
- row: rowChange + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let col = 0; col < numcols; col++) {
- for (let row = 0; row < numRows; row++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- row
- ][col],
- ).eq(thisNew[row]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues
- .cells[row][col],
- ).eq(thisNew[row]);
- }
- }
- });
- }
-
- cy.log("change text of each column in second spreadsheet");
-
- let newcolTextsB = [];
- for (let colChange = 0; colChange < numcols; colChange++) {
- newcolTextsB.push([]);
- let thisNew = newcolTextsB[colChange];
- for (let rowChange = 0; rowChange < numRows; rowChange++) {
- let newText = `b${colChange}${rowChange}`;
- thisNew.push(newText);
- enterSpreadsheetText({
- id: "__spreadsheet1",
- column: colChange + 1,
- row: rowChange + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let col = 0; col < numcols; col++) {
- for (let row = 0; row < numRows; row++) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- row
- ][col],
- ).eq(thisNew[row]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues
- .cells[row][col],
- ).eq(thisNew[row]);
- }
- }
- });
- }
- });
-
- it.skip("internal references to cell ranges", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
- a | b |
- c | d |
- e | f |
- g | h |
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get("#__text1").should("have.text", "b");
-
- let numRows = 4;
- let numcols = 6;
-
- let groupTexts = ["a", "b", "c", "d", "e", "f", "g", "h"];
-
- let groupInds = [
- [
- [0, 0],
- [0, 2],
- [0, 4],
- ],
- [
- [0, 1],
- [0, 3],
- [0, 5],
- ],
- [
- [1, 0],
- [1, 2],
- [1, 4],
- ],
- [
- [1, 1],
- [1, 3],
- [1, 5],
- ],
- [
- [2, 2],
- [2, 4],
- ],
- [
- [2, 3],
- [2, 5],
- ],
- [[3, 2]],
- [[3, 3]],
- ];
-
- let extraInds = [
- [2, 0],
- [2, 1],
- [3, 0],
- [3, 1],
- [3, 4],
- [3, 5],
- ];
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(
- numRows,
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- numcols,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(numRows);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(numcols);
- for (let group = 0; group < 8; group++) {
- for (let inds of groupInds[group]) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(groupTexts[group]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(groupTexts[group]);
- }
- }
- for (let inds of extraInds) {
- expect(
- ["", undefined].includes(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ),
- ).eq(true);
- expect(
- ["", undefined].includes(
- stateVariables["/s2"].replacements[0].stateValues.cells[
- inds[0]
- ][inds[1]],
- ),
- ).eq(true);
- }
- });
-
- cy.log("change text of each column in first spreadsheet");
- let newcolTexts = [];
- let newGroupTexts = [];
- for (let colChange = 0; colChange < numcols; colChange++) {
- newcolTexts.push([]);
- let thisNew = newcolTexts[colChange];
- for (let rowChange = 0; rowChange < numRows; rowChange++) {
- let newText = `a${colChange}${rowChange}`;
- thisNew.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: colChange + 1,
- row: rowChange + 1,
- text: newText,
- });
- }
- if (colChange === 0) {
- newGroupTexts.push([...groupTexts]);
- } else {
- newGroupTexts.push([...newGroupTexts[colChange - 1]]);
- }
- let thisNewGroup = newGroupTexts[colChange];
-
- if ([0, 2, 4].includes(colChange)) {
- thisNewGroup[0] = thisNew[0];
- thisNewGroup[2] = thisNew[1];
- }
- if ([2, 4].includes(colChange)) {
- thisNewGroup[4] = thisNew[2];
- }
- if (colChange === 2) {
- thisNewGroup[6] = thisNew[3];
- }
-
- if ([1, 3, 5].includes(colChange)) {
- thisNewGroup[1] = thisNew[0];
- thisNewGroup[3] = thisNew[1];
- }
- if ([3, 5].includes(colChange)) {
- thisNewGroup[5] = thisNew[2];
- }
- if (colChange === 3) {
- thisNewGroup[7] = thisNew[3];
- }
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let group = 0; group < 8; group++) {
- for (let inds of groupInds[group]) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(thisNewGroup[group]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues
- .cells[inds[0]][inds[1]],
- ).eq(thisNewGroup[group]);
- }
- }
- });
- }
-
- cy.log("change text of each column in first spreadsheet");
- let newcolTexts2 = [];
- let newGroupTexts2 = [];
- for (let colChange = 0; colChange < numcols; colChange++) {
- newcolTexts2.push([]);
- let thisNew = newcolTexts2[colChange];
- for (let rowChange = 0; rowChange < numRows; rowChange++) {
- let newText = `b${colChange}${rowChange}`;
- thisNew.push(newText);
- enterSpreadsheetText({
- id: "__spreadsheet1",
- column: colChange + 1,
- row: rowChange + 1,
- text: newText,
- });
- }
- if (colChange === 0) {
- newGroupTexts2.push([...newGroupTexts[numcols - 1]]);
- } else {
- newGroupTexts2.push([...newGroupTexts2[colChange - 1]]);
- }
- let thisNewGroup = newGroupTexts2[colChange];
-
- if ([0, 2, 4].includes(colChange)) {
- thisNewGroup[0] = thisNew[0];
- thisNewGroup[2] = thisNew[1];
- }
- if ([2, 4].includes(colChange)) {
- thisNewGroup[4] = thisNew[2];
- }
- if (colChange === 2) {
- thisNewGroup[6] = thisNew[3];
- }
-
- if ([1, 3, 5].includes(colChange)) {
- thisNewGroup[1] = thisNew[0];
- thisNewGroup[3] = thisNew[1];
- }
- if ([3, 5].includes(colChange)) {
- thisNewGroup[5] = thisNew[2];
- }
- if (colChange === 3) {
- thisNewGroup[7] = thisNew[3];
- }
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let group = 0; group < 8; group++) {
- for (let inds of groupInds[group]) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(thisNewGroup[group]);
- expect(
- stateVariables["/s2"].replacements[0].stateValues
- .cells[inds[0]][inds[1]],
- ).eq(thisNewGroup[group]);
- }
- }
- });
- }
- });
-
- it.skip("mutual references between two spreadsheets", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
-
-
-
-
-
- first |
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get("#__text1").should("have.text", "");
-
- let firstInds = [
- [2, 2],
- [1, 1],
- [1, 3],
- [3, 0],
- [3, 2],
- [3, 4],
- [4, 4],
- [6, 3],
- [6, 5],
- ];
- let secondInds = [
- [1, 0],
- [1, 2],
- [1, 4],
- [3, 1],
- [3, 3],
- [4, 3],
- [4, 5],
- [6, 4],
- [5, 4],
- ];
-
- let row1Inds = [[1, 5]];
- let row2Inds = [[3, 5]];
-
- let block1Inds = [
- [2, 1],
- [2, 3],
- ];
- let block2Inds = [
- [5, 3],
- [5, 5],
- ];
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(7);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 6,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.numRows).eq(7);
- expect(stateVariables["/_spreadsheet2"].stateValues.numColumns).eq(
- 6,
- );
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(`first`);
- expect(
- ["", undefined].includes(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ),
- ).eq(true);
- }
- for (let inds of secondInds) {
- expect(
- ["", undefined].includes(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ),
- ).eq(true);
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(`first`);
- }
- for (let inds of [
- ...row1Inds,
- ...row2Inds,
- ...block1Inds,
- ...block2Inds,
- ]) {
- expect(
- ["", undefined].includes(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ),
- ).eq(true);
- expect(
- ["", undefined].includes(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ),
- ).eq(true);
- }
- });
-
- cy.log("change text of second group in first spreadsheet");
- for (let indsChange of secondInds) {
- let newText = `a${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("first");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("first");
- }
- });
- }
-
- cy.log("change text of first group in first spreadsheet");
- for (let indsChange of firstInds) {
- let newText = `b${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("a54");
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("a54");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- }
- });
- }
-
- cy.log("change text of first group in second spreadsheet");
- for (let indsChange of firstInds) {
- let newText = `c${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("b65");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("b65");
- }
- });
- }
-
- cy.log("change text of second group in second spreadsheet");
- for (let indsChange of secondInds) {
- let newText = `d${indsChange[0]}${indsChange[1]}`;
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let inds of firstInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("c65");
- }
- for (let inds of secondInds) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq("c65");
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[
- inds[0]
- ][inds[1]],
- ).eq(newText);
- }
- });
- }
-
- cy.log("change text of blocks in first spreadsheet");
-
- let blockTexts1 = [];
- for (let indsChange of [...block1Inds, ...block2Inds]) {
- let newText = `e${indsChange[0]}${indsChange[1]}`;
- blockTexts1.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let [i, inds] of [...block1Inds, ...block2Inds].entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts1[i]);
- }
- for (let [i, inds] of [...block2Inds, ...block1Inds].entries()) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts1[i]);
- }
- });
-
- cy.log("change text of blocks in second spreadsheet");
-
- let blockTexts2 = [];
- for (let indsChange of [...block1Inds, ...block2Inds]) {
- let newText = `f${indsChange[0]}${indsChange[1]}`;
- blockTexts2.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let [i, inds] of [...block1Inds, ...block2Inds].entries()) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts2[i]);
- }
- for (let [i, inds] of [...block2Inds, ...block1Inds].entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(blockTexts2[i]);
- }
- });
-
- cy.log("change text of rows in first spreadsheet");
-
- let rowTexts1 = [];
- for (let indsChange of [...row1Inds, ...row2Inds]) {
- let newText = `e${indsChange[0]}${indsChange[1]}`;
- rowTexts1.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let [i, inds] of [...row1Inds, ...row2Inds].entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(rowTexts1[i]);
- }
- for (let [i, inds] of [...row2Inds, ...row1Inds].entries()) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(rowTexts1[i]);
- }
- });
-
- cy.log("change text of rows in second spreadsheet");
-
- let rowTexts2 = [];
- for (let indsChange of [...row1Inds, ...row2Inds]) {
- let newText = `f${indsChange[0]}${indsChange[1]}`;
- rowTexts2.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let [i, inds] of [...row1Inds, ...row2Inds].entries()) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(rowTexts2[i]);
- }
- for (let [i, inds] of [...row2Inds, ...row1Inds].entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(rowTexts2[i]);
- }
- });
- });
-
- it.skip("references to cells outside spreadsheet area", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get("#__text1").should("have.text", "");
-
- let numcols1 = 17;
- let numrows1 = 10;
- let numcols2 = 7;
- let numrows2 = 8;
-
- let inds1A = [
- [0, 0],
- [0, 1],
- [0, 2],
- [1, 1],
- [1, 2],
- [2, 1],
- [2, 2],
- [3, 0],
- [3, 4],
- [3, 8],
- [3, 12],
- [3, 16],
- ];
-
- let inds1B = [
- [0, 16],
- [5, 4],
- [5, 5],
- [6, 4],
- [6, 5],
- [7, 4],
- [7, 5],
- [9, 0],
- [9, 4],
- [9, 8],
- [9, 12],
- [9, 16],
- ];
-
- let inds1C = [
- [4, 0],
- [4, 2],
- [4, 4],
- [4, 6],
- [1, 3],
- ];
- let inds2 = [
- [7, 0],
- [7, 2],
- [7, 4],
- [7, 6],
- [1, 6],
- ];
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(
- numrows1,
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- numcols1,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.numRows).eq(
- numrows2,
- );
- expect(stateVariables["/_spreadsheet2"].stateValues.numColumns).eq(
- numcols2,
- );
- });
-
- cy.log("enter text into first groups");
- let textsA = [];
- for (let indsChange of [...inds1A, ...inds1C]) {
- let newText = `a${indsChange[0]}${indsChange[1]}`;
- textsA.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let [i, inds] of [...inds1A, ...inds1C].entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(textsA[i]);
- }
- for (let [i, inds] of inds1B.entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(textsA[i]);
- }
- for (let [i, inds] of inds2.entries()) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(textsA[i + inds1B.length]);
- }
- });
-
- cy.log("enter text into second groups");
- let textsB = [];
- for (let indsChange of inds1B) {
- let newText = `b${indsChange[0]}${indsChange[1]}`;
- textsB.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- }
- for (let indsChange of inds2) {
- let newText = `c${indsChange[0]}${indsChange[1]}`;
- textsB.push(newText);
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet2"),
- row: indsChange[0] + 1,
- column: indsChange[1] + 1,
- text: newText,
- });
- }
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let [i, inds] of [...inds1A, ...inds1C].entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(textsB[i]);
- }
- for (let [i, inds] of inds1B.entries()) {
- expect(
- stateVariables["/_spreadsheet1"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(textsB[i]);
- }
- for (let [i, inds] of inds2.entries()) {
- expect(
- stateVariables["/_spreadsheet2"].stateValues.cells[inds[0]][
- inds[1]
- ],
- ).eq(textsB[i + inds1B.length]);
- }
- });
- });
-
- it.skip("internal references to spreadsheet size", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- |
- |
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get(cesc("#\\/t1")).should("have.text", "4");
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(4);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 4,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(4);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(4);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "4",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "4",
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][0],
- ).eq("4");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][1],
- ).eq("4");
- });
-
- cy.log("increase rownum and colnum in first spreadsheet");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 1,
- text: "6",
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 2,
- row: 1,
- text: "7",
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(6);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 7,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(6);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(7);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "6",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "7",
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][0],
- ).eq("6");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][1],
- ).eq("7");
- });
-
- cy.log("can't decrease rownum and colnum");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 1,
- text: "3",
- verify: false,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 2,
- row: 1,
- text: "2",
- verify: false,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(6);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 7,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(6);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(7);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "6",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "7",
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][0],
- ).eq("6");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][1],
- ).eq("7");
- });
-
- cy.log("can't make non-numeric rownum and colnum");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 1,
- text: "hello",
- verify: false,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 2,
- row: 1,
- text: "x",
- verify: false,
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(6);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 7,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(6);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(7);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "6",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "7",
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][0],
- ).eq("6");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][1],
- ).eq("7");
- });
-
- cy.log("increase rownum and colnum in second spreadsheet");
- enterSpreadsheetText({
- id: "__spreadsheet1",
- column: 1,
- row: 1,
- text: "11",
- });
- enterSpreadsheetText({
- id: "__spreadsheet1",
- column: 2,
- row: 1,
- text: "9",
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(11);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 9,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(11);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(9);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "11",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "9",
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][0],
- ).eq("11");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][1],
- ).eq("9");
- });
- });
-
- it.skip("spreadsheet size based on internal references", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- // to wait for page to load
- cy.get("#__text1").should("have.text", "");
-
- cy.log("check initial cell values");
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(4);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 4,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(4);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(4);
- expect(
- [undefined, ""].includes(
- stateVariables["/_spreadsheet1"].stateValues.cells[0][0],
- ),
- ).eq(true);
- expect(
- [undefined, ""].includes(
- stateVariables["/_spreadsheet1"].stateValues.cells[0][1],
- ),
- ).eq(true);
- expect(
- [undefined, ""].includes(
- stateVariables["/s2"].replacements[0].stateValues
- .cells[0][0],
- ),
- ).eq(true);
- expect(
- [undefined, ""].includes(
- stateVariables["/s2"].replacements[0].stateValues
- .cells[0][1],
- ),
- ).eq(true);
- });
-
- cy.log("increase rownum and colnum in first spreadsheet");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 1,
- text: "6",
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 2,
- row: 1,
- text: "7",
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(6);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 7,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(6);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(7);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "6",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "7",
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][0],
- ).eq("6");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][1],
- ).eq("7");
- });
-
- cy.log("can't decrease rownum and colnum");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 1,
- text: "3",
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 2,
- row: 1,
- text: "2",
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(6);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 7,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(6);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(7);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "3",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "2",
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][0],
- ).eq("3");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][1],
- ).eq("2");
- });
-
- cy.log("can't make non-numeric rownum and colnum");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 1,
- text: "hello",
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 2,
- row: 1,
- text: "x",
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(6);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 7,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(6);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(7);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "hello",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "x",
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][0],
- ).eq("hello");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][1],
- ).eq("x");
- });
-
- cy.log("increase rownum and colnum in second spreadsheet");
- enterSpreadsheetText({
- id: "__spreadsheet1",
- column: 1,
- row: 1,
- text: "11",
- });
- enterSpreadsheetText({
- id: "__spreadsheet1",
- column: 2,
- row: 1,
- text: "9",
- });
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.numRows).eq(11);
- expect(stateVariables["/_spreadsheet1"].stateValues.numColumns).eq(
- 9,
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numRows,
- ).eq(11);
- expect(
- stateVariables["/s2"].replacements[0].stateValues.numColumns,
- ).eq(9);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "11",
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- "9",
- );
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][0],
- ).eq("11");
- expect(
- stateVariables["/s2"].replacements[0].stateValues.cells[0][1],
- ).eq("9");
- });
- });
-
- it("references to cells, adapter to math, number, or text", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- 1 |
-
-
- A
-
-
- +1
- +1
- B
-
-
-
- +
- +
- +
-
- `,
- },
- "*",
- );
- });
-
- cy.log("check initial cell values");
-
- cy.get(cesc("#\\/_p1")).should("have.text", "1 A");
-
- cy.get(cesc("#\\/_math1") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("2");
- });
- cy.get(cesc("#\\/_number1")).should("have.text", "2");
- cy.get(cesc("#\\/_text1")).should("have.text", "1 B");
-
- cy.get(cesc("#\\/_math2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("1+_");
- });
- cy.get(cesc("#\\/_number2")).should("have.text", "NaN");
- cy.get(cesc("#\\/_text2")).should("have.text", "1 + ");
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- "1",
- );
- });
-
- cy.log("different numbers in cells");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 1,
- text: "5",
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 2,
- text: "7",
- });
-
- cy.get(cesc("#\\/_text2")).should("have.text", "5 + 7");
- cy.get(cesc("#\\/_p1")).should("have.text", "5 A");
-
- cy.get(cesc("#\\/_math1") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("6");
- });
- cy.get(cesc("#\\/_number1")).should("have.text", "6");
- cy.get(cesc("#\\/_text1")).should("have.text", "5 B");
-
- cy.get(cesc("#\\/_math2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("12");
- });
- cy.get(cesc("#\\/_number2")).should("have.text", "12");
-
- cy.log("different variables in cells");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 1,
- text: "x",
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 2,
- text: "y",
- });
-
- cy.get(cesc("#\\/_text2")).should("have.text", "x + y");
- cy.get(cesc("#\\/_p1")).should("have.text", "x A");
-
- cy.get(cesc("#\\/_math1") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("x+1");
- });
- cy.get(cesc("#\\/_number1")).should("have.text", "NaN");
- cy.get(cesc("#\\/_text1")).should("have.text", "x B");
-
- cy.get(cesc("#\\/_math2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("x+y");
- });
- cy.get(cesc("#\\/_number2")).should("have.text", "NaN");
-
- cy.log("non-valid math in one cell");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 1,
- text: "q(",
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 2,
- text: "sin(w)",
- });
-
- cy.get(cesc("#\\/_text2")).should("have.text", "q( + sin(w)");
- cy.get(cesc("#\\/_p1")).should("have.text", "q( A");
-
- cy.get(cesc("#\\/_math1") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("_+1");
- });
- cy.get(cesc("#\\/_number1")).should("have.text", "NaN");
- cy.get(cesc("#\\/_text1")).should("have.text", "q( B");
-
- cy.get(cesc("#\\/_math2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("_+sin(w)");
- });
- cy.get(cesc("#\\/_number2")).should("have.text", "NaN");
-
- cy.log("one cell is blank");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 1,
- text: "",
- clear: true,
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 2,
- text: "5",
- });
-
- cy.get(cesc("#\\/_text2")).should("have.text", " + 5");
- cy.get(cesc("#\\/_p1")).should("have.text", " A");
-
- cy.get(cesc("#\\/_math1") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("_+1");
- });
- cy.get(cesc("#\\/_number1")).should("have.text", "NaN");
- cy.get(cesc("#\\/_text1")).should("have.text", " B");
-
- cy.get(cesc("#\\/_math2") + " .mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("_+5");
- });
- cy.get(cesc("#\\/_number2")).should("have.text", "NaN");
- });
-
- it("references to cells where not adapted", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- 1 | 2 |
-
-
-$s.cellB1{assignNames="c1"}
-$s.cellA1{assignNames="c2"}
-
-
-
-
- Hello |
-
-
-
- Bye |
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.log("check initial cell values");
-
- cy.get(cesc("#\\/c1")).should("have.text", "2");
- cy.get(cesc("#\\/c2")).should("have.text", "1");
- cy.get(cesc("#\\/_row1")).should("have.text", "2Hello");
- cy.get(cesc("#\\/_row2")).should("have.text", "Bye1");
-
- cy.log("change cells");
- enterSpreadsheetText({
- id: cesc("\\/s"),
- column: 1,
- row: 1,
- text: "A",
- });
- enterSpreadsheetText({
- id: cesc("\\/s"),
- column: 2,
- row: 1,
- text: "B",
- });
- enterSpreadsheetText({
- id: cesc("\\/s"),
- column: 2,
- row: 2,
- text: "C",
- });
-
- cy.get(cesc("#\\/_row1")).should("have.text", "BHelloC");
- cy.get(cesc("#\\/c1")).should("have.text", "B");
- cy.get(cesc("#\\/c2")).should("have.text", "A");
- cy.get(cesc("#\\/_row2")).should("have.text", "ByeA");
- });
-
- it.skip("references to cells within other cells math", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- 1 | + |
- 3 |
- + |
- 5 |
-
-
- +1
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_spreadsheet1")); //wait for window to load
-
- cy.log("check initial cell values");
-
- cy.get(cesc("#\\/x"))
- .find(".mjx-mrow")
- .eq(0)
- .invoke("text")
- .then((text) => {
- expect(text.trim()).equal("2");
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let A1 = 1;
- let C2 = 5;
- let A2 = 3;
- let x = A1 + 1;
- let B1 = x + A2;
- let B2 = A1 + C2;
-
- expect(stateVariables["/x"].stateValues.value).eq(x);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- A1.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- B1.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][0]).eq(
- A2.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][1]).eq(
- B2.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][2]).eq(
- C2.toString(),
- );
- });
-
- cy.log("enter different defining numbers");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 1,
- text: "7",
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 1,
- row: 2,
- text: "8",
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 3,
- row: 2,
- text: "9",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let A1 = 7;
- let C2 = 9;
- let A2 = 8;
- let x = A1 + 1;
- let B1 = x + A2;
- let B2 = A1 + C2;
-
- expect(stateVariables["/x"].stateValues.value).eq(x);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- A1.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- B1.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][0]).eq(
- A2.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][1]).eq(
- B2.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][2]).eq(
- C2.toString(),
- );
- });
-
- cy.log("enter different resulting numbers");
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 2,
- row: 1,
- text: "3",
- });
- enterSpreadsheetText({
- id: cesc("\\/_spreadsheet1"),
- column: 2,
- row: 2,
- text: "4",
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- let A1 = 7;
- let x = A1 + 1;
- let B1 = 3;
- let B2 = 4;
-
- let C2 = B2 - A1;
- let A2 = B1 - x;
-
- expect(stateVariables["/x"].stateValues.value).eq(x);
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][0]).eq(
- A1.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[0][1]).eq(
- B1.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][0]).eq(
- A2.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][1]).eq(
- B2.toString(),
- );
- expect(stateVariables["/_spreadsheet1"].stateValues.cells[1][2]).eq(
- C2.toString(),
- );
- });
- });
-
- it("spreadsheet can merge coordinates", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- |
-
-
-
-
- Change x-coordinate:
- Change y-coordinate:
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/x1") + " textarea").type("{end}{backspace}3{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/t1")).should("have.text", "( 3, 2 )");
-
- cy.get(cesc("#\\/x2") + " textarea").type("{end}{backspace}4{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/t1")).should("have.text", "( 3, 4 )");
- });
-
- it("spreadsheet can merge coordinates, with math child", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- (1,2) |
-
-
-
-
- Change x-coordinate:
- Change y-coordinate:
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
-
- cy.get(cesc("#\\/x1") + " textarea").type("{end}{backspace}3{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/t1")).should("have.text", "( 3, 2 )");
-
- cy.get(cesc("#\\/x2") + " textarea").type("{end}{backspace}4{enter}", {
- force: true,
- });
-
- cy.get(cesc("#\\/t1")).should("have.text", "( 3, 4 )");
- });
-
- it("copy propIndex of cells", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
- A | B | C |
- D | E | F |
- G | H | I |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let row = ["A", "B", "C"];
- let column = ["B", "E", "H"];
-
- cy.get(cesc("#\\/R1")).should("not.exist");
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("not.exist");
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("1{enter}", { force: true });
- cy.get(cesc("#\\/R1")).should("have.text", row[0]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[0]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}2{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("have.text", row[1]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[1]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}3{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("have.text", row[2]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[2]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}4{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("not.exist");
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("not.exist");
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
- });
-
- it("copy propIndex of cells, dot and array notation", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
- A | B | C |
- D | E | F |
- G | H | I |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let row = ["A", "B", "C"];
- let column = ["B", "E", "H"];
-
- cy.get(cesc("#\\/R1")).should("not.exist");
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("not.exist");
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("1{enter}", { force: true });
- cy.get(cesc("#\\/R1")).should("have.text", row[0]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[0]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}2{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("have.text", row[1]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[1]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}3{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("have.text", row[2]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[2]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}4{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("not.exist");
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("not.exist");
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
- });
-
- it("copy multidimensional propIndex of cells, array notation", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
- A | B | C |
- D | E | F |
- G | H | I |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let row = ["A", "B", "C"];
- let column = ["B", "E", "H"];
-
- cy.get(cesc("#\\/R1")).should("not.exist");
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("not.exist");
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("1{enter}", { force: true });
- cy.get(cesc("#\\/R1")).should("have.text", row[0]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[0]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}2{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("have.text", row[1]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[1]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}3{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("have.text", row[2]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[2]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}4{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("not.exist");
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("not.exist");
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
- });
-
- it("copy multidimensional propIndex of rows and columns, dot and array notation", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
- A | B | C |
- D | E | F |
- G | H | I |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let row = ["A", "B", "C"];
- let column = ["B", "E", "H"];
-
- cy.get(cesc("#\\/R1")).should("not.exist");
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("not.exist");
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("1{enter}", { force: true });
- cy.get(cesc("#\\/R1")).should("have.text", row[0]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[0]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}2{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("have.text", row[1]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[1]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}3{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("have.text", row[2]);
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("have.text", column[2]);
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}4{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("not.exist");
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("not.exist");
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
- });
-
- it("copy single propIndex of rows and columns, dot and array notation", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
- A | B | C |
- D | E | F |
- G | H | I |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- let rows = [
- ["A", "B", "C"],
- ["D", "E", "F"],
- ["G", "H", "I"],
- ];
- let columns = [
- ["A", "D", "G"],
- ["B", "E", "H"],
- ["C", "F", "I"],
- ];
-
- cy.get(cesc("#\\/R1")).should("not.exist");
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("not.exist");
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
-
- cy.get(cesc("#\\/n") + " textarea").type("1{enter}", { force: true });
- cy.get(cesc("#\\/R1")).should("have.text", rows[0][0]);
- cy.get(cesc("#\\/R2")).should("have.text", rows[0][1]);
- cy.get(cesc("#\\/R3")).should("have.text", rows[0][2]);
- cy.get(cesc("#\\/C1")).should("have.text", columns[0][0]);
- cy.get(cesc("#\\/C2")).should("have.text", columns[0][1]);
- cy.get(cesc("#\\/C3")).should("have.text", columns[0][2]);
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}2{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("have.text", rows[1][0]);
- cy.get(cesc("#\\/R2")).should("have.text", rows[1][1]);
- cy.get(cesc("#\\/R3")).should("have.text", rows[1][2]);
- cy.get(cesc("#\\/C1")).should("have.text", columns[1][0]);
- cy.get(cesc("#\\/C2")).should("have.text", columns[1][1]);
- cy.get(cesc("#\\/C3")).should("have.text", columns[1][2]);
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}3{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("have.text", rows[2][0]);
- cy.get(cesc("#\\/R2")).should("have.text", rows[2][1]);
- cy.get(cesc("#\\/R3")).should("have.text", rows[2][2]);
- cy.get(cesc("#\\/C1")).should("have.text", columns[2][0]);
- cy.get(cesc("#\\/C2")).should("have.text", columns[2][1]);
- cy.get(cesc("#\\/C3")).should("have.text", columns[2][2]);
-
- cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}4{enter}", {
- force: true,
- });
- cy.get(cesc("#\\/R1")).should("not.exist");
- cy.get(cesc("#\\/R2")).should("not.exist");
- cy.get(cesc("#\\/R3")).should("not.exist");
- cy.get(cesc("#\\/C1")).should("not.exist");
- cy.get(cesc("#\\/C2")).should("not.exist");
- cy.get(cesc("#\\/C3")).should("not.exist");
});
it("copy propIndex of evaluated cells", () => {
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/stickygroup.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/stickygroup.cy.js
deleted file mode 100644
index b317cb206..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/stickygroup.cy.js
+++ /dev/null
@@ -1,2043 +0,0 @@
-import me from "math-expressions";
-import { cesc2 } from "@doenet/utils";
-
-describe("StickyGroup Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- async function testScene({
- vertices1,
- vertices2,
- point,
- polygon1Name = "/pg1",
- polygon2Name = "/pg2",
- pointName = "/A",
- stickyGroupName = "/sg",
- graph1Name = "/g1",
- graph2Name = "/g2",
- graph3Name = "/g3",
- graph4Name = "/g4",
- }) {
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(
- stateVariables[graph1Name + stickyGroupName + polygon1Name]
- .stateValues.numVertices,
- ).eq(vertices1.length);
- expect(
- stateVariables[graph2Name + stickyGroupName + polygon1Name]
- .stateValues.numVertices,
- ).eq(vertices1.length);
- expect(
- stateVariables[graph3Name + stickyGroupName + polygon1Name]
- .stateValues.numVertices,
- ).eq(vertices1.length);
- expect(
- stateVariables[graph4Name + stickyGroupName + polygon1Name]
- .stateValues.numVertices,
- ).eq(vertices1.length);
-
- expect(
- stateVariables[graph1Name + stickyGroupName + polygon2Name]
- .stateValues.numVertices,
- ).eq(vertices2.length);
- expect(
- stateVariables[graph2Name + stickyGroupName + polygon2Name]
- .stateValues.numVertices,
- ).eq(vertices2.length);
- expect(
- stateVariables[graph3Name + stickyGroupName + polygon2Name]
- .stateValues.numVertices,
- ).eq(vertices2.length);
- expect(
- stateVariables[graph4Name + stickyGroupName + polygon2Name]
- .stateValues.numVertices,
- ).eq(vertices2.length);
-
- for (let i in vertices1) {
- for (let dim in vertices1[i]) {
- if (Number.isFinite(vertices1[i][dim])) {
- expect(
- me
- .fromAst(
- stateVariables[
- graph1Name +
- stickyGroupName +
- polygon1Name
- ].stateValues.vertices[i][dim],
- )
- .evaluate_to_constant(),
- ).closeTo(vertices1[i][dim], 1e-12);
- expect(
- me
- .fromAst(
- stateVariables[
- graph2Name +
- stickyGroupName +
- polygon1Name
- ].stateValues.vertices[i][dim],
- )
- .evaluate_to_constant(),
- ).closeTo(vertices1[i][dim], 1e-12);
- expect(
- me
- .fromAst(
- stateVariables[
- graph3Name +
- stickyGroupName +
- polygon1Name
- ].stateValues.vertices[i][dim],
- )
- .evaluate_to_constant(),
- ).closeTo(vertices1[i][dim], 1e-12);
- expect(
- me
- .fromAst(
- stateVariables[
- graph4Name +
- stickyGroupName +
- polygon1Name
- ].stateValues.vertices[i][dim],
- )
- .evaluate_to_constant(),
- ).closeTo(vertices1[i][dim], 1e-12);
- } else {
- expect(
- stateVariables[
- graph1Name + stickyGroupName + polygon1Name
- ].stateValues.vertices[i][dim],
- ).eq(vertices1[i][dim]);
- expect(
- stateVariables[
- graph2Name + stickyGroupName + polygon1Name
- ].stateValues.vertices[i][dim],
- ).eq(vertices1[i][dim]);
- expect(
- stateVariables[
- graph3Name + stickyGroupName + polygon1Name
- ].stateValues.vertices[i][dim],
- ).eq(vertices1[i][dim]);
- expect(
- stateVariables[
- graph4Name + stickyGroupName + polygon1Name
- ].stateValues.vertices[i][dim],
- ).eq(vertices1[i][dim]);
- }
- }
- }
-
- for (let i in vertices2) {
- for (let dim in vertices2[i]) {
- if (Number.isFinite(vertices2[i][dim])) {
- expect(
- me
- .fromAst(
- stateVariables[
- graph1Name +
- stickyGroupName +
- polygon2Name
- ].stateValues.vertices[i][dim],
- )
- .evaluate_to_constant(),
- ).closeTo(vertices2[i][dim], 1e-12);
- expect(
- me
- .fromAst(
- stateVariables[
- graph2Name +
- stickyGroupName +
- polygon2Name
- ].stateValues.vertices[i][dim],
- )
- .evaluate_to_constant(),
- ).closeTo(vertices2[i][dim], 1e-12);
- expect(
- me
- .fromAst(
- stateVariables[
- graph3Name +
- stickyGroupName +
- polygon2Name
- ].stateValues.vertices[i][dim],
- )
- .evaluate_to_constant(),
- ).closeTo(vertices2[i][dim], 1e-12);
- expect(
- me
- .fromAst(
- stateVariables[
- graph4Name +
- stickyGroupName +
- polygon2Name
- ].stateValues.vertices[i][dim],
- )
- .evaluate_to_constant(),
- ).closeTo(vertices2[i][dim], 1e-12);
- } else {
- expect(
- stateVariables[
- graph1Name + stickyGroupName + polygon2Name
- ].stateValues.vertices[i][dim],
- ).eq(vertices2[i][dim]);
- expect(
- stateVariables[
- graph2Name + stickyGroupName + polygon2Name
- ].stateValues.vertices[i][dim],
- ).eq(vertices2[i][dim]);
- expect(
- stateVariables[
- graph3Name + stickyGroupName + polygon2Name
- ].stateValues.vertices[i][dim],
- ).eq(vertices2[i][dim]);
- expect(
- stateVariables[
- graph4Name + stickyGroupName + polygon2Name
- ].stateValues.vertices[i][dim],
- ).eq(vertices2[i][dim]);
- }
- }
- }
-
- for (let dim in point) {
- if (Number.isFinite(point[dim])) {
- expect(
- me
- .fromAst(
- stateVariables[
- graph1Name + stickyGroupName + pointName
- ].stateValues.xs[dim],
- )
- .evaluate_to_constant(),
- ).closeTo(point[dim], 1e-12);
- expect(
- me
- .fromAst(
- stateVariables[
- graph2Name + stickyGroupName + pointName
- ].stateValues.xs[dim],
- )
- .evaluate_to_constant(),
- ).closeTo(point[dim], 1e-12);
- expect(
- me
- .fromAst(
- stateVariables[
- graph3Name + stickyGroupName + pointName
- ].stateValues.xs[dim],
- )
- .evaluate_to_constant(),
- ).closeTo(point[dim], 1e-12);
- expect(
- me
- .fromAst(
- stateVariables[
- graph4Name + stickyGroupName + pointName
- ].stateValues.xs[dim],
- )
- .evaluate_to_constant(),
- ).closeTo(point[dim], 1e-12);
- } else {
- expect(
- stateVariables[graph1Name + stickyGroupName + pointName]
- .stateValues.xs[dim],
- ).eq(point[dim]);
- expect(
- stateVariables[graph2Name + stickyGroupName + pointName]
- .stateValues.xs[dim],
- ).eq(point[dim]);
- expect(
- stateVariables[graph3Name + stickyGroupName + pointName]
- .stateValues.xs[dim],
- ).eq(point[dim]);
- expect(
- stateVariables[graph4Name + stickyGroupName + pointName]
- .stateValues.xs[dim],
- ).eq(point[dim]);
- }
- }
- });
- }
-
- it("attract polygons and point when translating", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
- (-6,2)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait for page to load
-
- let vertices1 = [
- [1, 2],
- [4, 5],
- [-2, 5],
- ];
-
- let vertices2 = [
- [7, 8],
- [5, 4],
- [9, 1],
- [7, 3],
- ];
-
- let point = [-6, 2];
-
- testScene({ vertices1, vertices2, point });
-
- cy.log("move polygon 1 vertex near vertex of polygon 2");
- cy.window().then(async (win) => {
- let moveX = 0.8;
- let moveY = -1.2;
-
- let requested_vertices1 = vertices1.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g1/sg/pg1",
- args: {
- pointCoords: requested_vertices1,
- },
- });
-
- let actualMoveX = 1;
- let actualMoveY = -1;
-
- vertices1 = vertices1.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move polygon 2 vertex near vertex of polygon 1");
- cy.window().then(async (win) => {
- let moveX = -5.2;
- let moveY = -2.3;
-
- let requested_vertices2 = vertices2.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g2/sg/pg2",
- args: {
- pointCoords: requested_vertices2,
- },
- });
-
- let actualMoveX = -5;
- let actualMoveY = -2;
-
- vertices2 = vertices2.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
-
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move polygon 2 left further to unstick from polygon 1");
- cy.window().then(async (win) => {
- let moveX = -1;
- let moveY = 0;
-
- let requested_vertices2 = vertices2.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g3/sg/pg2",
- args: {
- pointCoords: requested_vertices2,
- },
- });
-
- let actualMoveX = -1;
- let actualMoveY = 0;
-
- vertices2 = vertices2.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
-
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move polygon 1 vertex near point");
- cy.window().then(async (win) => {
- let moveX = -4.8;
- let moveY = -1.8;
-
- let requested_vertices1 = vertices1.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g4/sg/pg1",
- args: {
- pointCoords: requested_vertices1,
- },
- });
-
- let actualMoveX = -5;
- let actualMoveY = -2;
-
- vertices1 = vertices1.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
-
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move point near polygon2 vertex");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/g1/sg/A",
- args: {
- x: 0.8,
- y: 0.8,
- },
- });
-
- point = [1, 1];
-
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move point away from vertices and edges");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePoint",
- componentName: "/g2/sg/A",
- args: {
- x: -2,
- y: 1,
- },
- });
-
- point = [-2, 1];
-
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move polygon 1 vertex near edge of polygon 2");
- cy.window().then(async (win) => {
- let moveX = 1.4;
- let moveY = 3;
-
- let requested_vertices1 = vertices1.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g3/sg/pg1",
- args: {
- pointCoords: requested_vertices1,
- },
- });
-
- let actualMoveX = 1;
- let actualMoveY = 3;
-
- vertices1 = vertices1.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move polygon 2 vertex next edge of polygon 1");
- cy.window().then(async (win) => {
- let moveX = 1.2;
- let moveY = 1.8;
-
- let requested_vertices2 = vertices2.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g4/sg/pg2",
- args: {
- pointCoords: requested_vertices2,
- },
- });
-
- let actualMoveX = 1;
- let actualMoveY = 2;
-
- vertices2 = vertices2.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
-
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move polygon 1 edge near vertex of polygon 2");
- cy.window().then(async (win) => {
- let moveX = 2.8;
- let moveY = 0.2;
-
- let requested_vertices1 = vertices1.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g1/sg/pg1",
- args: {
- pointCoords: requested_vertices1,
- },
- });
-
- let actualMoveX = 3;
- let actualMoveY = 0;
-
- vertices1 = vertices1.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move polygon 2 edge next vertex of polygon 1");
- cy.window().then(async (win) => {
- let moveX = 2.2;
- let moveY = -2;
-
- let requested_vertices2 = vertices2.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g2/sg/pg2",
- args: {
- pointCoords: requested_vertices2,
- },
- });
-
- let actualMoveX = 2;
- let actualMoveY = -2;
-
- vertices2 = vertices2.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
-
- testScene({ vertices1, vertices2, point });
- });
- });
-
- it("attract parallel edges of polygons when translating", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait for page to load
-
- let vertices1 = [
- [1, 2],
- [4, 5],
- [-2, 5],
- ];
-
- let vertices2 = [
- [9, 8],
- [3, 2],
- [9, 1],
- ];
-
- let point = [];
-
- testScene({ vertices1, vertices2, point });
-
- cy.log("move polygon 1 edge near edge of polygon 2");
- cy.window().then(async (win) => {
- let moveX = 1.5;
- let moveY = 0;
-
- let requested_vertices1 = vertices1.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g1/sg/pg1",
- args: {
- pointCoords: requested_vertices1,
- },
- });
-
- let actualMoveX = 1.75;
- let actualMoveY = -0.25;
-
- vertices1 = vertices1.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log(
- "move polygon 1 so edge is just past edge of polygon 2, vertices attract",
- );
- cy.window().then(async (win) => {
- let moveX = 0;
- let moveY = 0.25;
-
- let requested_vertices1 = vertices1.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g2/sg/pg1",
- args: {
- pointCoords: requested_vertices1,
- },
- });
-
- let actualMoveX = 0.25;
- let actualMoveY = 0.25;
-
- vertices1 = vertices1.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
-
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log(
- "move polygon 1 edge so that polygon 2 edge is just past edge of polygon 1, vertices attract",
- );
- cy.window().then(async (win) => {
- let moveX = 2.9;
- let moveY = 2.8;
-
- let requested_vertices1 = vertices1.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g3/sg/pg1",
- args: {
- pointCoords: requested_vertices1,
- },
- });
-
- let actualMoveX = 3;
- let actualMoveY = 3;
-
- vertices1 = vertices1.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
-
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move polygon 1 edge further so vertices don't attract");
- cy.window().then(async (win) => {
- let moveX = -0.5;
- let moveY = -0.4;
-
- let requested_vertices1 = vertices1.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g4/sg/pg1",
- args: {
- pointCoords: requested_vertices1,
- },
- });
-
- let actualMoveX = -0.45;
- let actualMoveY = -0.45;
-
- vertices1 = vertices1.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
-
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move polygon 2 edge so just past edge of polygon 1");
- cy.window().then(async (win) => {
- let moveX = 2.5;
- let moveY = 2.0;
-
- let requested_vertices2 = vertices2.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g3/sg/pg2",
- args: {
- pointCoords: requested_vertices2,
- },
- });
-
- let actualMoveX = 2.25;
- let actualMoveY = 2.25;
-
- vertices2 = vertices2.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log(
- "move polygon 2 less past edge of polygon 1 so vertices attract",
- );
- cy.window().then(async (win) => {
- let moveX = 0.2;
- let moveY = 0.0;
-
- let requested_vertices2 = vertices2.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g4/sg/pg2",
- args: {
- pointCoords: requested_vertices2,
- },
- });
-
- let actualMoveX = 0.3;
- let actualMoveY = 0.3;
-
- vertices2 = vertices2.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
-
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log(
- "move polygon 2 edge so that polygon 1 edge is just past edge of polygon 2, vertices attract",
- );
- cy.window().then(async (win) => {
- let moveX = -2.8;
- let moveY = -2.6;
-
- let requested_vertices2 = vertices2.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g1/sg/pg2",
- args: {
- pointCoords: requested_vertices2,
- },
- });
-
- let actualMoveX = -3;
- let actualMoveY = -3;
-
- vertices2 = vertices2.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
- testScene({ vertices1, vertices2, point });
- });
-
- cy.log("move polygon 2 edge further so vertices don't attract");
- cy.window().then(async (win) => {
- let moveX = -0.5;
- let moveY = -0.3;
-
- let requested_vertices2 = vertices2.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/g2/sg/pg2",
- args: {
- pointCoords: requested_vertices2,
- },
- });
-
- let actualMoveX = -0.4;
- let actualMoveY = -0.4;
-
- vertices2 = vertices2.map((vertex) => [
- vertex[0] + actualMoveX,
- vertex[1] + actualMoveY,
- ]);
-
- testScene({ vertices1, vertices2, point });
- });
- });
-
- it("attract polygons when moving vertices, rigid and non-rigid", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
- $pg1.vertices
- $pg2.vertices
-
-
-
- `,
- },
- "*",
- );
- });
-
- let vertices2 = [
- [7, 8],
- [5, 4],
- [9, 1],
- [7, 3],
- ];
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.log(
- "rotate polygon 1 to nearly match slope of nearby polygon 2 edge",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg1",
- args: {
- pointCoords: { 0: [1.6, 2] },
- },
- });
-
- let desired_slope = 2;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pg1 = stateVariables["/pg1"].stateValues.numericalVertices;
- let actual_slope =
- (pg1[1][1] - pg1[0][1]) / (pg1[1][0] - pg1[0][0]);
-
- expect(actual_slope).closeTo(desired_slope, 1e-12);
- });
- });
-
- cy.log(
- "if move polygon 1 further away, slope does not attract to polygon 2 edge",
- );
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let moveX = -1;
- let moveY = 1;
-
- let desired_vertices = stateVariables[
- "/pg1"
- ].stateValues.numericalVertices.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg1",
- args: {
- pointCoords: desired_vertices,
- },
- });
-
- // perturb vertex slightly
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg1",
- args: {
- pointCoords: {
- 0: [
- desired_vertices[0][0] + 0.01,
- desired_vertices[0][1] - 0.01,
- ],
- },
- },
- });
- });
-
- let desired_slope = 2;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pg1 = stateVariables["/pg1"].stateValues.numericalVertices;
- let actual_slope =
- (pg1[1][1] - pg1[0][1]) / (pg1[1][0] - pg1[0][0]);
-
- expect(actual_slope).not.closeTo(desired_slope, 0.001);
- });
-
- cy.log("polygon 1 edge still attracts to vertical");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg1",
- args: {
- pointCoords: {
- 0: [-2.1, 5.1],
- },
- },
- });
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pg1 = stateVariables["/pg1"].stateValues.numericalVertices;
-
- // edge should be vertical
- expect(pg1[2][0]).closeTo(pg1[1][0], 1e-12);
- });
-
- cy.log("polygon 1 edge still attracts to horizontal");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg1",
- args: {
- pointCoords: {
- 0: [0.2, 7.2],
- },
- },
- });
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pg1 = stateVariables["/pg1"].stateValues.numericalVertices;
-
- // edge should be horizontal
- expect(pg1[2][1]).closeTo(pg1[1][1], 1e-12);
- });
-
- cy.log(
- "move polygon 1 and rotate so vertex is very close to polygon 2 vertex to attract",
- );
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let moveX = 7;
- let moveY = -6.5;
-
- let desired_vertices = stateVariables[
- "/pg1"
- ].stateValues.numericalVertices.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg1",
- args: {
- pointCoords: desired_vertices,
- },
- });
-
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg1",
- args: {
- pointCoords: {
- 0: [5.2, -0.8],
- },
- },
- });
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pg1 = stateVariables["/pg1"].stateValues.numericalVertices;
-
- // point3 should be at polygon 2's vertex
- expect(pg1[2][0]).closeTo(9, 1e-12);
- expect(pg1[2][1]).closeTo(1, 1e-12);
- });
-
- cy.log("small change in rotation stops attraction");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg1",
- args: {
- pointCoords: {
- 0: [5.3, -0.8],
- },
- },
- });
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pg1 = stateVariables["/pg1"].stateValues.numericalVertices;
-
- // point3 should be a small distance from polygon 2's vertex
- expect(pg1[2][0]).not.closeTo(9, 0.01);
- expect(pg1[2][1]).not.closeTo(1, 0.01);
- });
-
- cy.log("rotate and move polygon 1 to have vertical edge");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg1",
- args: {
- pointCoords: {
- 0: [4.9, -1.6],
- },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let moveX = -7;
- let moveY = 0.5;
-
- let desired_vertices = stateVariables[
- "/pg1"
- ].stateValues.numericalVertices.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg1",
- args: {
- pointCoords: desired_vertices,
- },
- });
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pg1 = stateVariables["/pg1"].stateValues.numericalVertices;
-
- // edge should be vertical
- expect(pg1[2][0]).closeTo(pg1[1][0], 1e-12);
- });
-
- cy.log("move polygon 2 vertex so edge attracts to polygon 1 vertex");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg2",
- args: {
- pointCoords: { 2: [-0.3, -6] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let pg1 = stateVariables["/pg1"].stateValues.numericalVertices;
- let pg2 = stateVariables["/pg2"].stateValues.numericalVertices;
-
- // vertex 2 of pg1 should be along edge of vertices of 2 and 3 of pg2
- let slope1 = (pg2[2][1] - pg2[1][1]) / (pg2[2][0] - pg2[1][0]);
- let slope2 = (pg1[1][1] - pg2[1][1]) / (pg1[1][0] - pg2[1][0]);
-
- expect(slope2).closeTo(slope1, 1e-12);
-
- // vertices other than 3 of polygon 2 should be in original positions
- expect(pg2[0]).eqls(vertices2[0]);
- expect(pg2[1]).eqls(vertices2[1]);
- expect(pg2[3]).eqls(vertices2[3]);
-
- vertices2[2] = pg2[2];
- });
-
- cy.log(
- "move polygon 2 vertex so edge almost attracts to polygon 1 vertex",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg2",
- args: {
- pointCoords: { 0: [-10, 0.8] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- let pg2 = stateVariables["/pg2"].stateValues.numericalVertices;
-
- // vertex did not attract
- expect(pg2[0]).eqls([-10, 0.8]);
-
- expect(pg2[1]).eqls(vertices2[1]);
- expect(pg2[2]).eqls(vertices2[2]);
- expect(pg2[3]).eqls(vertices2[3]);
-
- vertices2[0] = pg2[0];
- });
-
- cy.log(
- "move polygon 2 vertex closer so edge does attract to polygon 1 vertex",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg2",
- args: {
- pointCoords: { 0: [-10, 0.6] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let pg1 = stateVariables["/pg1"].stateValues.numericalVertices;
- let pg2 = stateVariables["/pg2"].stateValues.numericalVertices;
-
- // vertex 3 of pg1 should be along edge of vertices of 1 and 4 of pg2
- let slope1 = (pg2[3][1] - pg2[0][1]) / (pg2[3][0] - pg2[0][0]);
- let slope2 = (pg1[2][1] - pg2[0][1]) / (pg1[2][0] - pg2[0][0]);
-
- expect(slope2).closeTo(slope1, 1e-12);
-
- // vertices other than 1 of polygon 2 should be in original positions
- expect(pg2[1]).eqls(vertices2[1]);
- expect(pg2[2]).eqls(vertices2[2]);
- expect(pg2[3]).eqls(vertices2[3]);
-
- vertices2[0] = pg2[0];
- });
-
- cy.log("move polygon 2 vertex so almost attracts to polygon 1 edge");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg2",
- args: {
- pointCoords: { 1: [1.7, -1] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- let pg2 = stateVariables["/pg2"].stateValues.numericalVertices;
-
- // vertex did not attract
- expect(pg2[1]).eqls([1.7, -1]);
-
- expect(pg2[0]).eqls(vertices2[0]);
- expect(pg2[2]).eqls(vertices2[2]);
- expect(pg2[3]).eqls(vertices2[3]);
-
- vertices2[1] = pg2[1];
- });
-
- cy.log(
- "move polygon 2 vertex closer so does attract to polygon 1 edge",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg2",
- args: {
- pointCoords: { 1: [1.4, -1] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- let pg2 = stateVariables["/pg2"].stateValues.numericalVertices;
-
- // vertex did attract
- expect(pg2[1][0]).closeTo(1, 1e-12);
- expect(pg2[1][1]).closeTo(-1, 1e-12);
-
- expect(pg2[0]).eqls(vertices2[0]);
- expect(pg2[2]).eqls(vertices2[2]);
- expect(pg2[3]).eqls(vertices2[3]);
-
- vertices2[1] = pg2[1];
- });
-
- cy.log("move polygon 2 vertex close so attracts to polygon 1 vertex");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg2",
- args: {
- pointCoords: { 3: [1.2, 1.8] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- let pg2 = stateVariables["/pg2"].stateValues.numericalVertices;
-
- // vertex did attract
- expect(pg2[3][0]).closeTo(1, 1e-12);
- expect(pg2[3][1]).closeTo(2, 1e-12);
-
- expect(pg2[0]).eqls(vertices2[0]);
- expect(pg2[1]).eqls(vertices2[1]);
- expect(pg2[2]).eqls(vertices2[2]);
-
- vertices2[3] = pg2[3];
- });
-
- cy.log(
- "move polygon 2 vertex slightly away so no longer attracts to polygon 1 vertex",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg2",
- args: {
- pointCoords: { 3: [1.7, 2.8] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- let pg2 = stateVariables["/pg2"].stateValues.numericalVertices;
-
- // vertex did not attract
- expect(pg2[3]).eqls([1.7, 2.8]);
-
- expect(pg2[0]).eqls(vertices2[0]);
- expect(pg2[1]).eqls(vertices2[1]);
- expect(pg2[2]).eqls(vertices2[2]);
-
- vertices2[3] = pg2[3];
- });
-
- cy.log("move polygon 2 vertex so edge attracts to polygon 1 edge");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg2",
- args: {
- pointCoords: { 0: [-6, -5.1] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- let pg1 = stateVariables["/pg1"].stateValues.numericalVertices;
- let pg2 = stateVariables["/pg2"].stateValues.numericalVertices;
-
- // vertex 1 and 4 of pg2 should be along edge of vertices of 1 and 3 of pg1
- let slope1 = (pg1[2][1] - pg1[0][1]) / (pg1[2][0] - pg1[0][0]);
- let slope2 = (pg2[0][1] - pg1[0][1]) / (pg2[0][0] - pg1[0][0]);
- let slope3 = (pg2[3][1] - pg1[0][1]) / (pg2[3][0] - pg1[0][0]);
-
- expect(slope2).closeTo(slope1, 1e-12);
- expect(slope3).closeTo(slope1, 1e-12);
-
- // vertex 4 moved
- expect(pg2[3][0]).not.closeTo(vertices2[3][0], 0.01);
- expect(pg2[3][1]).not.closeTo(vertices2[3][1], 0.01);
-
- // other vertices did not move
- expect(pg2[1]).eqls(vertices2[1]);
- expect(pg2[2]).eqls(vertices2[2]);
-
- vertices2[0] = pg2[0];
- vertices2[3] = pg2[3];
- });
-
- cy.log(
- "make sure don't move point along polygon 1 edge when attracting polygon 2 point to vertex",
- );
-
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg2",
- args: {
- pointCoords: { 2: [1.2, -4.2] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- let pg2 = stateVariables["/pg2"].stateValues.numericalVertices;
-
- // vertex did attract
- expect(pg2[2][0]).closeTo(1, 1e-12);
- expect(pg2[2][1]).closeTo(-4, 1e-12);
-
- // other vertices did not move
- expect(pg2[0][0]).closeTo(vertices2[0][0], 1e-12);
- expect(pg2[0][1]).closeTo(vertices2[0][1], 1e-12);
- expect(pg2[1][0]).closeTo(vertices2[1][0], 1e-12);
- expect(pg2[1][1]).closeTo(vertices2[1][1], 1e-12);
- expect(pg2[3][0]).closeTo(vertices2[3][0], 1e-12);
- expect(pg2[3][1]).closeTo(vertices2[3][1], 1e-12);
-
- vertices2[2] = pg2[2];
- });
-
- cy.window().then(async (win) => {
- // attract from other side of vertex
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg2",
- args: {
- pointCoords: { 2: [0.8, -3.8] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- let pg2 = stateVariables["/pg2"].stateValues.numericalVertices;
-
- // vertices did not move
- expect(pg2[0][0]).closeTo(vertices2[0][0], 1e-12);
- expect(pg2[0][1]).closeTo(vertices2[0][1], 1e-12);
- expect(pg2[1][0]).closeTo(vertices2[1][0], 1e-12);
- expect(pg2[1][1]).closeTo(vertices2[1][1], 1e-12);
- expect(pg2[2][0]).closeTo(vertices2[2][0], 1e-12);
- expect(pg2[2][1]).closeTo(vertices2[2][1], 1e-12);
- expect(pg2[3][0]).closeTo(vertices2[3][0], 1e-12);
- expect(pg2[3][1]).closeTo(vertices2[3][1], 1e-12);
- });
- });
-
- it("attract rigid polyline and preserveSimilarity polygon when moving vertices", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
- $pg1.vertices
- $pg2.vertices
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.log(
- "rotate polyline 1 to nearly match slope of nearby polygon edge",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolyline",
- componentName: "/pl",
- args: {
- pointCoords: { 1: [1.6, 2] },
- },
- });
-
- let desired_slope = 2;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pl = stateVariables["/pl"].stateValues.numericalVertices;
- let actual_slope =
- (pl[1][1] - pl[2][1]) / (pl[1][0] - pl[2][0]);
-
- expect(actual_slope).closeTo(desired_slope, 1e-12);
- });
- });
-
- cy.log(
- "if move polyline further away, slope does not attract to polygon edge",
- );
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let moveX = -1;
- let moveY = 1;
-
- let desired_vertices = stateVariables[
- "/pl"
- ].stateValues.numericalVertices.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
- await win.callAction1({
- actionName: "movePolyline",
- componentName: "/pl",
- args: {
- pointCoords: desired_vertices,
- },
- });
-
- // perturb vertex slightly
- await win.callAction1({
- actionName: "movePolyline",
- componentName: "/pl",
- args: {
- pointCoords: {
- 1: [
- desired_vertices[1][0] + 0.01,
- desired_vertices[1][1] - 0.01,
- ],
- },
- },
- });
- });
-
- let desired_slope = 2;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pl = stateVariables["/pl"].stateValues.numericalVertices;
- let actual_slope = (pl[1][1] - pl[2][1]) / (pl[1][0] - pl[2][0]);
-
- expect(actual_slope).closeTo(desired_slope, 0.05);
- expect(actual_slope).not.closeTo(desired_slope, 0.001);
- });
-
- cy.log(
- "missing edge of polyline does not attract to slope of polygon edge",
- );
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let moveX = 3.5;
- let moveY = 0;
-
- let desired_vertices = stateVariables[
- "/pl"
- ].stateValues.numericalVertices.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
- await win.callAction1({
- actionName: "movePolyline",
- componentName: "/pl",
- args: {
- pointCoords: desired_vertices,
- },
- });
-
- await win.callAction1({
- actionName: "movePolyline",
- componentName: "/pl",
- args: {
- pointCoords: {
- 1: [2.1, 5.71],
- },
- },
- });
- });
-
- desired_slope = 2;
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pl = stateVariables["/pl"].stateValues.numericalVertices;
- let actual_slope = (pl[0][1] - pl[2][1]) / (pl[0][0] - pl[2][0]);
-
- expect(actual_slope).closeTo(desired_slope, 0.05);
- expect(actual_slope).not.closeTo(desired_slope, 0.001);
- });
-
- cy.log("missing edge of polyline does not attract to polygon vertex");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolyline",
- componentName: "/pl",
- args: {
- pointCoords: {
- 1: [2.1, 4.3],
- },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let moveX = -0.13;
- let moveY = 0;
-
- let desired_vertices = stateVariables[
- "/pl"
- ].stateValues.numericalVertices.map((vertex) => [
- vertex[0] + moveX,
- vertex[1] + moveY,
- ]);
- await win.callAction1({
- actionName: "movePolyline",
- componentName: "/pl",
- args: {
- pointCoords: desired_vertices,
- },
- });
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pl = stateVariables["/pl"].stateValues.numericalVertices;
-
- // expect point [5,4] of polygon 2 to be nearly but not quite colinear
- // with the first and last vertex (so would have attracted if edge existed)
-
- let slope1 = (4 - pl[0][1]) / (5 - pl[0][0]);
- let slope2 = (4 - pl[2][1]) / (5 - pl[2][0]);
-
- expect(slope1).closeTo(slope2, 0.1);
- expect(slope1).not.closeTo(slope2, 0.001);
- });
-
- cy.log("rotate polyline to have vertical edge");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolyline",
- componentName: "/pl",
- args: {
- pointCoords: {
- 1: [2.3, 6.3],
- },
- },
- });
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pl = stateVariables["/pl"].stateValues.numericalVertices;
-
- // edge should be vertical
- expect(pl[2][0]).closeTo(pl[1][0], 1e-12);
- });
-
- cy.log("polyline's missing edge does not snap to vertical");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolyline",
- componentName: "/pl",
- args: {
- pointCoords: {
- 1: [5.8, 4.8],
- },
- },
- });
- });
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
-
- let pl = stateVariables["/pl"].stateValues.numericalVertices;
-
- // edge should be vertical
- expect(pl[2][0]).closeTo(pl[0][0], 0.1);
- expect(pl[2][0]).not.closeTo(pl[0][0], 0.001);
- });
-
- cy.log("move polygon vertex so edge attracts to polyline vertex");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg",
- args: {
- pointCoords: { 0: [0, 2.4] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let pl = stateVariables["/pl"].stateValues.numericalVertices;
- let pg = stateVariables["/pg"].stateValues.numericalVertices;
-
- // vertex 2 of pg1 should be along edge of vertices of 2 and 3 of pg2
- let slope1 = (pg[1][1] - pg[0][1]) / (pg[1][0] - pg[0][0]);
- let slope2 = (pl[0][1] - pg[0][1]) / (pl[0][0] - pg[0][0]);
-
- expect(slope2).closeTo(slope1, 1e-12);
-
- // vertex1 should be close to where moved it
- expect(pg[0][0]).closeTo(0, 0.1);
- expect(pg[0][1]).closeTo(2.4, 0.1);
- });
-
- cy.log(
- "move polygon vertex so edge almost attracts to polyline vertex",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg",
- args: {
- pointCoords: { 0: [0, 2.2] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- let pg = stateVariables["/pg"].stateValues.numericalVertices;
-
- // vertex did not attract
- expect(pg[0][0]).closeTo(0, 1e-10);
- expect(pg[0][1]).closeTo(2.2, 1e-10);
- });
-
- cy.log("move polygon vertex so almost attracts to polyline edge");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg",
- args: {
- pointCoords: { 0: [4.4, 3.1] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
- let pg = stateVariables["/pg"].stateValues.numericalVertices;
-
- // vertex did not attract
- expect(pg[0][0]).closeTo(4.4, 1e-10);
- expect(pg[0][1]).closeTo(3.1, 1e-10);
- });
-
- cy.log("move polygon vertex closer so does attract to polyline edge");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg",
- args: {
- pointCoords: { 0: [4.4, 3.3] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let pl = stateVariables["/pl"].stateValues.numericalVertices;
- let pg = stateVariables["/pg"].stateValues.numericalVertices;
-
- // vertex 1 of pg should be along edge of vertices of 1 and 2 of pg
- let slope1 = (pl[1][1] - pl[0][1]) / (pl[1][0] - pl[0][0]);
- let slope2 = (pg[0][1] - pl[0][1]) / (pg[0][0] - pl[0][0]);
-
- expect(slope2).closeTo(slope1, 1e-12);
- });
-
- cy.log("move polygon vertex does not attract missing polyline edge");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "movePolygon",
- componentName: "/pg",
- args: {
- pointCoords: { 0: [2.8, 5.2] },
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let pl = stateVariables["/pl"].stateValues.numericalVertices;
- let pg = stateVariables["/pg"].stateValues.numericalVertices;
-
- // vertex 1 of pg should close but not exactly along edge of vertices of 1 and 3 of pg
- let invslope1 = (pl[2][0] - pl[0][0]) / (pl[2][1] - pl[0][1]);
- let invslope2 = (pg[0][0] - pl[0][0]) / (pg[0][1] - pl[0][1]);
-
- expect(invslope2).closeTo(invslope1, 0.1);
- expect(invslope2).not.closeTo(invslope1, 0.001);
-
- // vertex did not attract
- expect(pg[0][0]).closeTo(2.8, 1e-10);
- expect(pg[0][1]).closeTo(5.2, 1e-10);
- });
- });
-
- it("attract line segments", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.log("move endpoint of segment 1 to attract to edge of segment 2 ");
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls1",
- args: {
- point1coords: [-2.2, 2.8],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls1 = stateVariables["/ls1"].stateValues.numericalEndpoints;
-
- expect(ls1[0][0]).closeTo(-2, 1e-12);
- expect(ls1[0][1]).closeTo(3, 1e-12);
- });
-
- cy.log(
- "move endpoint of segment 1 further away so does not attract to edge of segment 2 ",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls1",
- args: {
- point1coords: [-2.5, 2.5],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls1 = stateVariables["/ls1"].stateValues.numericalEndpoints;
-
- expect(ls1[0][0]).closeTo(-2.5, 1e-12);
- expect(ls1[0][1]).closeTo(2.5, 1e-12);
- });
-
- cy.log(
- "move endpoint of segment 1 so edge attracts to endpoint of segment 2 ",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls1",
- args: {
- point1coords: [-3.2, 1.2],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls1 = stateVariables["/ls1"].stateValues.numericalEndpoints;
-
- let desired_slope = 0.5;
- let actual_slope =
- (ls1[1][1] - ls1[0][1]) / (ls1[1][0] - ls1[0][0]);
-
- expect(actual_slope).closeTo(desired_slope, 1e-12);
- });
-
- cy.log(
- "move endpoint of segment 1 so edge no longer attracts to endpoint of segment 2 ",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls1",
- args: {
- point1coords: [-3.4, 1.4],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls1 = stateVariables["/ls1"].stateValues.numericalEndpoints;
-
- expect(ls1[0][0]).closeTo(-3.4, 1e-12);
- expect(ls1[0][1]).closeTo(1.4, 1e-12);
- });
-
- cy.log(
- "extension of edge of segment 1 does not attract to endpoint of segment 2 ",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls1",
- args: {
- point1coords: [0, 2.45],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls1 = stateVariables["/ls1"].stateValues.numericalEndpoints;
-
- expect(ls1[0][0]).closeTo(0, 1e-12);
- expect(ls1[0][1]).closeTo(2.45, 1e-12);
- });
-
- cy.log(
- "move endpoint of segment 1 so attracts to endpoint of segment 2 ",
- );
- cy.window().then(async (win) => {
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls1",
- args: {
- point1coords: [-2.8, 4.2],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls1 = stateVariables["/ls1"].stateValues.numericalEndpoints;
-
- expect(ls1[0][0]).closeTo(-3, 1e-12);
- expect(ls1[0][1]).closeTo(4, 1e-12);
- });
-
- cy.log("translate segment 2 so edge attracts to endpoint of segment 1");
- cy.window().then(async (win) => {
- let dx = 0.2;
- let dy = 0.2;
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls2",
- args: {
- point1coords: [-2 + dx, 3 + dy],
- point2coords: [-4 + dx, 5 + dy],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls2 = stateVariables["/ls2"].stateValues.numericalEndpoints;
-
- expect(ls2[0][0]).closeTo(-2, 1e-12);
- expect(ls2[0][1]).closeTo(3, 1e-12);
- expect(ls2[1][0]).closeTo(-4, 1e-12);
- expect(ls2[1][1]).closeTo(5, 1e-12);
- });
-
- cy.log(
- "translate segment 2 so edge no longer attracts to endpoint of segment 1",
- );
- cy.window().then(async (win) => {
- let dx = 0.4;
- let dy = 0.4;
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls2",
- args: {
- point1coords: [-2 + dx, 3 + dy],
- point2coords: [-4 + dx, 5 + dy],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls2 = stateVariables["/ls2"].stateValues.numericalEndpoints;
-
- expect(ls2[0][0]).closeTo(-2 + dx, 1e-12);
- expect(ls2[0][1]).closeTo(3 + dy, 1e-12);
- expect(ls2[1][0]).closeTo(-4 + dx, 1e-12);
- expect(ls2[1][1]).closeTo(5 + dy, 1e-12);
- });
-
- cy.log("translate segment 2 so endpoint attracts to edge of segment 1");
- cy.window().then(async (win) => {
- let dx = 0.0;
- let dy = 0.4;
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls2",
- args: {
- point1coords: [-1 + dx, 4 + dy],
- point2coords: [-3 + dx, 6 + dy],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls2 = stateVariables["/ls2"].stateValues.numericalEndpoints;
-
- expect(ls2[0][0]).closeTo(-1, 1e-12);
- expect(ls2[0][1]).closeTo(4, 1e-12);
- expect(ls2[1][0]).closeTo(-3, 1e-12);
- expect(ls2[1][1]).closeTo(6, 1e-12);
- });
-
- cy.log(
- "translate segment 2 so endpoint no longer attracts to edge of segment 1",
- );
- cy.window().then(async (win) => {
- let dx = 0.0;
- let dy = 0.6;
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls2",
- args: {
- point1coords: [-1 + dx, 4 + dy],
- point2coords: [-3 + dx, 6 + dy],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls2 = stateVariables["/ls2"].stateValues.numericalEndpoints;
-
- expect(ls2[0][0]).closeTo(-1 + dx, 1e-12);
- expect(ls2[0][1]).closeTo(4 + dy, 1e-12);
- expect(ls2[1][0]).closeTo(-3 + dx, 1e-12);
- expect(ls2[1][1]).closeTo(6 + dy, 1e-12);
- });
-
- cy.log(
- "translate segment 2 so endpoint attracts to endpoint of segment 1",
- );
- cy.window().then(async (win) => {
- let dx = 0.2;
- let dy = 0.3;
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls2",
- args: {
- point1coords: [3 + dx, 4 + dy],
- point2coords: [1 + dx, 6 + dy],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls2 = stateVariables["/ls2"].stateValues.numericalEndpoints;
-
- expect(ls2[0][0]).closeTo(3, 1e-12);
- expect(ls2[0][1]).closeTo(4, 1e-12);
- expect(ls2[1][0]).closeTo(1, 1e-12);
- expect(ls2[1][1]).closeTo(6, 1e-12);
- });
-
- cy.log(
- "translate segment 2 so endpoint no longer attracts to endpoint of segment 1",
- );
- cy.window().then(async (win) => {
- let dx = 0.5;
- let dy = 0.3;
- await win.callAction1({
- actionName: "moveLineSegment",
- componentName: "/ls2",
- args: {
- point1coords: [3 + dx, 4 + dy],
- point2coords: [1 + dx, 6 + dy],
- },
- });
-
- let stateVariables = await win.returnAllStateVariables1();
-
- let ls2 = stateVariables["/ls2"].stateValues.numericalEndpoints;
-
- expect(ls2[0][0]).closeTo(3 + dx, 1e-12);
- expect(ls2[0][1]).closeTo(4 + dy, 1e-12);
- expect(ls2[1][0]).closeTo(1 + dx, 1e-12);
- expect(ls2[1][1]).closeTo(6 + dy, 1e-12);
- });
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/subsetofreals.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/subsetofreals.cy.js
deleted file mode 100644
index 1eeb10f5e..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/subsetofreals.cy.js
+++ /dev/null
@@ -1,2934 +0,0 @@
-import { cesc } from "@doenet/utils";
-
-describe("SubsetOfReals Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("single intervals", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- (4,5)
- (5,4)
- (5,5)
- (4,infinity)
- (4,-infinity)
- (-infinity,5)
- (infinity,5)
- (-infinity,infinity)
- (a,b)
-
- [4,5]
- [5,4]
- [5,5]
- [4,infinity]
- [4,-infinity]
- [-infinity,5]
- [infinity,5]
- [-infinity,infinity]
- [a,b]
-
- (4,5]
- (5,4]
- (5,5]
- (4,infinity]
- (4,-infinity]
- (-infinity,5]
- (infinity,5]
- (-infinity,infinity]
- (a,b]
-
- [4,5)
- [5,4)
- [5,5)
- [4,infinity)
- [4,-infinity)
- [-infinity,5)
- [infinity,5)
- [-infinity,infinity)
- [a,b)
-
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/o1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)");
- cy.get(cesc("#\\/o2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/o5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/o7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/o9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/c1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,5]");
- cy.get(cesc("#\\/c2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/c4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/c5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/c7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/c9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/oc1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5]");
- cy.get(cesc("#\\/oc2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/oc5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/oc7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/oc9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/co1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,5)");
- cy.get(cesc("#\\/co2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/co5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/co7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/co9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
- });
-
- it("single intervals, display as inequality", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- (4,5)
- (5,4)
- (5,5)
- (4,infinity)
- (4,-infinity)
- (-infinity,5)
- (infinity,5)
- (-infinity,infinity)
- (a,b)
-
- [4,5]
- [5,4]
- [5,5]
- [4,infinity]
- [4,-infinity]
- [-infinity,5]
- [infinity,5]
- [-infinity,infinity]
- [a,b]
-
- (4,5]
- (5,4]
- (5,5]
- (4,infinity]
- (4,-infinity]
- (-infinity,5]
- (infinity,5]
- (-infinity,infinity]
- (a,b]
-
- [4,5)
- [5,4)
- [5,5)
- [4,infinity)
- [4,-infinity)
- [-infinity,5)
- [infinity,5)
- [-infinity,infinity)
- [a,b)
-
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/o1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "44");
- cy.get(cesc("#\\/o5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈∅");
- cy.get(cesc("#\\/o6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x<5");
- cy.get(cesc("#\\/o7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈∅");
- cy.get(cesc("#\\/o8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈R");
- cy.get(cesc("#\\/o9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/c1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "4≤x≤5");
- cy.get(cesc("#\\/c2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈∅");
- cy.get(cesc("#\\/c3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x=5");
- cy.get(cesc("#\\/c4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x≥4");
- cy.get(cesc("#\\/c5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈∅");
- cy.get(cesc("#\\/c6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x≤5");
- cy.get(cesc("#\\/c7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈∅");
- cy.get(cesc("#\\/c8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈R");
- cy.get(cesc("#\\/c9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/oc1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "44");
- cy.get(cesc("#\\/oc5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈∅");
- cy.get(cesc("#\\/oc6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x≤5");
- cy.get(cesc("#\\/oc7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈∅");
- cy.get(cesc("#\\/oc8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈R");
- cy.get(cesc("#\\/oc9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/co1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "4≤x<5");
- cy.get(cesc("#\\/co2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈∅");
- cy.get(cesc("#\\/co3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈∅");
- cy.get(cesc("#\\/co4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x≥4");
- cy.get(cesc("#\\/co5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈∅");
- cy.get(cesc("#\\/co6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x<5");
- cy.get(cesc("#\\/co7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈∅");
- cy.get(cesc("#\\/co8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x∈R");
- cy.get(cesc("#\\/co9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
- });
-
- it("single intervals, display as inequality, change variable", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- (4,5)
- (5,4)
- (5,5)
- (4,infinity)
- (4,-infinity)
- (-infinity,5)
- (infinity,5)
- (-infinity,infinity)
- (a,b)
-
- [4,5]
- [5,4]
- [5,5]
- [4,infinity]
- [4,-infinity]
- [-infinity,5]
- [infinity,5]
- [-infinity,infinity]
- [a,b]
-
- (4,5]
- (5,4]
- (5,5]
- (4,infinity]
- (4,-infinity]
- (-infinity,5]
- (infinity,5]
- (-infinity,infinity]
- (a,b]
-
- [4,5)
- [5,4)
- [5,5)
- [4,infinity)
- [4,-infinity)
- [-infinity,5)
- [infinity,5)
- [-infinity,infinity)
- [a,b)
-
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/o1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "44");
- cy.get(cesc("#\\/o5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈∅");
- cy.get(cesc("#\\/o6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v<5");
- cy.get(cesc("#\\/o7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈∅");
- cy.get(cesc("#\\/o8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈R");
- cy.get(cesc("#\\/o9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/c1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "4≤v≤5");
- cy.get(cesc("#\\/c2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈∅");
- cy.get(cesc("#\\/c3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v=5");
- cy.get(cesc("#\\/c4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v≥4");
- cy.get(cesc("#\\/c5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈∅");
- cy.get(cesc("#\\/c6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v≤5");
- cy.get(cesc("#\\/c7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈∅");
- cy.get(cesc("#\\/c8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈R");
- cy.get(cesc("#\\/c9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/oc1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "44");
- cy.get(cesc("#\\/oc5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈∅");
- cy.get(cesc("#\\/oc6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v≤5");
- cy.get(cesc("#\\/oc7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈∅");
- cy.get(cesc("#\\/oc8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈R");
- cy.get(cesc("#\\/oc9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/co1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "4≤v<5");
- cy.get(cesc("#\\/co2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈∅");
- cy.get(cesc("#\\/co3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈∅");
- cy.get(cesc("#\\/co4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v≥4");
- cy.get(cesc("#\\/co5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈∅");
- cy.get(cesc("#\\/co6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v<5");
- cy.get(cesc("#\\/co7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈∅");
- cy.get(cesc("#\\/co8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "v∈R");
- cy.get(cesc("#\\/co9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
- });
-
- it("single inequality", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- 4 < x < 5
- 5 < x < 4
- 5 < x < 5
- x > 4
- infinity > x > 4
- x > infinity
- x < 5
- -infinity < x < 5
- x < -infinity
- -infinity < x < infinity
- x < a
-
- 4 <= x <= 5
- 5 <= x <= 4
- 5 <= x <= 5
- x >= 4
- infinity >= x >= 4
- x >= infinity
- x <= 5
- -infinity <= x <= 5
- x <= -infinity
- -infinity <= x <= infinity
- x <= a
-
- 4 < x <= 5
- 5 < x <= 4
- 5 < x <= 5
- x > 4
- infinity >= x > 4
- x > infinity
- x <= 5
- -infinity < x <= 5
- x <= -infinity
- -infinity < x <= infinity
- x <= a
-
- 4 <= x < 5
- 5 <= x < 4
- 5 <= x < 5
- x >= 4
- infinity > x >= 4
- x >= infinity
- x < 5
- -infinity <= x < 5
- x < -infinity
- -infinity <= x < infinity
- x < a
-
- x != 6
- x != infinity
- x != -infinity
- 6 != x
- infinity != x
- -infinity != x
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/o1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)");
- cy.get(cesc("#\\/o2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/o5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/o6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/o8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/o9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/o11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/c1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,5]");
- cy.get(cesc("#\\/c2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/c4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/c5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/c6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/c8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/c9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/c11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/oc1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5]");
- cy.get(cesc("#\\/oc2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/oc5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/oc6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/oc8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/oc9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/oc11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/co1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,5)");
- cy.get(cesc("#\\/co2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/co5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/co6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/co8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/co9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/co11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/ne1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,6)∪(6,∞)");
- cy.get(cesc("#\\/ne2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/ne3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/ne4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,6)∪(6,∞)");
- cy.get(cesc("#\\/ne5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/ne6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- });
-
- it("single inequality, change variable", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- 4 < q < 5
- 5 < q < 4
- 5 < q < 5
- q > 4
- infinity > q > 4
- q > infinity
- q < 5
- -infinity < q < 5
- q < -infinity
- -infinity < q < infinity
- q < a
-
- 4 <= q <= 5
- 5 <= q <= 4
- 5 <= q <= 5
- q >= 4
- infinity >= q >= 4
- q >= infinity
- q <= 5
- -infinity <= q <= 5
- q <= -infinity
- -infinity <= q <= infinity
- q <= a
-
- 4 < q <= 5
- 5 < q <= 4
- 5 < q <= 5
- q > 4
- infinity >= q > 4
- q > infinity
- q <= 5
- -infinity < q <= 5
- q <= -infinity
- -infinity < q <= infinity
- q <= a
-
- 4 <= q < 5
- 5 <= q < 4
- 5 <= q < 5
- q >= 4
- infinity > q >= 4
- q >= infinity
- q < 5
- -infinity <= q < 5
- q < -infinity
- -infinity <= q < infinity
- q < a
-
- q != 6
- q != infinity
- q != -infinity
- 6 != q
- infinity != q
- -infinity != q
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/o1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)");
- cy.get(cesc("#\\/o2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/o5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/o6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/o8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/o9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/o11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/c1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,5]");
- cy.get(cesc("#\\/c2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/c4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/c5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/c6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/c8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/c9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/c11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/oc1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5]");
- cy.get(cesc("#\\/oc2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/oc5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/oc6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/oc8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/oc9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/oc11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/co1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,5)");
- cy.get(cesc("#\\/co2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/co5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/co6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/co8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/co9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/co11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/ne1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,6)∪(6,∞)");
- cy.get(cesc("#\\/ne2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/ne3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/ne4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,6)∪(6,∞)");
- cy.get(cesc("#\\/ne5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/ne6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- });
-
- it("single equality", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- x=5
- x=infinity
- x=-infinity
- x=a
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/e1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/e2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/e3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/e4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
- });
-
- it("single inequality in set notation", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- {q | 4 < q < 5}
- {q | 5 < q < 4}
- {q | 5 < q < 5}
- {q | q > 4}
- {q | infinity > q > 4}
- {q | q > infinity}
- {q | q < 5}
- {q | -infinity < q < 5}
- {q | q < -infinity}
- {q | -infinity < q < infinity}
- {q | q < a}
-
- {q | 4 <= q <= 5}
- {q | 5 <= q <= 4}
- {q | 5 <= q <= 5}
- {q | q >= 4}
- {q | infinity >= q >= 4}
- {q | q >= infinity}
- {q | q <= 5}
- {q | -infinity <= q <= 5}
- {q | q <= -infinity}
- {q | -infinity <= q <= infinity}
- {q | q <= a}
-
- {q | 4 < q <= 5}
- {q | 5 < q <= 4}
- {q | 5 < q <= 5}
- {q | q > 4}
- {q | infinity >= q > 4}
- {q | q > infinity}
- {q | q <= 5}
- {q | -infinity < q <= 5}
- {q | q <= -infinity}
- {q | -infinity < q <= infinity}
- {q | q <= a}
-
- {q | 4 <= q < 5}
- {q | 5 <= q < 4}
- {q | 5 <= q < 5}
- {q | q >= 4}
- {q | infinity > q >= 4}
- {q | q >= infinity}
- {q | q < 5}
- {q | -infinity <= q < 5}
- {q | q < -infinity}
- {q | -infinity <= q < infinity}
- {q | q < a}
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/o1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)");
- cy.get(cesc("#\\/o2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/o5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/o6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/o8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/o9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/o10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/o11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/c1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,5]");
- cy.get(cesc("#\\/c2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/c4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/c5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/c6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/c8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/c9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/c10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/c11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/oc1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5]");
- cy.get(cesc("#\\/oc2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/oc5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,∞)");
- cy.get(cesc("#\\/oc6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/oc8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]");
- cy.get(cesc("#\\/oc9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/oc10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/oc11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/co1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,5)");
- cy.get(cesc("#\\/co2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/co5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,∞)");
- cy.get(cesc("#\\/co6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/co8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5)");
- cy.get(cesc("#\\/co9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/co10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/co11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
- });
-
- it("union and intersections of intervals and singletons", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- (4,5) union (6,7)
- (4,5) union (5,6)
- (4,5] union (5,6]
- (4,5] union [5,6]
- (4,6) union (5,7)
- (4,8) union (5,7)
- (4,7) union (5,7]
- (4,6) union {4}
- (4,6) union {5}
- (4,6) union {6}
- (4,6) union {7}
- (4,5) union (5,6) union {5}
- (-infinity,5) union (2,infinity)
- (-infinity,5) union [2,infinity)
- (-infinity,5] union (2,infinity)
- (-infinity,5] union [2,infinity)
- (-infinity,5) union (9,infinity) union (4,10)
- [-4,-2) union {-4}
-
- (4,5) intersect (6,7)
- (4,5) intersect (5,6)
- (4,5] intersect (5,6]
- (4,5] intersect [5,6]
- (4,6) intersect (5,7)
- (4,8) intersect (5,7)
- (4,7) intersect (5,7]
- (4,6) intersect {4}
- (4,6) intersect {5}
- (4,6) intersect {6}
- (4,6) intersect {7}
- (4,5) intersect (5,6) intersect {5}
- (-infinity,5) intersect (2,infinity)
- (-infinity,5) intersect [2,infinity)
- (-infinity,5] intersect (2,infinity)
- (-infinity,5] intersect [2,infinity)
- (-infinity,5) intersect (9,infinity) intersect (4,10)
- [-4,-2) intersect {-4}
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/u1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(6,7)");
- cy.get(cesc("#\\/u2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(5,6)");
- cy.get(cesc("#\\/u3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7)");
- cy.get(cesc("#\\/u6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,8)");
- cy.get(cesc("#\\/u7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7]");
- cy.get(cesc("#\\/u8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,6)");
- cy.get(cesc("#\\/u9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)∪{7}");
- cy.get(cesc("#\\/u12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[−4,−2)");
-
- cy.get(cesc("#\\/i1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,6)");
- cy.get(cesc("#\\/i6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5)");
- cy.get(cesc("#\\/i14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5)");
- cy.get(cesc("#\\/i15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5]");
- cy.get(cesc("#\\/i16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5]");
- cy.get(cesc("#\\/i17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{−4}");
- });
-
- it("union and intersections of intervals and singletons, latex format", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- (4,5) \\cup (6,7)
- (4,5) \\cup (5,6)
- (4,5] \\cup (5,6]
- (4,5] \\cup [5,6]
- (4,6) \\cup (5,7)
- (4,8) \\cup (5,7)
- (4,7) \\cup (5,7]
- (4,6) \\cup {4}
- (4,6) \\cup {5}
- (4,6) \\cup {6}
- (4,6) \\cup {7}
- (4,5) \\cup (5,6) \\cup {5}
- (-\\infty,5) \\cup (2,\\infty)
- (-\\infty,5) \\cup [2,\\infty)
- (-\\infty,5] \\cup (2,\\infty)
- (-\\infty,5] \\cup [2,\\infty)
- (-\\infty,5) \\cup (9,\\infty) \\cup (4,10)
- [-4,-2) \\cup {-4}
-
- (4,5) \\cap (6,7)
- (4,5) \\cap (5,6)
- (4,5] \\cap (5,6]
- (4,5] \\cap [5,6]
- (4,6) \\cap (5,7)
- (4,8) \\cap (5,7)
- (4,7) \\cap (5,7]
- (4,6) \\cap {4}
- (4,6) \\cap {5}
- (4,6) \\cap {6}
- (4,6) \\cap {7}
- (4,5) \\cap (5,6) \\cap {5}
- (-\\infty,5) \\cap (2,\\infty)
- (-\\infty,5) \\cap [2,\\infty)
- (-\\infty,5] \\cap (2,\\infty)
- (-\\infty,5] \\cap [2,\\infty)
- (-\\infty,5) \\cap (9,\\infty) \\cap (4,10)
- [-4,-2) \\cap {-4}
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/u1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(6,7)");
- cy.get(cesc("#\\/u2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(5,6)");
- cy.get(cesc("#\\/u3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7)");
- cy.get(cesc("#\\/u6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,8)");
- cy.get(cesc("#\\/u7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7]");
- cy.get(cesc("#\\/u8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,6)");
- cy.get(cesc("#\\/u9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)∪{7}");
- cy.get(cesc("#\\/u12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[−4,−2)");
-
- cy.get(cesc("#\\/i1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,6)");
- cy.get(cesc("#\\/i6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5)");
- cy.get(cesc("#\\/i14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5)");
- cy.get(cesc("#\\/i15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5]");
- cy.get(cesc("#\\/i16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5]");
- cy.get(cesc("#\\/i17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{−4}");
- });
-
- it("x element of union and intersections of intervals and singletons", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- x elementof (4,5) union (6,7)
- x elementof (4,5) union (5,6)
- x elementof (4,5] union (5,6]
- x elementof (4,5] union [5,6]
- x elementof (4,6) union (5,7)
- x elementof (4,8) union (5,7)
- x elementof (4,7) union (5,7]
- x elementof (4,6) union {4}
- x elementof (4,6) union {5}
- x elementof (4,6) union {6}
- x elementof (4,6) union {7}
- x elementof (4,5) union (5,6) union {5}
- x elementof (-infinity,5) union (2,infinity)
- x elementof (-infinity,5) union [2,infinity)
- x elementof (-infinity,5] union (2,infinity)
- x elementof (-infinity,5] union [2,infinity)
- x elementof (-infinity,5) union (9,infinity) union (4,10)
- x elementof [-4,-2) union {-4}
-
- x elementof (4,5) intersect (6,7)
- x elementof (4,5) intersect (5,6)
- x elementof (4,5] intersect (5,6]
- x elementof (4,5] intersect [5,6]
- x elementof (4,6) intersect (5,7)
- x elementof (4,8) intersect (5,7)
- x elementof (4,7) intersect (5,7]
- x elementof (4,6) intersect {4}
- x elementof (4,6) intersect {5}
- x elementof (4,6) intersect {6}
- x elementof (4,6) intersect {7}
- x elementof (4,5) intersect (5,6) intersect {5}
- x elementof (-infinity,5) intersect (2,infinity)
- x elementof (-infinity,5) intersect [2,infinity)
- x elementof (-infinity,5] intersect (2,infinity)
- x elementof (-infinity,5] intersect [2,infinity)
- x elementof (-infinity,5) intersect (9,infinity) intersect (4,10)
- x elementof [-4,-2) intersect {-4}
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/u1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(6,7)");
- cy.get(cesc("#\\/u2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(5,6)");
- cy.get(cesc("#\\/u3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7)");
- cy.get(cesc("#\\/u6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,8)");
- cy.get(cesc("#\\/u7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7]");
- cy.get(cesc("#\\/u8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,6)");
- cy.get(cesc("#\\/u9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)∪{7}");
- cy.get(cesc("#\\/u12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[−4,−2)");
-
- cy.get(cesc("#\\/i1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,6)");
- cy.get(cesc("#\\/i6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5)");
- cy.get(cesc("#\\/i14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5)");
- cy.get(cesc("#\\/i15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5]");
- cy.get(cesc("#\\/i16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5]");
- cy.get(cesc("#\\/i17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{−4}");
- });
-
- it("union and intersections of intervals and singletons contains element x", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- (4,5) union (6,7) containselement x
- (4,5) union (5,6) containselement x
- (4,5] union (5,6] containselement x
- (4,5] union [5,6] containselement x
- (4,6) union (5,7) containselement x
- (4,8) union (5,7) containselement x
- (4,7) union (5,7] containselement x
- (4,6) union {4} containselement x
- (4,6) union {5} containselement x
- (4,6) union {6} containselement x
- (4,6) union {7} containselement x
- (4,5) union (5,6) union {5} containselement x
- (-infinity,5) union (2,infinity) containselement x
- (-infinity,5) union [2,infinity) containselement x
- (-infinity,5] union (2,infinity) containselement x
- (-infinity,5] union [2,infinity) containselement x
- (-infinity,5) union (9,infinity) union (4,10) containselement x
- [-4,-2) union {-4} containselement x
-
- (4,5) intersect (6,7) containselement x
- (4,5) intersect (5,6) containselement x
- (4,5] intersect (5,6] containselement x
- (4,5] intersect [5,6] containselement x
- (4,6) intersect (5,7) containselement x
- (4,8) intersect (5,7) containselement x
- (4,7) intersect (5,7] containselement x
- (4,6) intersect {4} containselement x
- (4,6) intersect {5} containselement x
- (4,6) intersect {6} containselement x
- (4,6) intersect {7} containselement x
- (4,5) intersect (5,6) intersect {5} containselement x
- (-infinity,5) intersect (2,infinity) containselement x
- (-infinity,5) intersect [2,infinity) containselement x
- (-infinity,5] intersect (2,infinity) containselement x
- (-infinity,5] intersect [2,infinity) containselement x
- (-infinity,5) intersect (9,infinity) intersect (4,10) containselement x
- [-4,-2) intersect {-4} containselement x
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/u1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(6,7)");
- cy.get(cesc("#\\/u2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(5,6)");
- cy.get(cesc("#\\/u3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7)");
- cy.get(cesc("#\\/u6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,8)");
- cy.get(cesc("#\\/u7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7]");
- cy.get(cesc("#\\/u8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,6)");
- cy.get(cesc("#\\/u9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)∪{7}");
- cy.get(cesc("#\\/u12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[−4,−2)");
-
- cy.get(cesc("#\\/i1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,6)");
- cy.get(cesc("#\\/i6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5)");
- cy.get(cesc("#\\/i14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5)");
- cy.get(cesc("#\\/i15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5]");
- cy.get(cesc("#\\/i16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5]");
- cy.get(cesc("#\\/i17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{−4}");
- });
-
- it("x in union and intersections of intervals and singletons, latex format", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- x \\in (4,5) \\cup (6,7)
- x \\in (4,5) \\cup (5,6)
- x \\in (4,5] \\cup (5,6]
- x \\in (4,5] \\cup [5,6]
- x \\in (4,6) \\cup (5,7)
- x \\in (4,8) \\cup (5,7)
- x \\in (4,7) \\cup (5,7]
- x \\in (4,6) \\cup {4}
- x \\in (4,6) \\cup {5}
- x \\in (4,6) \\cup {6}
- x \\in (4,6) \\cup {7}
- x \\in (4,5) \\cup (5,6) \\cup {5}
- x \\in (-\\infty,5) \\cup (2,\\infty)
- x \\in (-\\infty,5) \\cup [2,\\infty)
- x \\in (-\\infty,5] \\cup (2,\\infty)
- x \\in (-\\infty,5] \\cup [2,\\infty)
- x \\in (-\\infty,5) \\cup (9,\\infty) \\cup (4,10)
- x \\in [-4,-2) \\cup {-4}
-
- x \\in (4,5) \\cap (6,7)
- x \\in (4,5) \\cap (5,6)
- x \\in (4,5] \\cap (5,6]
- x \\in (4,5] \\cap [5,6]
- x \\in (4,6) \\cap (5,7)
- x \\in (4,8) \\cap (5,7)
- x \\in (4,7) \\cap (5,7]
- x \\in (4,6) \\cap {4}
- x \\in (4,6) \\cap {5}
- x \\in (4,6) \\cap {6}
- x \\in (4,6) \\cap {7}
- x \\in (4,5) \\cap (5,6) \\cap {5}
- x \\in (-\\infty,5) \\cap (2,\\infty)
- x \\in (-\\infty,5) \\cap [2,\\infty)
- x \\in (-\\infty,5] \\cap (2,\\infty)
- x \\in (-\\infty,5] \\cap [2,\\infty)
- x \\in (-\\infty,5) \\cap (9,\\infty) \\cap (4,10)
- x \\in [-4,-2) \\cap {-4}
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/u1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(6,7)");
- cy.get(cesc("#\\/u2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(5,6)");
- cy.get(cesc("#\\/u3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7)");
- cy.get(cesc("#\\/u6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,8)");
- cy.get(cesc("#\\/u7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7]");
- cy.get(cesc("#\\/u8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,6)");
- cy.get(cesc("#\\/u9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)∪{7}");
- cy.get(cesc("#\\/u12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[−4,−2)");
-
- cy.get(cesc("#\\/i1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,6)");
- cy.get(cesc("#\\/i6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5)");
- cy.get(cesc("#\\/i14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5)");
- cy.get(cesc("#\\/i15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5]");
- cy.get(cesc("#\\/i16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5]");
- cy.get(cesc("#\\/i17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{−4}");
- });
-
- it("union and intersections of intervals and singletons ni x, latex format", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- (4,5) \\cup (6,7) \\ni x
- (4,5) \\cup (5,6) \\ni x
- (4,5] \\cup (5,6] \\ni x
- (4,5] \\cup [5,6] \\ni x
- (4,6) \\cup (5,7) \\ni x
- (4,8) \\cup (5,7) \\ni x
- (4,7) \\cup (5,7] \\ni x
- (4,6) \\cup {4} \\ni x
- (4,6) \\cup {5} \\ni x
- (4,6) \\cup {6} \\ni x
- (4,6) \\cup {7} \\ni x
- (4,5) \\cup (5,6) \\cup {5} \\ni x
- (-\\infty,5) \\cup (2,\\infty) \\ni x
- (-\\infty,5) \\cup [2,\\infty) \\ni x
- (-\\infty,5] \\cup (2,\\infty) \\ni x
- (-\\infty,5] \\cup [2,\\infty) \\ni x
- (-\\infty,5) \\cup (9,\\infty) \\cup (4,10) \\ni x
- [-4,-2) \\cup {-4} \\ni x
-
- (4,5) \\cap (6,7) \\ni x
- (4,5) \\cap (5,6) \\ni x
- (4,5] \\cap (5,6] \\ni x
- (4,5] \\cap [5,6] \\ni x
- (4,6) \\cap (5,7) \\ni x
- (4,8) \\cap (5,7) \\ni x
- (4,7) \\cap (5,7] \\ni x
- (4,6) \\cap {4} \\ni x
- (4,6) \\cap {5} \\ni x
- (4,6) \\cap {6} \\ni x
- (4,6) \\cap {7} \\ni x
- (4,5) \\cap (5,6) \\cap {5} \\ni x
- (-\\infty,5) \\cap (2,\\infty) \\ni x
- (-\\infty,5) \\cap [2,\\infty) \\ni x
- (-\\infty,5] \\cap (2,\\infty) \\ni x
- (-\\infty,5] \\cap [2,\\infty) \\ni x
- (-\\infty,5) \\cap (9,\\infty) \\cap (4,10) \\ni x
- [-4,-2) \\cap {-4} \\ni x
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/u1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(6,7)");
- cy.get(cesc("#\\/u2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(5,6)");
- cy.get(cesc("#\\/u3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7)");
- cy.get(cesc("#\\/u6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,8)");
- cy.get(cesc("#\\/u7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7]");
- cy.get(cesc("#\\/u8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,6)");
- cy.get(cesc("#\\/u9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/u11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)∪{7}");
- cy.get(cesc("#\\/u12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/u13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/u18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[−4,−2)");
-
- cy.get(cesc("#\\/i1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,6)");
- cy.get(cesc("#\\/i6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/i8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/i10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5)");
- cy.get(cesc("#\\/i14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5)");
- cy.get(cesc("#\\/i15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5]");
- cy.get(cesc("#\\/i16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5]");
- cy.get(cesc("#\\/i17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/i18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{−4}");
- });
-
- it("ands and ors with inequalities", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- (4 < x < 5) or (6 < x < 7)
- (4 < x < 5) or (5 < x < 6)
- (4 < x <= 5) or (5 < x <= 6)
- (4 < x <= 5) or (5 <= x <= 6)
- (4 < x < 6) or (5 < x < 7)
- (4 < x < 8) or (5 < x < 7)
- (4 < x < 7) or (5 < x <= 7)
- (4 < x < 6) or (x = 4)
- (4 < x < 6) or (x = 5)
- (4 < x < 6) or (x = 6)
- (4 < x < 6) or (x = 7)
- (4 < x < 5) or (5 < x < 6) or (x = 5)
- (x < 5) or (x > 2)
- (x < 5) or (x >= 2)
- (x <= 5) or (x > 2)
- (x <= 5) or (x >= 2)
- (x < 5) or (x > 9) or (4 < x < 10)
- (x != 5) or (4 < x < 10)
-
- (4 < x < 5) and (6 < x < 7)
- (4 < x < 5) and (5 < x < 6)
- (4 < x <= 5) and (5 < x <= 6)
- (4 < x <= 5) and (5 <= x <= 6)
- (4 < x < 6) and (5 < x < 7)
- (4 < x < 8) and (5 < x < 7)
- (4 < x < 7) and (5 < x <= 7)
- (4 < x < 6) and (x = 4)
- (4 < x < 6) and (x = 5)
- (4 < x < 6) and (x = 6)
- (4 < x < 6) and (x = 7)
- (4 < x < 5) and (5 < x < 6) and (x = 5)
- (x < 5) and (x > 2)
- (x < 5) and (x >= 2)
- (x <= 5) and (x > 2)
- (x <= 5) and (x >= 2)
- (x < 5) and (x > 9) and (4 < x < 10)
- (x != 5) and (4 < x < 10)
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/o1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(6,7)");
- cy.get(cesc("#\\/o2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(5,6)");
- cy.get(cesc("#\\/o3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/o4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/o5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7)");
- cy.get(cesc("#\\/o6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,8)");
- cy.get(cesc("#\\/o7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,7]");
- cy.get(cesc("#\\/o8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[4,6)");
- cy.get(cesc("#\\/o9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/o10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6]");
- cy.get(cesc("#\\/o11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)∪{7}");
- cy.get(cesc("#\\/o12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,6)");
- cy.get(cesc("#\\/o13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/o14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/o15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/o16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/o17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
- cy.get(cesc("#\\/o18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "R");
-
- cy.get(cesc("#\\/a1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/a2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/a3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/a4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/a5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,6)");
- cy.get(cesc("#\\/a6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/a7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(5,7)");
- cy.get(cesc("#\\/a8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/a9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "{5}");
- cy.get(cesc("#\\/a10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/a11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/a12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/a13") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5)");
- cy.get(cesc("#\\/a14") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5)");
- cy.get(cesc("#\\/a15") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(2,5]");
- cy.get(cesc("#\\/a16") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[2,5]");
- cy.get(cesc("#\\/a17") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "∅");
- cy.get(cesc("#\\/a18") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(4,5)∪(5,10)");
- });
-
- it("complements of intervals and singletons", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- (4,5)^c
- (4,5)^C
- (4,5]^c
- (4,5]^C
- [4,5)^c
- [4,5)^C
- [4,5]^c
- [4,5]^C
- {4}^c
- {4}^C
- ((4,5) union (5,6))^c
- (4,6)^c or (5,7)^c
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/c1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,4]∪[5,∞)");
- cy.get(cesc("#\\/c2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,4]∪[5,∞)");
- cy.get(cesc("#\\/c3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,4]∪(5,∞)");
- cy.get(cesc("#\\/c4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,4]∪(5,∞)");
- cy.get(cesc("#\\/c5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,4)∪[5,∞)");
- cy.get(cesc("#\\/c6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,4)∪[5,∞)");
- cy.get(cesc("#\\/c7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,4)∪(5,∞)");
- cy.get(cesc("#\\/c8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,4)∪(5,∞)");
- cy.get(cesc("#\\/c9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,4)∪(4,∞)");
- cy.get(cesc("#\\/c10") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,4)∪(4,∞)");
- cy.get(cesc("#\\/c11") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,4]∪{5}∪[6,∞)");
- cy.get(cesc("#\\/c12") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,5]∪[6,∞)");
- });
-
- it("dynamic subsets", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Variable:
- Input:
- Display mode:
-
- intervals
- inequalities
-
- Result: $input
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/result") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(1,∞)");
-
- cy.get(cesc(`#\\/displayMode_choice${2}_input`)).click();
- cy.get(cesc("#\\/result") + " .mjx-mrow").should("contain.text", "x>1");
- cy.get(cesc("#\\/result") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "x>1");
-
- cy.get(cesc("#\\/variable") + " textarea").type(
- "{end}{backspace}y{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/result") + " .mjx-mrow").should("contain.text", "_");
- cy.get(cesc("#\\/result") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "_");
-
- cy.get(cesc("#\\/input") + " textarea").type(
- "{home}{rightArrow}{backspace}y{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/result") + " .mjx-mrow").should("contain.text", "y>1");
- cy.get(cesc("#\\/result") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "y>1");
-
- cy.get(cesc(`#\\/displayMode_choice${1}_input`)).click();
- cy.get(cesc("#\\/result") + " .mjx-mrow").should(
- "contain.text",
- "(1,∞)",
- );
- cy.get(cesc("#\\/result") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(1,∞)");
-
- cy.get(cesc("#\\/input") + " textarea").type(
- "{end}{leftArrow}{backspace}\\ne{enter}{enter}",
- { force: true },
- );
- cy.get(cesc("#\\/result") + " .mjx-mrow").should(
- "contain.text",
- "(−∞,1)∪(1,∞)",
- );
- cy.get(cesc("#\\/result") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,1)∪(1,∞)");
-
- cy.get(cesc("#\\/input") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}(y>1)\\and(y<3){enter}",
- { force: true },
- );
- cy.get(cesc("#\\/result") + " .mjx-mrow").should(
- "contain.text",
- "(1,3)",
- );
- cy.get(cesc("#\\/result") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(1,3)");
-
- cy.get(cesc(`#\\/displayMode_choice${2}_input`)).click();
- cy.get(cesc("#\\/result") + " .mjx-mrow").should(
- "contain.text",
- "16){enter}", {
- force: true,
- });
- cy.get(cesc("#\\/result") + " .mjx-mrow").should(
- "contain.text",
- "(16)",
- );
- cy.get(cesc("#\\/result") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(16)");
-
- cy.get(cesc(`#\\/displayMode_choice${1}_input`)).click();
- cy.get(cesc("#\\/result") + " .mjx-mrow").should(
- "contain.text",
- "(1,3)∪(6,∞)",
- );
- cy.get(cesc("#\\/result") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(1,3)∪(6,∞)");
- });
-
- it("modifying copies of subsets", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- Enter subset:
- Subset 1: $input0
- Subset 2: $s1{name="s2"}
- Subset 3: $s1.value{assignNames="s3"}
- Subset 4: $s2{name="s4"}
- Subset 5: $s2.value{assignNames="s5"}
- Subset 6: $s3{name="s6"}
- Subset 7: $s3.value{assignNames="s7"}
- Subset 8: $s1
- Subset 9: $(s1.value)
- Modify subset 1:
- Modify subset 2:
- Modify subset 3:
- Modify subset 4:
- Modify subset 5:
- Modify subset 6:
- Modify subset 7:
- Modify subset 8:
- Modify subset 9:
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- function checkDisplay(str, str0) {
- if (str0 === undefined) {
- str0 = str;
- }
-
- cy.get(cesc("#\\/s1") + " .mjx-mrow").should("contain.text", str);
- cy.get(cesc("#\\/s2") + " .mjx-mrow").should("contain.text", str);
- cy.get(cesc("#\\/s3") + " .mjx-mrow").should("contain.text", str);
- cy.get(cesc("#\\/s4") + " .mjx-mrow").should("contain.text", str);
- cy.get(cesc("#\\/s5") + " .mjx-mrow").should("contain.text", str);
- cy.get(cesc("#\\/s6") + " .mjx-mrow").should("contain.text", str);
- cy.get(cesc("#\\/s7") + " .mjx-mrow").should("contain.text", str);
- cy.get(cesc("#\\/s8") + " .mjx-mrow").should("contain.text", str);
- cy.get(cesc("#\\/s9") + " .mjx-mrow").should("contain.text", str);
-
- cy.get(cesc("#\\/input0") + " .mq-editable-field").should(
- "contain.text",
- str0,
- );
- cy.get(cesc("#\\/input1") + " .mq-editable-field").should(
- "contain.text",
- str,
- );
- cy.get(cesc("#\\/input2") + " .mq-editable-field").should(
- "contain.text",
- str,
- );
- cy.get(cesc("#\\/input3") + " .mq-editable-field").should(
- "contain.text",
- str,
- );
- cy.get(cesc("#\\/input4") + " .mq-editable-field").should(
- "contain.text",
- str,
- );
- cy.get(cesc("#\\/input5") + " .mq-editable-field").should(
- "contain.text",
- str,
- );
- cy.get(cesc("#\\/input6") + " .mq-editable-field").should(
- "contain.text",
- str,
- );
- cy.get(cesc("#\\/input7") + " .mq-editable-field").should(
- "contain.text",
- str,
- );
- cy.get(cesc("#\\/input8") + " .mq-editable-field").should(
- "contain.text",
- str,
- );
- cy.get(cesc("#\\/input9") + " .mq-editable-field").should(
- "contain.text",
- str,
- );
-
- cy.get(cesc("#\\/s1") + " .mjx-mrow")
- .eq(0)
- .should("have.text", str);
- cy.get(cesc("#\\/s2") + " .mjx-mrow")
- .eq(0)
- .should("have.text", str);
- cy.get(cesc("#\\/s3") + " .mjx-mrow")
- .eq(0)
- .should("have.text", str);
- cy.get(cesc("#\\/s4") + " .mjx-mrow")
- .eq(0)
- .should("have.text", str);
- cy.get(cesc("#\\/s5") + " .mjx-mrow")
- .eq(0)
- .should("have.text", str);
- cy.get(cesc("#\\/s6") + " .mjx-mrow")
- .eq(0)
- .should("have.text", str);
- cy.get(cesc("#\\/s7") + " .mjx-mrow")
- .eq(0)
- .should("have.text", str);
- cy.get(cesc("#\\/s8") + " .mjx-mrow")
- .eq(0)
- .should("have.text", str);
- cy.get(cesc("#\\/s9") + " .mjx-mrow")
- .eq(0)
- .should("have.text", str);
- cy.get(cesc(`#\\/input0`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- str0,
- );
- });
- cy.get(cesc(`#\\/input1`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- str,
- );
- });
- cy.get(cesc(`#\\/input2`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- str,
- );
- });
- cy.get(cesc(`#\\/input3`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- str,
- );
- });
- cy.get(cesc(`#\\/input4`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- str,
- );
- });
- cy.get(cesc(`#\\/input5`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- str,
- );
- });
- cy.get(cesc(`#\\/input6`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- str,
- );
- });
- cy.get(cesc(`#\\/input7`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- str,
- );
- });
- cy.get(cesc(`#\\/input8`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- str,
- );
- });
- cy.get(cesc(`#\\/input9`) + ` .mq-editable-field`)
- .invoke("text")
- .then((text) => {
- expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
- str,
- );
- });
- }
-
- checkDisplay("(0,1)");
-
- cy.get(cesc("#\\/input0") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}x>=3{enter}",
- { force: true },
- );
-
- checkDisplay("[3,∞)", "x≥3");
-
- cy.get(cesc("#\\/input1") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}{{}q\\mid q=5}{enter}",
- { force: true },
- );
-
- checkDisplay("{5}");
-
- cy.get(cesc("#\\/input2") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}[-\\infty, \\pi){enter}",
- { force: true },
- );
-
- checkDisplay("(−∞,3.141592654)");
-
- cy.get(cesc("#\\/input3") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}(-\\infty,\\infty){enter}",
- { force: true },
- );
-
- checkDisplay("R");
-
- cy.get(cesc("#\\/input4") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}x\\in \\emptyset {enter}",
- { force: true },
- );
-
- checkDisplay("∅");
-
- cy.get(cesc("#\\/input5") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}x\\notin [9, \\infty){enter}",
- { force: true },
- );
-
- checkDisplay("(−∞,9)");
-
- cy.get(cesc("#\\/input6") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}{7}\\ni x{enter}",
- { force: true },
- );
-
- checkDisplay("{7}");
-
- cy.get(cesc("#\\/input7") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}(-\\infty, -2) \\notni x{enter}",
- { force: true },
- );
-
- checkDisplay("[−2,∞)");
-
- cy.get(cesc("#\\/input8") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}{{}1}^c{rightArrow} \\cap {{}v\\mid v>=1}{enter}",
- { force: true },
- );
-
- checkDisplay("(1,∞)");
-
- cy.get(cesc("#\\/input9") + " textarea").type(
- "{ctrl+home}{shift+end}{backspace}x\\ne -6{enter}",
- { force: true },
- );
-
- checkDisplay("(−∞,−6)∪(−6,∞)");
- });
-
- it("union of subset with numbers", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- -9
- -6
- -1
- 8
-
- ($x1,$x2) union ($x3,$x4)
-
- $S union $x1 union $x2 union $x3 union $x4
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/S") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−9,−6)∪(−1,8)");
- cy.get(cesc("#\\/Sclosed") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[−9,−6]∪[−1,8]");
- });
-
- it("point and interval properties", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
- emptyset
- [-1,2)
- (-1,2] union {-5}
- (-infinity,3) union (3,infinity)
- R
-
- empty points: $empty.points
- empty points closed: $empty.pointsClosed
- empty intervals: $empty.intervals
- empty isolated points: $empty.isolatedPoints
-
- interval points: $interval.points
- interval points closed: $interval.pointsClosed
- interval intervals: $interval.intervals
- interval isolated points: $interval.isolatedPoints
-
- intervalSingleton points: $intervalSingleton.points
- intervalSingleton points closed: $intervalSingleton.pointsClosed
- intervalSingleton intervals: $intervalSingleton.intervals
- intervalSingleton isolated points: $intervalSingleton.isolatedPoints
-
- missPoint points: $missPoint.points
- missPoint points closed: $missPoint.pointsClosed
- missPoint intervals: $missPoint.intervals
- missPoint isolated points: $missPoint.isolatedPoints
-
- R points: $R.points
- R points closed: $R.pointsClosed
- R intervals: $R.intervals
- R isolated points: $R.isolatedPoints
-
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
-
- cy.get(cesc("#\\/emptyPoints") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/emptyPointsClosed")).should(
- "have.text",
- "empty points closed: ",
- );
- cy.get(cesc("#\\/emptyIntervals") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/emptyIsolated") + " .mjx-mrow").should("not.exist");
-
- cy.get(cesc("#\\/intervalPoints") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "−1");
- cy.get(cesc("#\\/intervalPoints") + " .mjx-mrow")
- .eq(1)
- .should("have.text", "2");
- cy.get(cesc("#\\/intervalPoints") + " .mjx-mrow")
- .eq(2)
- .should("not.exist");
-
- cy.get(cesc("#\\/intervalPointsClosed")).should(
- "have.text",
- "interval points closed: true, false",
- );
-
- cy.get(cesc("#\\/intervalIntervals") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "[−1,2)");
-
- cy.get(cesc("#\\/intervalIsolated") + " .mjx-mrow").should("not.exist");
-
- cy.get(cesc("#\\/intervalSingletonPoints") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "−5");
- cy.get(cesc("#\\/intervalSingletonPoints") + " .mjx-mrow")
- .eq(1)
- .should("have.text", "−1");
- cy.get(cesc("#\\/intervalSingletonPoints") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "2");
- cy.get(cesc("#\\/intervalSingletonPoints") + " .mjx-mrow")
- .eq(3)
- .should("not.exist");
-
- cy.get(cesc("#\\/intervalSingletonPointsClosed")).should(
- "have.text",
- "intervalSingleton points closed: true, false, true",
- );
- cy.get(cesc("#\\/intervalSingletonIntervals") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−1,2]");
- cy.get(cesc("#\\/intervalSingletonIsolated") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "−5");
-
- cy.get(cesc("#\\/missPointPoints") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "3");
- cy.get(cesc("#\\/missPointPoints") + " .mjx-mrow")
- .eq(1)
- .should("not.exist");
- cy.get(cesc("#\\/missPointPointsClosed")).should(
- "have.text",
- "missPoint points closed: false",
- );
- cy.get(cesc("#\\/missPointIntervals") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,3)");
- cy.get(cesc("#\\/missPointIntervals") + " .mjx-mrow")
- .eq(2)
- .should("have.text", "(3,∞)");
- cy.get(cesc("#\\/missPointIsolated") + " .mjx-mrow").should(
- "not.exist",
- );
-
- cy.get(cesc("#\\/RPoints") + " .mjx-mrow").should("not.exist");
- cy.get(cesc("#\\/RPointsClosed")).should(
- "have.text",
- "R points closed: ",
- );
- cy.get(cesc("#\\/RIntervals") + " .mjx-mrow")
- .eq(0)
- .should("have.text", "(−∞,∞)");
- cy.get(cesc("#\\/RIsolated") + " .mjx-mrow").should("not.exist");
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/tabular.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/tabular.cy.js
deleted file mode 100644
index 9a2d4f9fe..000000000
--- a/packages/test-cypress/cypress/e2e/tagSpecific/tabular.cy.js
+++ /dev/null
@@ -1,36 +0,0 @@
-import { cesc2 } from "@doenet/utils";
-
-describe("Tabular Tag Tests", function () {
- beforeEach(() => {
- cy.clearIndexedDB();
- cy.visit("/");
- });
-
- it("inHeader attribute", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
-
- A |
- B |
-
-
- 🟣 |
- 🔴 |
-
-
-
- Top: inHeader = $_cell1.inHeader
- Bottom: inHeader = $_cell3.inHeader
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc2("#/_p1")).should("have.text", "Top: inHeader = true");
- cy.get(cesc2("#/_p2")).should("have.text", "Bottom: inHeader = false");
- });
-});
diff --git a/packages/test-cypress/cypress/e2e/tagSpecific/video.cy.js b/packages/test-cypress/cypress/e2e/tagSpecific/video.cy.js
index ad0b71a4c..69211d409 100644
--- a/packages/test-cypress/cypress/e2e/tagSpecific/video.cy.js
+++ b/packages/test-cypress/cypress/e2e/tagSpecific/video.cy.js
@@ -60,243 +60,6 @@ describe("Video Tag Tests", function () {
.then((type) => expect(type).eq("video/mp4"));
});
- it.skip("video from multiple sources", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
-
- https://flowergarden.noaa.gov/video_library/video/seaharew.mp4
- https://flowergarden.noaa.gov/video_library/video/seaharew.ogg
- https://flowergarden.noaa.gov/video_library/video/seaharew.webm
-
- `,
- },
- "*",
- );
- });
- cy.get(cesc("#\\/_video1"))
- .invoke("attr", "width")
- .then((width) => expect(width).eq("560px"));
- cy.get(cesc("#\\/_video1"))
- .invoke("attr", "height")
- .then((height) => expect(height).eq("315px"));
- cy.get(cesc("#\\/_video1") + " source:first-child")
- .invoke("attr", "src")
- .then((src) =>
- expect(src).eq(
- "https://flowergarden.noaa.gov/image_library/video/seaharew.mp4",
- ),
- );
- cy.get(cesc("#\\/_video1") + " source:first-child")
- .invoke("attr", "type")
- .then((type) => expect(type).eq("video/mp4"));
- cy.get(cesc("#\\/_video1") + " source:nth-child(2)")
- .invoke("attr", "src")
- .then((src) =>
- expect(src).eq(
- "https://flowergarden.noaa.gov/image_library/video/seaharew.ogg",
- ),
- );
- cy.get(cesc("#\\/_video1") + " source:nth-child(2)")
- .invoke("attr", "type")
- .then((type) => expect(type).eq("video/ogg"));
- cy.get(cesc("#\\/_video1") + " source:nth-child(3)")
- .invoke("attr", "src")
- .then((src) =>
- expect(src).eq(
- "https://flowergarden.noaa.gov/image_library/video/seaharew.webm",
- ),
- );
- cy.get(cesc("#\\/_video1") + " source:nth-child(3)")
- .invoke("attr", "type")
- .then((type) => expect(type).eq("video/webm"));
- });
-
- it("video sizes", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- let expectedSizes = {
- v: "full",
- vtiny: "tiny",
- vsmall: "small",
- vmedium: "medium",
- vlarge: "large",
- vfull: "full",
- vinvalid: "full",
- va10: "tiny",
- va100: "tiny",
- va200: "small",
- va300: "small",
- va400: "medium",
- va500: "medium",
- va600: "large",
- va700: "large",
- va800: "full",
- va900: "full",
- va10000: "full",
- vp1: "tiny",
- vp10: "tiny",
- vp20: "small",
- vp30: "small",
- vp40: "small",
- vp50: "medium",
- vp60: "medium",
- vp70: "large",
- vp80: "large",
- vp90: "full",
- vp100: "full",
- vp1000: "full",
- vbadwidth: "full",
- };
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- for (let name in expectedSizes) {
- console.log(stateVariables);
- console.log("/" + name);
- expect(stateVariables["/" + name].stateValues.size).eq(
- expectedSizes[name],
- );
- }
- });
-
- for (let name in expectedSizes) {
- cy.get(cesc2("#/" + name))
- .invoke("css", "width")
- .then((width) => parseInt(width))
- .should("be.gte", widthsBySize[expectedSizes[name]] - 4)
- .and("be.lte", widthsBySize[expectedSizes[name]] + 1);
- }
- });
-
- it("horizontal align", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/v"].stateValues.horizontalAlign).eq(
- "center",
- );
- expect(stateVariables["/vleft"].stateValues.horizontalAlign).eq(
- "left",
- );
- expect(stateVariables["/vright"].stateValues.horizontalAlign).eq(
- "right",
- );
- expect(stateVariables["/vcenter"].stateValues.horizontalAlign).eq(
- "center",
- );
- expect(stateVariables["/vinvalid"].stateValues.horizontalAlign).eq(
- "center",
- );
- });
-
- // TODO: anything to check in the DOM?
- });
-
- it("displayMode", () => {
- cy.window().then(async (win) => {
- win.postMessage(
- {
- doenetML: `
- a
-
-
-
-
-
-
- `,
- },
- "*",
- );
- });
-
- cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
-
- cy.window().then(async (win) => {
- let stateVariables = await win.returnAllStateVariables1();
- expect(stateVariables["/v"].stateValues.displayMode).eq("block");
- expect(stateVariables["/vinline"].stateValues.displayMode).eq(
- "inline",
- );
- expect(stateVariables["/vblock"].stateValues.displayMode).eq(
- "block",
- );
- expect(stateVariables["/vinvalid"].stateValues.displayMode).eq(
- "block",
- );
- });
-
- // TODO: anything to check in the DOM?
- });
-
it("actions on youtube video", () => {
cy.window().then(async (win) => {
win.postMessage(