@doenet/doenetml 0.6.0-alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (549) hide show
  1. package/.prettierrc +3 -0
  2. package/LICENSE +661 -0
  3. package/README.md +146 -0
  4. package/cypress/e2e/ActivityViewer/activityVariants.cy.js +1770 -0
  5. package/cypress/e2e/ActivityViewer/compiledActivity.cy.js +83 -0
  6. package/cypress/e2e/ActivityViewer/relationshipsAmongPages.cy.js +697 -0
  7. package/cypress/e2e/answerValidation/errorinnumbers.cy.js +2125 -0
  8. package/cypress/e2e/answerValidation/factoring.cy.js +1945 -0
  9. package/cypress/e2e/answerValidation/factoringOldAlgorithm.cy.js +892 -0
  10. package/cypress/e2e/answerValidation/functionanswers.cy.js +314 -0
  11. package/cypress/e2e/answerValidation/matchingpatterns.cy.js +287 -0
  12. package/cypress/e2e/answerValidation/matchpartial.cy.js +6711 -0
  13. package/cypress/e2e/answerValidation/pointlocation.cy.js +3989 -0
  14. package/cypress/e2e/answerValidation/symbolicequality.cy.js +1893 -0
  15. package/cypress/e2e/answerValidation/videoProgress.cy.js +210 -0
  16. package/cypress/e2e/assignNames/basiccopy.cy.js +2376 -0
  17. package/cypress/e2e/assignNames/collections.cy.js +9247 -0
  18. package/cypress/e2e/assignNames/selects.cy.js +105 -0
  19. package/cypress/e2e/assignNames/sequences.cy.js +1964 -0
  20. package/cypress/e2e/baseComponent/basecomponentproperties.cy.js +999 -0
  21. package/cypress/e2e/baseComponent/doenetMLtext.cy.js +427 -0
  22. package/cypress/e2e/chemistry/atom.cy.js +201 -0
  23. package/cypress/e2e/chemistry/ion.cy.js +608 -0
  24. package/cypress/e2e/chemistry/ioniccompound.cy.js +133 -0
  25. package/cypress/e2e/dynamicalsystem/cobwebpolyline.cy.js +2653 -0
  26. package/cypress/e2e/dynamicalsystem/equilibriumcurve.cy.js +311 -0
  27. package/cypress/e2e/dynamicalsystem/equilibriumline.cy.js +279 -0
  28. package/cypress/e2e/dynamicalsystem/equilibriumpoint.cy.js +283 -0
  29. package/cypress/e2e/dynamicalsystem/odesystem.cy.js +1834 -0
  30. package/cypress/e2e/equality/mathexpressions.cy.js +948 -0
  31. package/cypress/e2e/graphing/graphreferences.cy.js +978 -0
  32. package/cypress/e2e/graphing/graphreferences2.cy.js +615 -0
  33. package/cypress/e2e/linearAlgebra/eigenDecomposition.cy.js +401 -0
  34. package/cypress/e2e/tagSpecific/angle.cy.js +3898 -0
  35. package/cypress/e2e/tagSpecific/animatefromsequence.cy.js +2306 -0
  36. package/cypress/e2e/tagSpecific/answer.cy.js +31647 -0
  37. package/cypress/e2e/tagSpecific/bestfitline.cy.js +612 -0
  38. package/cypress/e2e/tagSpecific/blockquote.cy.js +30 -0
  39. package/cypress/e2e/tagSpecific/boolean.cy.js +742 -0
  40. package/cypress/e2e/tagSpecific/booleaninput.cy.js +1283 -0
  41. package/cypress/e2e/tagSpecific/booleanlist.cy.js +588 -0
  42. package/cypress/e2e/tagSpecific/booleanoperators.cy.js +596 -0
  43. package/cypress/e2e/tagSpecific/booleanoperatorsonmath.cy.js +498 -0
  44. package/cypress/e2e/tagSpecific/callaction.cy.js +2835 -0
  45. package/cypress/e2e/tagSpecific/choiceinput.cy.js +3205 -0
  46. package/cypress/e2e/tagSpecific/circle.cy.js +22036 -0
  47. package/cypress/e2e/tagSpecific/codeeditor.cy.js +1995 -0
  48. package/cypress/e2e/tagSpecific/collect.cy.js +5035 -0
  49. package/cypress/e2e/tagSpecific/componentsize.cy.js +502 -0
  50. package/cypress/e2e/tagSpecific/conditionalcontent.cy.js +3495 -0
  51. package/cypress/e2e/tagSpecific/contentBrowser.cy.js +335 -0
  52. package/cypress/e2e/tagSpecific/contentpicker.cy.js +261 -0
  53. package/cypress/e2e/tagSpecific/copy.cy.js +12627 -0
  54. package/cypress/e2e/tagSpecific/copy2.cy.js +5698 -0
  55. package/cypress/e2e/tagSpecific/curve.bezier.cy.js +12440 -0
  56. package/cypress/e2e/tagSpecific/curve.cy.js +1716 -0
  57. package/cypress/e2e/tagSpecific/curve.function.cy.js +1471 -0
  58. package/cypress/e2e/tagSpecific/curve.parametrized.cy.js +920 -0
  59. package/cypress/e2e/tagSpecific/document.cy.js +234 -0
  60. package/cypress/e2e/tagSpecific/endpoint.cy.js +197 -0
  61. package/cypress/e2e/tagSpecific/evaluate.cy.js +8895 -0
  62. package/cypress/e2e/tagSpecific/extract.cy.js +2282 -0
  63. package/cypress/e2e/tagSpecific/feedback.cy.js +2941 -0
  64. package/cypress/e2e/tagSpecific/function.cy.js +9450 -0
  65. package/cypress/e2e/tagSpecific/functioniterates.cy.js +1178 -0
  66. package/cypress/e2e/tagSpecific/functionoperators.cy.js +4047 -0
  67. package/cypress/e2e/tagSpecific/graph.cy.js +2491 -0
  68. package/cypress/e2e/tagSpecific/group.cy.js +683 -0
  69. package/cypress/e2e/tagSpecific/hint.cy.js +204 -0
  70. package/cypress/e2e/tagSpecific/image.cy.js +770 -0
  71. package/cypress/e2e/tagSpecific/integer.cy.js +206 -0
  72. package/cypress/e2e/tagSpecific/label.cy.js +800 -0
  73. package/cypress/e2e/tagSpecific/legend.cy.js +1001 -0
  74. package/cypress/e2e/tagSpecific/line.cy.js +12167 -0
  75. package/cypress/e2e/tagSpecific/linesegment.cy.js +4749 -0
  76. package/cypress/e2e/tagSpecific/lorem.cy.js +289 -0
  77. package/cypress/e2e/tagSpecific/map.cy.js +4476 -0
  78. package/cypress/e2e/tagSpecific/matchespattern.cy.js +693 -0
  79. package/cypress/e2e/tagSpecific/math.cy.js +10990 -0
  80. package/cypress/e2e/tagSpecific/mathdisplay.cy.js +2689 -0
  81. package/cypress/e2e/tagSpecific/mathinput.cy.js +15628 -0
  82. package/cypress/e2e/tagSpecific/mathinputgraph.cy.js +566 -0
  83. package/cypress/e2e/tagSpecific/mathlist.cy.js +4073 -0
  84. package/cypress/e2e/tagSpecific/mathoperators.cy.js +13851 -0
  85. package/cypress/e2e/tagSpecific/matrix.cy.js +8825 -0
  86. package/cypress/e2e/tagSpecific/matrixinput.cy.js +16277 -0
  87. package/cypress/e2e/tagSpecific/module.cy.js +1771 -0
  88. package/cypress/e2e/tagSpecific/number.cy.js +2221 -0
  89. package/cypress/e2e/tagSpecific/numberlist.cy.js +1285 -0
  90. package/cypress/e2e/tagSpecific/p.cy.js +72 -0
  91. package/cypress/e2e/tagSpecific/paginator.cy.js +2983 -0
  92. package/cypress/e2e/tagSpecific/parabola.cy.js +14331 -0
  93. package/cypress/e2e/tagSpecific/paragraphmarkup.cy.js +104 -0
  94. package/cypress/e2e/tagSpecific/periodicset.cy.js +1439 -0
  95. package/cypress/e2e/tagSpecific/piecewisefunction.cy.js +1055 -0
  96. package/cypress/e2e/tagSpecific/pluralize.cy.js +274 -0
  97. package/cypress/e2e/tagSpecific/point.cy.js +8895 -0
  98. package/cypress/e2e/tagSpecific/point2.cy.js +10259 -0
  99. package/cypress/e2e/tagSpecific/polygon.cy.js +5039 -0
  100. package/cypress/e2e/tagSpecific/polyline.cy.js +4704 -0
  101. package/cypress/e2e/tagSpecific/problem.cy.js +2768 -0
  102. package/cypress/e2e/tagSpecific/ray.cy.js +10770 -0
  103. package/cypress/e2e/tagSpecific/rectangle.cy.js +2143 -0
  104. package/cypress/e2e/tagSpecific/ref.cy.js +420 -0
  105. package/cypress/e2e/tagSpecific/regularPolygon.cy.js +1006 -0
  106. package/cypress/e2e/tagSpecific/regularPolygon2.cy.js +100 -0
  107. package/cypress/e2e/tagSpecific/regularPolygon3.cy.js +777 -0
  108. package/cypress/e2e/tagSpecific/samplerandomnumbers.cy.js +3619 -0
  109. package/cypress/e2e/tagSpecific/sectioning.cy.js +3530 -0
  110. package/cypress/e2e/tagSpecific/select.cy.js +5376 -0
  111. package/cypress/e2e/tagSpecific/selectfromsequence.cy.js +3846 -0
  112. package/cypress/e2e/tagSpecific/selectrandomnumbers.cy.js +2914 -0
  113. package/cypress/e2e/tagSpecific/sequence.cy.js +2093 -0
  114. package/cypress/e2e/tagSpecific/shuffle.cy.js +490 -0
  115. package/cypress/e2e/tagSpecific/sidebyside.cy.js +8057 -0
  116. package/cypress/e2e/tagSpecific/singlecharactercomponents.cy.js +72 -0
  117. package/cypress/e2e/tagSpecific/slider.cy.js +914 -0
  118. package/cypress/e2e/tagSpecific/solution.cy.js +109 -0
  119. package/cypress/e2e/tagSpecific/solveequations.cy.js +1026 -0
  120. package/cypress/e2e/tagSpecific/sort.cy.js +1685 -0
  121. package/cypress/e2e/tagSpecific/spreadsheet.cy.js +5971 -0
  122. package/cypress/e2e/tagSpecific/subsetofreals.cy.js +2725 -0
  123. package/cypress/e2e/tagSpecific/substitute.cy.js +2646 -0
  124. package/cypress/e2e/tagSpecific/tabular.cy.js +36 -0
  125. package/cypress/e2e/tagSpecific/text.cy.js +975 -0
  126. package/cypress/e2e/tagSpecific/textinput.cy.js +2177 -0
  127. package/cypress/e2e/tagSpecific/textlist.cy.js +369 -0
  128. package/cypress/e2e/tagSpecific/triangle.cy.js +1936 -0
  129. package/cypress/e2e/tagSpecific/triggerset.cy.js +2023 -0
  130. package/cypress/e2e/tagSpecific/updatevalue.cy.js +3288 -0
  131. package/cypress/e2e/tagSpecific/vector.cy.js +20183 -0
  132. package/cypress/e2e/tagSpecific/video.cy.js +612 -0
  133. package/cypress/e2e/tagSpecific/when.cy.js +202 -0
  134. package/cypress/e2e/variants/specifysinglevariant.cy.js +6726 -0
  135. package/cypress/e2e/variants/uniquevariants.cy.js +4846 -0
  136. package/cypress/fixtures/example.json +5 -0
  137. package/cypress/support/commands.js +32 -0
  138. package/cypress/support/e2e.js +31 -0
  139. package/cypress.config.js +18 -0
  140. package/docs/codeSnippet.jsx +11 -0
  141. package/docs/index.html +133 -0
  142. package/docs/index.jsx +138 -0
  143. package/docs/prism.css +3 -0
  144. package/index.html +14 -0
  145. package/index.js +21 -0
  146. package/media/answer_example.png +0 -0
  147. package/media/graph_example.png +0 -0
  148. package/media/graph_markup_example.png +0 -0
  149. package/package.json +83 -0
  150. package/public/favicon.ico +0 -0
  151. package/public/fonts/files/open-sans-v18-latin-700.woff +0 -0
  152. package/public/fonts/files/open-sans-v18-latin-700.woff2 +0 -0
  153. package/public/fonts/files/open-sans-v18-latin-700italic.woff +0 -0
  154. package/public/fonts/files/open-sans-v18-latin-700italic.woff2 +0 -0
  155. package/public/fonts/files/open-sans-v18-latin-italic.woff +0 -0
  156. package/public/fonts/files/open-sans-v18-latin-italic.woff2 +0 -0
  157. package/public/fonts/files/open-sans-v18-latin-light-italic.woff +0 -0
  158. package/public/fonts/files/open-sans-v18-latin-light-italic.woff2 +0 -0
  159. package/public/fonts/files/open-sans-v18-latin-light.woff +0 -0
  160. package/public/fonts/files/open-sans-v18-latin-light.woff2 +0 -0
  161. package/public/fonts/files/open-sans-v18-latin-regular.woff +0 -0
  162. package/public/fonts/files/open-sans-v18-latin-regular.woff2 +0 -0
  163. package/src/Core/ComponentTypes.js +426 -0
  164. package/src/Core/Core.js +11852 -0
  165. package/src/Core/CoreWorker.js +127 -0
  166. package/src/Core/Dependencies.js +8226 -0
  167. package/src/Core/Numerics.js +473 -0
  168. package/src/Core/ParameterStack.js +36 -0
  169. package/src/Core/ReadOnlyProxyHandler.js +41 -0
  170. package/src/Core/StateProxyHandler.js +88 -0
  171. package/src/Core/components/Aliases.js +67 -0
  172. package/src/Core/components/Angle.js +758 -0
  173. package/src/Core/components/AnimateFromSequence.js +922 -0
  174. package/src/Core/components/Answer.js +2087 -0
  175. package/src/Core/components/AsList.js +83 -0
  176. package/src/Core/components/AttractTo.js +245 -0
  177. package/src/Core/components/AttractToAngles.js +262 -0
  178. package/src/Core/components/AttractToConstraint.js +104 -0
  179. package/src/Core/components/AttractToGrid.js +315 -0
  180. package/src/Core/components/Award.js +906 -0
  181. package/src/Core/components/BestFitLine.js +318 -0
  182. package/src/Core/components/BezierControls.js +719 -0
  183. package/src/Core/components/BlockQuote.js +35 -0
  184. package/src/Core/components/Boolean.js +500 -0
  185. package/src/Core/components/BooleanInput.js +330 -0
  186. package/src/Core/components/BooleanList.js +396 -0
  187. package/src/Core/components/BooleanOperators.js +35 -0
  188. package/src/Core/components/BooleanOperatorsOfMath.js +148 -0
  189. package/src/Core/components/CallAction.js +261 -0
  190. package/src/Core/components/Caption.js +73 -0
  191. package/src/Core/components/Case.js +56 -0
  192. package/src/Core/components/Cell.js +439 -0
  193. package/src/Core/components/CellBlock.js +64 -0
  194. package/src/Core/components/Chart.js +795 -0
  195. package/src/Core/components/Choice.js +266 -0
  196. package/src/Core/components/ChoiceInput.js +1407 -0
  197. package/src/Core/components/Circle.js +2884 -0
  198. package/src/Core/components/CodeEditor.js +647 -0
  199. package/src/Core/components/CodeViewer.js +294 -0
  200. package/src/Core/components/CollaborateGroupSetup.js +46 -0
  201. package/src/Core/components/CollaborateGroups.js +119 -0
  202. package/src/Core/components/Collect.js +850 -0
  203. package/src/Core/components/Column.js +608 -0
  204. package/src/Core/components/ConditionalContent.js +468 -0
  205. package/src/Core/components/ConsiderAsResponses.js +49 -0
  206. package/src/Core/components/ConstrainTo.js +161 -0
  207. package/src/Core/components/ConstrainToAngles.js +244 -0
  208. package/src/Core/components/ConstrainToGraph.js +142 -0
  209. package/src/Core/components/ConstrainToGrid.js +175 -0
  210. package/src/Core/components/ConstraintUnion.js +119 -0
  211. package/src/Core/components/Constraints.js +497 -0
  212. package/src/Core/components/ContentBrowser.js +441 -0
  213. package/src/Core/components/ContentPicker.js +263 -0
  214. package/src/Core/components/ControlVectors.js +25 -0
  215. package/src/Core/components/Coords.js +63 -0
  216. package/src/Core/components/Copy.js +3412 -0
  217. package/src/Core/components/Curve.js +4130 -0
  218. package/src/Core/components/CustomAttribute.js +175 -0
  219. package/src/Core/components/DataFrame.js +357 -0
  220. package/src/Core/components/DiscreteSimulationResultList.js +342 -0
  221. package/src/Core/components/DiscreteSimulationResultPolyline.js +581 -0
  222. package/src/Core/components/Divisions.js +55 -0
  223. package/src/Core/components/Document.js +888 -0
  224. package/src/Core/components/Embed.js +65 -0
  225. package/src/Core/components/Endpoint.js +62 -0
  226. package/src/Core/components/Evaluate.js +321 -0
  227. package/src/Core/components/Extract.js +656 -0
  228. package/src/Core/components/Extrema.js +556 -0
  229. package/src/Core/components/Feedback.js +200 -0
  230. package/src/Core/components/FeedbackDefinitions.js +97 -0
  231. package/src/Core/components/Figure.js +148 -0
  232. package/src/Core/components/Footnote.js +73 -0
  233. package/src/Core/components/Function.js +5344 -0
  234. package/src/Core/components/FunctionIterates.js +306 -0
  235. package/src/Core/components/FunctionOperators.js +702 -0
  236. package/src/Core/components/Graph.js +1679 -0
  237. package/src/Core/components/Group.js +7 -0
  238. package/src/Core/components/HasSameFactoring.js +407 -0
  239. package/src/Core/components/Hint.js +241 -0
  240. package/src/Core/components/Image.js +524 -0
  241. package/src/Core/components/Indexing.js +79 -0
  242. package/src/Core/components/IntComma.js +64 -0
  243. package/src/Core/components/Integer.js +81 -0
  244. package/src/Core/components/Intersection.js +328 -0
  245. package/src/Core/components/Interval.js +29 -0
  246. package/src/Core/components/Label.js +492 -0
  247. package/src/Core/components/Latex.js +104 -0
  248. package/src/Core/components/Legend.js +329 -0
  249. package/src/Core/components/Line.js +2040 -0
  250. package/src/Core/components/LineSegment.js +882 -0
  251. package/src/Core/components/Lists.js +180 -0
  252. package/src/Core/components/Lorem.js +249 -0
  253. package/src/Core/components/MMeMen.js +377 -0
  254. package/src/Core/components/Map.js +873 -0
  255. package/src/Core/components/Markers.js +101 -0
  256. package/src/Core/components/MatchesPattern.js +339 -0
  257. package/src/Core/components/Math.js +2552 -0
  258. package/src/Core/components/MathInput.js +948 -0
  259. package/src/Core/components/MathList.js +828 -0
  260. package/src/Core/components/MathOperators.js +1286 -0
  261. package/src/Core/components/Matrix.js +497 -0
  262. package/src/Core/components/MatrixInput.js +3157 -0
  263. package/src/Core/components/MdMdnMrow.js +394 -0
  264. package/src/Core/components/Module.js +16 -0
  265. package/src/Core/components/Number.js +1031 -0
  266. package/src/Core/components/NumberList.js +550 -0
  267. package/src/Core/components/Option.js +24 -0
  268. package/src/Core/components/P.js +71 -0
  269. package/src/Core/components/Paginator.js +338 -0
  270. package/src/Core/components/Panel.js +126 -0
  271. package/src/Core/components/Parabola.js +1561 -0
  272. package/src/Core/components/ParagraphMarkup.js +59 -0
  273. package/src/Core/components/Pegboard.js +43 -0
  274. package/src/Core/components/PeriodicSet.js +291 -0
  275. package/src/Core/components/PiecewiseFunction.js +832 -0
  276. package/src/Core/components/Pluralize.js +198 -0
  277. package/src/Core/components/Point.js +1295 -0
  278. package/src/Core/components/Polygon.js +408 -0
  279. package/src/Core/components/Polyline.js +841 -0
  280. package/src/Core/components/RandomizedTextList.js +225 -0
  281. package/src/Core/components/Ray.js +1737 -0
  282. package/src/Core/components/Rectangle.js +1535 -0
  283. package/src/Core/components/Ref.js +350 -0
  284. package/src/Core/components/RegionBetweenCurveXAxis.js +124 -0
  285. package/src/Core/components/RegionHalfPlane.js +107 -0
  286. package/src/Core/components/RegularPolygon.js +2118 -0
  287. package/src/Core/components/RenderDoenetML.js +181 -0
  288. package/src/Core/components/Row.js +780 -0
  289. package/src/Core/components/SampleRandomNumbers.js +653 -0
  290. package/src/Core/components/Sectioning.js +303 -0
  291. package/src/Core/components/Select.js +947 -0
  292. package/src/Core/components/SelectFromSequence.js +1242 -0
  293. package/src/Core/components/SelectRandomNumbers.js +225 -0
  294. package/src/Core/components/Sequence.js +444 -0
  295. package/src/Core/components/Setup.js +53 -0
  296. package/src/Core/components/Shuffle.js +470 -0
  297. package/src/Core/components/SideBySide.js +2130 -0
  298. package/src/Core/components/SingleCharacterComponents.js +41 -0
  299. package/src/Core/components/Slider.js +819 -0
  300. package/src/Core/components/SolutionContainer.js +67 -0
  301. package/src/Core/components/Solutions.js +334 -0
  302. package/src/Core/components/SolveEquations.js +568 -0
  303. package/src/Core/components/Sort.js +398 -0
  304. package/src/Core/components/Sources.js +108 -0
  305. package/src/Core/components/Split.js +205 -0
  306. package/src/Core/components/Spreadsheet.js +1507 -0
  307. package/src/Core/components/StyleDefinitions.js +111 -0
  308. package/src/Core/components/SubsetOfReals.js +348 -0
  309. package/src/Core/components/SubsetOfRealsInput.js +1474 -0
  310. package/src/Core/components/Substitute.js +496 -0
  311. package/src/Core/components/SummaryStatistics.js +652 -0
  312. package/src/Core/components/Table.js +145 -0
  313. package/src/Core/components/Tabular.js +384 -0
  314. package/src/Core/components/Template.js +360 -0
  315. package/src/Core/components/Text.js +341 -0
  316. package/src/Core/components/TextInput.js +566 -0
  317. package/src/Core/components/TextList.js +442 -0
  318. package/src/Core/components/TextListFromString.js +137 -0
  319. package/src/Core/components/TextOperatorsOfMath.js +21 -0
  320. package/src/Core/components/Triangle.js +280 -0
  321. package/src/Core/components/TriggerSet.js +189 -0
  322. package/src/Core/components/TupleList.js +43 -0
  323. package/src/Core/components/UpdateValue.js +435 -0
  324. package/src/Core/components/VariantControl.js +36 -0
  325. package/src/Core/components/Vector.js +2478 -0
  326. package/src/Core/components/Verbatim.js +125 -0
  327. package/src/Core/components/Video.js +673 -0
  328. package/src/Core/components/When.js +198 -0
  329. package/src/Core/components/abstract/AngleListComponent.js +140 -0
  330. package/src/Core/components/abstract/BaseComponent.js +1496 -0
  331. package/src/Core/components/abstract/BlockComponent.js +5 -0
  332. package/src/Core/components/abstract/BooleanBaseOperator.js +88 -0
  333. package/src/Core/components/abstract/BooleanBaseOperatorOfMath.js +100 -0
  334. package/src/Core/components/abstract/BooleanBaseOperatorOneInput.js +44 -0
  335. package/src/Core/components/abstract/ComponentSize.js +789 -0
  336. package/src/Core/components/abstract/ComponentWithSelectableType.js +537 -0
  337. package/src/Core/components/abstract/CompositeComponent.js +142 -0
  338. package/src/Core/components/abstract/ConstraintComponent.js +19 -0
  339. package/src/Core/components/abstract/FunctionBaseOperator.js +680 -0
  340. package/src/Core/components/abstract/GraphicalComponent.js +56 -0
  341. package/src/Core/components/abstract/InlineComponent.js +5 -0
  342. package/src/Core/components/abstract/InlineRenderInlineChildren.js +63 -0
  343. package/src/Core/components/abstract/Input.js +192 -0
  344. package/src/Core/components/abstract/IntervalListComponent.js +218 -0
  345. package/src/Core/components/abstract/LineListComponent.js +114 -0
  346. package/src/Core/components/abstract/MathBaseOperator.js +631 -0
  347. package/src/Core/components/abstract/MathBaseOperatorOneInput.js +112 -0
  348. package/src/Core/components/abstract/PointListComponent.js +238 -0
  349. package/src/Core/components/abstract/SectioningComponent.js +1262 -0
  350. package/src/Core/components/abstract/SingleCharacterInline.js +23 -0
  351. package/src/Core/components/abstract/TextBaseOperatorOfMath.js +47 -0
  352. package/src/Core/components/abstract/TextOrInline.js +66 -0
  353. package/src/Core/components/abstract/VariableName.js +31 -0
  354. package/src/Core/components/abstract/VariableNameList.js +83 -0
  355. package/src/Core/components/abstract/VectorListComponent.js +235 -0
  356. package/src/Core/components/chemistry/Atom.js +910 -0
  357. package/src/Core/components/chemistry/ElectronConfiguration.js +36 -0
  358. package/src/Core/components/chemistry/Ion.js +684 -0
  359. package/src/Core/components/chemistry/IonicCompound.js +189 -0
  360. package/src/Core/components/chemistry/OrbitalDiagram.js +175 -0
  361. package/src/Core/components/chemistry/OrbitalDiagramInput.js +753 -0
  362. package/src/Core/components/chemistry/index.js +6 -0
  363. package/src/Core/components/commonsugar/breakstrings.js +627 -0
  364. package/src/Core/components/commonsugar/lists.js +177 -0
  365. package/src/Core/components/dynamicalSystems/CobwebPolyline.js +913 -0
  366. package/src/Core/components/dynamicalSystems/EquilibriumCurve.js +95 -0
  367. package/src/Core/components/dynamicalSystems/EquilibriumLine.js +93 -0
  368. package/src/Core/components/dynamicalSystems/EquilibriumPoint.js +93 -0
  369. package/src/Core/components/dynamicalSystems/ODESystem.js +943 -0
  370. package/src/Core/components/dynamicalSystems/index.js +5 -0
  371. package/src/Core/components/linearAlgebra/EigenDecomposition.js +294 -0
  372. package/src/Core/utils/array.js +30 -0
  373. package/src/Core/utils/booleanLogic.js +965 -0
  374. package/src/Core/utils/checkEquality.js +818 -0
  375. package/src/Core/utils/cid.js +29 -0
  376. package/src/Core/utils/componentInfoObjects.js +100 -0
  377. package/src/Core/utils/constraints.js +23 -0
  378. package/src/Core/utils/copy.js +572 -0
  379. package/src/Core/utils/deepFunctions.js +173 -0
  380. package/src/Core/utils/descendants.js +252 -0
  381. package/src/Core/utils/enumeration.js +234 -0
  382. package/src/Core/utils/feedback.js +84 -0
  383. package/src/Core/utils/function.js +1343 -0
  384. package/src/Core/utils/graphical.js +196 -0
  385. package/src/Core/utils/label.js +396 -0
  386. package/src/Core/utils/math.js +1056 -0
  387. package/src/Core/utils/naming.js +45 -0
  388. package/src/Core/utils/periodicSetEquality.js +403 -0
  389. package/src/Core/utils/randomNumbers.js +70 -0
  390. package/src/Core/utils/retrieveMedia.js +98 -0
  391. package/src/Core/utils/retrieveTextFile.js +140 -0
  392. package/src/Core/utils/returnAllPossibleVariants.js +73 -0
  393. package/src/Core/utils/rounding.js +316 -0
  394. package/src/Core/utils/sequence.js +754 -0
  395. package/src/Core/utils/serializedStateProcessing.js +4049 -0
  396. package/src/Core/utils/size.js +22 -0
  397. package/src/Core/utils/stateVariables.js +138 -0
  398. package/src/Core/utils/style.js +535 -0
  399. package/src/Core/utils/subset-of-reals.js +796 -0
  400. package/src/Core/utils/table.js +41 -0
  401. package/src/Core/utils/text.js +16 -0
  402. package/src/Core/utils/triggering.js +167 -0
  403. package/src/Core/utils/variants.js +477 -0
  404. package/src/DoenetML.css +308 -0
  405. package/src/DoenetML.jsx +201 -0
  406. package/src/Parser/doenet.grammar +90 -0
  407. package/src/Parser/doenet.js +33 -0
  408. package/src/Parser/doenet.terms.js +20 -0
  409. package/src/Parser/parser.js +266 -0
  410. package/src/Parser/tokens.js +129 -0
  411. package/src/Tools/CodeMirror.jsx +440 -0
  412. package/src/Tools/DarkmodeController.jsx +21 -0
  413. package/src/Tools/Footers/MathInputSelector.jsx +34 -0
  414. package/src/Tools/Footers/VirtualKeyboard.jsx +751 -0
  415. package/src/Tools/cypressTest/CypressTest.jsx +341 -0
  416. package/src/Tools/cypressTest/index.html +102 -0
  417. package/src/Tools/cypressTest/index.jsx +40 -0
  418. package/src/Viewer/ActivityViewer.jsx +1461 -0
  419. package/src/Viewer/PageViewer.jsx +1329 -0
  420. package/src/Viewer/renderers/alert.jsx +17 -0
  421. package/src/Viewer/renderers/angle.jsx +209 -0
  422. package/src/Viewer/renderers/answer.jsx +206 -0
  423. package/src/Viewer/renderers/asList.jsx +25 -0
  424. package/src/Viewer/renderers/blockQuote.jsx +41 -0
  425. package/src/Viewer/renderers/boolean.jsx +17 -0
  426. package/src/Viewer/renderers/booleanInput.css +105 -0
  427. package/src/Viewer/renderers/booleanInput.jsx +636 -0
  428. package/src/Viewer/renderers/button.jsx +369 -0
  429. package/src/Viewer/renderers/c.jsx +17 -0
  430. package/src/Viewer/renderers/callAction.jsx +18 -0
  431. package/src/Viewer/renderers/cell.jsx +59 -0
  432. package/src/Viewer/renderers/chart.jsx +83 -0
  433. package/src/Viewer/renderers/choiceInput.css +223 -0
  434. package/src/Viewer/renderers/choiceInput.jsx +535 -0
  435. package/src/Viewer/renderers/circle.jsx +990 -0
  436. package/src/Viewer/renderers/cobwebPolyline.jsx +442 -0
  437. package/src/Viewer/renderers/codeEditor.jsx +248 -0
  438. package/src/Viewer/renderers/codeViewer.jsx +105 -0
  439. package/src/Viewer/renderers/containerBlock.jsx +41 -0
  440. package/src/Viewer/renderers/containerInline.jsx +17 -0
  441. package/src/Viewer/renderers/contentBrowser.jsx +159 -0
  442. package/src/Viewer/renderers/contentPicker.jsx +160 -0
  443. package/src/Viewer/renderers/curve.jsx +1072 -0
  444. package/src/Viewer/renderers/ellipsis.jsx +17 -0
  445. package/src/Viewer/renderers/em.jsx +17 -0
  446. package/src/Viewer/renderers/embed.jsx +110 -0
  447. package/src/Viewer/renderers/feedback.jsx +74 -0
  448. package/src/Viewer/renderers/figure.jsx +131 -0
  449. package/src/Viewer/renderers/footnote.jsx +52 -0
  450. package/src/Viewer/renderers/graph.jsx +925 -0
  451. package/src/Viewer/renderers/hint.jsx +142 -0
  452. package/src/Viewer/renderers/image.jsx +581 -0
  453. package/src/Viewer/renderers/jsxgraph-distrib/jsxgraphcore.mjs +2 -0
  454. package/src/Viewer/renderers/jsxgraph-distrib/jsxgraphcore.mjs.map +1 -0
  455. package/src/Viewer/renderers/label.jsx +470 -0
  456. package/src/Viewer/renderers/legend.jsx +306 -0
  457. package/src/Viewer/renderers/line.jsx +511 -0
  458. package/src/Viewer/renderers/lineSegment.jsx +754 -0
  459. package/src/Viewer/renderers/list.jsx +111 -0
  460. package/src/Viewer/renderers/lq.jsx +12 -0
  461. package/src/Viewer/renderers/lsq.jsx +12 -0
  462. package/src/Viewer/renderers/math.jsx +582 -0
  463. package/src/Viewer/renderers/mathInput.css +10 -0
  464. package/src/Viewer/renderers/mathInput.jsx +425 -0
  465. package/src/Viewer/renderers/mathInputog.jsx +534 -0
  466. package/src/Viewer/renderers/mathList.jsx +39 -0
  467. package/src/Viewer/renderers/matrixInput.jsx +317 -0
  468. package/src/Viewer/renderers/mdash.jsx +12 -0
  469. package/src/Viewer/renderers/nbsp.jsx +12 -0
  470. package/src/Viewer/renderers/ndash.jsx +12 -0
  471. package/src/Viewer/renderers/number.jsx +454 -0
  472. package/src/Viewer/renderers/numberList.jsx +35 -0
  473. package/src/Viewer/renderers/orbitalDiagram.jsx +247 -0
  474. package/src/Viewer/renderers/orbitalDiagramInput.jsx +450 -0
  475. package/src/Viewer/renderers/p.jsx +38 -0
  476. package/src/Viewer/renderers/paginatorControls.jsx +41 -0
  477. package/src/Viewer/renderers/pegboard.jsx +239 -0
  478. package/src/Viewer/renderers/point.jsx +649 -0
  479. package/src/Viewer/renderers/polygon.jsx +612 -0
  480. package/src/Viewer/renderers/polyline.jsx +608 -0
  481. package/src/Viewer/renderers/pre.jsx +34 -0
  482. package/src/Viewer/renderers/q.jsx +17 -0
  483. package/src/Viewer/renderers/ray.jsx +410 -0
  484. package/src/Viewer/renderers/ref.jsx +149 -0
  485. package/src/Viewer/renderers/regionBetweenCurveXAxis.jsx +182 -0
  486. package/src/Viewer/renderers/renderDoenetML.jsx +56 -0
  487. package/src/Viewer/renderers/row.jsx +31 -0
  488. package/src/Viewer/renderers/rq.jsx +12 -0
  489. package/src/Viewer/renderers/rsq.jsx +12 -0
  490. package/src/Viewer/renderers/section.jsx +427 -0
  491. package/src/Viewer/renderers/sideBySide.jsx +80 -0
  492. package/src/Viewer/renderers/slider.jsx +800 -0
  493. package/src/Viewer/renderers/solution.jsx +134 -0
  494. package/src/Viewer/renderers/spreadsheet.jsx +83 -0
  495. package/src/Viewer/renderers/sq.jsx +17 -0
  496. package/src/Viewer/renderers/styles/global.css +14 -0
  497. package/src/Viewer/renderers/subsetOfRealsInput.jsx +392 -0
  498. package/src/Viewer/renderers/summaryStatistics.jsx +83 -0
  499. package/src/Viewer/renderers/table.jsx +78 -0
  500. package/src/Viewer/renderers/tabular.jsx +58 -0
  501. package/src/Viewer/renderers/tag.jsx +26 -0
  502. package/src/Viewer/renderers/text.jsx +439 -0
  503. package/src/Viewer/renderers/textInput.jsx +774 -0
  504. package/src/Viewer/renderers/textList.jsx +30 -0
  505. package/src/Viewer/renderers/triggerSet.jsx +52 -0
  506. package/src/Viewer/renderers/updateValue.jsx +30 -0
  507. package/src/Viewer/renderers/utils/css.js +13 -0
  508. package/src/Viewer/renderers/utils/graph.js +159 -0
  509. package/src/Viewer/renderers/utils/offGraphIndicators.js +91 -0
  510. package/src/Viewer/renderers/vector.jsx +678 -0
  511. package/src/Viewer/renderers/video.jsx +494 -0
  512. package/src/Viewer/useDoenetRenderer.jsx +128 -0
  513. package/src/main.jsx +16 -0
  514. package/src/media/fonts/files/open-sans-v18-latin-700.woff +0 -0
  515. package/src/media/fonts/files/open-sans-v18-latin-700.woff2 +0 -0
  516. package/src/media/fonts/files/open-sans-v18-latin-700italic.woff +0 -0
  517. package/src/media/fonts/files/open-sans-v18-latin-700italic.woff2 +0 -0
  518. package/src/media/fonts/files/open-sans-v18-latin-italic.woff +0 -0
  519. package/src/media/fonts/files/open-sans-v18-latin-italic.woff2 +0 -0
  520. package/src/media/fonts/files/open-sans-v18-latin-light-italic.woff +0 -0
  521. package/src/media/fonts/files/open-sans-v18-latin-light-italic.woff2 +0 -0
  522. package/src/media/fonts/files/open-sans-v18-latin-light.woff +0 -0
  523. package/src/media/fonts/files/open-sans-v18-latin-light.woff2 +0 -0
  524. package/src/media/fonts/files/open-sans-v18-latin-regular.woff +0 -0
  525. package/src/media/fonts/files/open-sans-v18-latin-regular.woff2 +0 -0
  526. package/src/test/testCode.doenet +26 -0
  527. package/src/test/testViewer.jsx +158 -0
  528. package/src/uiComponents/ActionButton.jsx +157 -0
  529. package/src/uiComponents/ActionButtonGroup.jsx +93 -0
  530. package/src/uiComponents/Button.jsx +160 -0
  531. package/src/uiComponents/ButtonGroup.jsx +56 -0
  532. package/src/uiComponents/ToggleButton.jsx +194 -0
  533. package/src/uiComponents/ToggleButtonGroup.jsx +77 -0
  534. package/src/utils/activityUtils.js +713 -0
  535. package/src/utils/array.js +17 -0
  536. package/src/utils/cid.js +34 -0
  537. package/src/utils/componentInfoObjects.js +89 -0
  538. package/src/utils/deepFunctions.js +165 -0
  539. package/src/utils/enumeration.js +226 -0
  540. package/src/utils/math.js +624 -0
  541. package/src/utils/naming.js +44 -0
  542. package/src/utils/retrieveTextFile.js +156 -0
  543. package/src/utils/returnAllPossibleVariants.js +81 -0
  544. package/src/utils/sequence.js +715 -0
  545. package/src/utils/serialize.js +29 -0
  546. package/src/utils/serializedStateProcessing.js +2587 -0
  547. package/src/utils/subset-of-reals.js +783 -0
  548. package/src/utils/url.js +19 -0
  549. package/vite.config.js +14 -0
@@ -0,0 +1,4073 @@
1
+ import { cesc, cesc2 } from "../../../../src/utils/url";
2
+
3
+ describe("MathList Tag Tests", function () {
4
+ beforeEach(() => {
5
+ cy.clearIndexedDB();
6
+ cy.visit("/src/Tools/cypressTest/");
7
+ });
8
+
9
+ it("mathlist from string", () => {
10
+ cy.window().then(async (win) => {
11
+ win.postMessage(
12
+ {
13
+ doenetML: `
14
+ <text>a</text>
15
+ <mathlist>a 1+1 </mathlist>
16
+ `,
17
+ },
18
+ "*",
19
+ );
20
+ });
21
+
22
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
23
+
24
+ cy.window().then(async (win) => {
25
+ let stateVariables = await win.returnAllStateVariables1();
26
+ let child1Name =
27
+ stateVariables["/_mathlist1"].activeChildren[0].componentName;
28
+ let child1Anchor = cesc2("#" + child1Name);
29
+ let child2Name =
30
+ stateVariables["/_mathlist1"].activeChildren[1].componentName;
31
+ let child2Anchor = cesc2("#" + child2Name);
32
+
33
+ cy.log("Test value displayed in browser");
34
+ cy.get(child1Anchor)
35
+ .find(".mjx-mrow")
36
+ .eq(0)
37
+ .invoke("text")
38
+ .then((text) => {
39
+ expect(text.trim()).equal("a");
40
+ });
41
+ cy.get(child2Anchor)
42
+ .find(".mjx-mrow")
43
+ .eq(0)
44
+ .invoke("text")
45
+ .then((text) => {
46
+ expect(text.trim()).equal("1+1");
47
+ });
48
+
49
+ cy.log("Test internal values are set to the correct values");
50
+ cy.window().then(async (win) => {
51
+ let stateVariables = await win.returnAllStateVariables1();
52
+ expect(
53
+ stateVariables[
54
+ stateVariables["/_mathlist1"].activeChildren[0].componentName
55
+ ].stateValues.value,
56
+ ).eq("a");
57
+ expect(
58
+ stateVariables[
59
+ stateVariables["/_mathlist1"].activeChildren[1].componentName
60
+ ].stateValues.value,
61
+ ).eqls(["+", 1, 1]);
62
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("a");
63
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eqls([
64
+ "+",
65
+ 1,
66
+ 1,
67
+ ]);
68
+ });
69
+ });
70
+ });
71
+
72
+ it("mathlist with error in string", () => {
73
+ cy.window().then(async (win) => {
74
+ win.postMessage(
75
+ {
76
+ doenetML: `
77
+ <text>a</text>
78
+ <mathlist>a @ 1+1 </mathlist>
79
+ `,
80
+ },
81
+ "*",
82
+ );
83
+ });
84
+
85
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
86
+
87
+ cy.window().then(async (win) => {
88
+ let stateVariables = await win.returnAllStateVariables1();
89
+ let child1Name =
90
+ stateVariables["/_mathlist1"].activeChildren[0].componentName;
91
+ let child1Anchor = cesc2("#" + child1Name);
92
+ let child2Name =
93
+ stateVariables["/_mathlist1"].activeChildren[1].componentName;
94
+ let child2Anchor = cesc2("#" + child2Name);
95
+ let child3Name =
96
+ stateVariables["/_mathlist1"].activeChildren[2].componentName;
97
+ let child3Anchor = cesc2("#" + child3Name);
98
+
99
+ cy.log("Test value displayed in browser");
100
+ cy.get(child1Anchor)
101
+ .find(".mjx-mrow")
102
+ .eq(0)
103
+ .invoke("text")
104
+ .then((text) => {
105
+ expect(text.trim()).equal("a");
106
+ });
107
+ cy.get(child2Anchor)
108
+ .find(".mjx-mrow")
109
+ .eq(0)
110
+ .invoke("text")
111
+ .then((text) => {
112
+ expect(text.trim()).equal("_");
113
+ });
114
+ cy.get(child3Anchor)
115
+ .find(".mjx-mrow")
116
+ .eq(0)
117
+ .invoke("text")
118
+ .then((text) => {
119
+ expect(text.trim()).equal("1+1");
120
+ });
121
+ cy.log("Test internal values are set to the correct values");
122
+ cy.window().then(async (win) => {
123
+ let stateVariables = await win.returnAllStateVariables1();
124
+ expect(
125
+ stateVariables[
126
+ stateVariables["/_mathlist1"].activeChildren[0].componentName
127
+ ].stateValues.value,
128
+ ).eq("a");
129
+ expect(
130
+ stateVariables[
131
+ stateVariables["/_mathlist1"].activeChildren[1].componentName
132
+ ].stateValues.value,
133
+ ).eq("_");
134
+ expect(
135
+ stateVariables[
136
+ stateVariables["/_mathlist1"].activeChildren[2].componentName
137
+ ].stateValues.value,
138
+ ).eqls(["+", 1, 1]);
139
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("a");
140
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq("_");
141
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eqls([
142
+ "+",
143
+ 1,
144
+ 1,
145
+ ]);
146
+ });
147
+ });
148
+ });
149
+
150
+ it("mathlist in attribute containing math and number macros", () => {
151
+ cy.window().then(async (win) => {
152
+ win.postMessage(
153
+ {
154
+ doenetML: `
155
+ <text>a</text>
156
+ <p><math name="m1">x</math>
157
+ <math name="m2">3y</math>
158
+ <number name="n1">7</number>
159
+ <number name="n2">11</number></p>
160
+ <p><point xs="$m1 $m2/$n1 $n1 $n1-$n2 $n1 -$n2 $n1 - $n2 $n1$m1$m2 ($n1+$m1)/($n2$m2)" /></p>
161
+ <p><aslist><copy prop="xs" target="_point1" assignNames="x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11" /></aslist></p>
162
+ `,
163
+ },
164
+ "*",
165
+ );
166
+ });
167
+
168
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
169
+
170
+ cy.log("Test value displayed in browser");
171
+ cy.get(cesc("#\\/x1"))
172
+ .find(".mjx-mrow")
173
+ .eq(0)
174
+ .invoke("text")
175
+ .then((text) => {
176
+ expect(text.trim()).equal("x");
177
+ });
178
+ cy.get(cesc("#\\/x2"))
179
+ .find(".mjx-mrow")
180
+ .eq(0)
181
+ .invoke("text")
182
+ .then((text) => {
183
+ expect(text.trim()).equal("3y7");
184
+ });
185
+ cy.get(cesc("#\\/x3"))
186
+ .find(".mjx-mrow")
187
+ .eq(0)
188
+ .invoke("text")
189
+ .then((text) => {
190
+ expect(text.trim()).equal("7");
191
+ });
192
+ cy.get(cesc("#\\/x4"))
193
+ .find(".mjx-mrow")
194
+ .eq(0)
195
+ .invoke("text")
196
+ .then((text) => {
197
+ expect(text.trim()).equal("−4");
198
+ });
199
+ cy.get(cesc("#\\/x5"))
200
+ .find(".mjx-mrow")
201
+ .eq(0)
202
+ .invoke("text")
203
+ .then((text) => {
204
+ expect(text.trim()).equal("7");
205
+ });
206
+ cy.get(cesc("#\\/x6"))
207
+ .find(".mjx-mrow")
208
+ .eq(0)
209
+ .invoke("text")
210
+ .then((text) => {
211
+ expect(text.trim()).equal("−11");
212
+ });
213
+ cy.get(cesc("#\\/x7"))
214
+ .find(".mjx-mrow")
215
+ .eq(0)
216
+ .invoke("text")
217
+ .then((text) => {
218
+ expect(text.trim()).equal("7");
219
+ });
220
+ cy.get(cesc("#\\/x8"))
221
+ .find(".mjx-mrow")
222
+ .eq(0)
223
+ .invoke("text")
224
+ .then((text) => {
225
+ expect(text.trim()).equal("−");
226
+ });
227
+ cy.get(cesc("#\\/x9"))
228
+ .find(".mjx-mrow")
229
+ .eq(0)
230
+ .invoke("text")
231
+ .then((text) => {
232
+ expect(text.trim()).equal("11");
233
+ });
234
+ cy.get(cesc("#\\/x10"))
235
+ .find(".mjx-mrow")
236
+ .eq(0)
237
+ .invoke("text")
238
+ .then((text) => {
239
+ expect(text.trim()).equal("21xy");
240
+ });
241
+ cy.get(cesc("#\\/x11"))
242
+ .find(".mjx-mrow")
243
+ .eq(0)
244
+ .invoke("text")
245
+ .then((text) => {
246
+ expect(text.trim()).equal("x+733y");
247
+ });
248
+ cy.log("Test internal values are set to the correct values");
249
+ cy.window().then(async (win) => {
250
+ let stateVariables = await win.returnAllStateVariables1();
251
+ let xs = stateVariables["/_point1"].stateValues.xs;
252
+
253
+ expect(xs.length).eq(11);
254
+ expect(xs[0]).eq("x");
255
+ expect(stateVariables["/x1"].stateValues.value).eq("x");
256
+ expect(xs[1]).eqls(["/", ["*", 3, "y"], 7]);
257
+ expect(stateVariables["/x2"].stateValues.value).eqls([
258
+ "/",
259
+ ["*", 3, "y"],
260
+ 7,
261
+ ]);
262
+ expect(xs[2]).eqls(7);
263
+ expect(stateVariables["/x3"].stateValues.value).eqls(7);
264
+ expect(xs[3]).eqls(-4);
265
+ expect(stateVariables["/x4"].stateValues.value).eqls(-4);
266
+ expect(xs[4]).eqls(7);
267
+ expect(stateVariables["/x5"].stateValues.value).eqls(7);
268
+ expect(xs[5]).eqls(-11);
269
+ expect(stateVariables["/x6"].stateValues.value).eqls(-11);
270
+ expect(xs[6]).eqls(7);
271
+ expect(stateVariables["/x7"].stateValues.value).eqls(7);
272
+ expect(xs[7]).eqls("-");
273
+ expect(stateVariables["/x8"].stateValues.value).eqls("-");
274
+ expect(xs[8]).eqls(11);
275
+ expect(stateVariables["/x9"].stateValues.value).eqls(11);
276
+ expect(xs[9]).eqls(["*", 21, "x", "y"]);
277
+ expect(stateVariables["/x10"].stateValues.value).eqls([
278
+ "*",
279
+ 21,
280
+ "x",
281
+ "y",
282
+ ]);
283
+ expect(xs[10]).eqls(["/", ["+", "x", 7], ["*", 33, "y"]]);
284
+ expect(stateVariables["/x11"].stateValues.value).eqls([
285
+ "/",
286
+ ["+", "x", 7],
287
+ ["*", 33, "y"],
288
+ ]);
289
+ });
290
+ });
291
+
292
+ it("mathlist with math children", () => {
293
+ cy.window().then(async (win) => {
294
+ win.postMessage(
295
+ {
296
+ doenetML: `
297
+ <text>a</text>
298
+ <mathlist>
299
+ <math>a</math>
300
+ <math>1+1</math>
301
+ </mathlist>
302
+
303
+ <mathlist>
304
+ <math>a</math><math>1+1</math>
305
+ </mathlist>
306
+ `,
307
+ },
308
+ "*",
309
+ );
310
+ });
311
+
312
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
313
+
314
+ cy.log("Test value displayed in browser");
315
+ cy.window().then(async (win) => {
316
+ let stateVariables = await win.returnAllStateVariables1();
317
+
318
+ cy.get(cesc("#\\/_math1"))
319
+ .find(".mjx-mrow")
320
+ .eq(0)
321
+ .invoke("text")
322
+ .then((text) => {
323
+ expect(text.trim()).equal("a");
324
+ });
325
+ cy.get(cesc("#\\/_math2"))
326
+ .find(".mjx-mrow")
327
+ .eq(0)
328
+ .invoke("text")
329
+ .then((text) => {
330
+ expect(text.trim()).equal("1+1");
331
+ });
332
+ cy.get(cesc("#\\/_math3"))
333
+ .find(".mjx-mrow")
334
+ .eq(0)
335
+ .invoke("text")
336
+ .then((text) => {
337
+ expect(text.trim()).equal("a");
338
+ });
339
+ cy.get(cesc("#\\/_math4"))
340
+ .find(".mjx-mrow")
341
+ .eq(0)
342
+ .invoke("text")
343
+ .then((text) => {
344
+ expect(text.trim()).equal("1+1");
345
+ });
346
+ cy.log("Test internal values are set to the correct values");
347
+ cy.window().then(async (win) => {
348
+ let stateVariables = await win.returnAllStateVariables1();
349
+ expect(stateVariables["/_mathlist1"].activeChildren.length).eq(2);
350
+ expect(
351
+ stateVariables[
352
+ stateVariables["/_mathlist1"].activeChildren[0].componentName
353
+ ].stateValues.value,
354
+ ).eq("a");
355
+ expect(
356
+ stateVariables[
357
+ stateVariables["/_mathlist1"].activeChildren[1].componentName
358
+ ].stateValues.value,
359
+ ).eqls(["+", 1, 1]);
360
+ expect(stateVariables["/_mathlist1"].stateValues.maths.length).eq(2);
361
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("a");
362
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eqls([
363
+ "+",
364
+ 1,
365
+ 1,
366
+ ]);
367
+ expect(stateVariables["/_mathlist2"].activeChildren.length).eq(2);
368
+ expect(
369
+ stateVariables[
370
+ stateVariables["/_mathlist2"].activeChildren[0].componentName
371
+ ].stateValues.value,
372
+ ).eq("a");
373
+ expect(
374
+ stateVariables[
375
+ stateVariables["/_mathlist2"].activeChildren[1].componentName
376
+ ].stateValues.value,
377
+ ).eqls(["+", 1, 1]);
378
+ expect(stateVariables["/_mathlist2"].stateValues.maths.length).eq(2);
379
+ expect(stateVariables["/_mathlist2"].stateValues.maths[0]).eq("a");
380
+ expect(stateVariables["/_mathlist2"].stateValues.maths[1]).eqls([
381
+ "+",
382
+ 1,
383
+ 1,
384
+ ]);
385
+ });
386
+ });
387
+ });
388
+
389
+ it("mathlist with math and string children", () => {
390
+ cy.window().then(async (win) => {
391
+ win.postMessage(
392
+ {
393
+ doenetML: `
394
+ <text>a</text>
395
+ <mathlist>
396
+ <math>a</math> q <math>1+1</math>h
397
+ </mathlist>
398
+ `,
399
+ },
400
+ "*",
401
+ );
402
+ });
403
+
404
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
405
+
406
+ cy.window().then(async (win) => {
407
+ let stateVariables = await win.returnAllStateVariables1();
408
+ let matha = stateVariables["/_mathlist1"].activeChildren[1];
409
+ let mathaAnchor = cesc2("#" + matha.componentName);
410
+ let mathb = stateVariables["/_mathlist1"].activeChildren[3];
411
+ let mathbAnchor = cesc2("#" + mathb.componentName);
412
+
413
+ cy.log("Test value displayed in browser");
414
+ cy.get(cesc("#\\/_math1"))
415
+ .find(".mjx-mrow")
416
+ .eq(0)
417
+ .invoke("text")
418
+ .then((text) => {
419
+ expect(text.trim()).equal("a");
420
+ });
421
+ cy.get(mathaAnchor)
422
+ .find(".mjx-mrow")
423
+ .eq(0)
424
+ .invoke("text")
425
+ .then((text) => {
426
+ expect(text.trim()).equal("q");
427
+ });
428
+ cy.get(cesc("#\\/_math2"))
429
+ .find(".mjx-mrow")
430
+ .eq(0)
431
+ .invoke("text")
432
+ .then((text) => {
433
+ expect(text.trim()).equal("1+1");
434
+ });
435
+ cy.get(mathbAnchor)
436
+ .find(".mjx-mrow")
437
+ .eq(0)
438
+ .invoke("text")
439
+ .then((text) => {
440
+ expect(text.trim()).equal("h");
441
+ });
442
+ cy.log("Test internal values are set to the correct values");
443
+ cy.window().then(async (win) => {
444
+ expect(
445
+ stateVariables[
446
+ stateVariables["/_mathlist1"].activeChildren[0].componentName
447
+ ].stateValues.value,
448
+ ).eq("a");
449
+ expect(
450
+ stateVariables[
451
+ stateVariables["/_mathlist1"].activeChildren[1].componentName
452
+ ].stateValues.value,
453
+ ).eq("q");
454
+ expect(
455
+ stateVariables[
456
+ stateVariables["/_mathlist1"].activeChildren[2].componentName
457
+ ].stateValues.value,
458
+ ).eqls(["+", 1, 1]);
459
+ expect(
460
+ stateVariables[
461
+ stateVariables["/_mathlist1"].activeChildren[3].componentName
462
+ ].stateValues.value,
463
+ ).eq("h");
464
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("a");
465
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq("q");
466
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eqls([
467
+ "+",
468
+ 1,
469
+ 1,
470
+ ]);
471
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq("h");
472
+ });
473
+ });
474
+ });
475
+
476
+ it("mathlist with math and number children", () => {
477
+ cy.window().then(async (win) => {
478
+ win.postMessage(
479
+ {
480
+ doenetML: `
481
+ <text>a</text>
482
+ <mathlist>
483
+ <math>a</math>
484
+ <number>1+1</number>
485
+ </mathlist>
486
+ <mathlist>
487
+ <math>a</math><number>1+1</number>
488
+ </mathlist>
489
+ `,
490
+ },
491
+ "*",
492
+ );
493
+ });
494
+
495
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
496
+
497
+ cy.log("Test value displayed in browser");
498
+ cy.get(cesc("#\\/_math1"))
499
+ .find(".mjx-mrow")
500
+ .eq(0)
501
+ .invoke("text")
502
+ .then((text) => {
503
+ expect(text.trim()).equal("a");
504
+ });
505
+ cy.get(cesc("#\\/_number1"))
506
+ .find(".mjx-mrow")
507
+ .eq(0)
508
+ .invoke("text")
509
+ .then((text) => {
510
+ expect(text.trim()).equal("2");
511
+ });
512
+ cy.get(cesc("#\\/_math2"))
513
+ .find(".mjx-mrow")
514
+ .eq(0)
515
+ .invoke("text")
516
+ .then((text) => {
517
+ expect(text.trim()).equal("a");
518
+ });
519
+ cy.get(cesc("#\\/_number2"))
520
+ .find(".mjx-mrow")
521
+ .eq(0)
522
+ .invoke("text")
523
+ .then((text) => {
524
+ expect(text.trim()).equal("2");
525
+ });
526
+
527
+ cy.log("Test internal values are set to the correct values");
528
+ cy.window().then(async (win) => {
529
+ let stateVariables = await win.returnAllStateVariables1();
530
+ expect(stateVariables["/_mathlist1"].activeChildren.length).eq(2);
531
+ expect(
532
+ stateVariables[
533
+ stateVariables["/_mathlist1"].activeChildren[0].componentName
534
+ ].stateValues.value,
535
+ ).eq("a");
536
+ expect(
537
+ stateVariables[
538
+ stateVariables["/_mathlist1"].activeChildren[1].componentName
539
+ ].stateValues.number,
540
+ ).eq(2);
541
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("a");
542
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq(2);
543
+ expect(stateVariables["/_mathlist2"].activeChildren.length).eq(2);
544
+ expect(
545
+ stateVariables[
546
+ stateVariables["/_mathlist2"].activeChildren[0].componentName
547
+ ].stateValues.value,
548
+ ).eq("a");
549
+ expect(
550
+ stateVariables[
551
+ stateVariables["/_mathlist2"].activeChildren[1].componentName
552
+ ].stateValues.number,
553
+ ).eq(2);
554
+ expect(stateVariables["/_mathlist2"].stateValues.maths[0]).eq("a");
555
+ expect(stateVariables["/_mathlist2"].stateValues.maths[1]).eq(2);
556
+ });
557
+ });
558
+
559
+ it("mathlist with mathlist children, test inverse", () => {
560
+ cy.window().then(async (win) => {
561
+ win.postMessage(
562
+ {
563
+ doenetML: `
564
+ <text>a</text>
565
+ <mathlist>
566
+ <math>a</math>
567
+ <mathlist>q r</mathlist>
568
+ <math>h</math>
569
+ <mathlist>
570
+ <mathlist>
571
+ <math>b</math>
572
+ <mathlist>u v</mathlist>
573
+ </mathlist>
574
+ <mathlist>i j</mathlist>
575
+ </mathlist>
576
+ </mathlist>
577
+
578
+ <mathinput bindValueTo="$(_mathlist1.math1)" />
579
+ <mathinput bindValueTo="$(_mathlist1.math2)" />
580
+ <mathinput bindValueTo="$(_mathlist1.math3)" />
581
+ <mathinput bindValueTo="$(_mathlist1.math4)" />
582
+ <mathinput bindValueTo="$(_mathlist1.math5)" />
583
+ <mathinput bindValueTo="$(_mathlist1.math6)" />
584
+ <mathinput bindValueTo="$(_mathlist1.math7)" />
585
+ <mathinput bindValueTo="$(_mathlist1.math8)" />
586
+ <mathinput bindValueTo="$(_mathlist1.math9)" />
587
+
588
+ `,
589
+ },
590
+ "*",
591
+ );
592
+ });
593
+
594
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
595
+
596
+ cy.window().then(async (win) => {
597
+ let stateVariables = await win.returnAllStateVariables1();
598
+ let child1Name =
599
+ stateVariables["/_mathlist2"].activeChildren[0].componentName;
600
+ let child1Anchor = cesc2("#" + child1Name);
601
+ let child2Name =
602
+ stateVariables["/_mathlist2"].activeChildren[1].componentName;
603
+ let child2Anchor = cesc2("#" + child2Name);
604
+ let child5Name =
605
+ stateVariables["/_mathlist5"].activeChildren[0].componentName;
606
+ let child5Anchor = cesc2("#" + child5Name);
607
+ let child6Name =
608
+ stateVariables["/_mathlist5"].activeChildren[1].componentName;
609
+ let child6Anchor = cesc2("#" + child6Name);
610
+ let child7Name =
611
+ stateVariables["/_mathlist6"].activeChildren[0].componentName;
612
+ let child7Anchor = cesc2("#" + child7Name);
613
+ let child8Name =
614
+ stateVariables["/_mathlist6"].activeChildren[1].componentName;
615
+ let child8Anchor = cesc2("#" + child8Name);
616
+
617
+ cy.log("Test value displayed in browser");
618
+ cy.get(cesc("#\\/_math1"))
619
+ .find(".mjx-mrow")
620
+ .eq(0)
621
+ .invoke("text")
622
+ .then((text) => {
623
+ expect(text.trim()).equal("a");
624
+ });
625
+ cy.get(child1Anchor)
626
+ .find(".mjx-mrow")
627
+ .eq(0)
628
+ .invoke("text")
629
+ .then((text) => {
630
+ expect(text.trim()).equal("q");
631
+ });
632
+ cy.get(child2Anchor)
633
+ .find(".mjx-mrow")
634
+ .eq(0)
635
+ .invoke("text")
636
+ .then((text) => {
637
+ expect(text.trim()).equal("r");
638
+ });
639
+ cy.get(cesc("#\\/_math2"))
640
+ .find(".mjx-mrow")
641
+ .eq(0)
642
+ .invoke("text")
643
+ .then((text) => {
644
+ expect(text.trim()).equal("h");
645
+ });
646
+ cy.get(cesc("#\\/_math3"))
647
+ .find(".mjx-mrow")
648
+ .eq(0)
649
+ .invoke("text")
650
+ .then((text) => {
651
+ expect(text.trim()).equal("b");
652
+ });
653
+ cy.get(child5Anchor)
654
+ .find(".mjx-mrow")
655
+ .eq(0)
656
+ .invoke("text")
657
+ .then((text) => {
658
+ expect(text.trim()).equal("u");
659
+ });
660
+ cy.get(child6Anchor)
661
+ .find(".mjx-mrow")
662
+ .eq(0)
663
+ .invoke("text")
664
+ .then((text) => {
665
+ expect(text.trim()).equal("v");
666
+ });
667
+ cy.get(child7Anchor)
668
+ .find(".mjx-mrow")
669
+ .eq(0)
670
+ .invoke("text")
671
+ .then((text) => {
672
+ expect(text.trim()).equal("i");
673
+ });
674
+ cy.get(child8Anchor)
675
+ .find(".mjx-mrow")
676
+ .eq(0)
677
+ .invoke("text")
678
+ .then((text) => {
679
+ expect(text.trim()).equal("j");
680
+ });
681
+
682
+ cy.log("Test internal values are set to the correct values");
683
+ cy.window().then(async (win) => {
684
+ let stateVariables = await win.returnAllStateVariables1();
685
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("a");
686
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq("q");
687
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eq("r");
688
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq("h");
689
+ expect(stateVariables["/_mathlist1"].stateValues.maths[4]).eq("b");
690
+ expect(stateVariables["/_mathlist1"].stateValues.maths[5]).eq("u");
691
+ expect(stateVariables["/_mathlist1"].stateValues.maths[6]).eq("v");
692
+ expect(stateVariables["/_mathlist1"].stateValues.maths[7]).eq("i");
693
+ expect(stateVariables["/_mathlist1"].stateValues.maths[8]).eq("j");
694
+ expect(stateVariables["/_mathlist2"].stateValues.maths[0]).eq("q");
695
+ expect(stateVariables["/_mathlist2"].stateValues.maths[1]).eq("r");
696
+ expect(stateVariables["/_mathlist3"].stateValues.maths[0]).eq("b");
697
+ expect(stateVariables["/_mathlist3"].stateValues.maths[1]).eq("u");
698
+ expect(stateVariables["/_mathlist3"].stateValues.maths[2]).eq("v");
699
+ expect(stateVariables["/_mathlist3"].stateValues.maths[3]).eq("i");
700
+ expect(stateVariables["/_mathlist3"].stateValues.maths[4]).eq("j");
701
+ expect(stateVariables["/_mathlist4"].stateValues.maths[0]).eq("b");
702
+ expect(stateVariables["/_mathlist4"].stateValues.maths[1]).eq("u");
703
+ expect(stateVariables["/_mathlist4"].stateValues.maths[2]).eq("v");
704
+ expect(stateVariables["/_mathlist5"].stateValues.maths[0]).eq("u");
705
+ expect(stateVariables["/_mathlist5"].stateValues.maths[1]).eq("v");
706
+ expect(stateVariables["/_mathlist6"].stateValues.maths[0]).eq("i");
707
+ expect(stateVariables["/_mathlist6"].stateValues.maths[1]).eq("j");
708
+ });
709
+
710
+ cy.log("change values");
711
+
712
+ cy.get(cesc("#\\/_mathinput1") + " textarea").type(
713
+ "{end}{backspace}1{enter}",
714
+ { force: true },
715
+ );
716
+ cy.get(cesc("#\\/_mathinput2") + " textarea").type(
717
+ "{end}{backspace}2{enter}",
718
+ { force: true },
719
+ );
720
+ cy.get(cesc("#\\/_mathinput3") + " textarea").type(
721
+ "{end}{backspace}3{enter}",
722
+ { force: true },
723
+ );
724
+ cy.get(cesc("#\\/_mathinput4") + " textarea").type(
725
+ "{end}{backspace}4{enter}",
726
+ { force: true },
727
+ );
728
+ cy.get(cesc("#\\/_mathinput5") + " textarea").type(
729
+ "{end}{backspace}5{enter}",
730
+ { force: true },
731
+ );
732
+ cy.get(cesc("#\\/_mathinput6") + " textarea").type(
733
+ "{end}{backspace}6{enter}",
734
+ { force: true },
735
+ );
736
+ cy.get(cesc("#\\/_mathinput7") + " textarea").type(
737
+ "{end}{backspace}7{enter}",
738
+ { force: true },
739
+ );
740
+ cy.get(cesc("#\\/_mathinput8") + " textarea").type(
741
+ "{end}{backspace}8{enter}",
742
+ { force: true },
743
+ );
744
+ cy.get(cesc("#\\/_mathinput9") + " textarea").type(
745
+ "{end}{backspace}9{enter}",
746
+ { force: true },
747
+ );
748
+
749
+ cy.get(child8Anchor).should("contain.text", "9");
750
+
751
+ cy.log("Test value displayed in browser");
752
+ cy.get(cesc("#\\/_math1"))
753
+ .find(".mjx-mrow")
754
+ .eq(0)
755
+ .invoke("text")
756
+ .then((text) => {
757
+ expect(text.trim()).equal("1");
758
+ });
759
+ cy.get(child1Anchor)
760
+ .find(".mjx-mrow")
761
+ .eq(0)
762
+ .invoke("text")
763
+ .then((text) => {
764
+ expect(text.trim()).equal("2");
765
+ });
766
+ cy.get(child2Anchor)
767
+ .find(".mjx-mrow")
768
+ .eq(0)
769
+ .invoke("text")
770
+ .then((text) => {
771
+ expect(text.trim()).equal("3");
772
+ });
773
+ cy.get(cesc("#\\/_math2"))
774
+ .find(".mjx-mrow")
775
+ .eq(0)
776
+ .invoke("text")
777
+ .then((text) => {
778
+ expect(text.trim()).equal("4");
779
+ });
780
+ cy.get(cesc("#\\/_math3"))
781
+ .find(".mjx-mrow")
782
+ .eq(0)
783
+ .invoke("text")
784
+ .then((text) => {
785
+ expect(text.trim()).equal("5");
786
+ });
787
+ cy.get(child5Anchor)
788
+ .find(".mjx-mrow")
789
+ .eq(0)
790
+ .invoke("text")
791
+ .then((text) => {
792
+ expect(text.trim()).equal("6");
793
+ });
794
+ cy.get(child6Anchor)
795
+ .find(".mjx-mrow")
796
+ .eq(0)
797
+ .invoke("text")
798
+ .then((text) => {
799
+ expect(text.trim()).equal("7");
800
+ });
801
+ cy.get(child7Anchor)
802
+ .find(".mjx-mrow")
803
+ .eq(0)
804
+ .invoke("text")
805
+ .then((text) => {
806
+ expect(text.trim()).equal("8");
807
+ });
808
+ cy.get(child8Anchor)
809
+ .find(".mjx-mrow")
810
+ .eq(0)
811
+ .invoke("text")
812
+ .then((text) => {
813
+ expect(text.trim()).equal("9");
814
+ });
815
+
816
+ cy.log("Test internal values are set to the correct values");
817
+ cy.window().then(async (win) => {
818
+ let stateVariables = await win.returnAllStateVariables1();
819
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq(1);
820
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq(2);
821
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eq(3);
822
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq(4);
823
+ expect(stateVariables["/_mathlist1"].stateValues.maths[4]).eq(5);
824
+ expect(stateVariables["/_mathlist1"].stateValues.maths[5]).eq(6);
825
+ expect(stateVariables["/_mathlist1"].stateValues.maths[6]).eq(7);
826
+ expect(stateVariables["/_mathlist1"].stateValues.maths[7]).eq(8);
827
+ expect(stateVariables["/_mathlist1"].stateValues.maths[8]).eq(9);
828
+ expect(stateVariables["/_mathlist2"].stateValues.maths[0]).eq(2);
829
+ expect(stateVariables["/_mathlist2"].stateValues.maths[1]).eq(3);
830
+ expect(stateVariables["/_mathlist3"].stateValues.maths[0]).eq(5);
831
+ expect(stateVariables["/_mathlist3"].stateValues.maths[1]).eq(6);
832
+ expect(stateVariables["/_mathlist3"].stateValues.maths[2]).eq(7);
833
+ expect(stateVariables["/_mathlist3"].stateValues.maths[3]).eq(8);
834
+ expect(stateVariables["/_mathlist3"].stateValues.maths[4]).eq(9);
835
+ expect(stateVariables["/_mathlist4"].stateValues.maths[0]).eq(5);
836
+ expect(stateVariables["/_mathlist4"].stateValues.maths[1]).eq(6);
837
+ expect(stateVariables["/_mathlist4"].stateValues.maths[2]).eq(7);
838
+ expect(stateVariables["/_mathlist5"].stateValues.maths[0]).eq(6);
839
+ expect(stateVariables["/_mathlist5"].stateValues.maths[1]).eq(7);
840
+ expect(stateVariables["/_mathlist6"].stateValues.maths[0]).eq(8);
841
+ expect(stateVariables["/_mathlist6"].stateValues.maths[1]).eq(9);
842
+ });
843
+ });
844
+ });
845
+
846
+ it("mathlist with mathlist children and sugar, test inverse", () => {
847
+ cy.window().then(async (win) => {
848
+ win.postMessage(
849
+ {
850
+ doenetML: `
851
+ <text>a</text>
852
+ <mathlist>
853
+ a
854
+ <mathlist>q r</mathlist>
855
+ <math>h</math>
856
+ <mathlist>
857
+ <mathlist>
858
+ b
859
+ <mathlist>u v</mathlist>
860
+ </mathlist>
861
+ <mathlist>i j</mathlist>
862
+ </mathlist>
863
+ </mathlist>
864
+
865
+ <mathinput bindValueTo="$(_mathlist1.math1)" />
866
+ <mathinput bindValueTo="$(_mathlist1.math2)" />
867
+ <mathinput bindValueTo="$(_mathlist1.math3)" />
868
+ <mathinput bindValueTo="$(_mathlist1.math4)" />
869
+ <mathinput bindValueTo="$(_mathlist1.math5)" />
870
+ <mathinput bindValueTo="$(_mathlist1.math6)" />
871
+ <mathinput bindValueTo="$(_mathlist1.math7)" />
872
+ <mathinput bindValueTo="$(_mathlist1.math8)" />
873
+ <mathinput bindValueTo="$(_mathlist1.math9)" />
874
+
875
+ `,
876
+ },
877
+ "*",
878
+ );
879
+ });
880
+
881
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
882
+
883
+ cy.window().then(async (win) => {
884
+ let stateVariables = await win.returnAllStateVariables1();
885
+ let child0Name =
886
+ stateVariables["/_mathlist1"].activeChildren[0].componentName;
887
+ let child0Anchor = cesc2("#" + child0Name);
888
+ let child1Name =
889
+ stateVariables["/_mathlist2"].activeChildren[0].componentName;
890
+ let child1Anchor = cesc2("#" + child1Name);
891
+ let child2Name =
892
+ stateVariables["/_mathlist2"].activeChildren[1].componentName;
893
+ let child2Anchor = cesc2("#" + child2Name);
894
+ let child4Name =
895
+ stateVariables["/_mathlist4"].activeChildren[0].componentName;
896
+ let child4Anchor = cesc2("#" + child4Name);
897
+ let child5Name =
898
+ stateVariables["/_mathlist5"].activeChildren[0].componentName;
899
+ let child5Anchor = cesc2("#" + child5Name);
900
+ let child6Name =
901
+ stateVariables["/_mathlist5"].activeChildren[1].componentName;
902
+ let child6Anchor = cesc2("#" + child6Name);
903
+ let child7Name =
904
+ stateVariables["/_mathlist6"].activeChildren[0].componentName;
905
+ let child7Anchor = cesc2("#" + child7Name);
906
+ let child8Name =
907
+ stateVariables["/_mathlist6"].activeChildren[1].componentName;
908
+ let child8Anchor = cesc2("#" + child8Name);
909
+
910
+ cy.log("Test value displayed in browser");
911
+ cy.get(child0Anchor)
912
+ .find(".mjx-mrow")
913
+ .eq(0)
914
+ .invoke("text")
915
+ .then((text) => {
916
+ expect(text.trim()).equal("a");
917
+ });
918
+ cy.get(child1Anchor)
919
+ .find(".mjx-mrow")
920
+ .eq(0)
921
+ .invoke("text")
922
+ .then((text) => {
923
+ expect(text.trim()).equal("q");
924
+ });
925
+ cy.get(child2Anchor)
926
+ .find(".mjx-mrow")
927
+ .eq(0)
928
+ .invoke("text")
929
+ .then((text) => {
930
+ expect(text.trim()).equal("r");
931
+ });
932
+ cy.get(cesc("#\\/_math1"))
933
+ .find(".mjx-mrow")
934
+ .eq(0)
935
+ .invoke("text")
936
+ .then((text) => {
937
+ expect(text.trim()).equal("h");
938
+ });
939
+ cy.get(child4Anchor)
940
+ .find(".mjx-mrow")
941
+ .eq(0)
942
+ .invoke("text")
943
+ .then((text) => {
944
+ expect(text.trim()).equal("b");
945
+ });
946
+ cy.get(child5Anchor)
947
+ .find(".mjx-mrow")
948
+ .eq(0)
949
+ .invoke("text")
950
+ .then((text) => {
951
+ expect(text.trim()).equal("u");
952
+ });
953
+ cy.get(child6Anchor)
954
+ .find(".mjx-mrow")
955
+ .eq(0)
956
+ .invoke("text")
957
+ .then((text) => {
958
+ expect(text.trim()).equal("v");
959
+ });
960
+ cy.get(child7Anchor)
961
+ .find(".mjx-mrow")
962
+ .eq(0)
963
+ .invoke("text")
964
+ .then((text) => {
965
+ expect(text.trim()).equal("i");
966
+ });
967
+ cy.get(child8Anchor)
968
+ .find(".mjx-mrow")
969
+ .eq(0)
970
+ .invoke("text")
971
+ .then((text) => {
972
+ expect(text.trim()).equal("j");
973
+ });
974
+
975
+ cy.log("Test internal values are set to the correct values");
976
+ cy.window().then(async (win) => {
977
+ let stateVariables = await win.returnAllStateVariables1();
978
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("a");
979
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq("q");
980
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eq("r");
981
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq("h");
982
+ expect(stateVariables["/_mathlist1"].stateValues.maths[4]).eq("b");
983
+ expect(stateVariables["/_mathlist1"].stateValues.maths[5]).eq("u");
984
+ expect(stateVariables["/_mathlist1"].stateValues.maths[6]).eq("v");
985
+ expect(stateVariables["/_mathlist1"].stateValues.maths[7]).eq("i");
986
+ expect(stateVariables["/_mathlist1"].stateValues.maths[8]).eq("j");
987
+ expect(stateVariables["/_mathlist2"].stateValues.maths[0]).eq("q");
988
+ expect(stateVariables["/_mathlist2"].stateValues.maths[1]).eq("r");
989
+ expect(stateVariables["/_mathlist3"].stateValues.maths[0]).eq("b");
990
+ expect(stateVariables["/_mathlist3"].stateValues.maths[1]).eq("u");
991
+ expect(stateVariables["/_mathlist3"].stateValues.maths[2]).eq("v");
992
+ expect(stateVariables["/_mathlist3"].stateValues.maths[3]).eq("i");
993
+ expect(stateVariables["/_mathlist3"].stateValues.maths[4]).eq("j");
994
+ expect(stateVariables["/_mathlist4"].stateValues.maths[0]).eq("b");
995
+ expect(stateVariables["/_mathlist4"].stateValues.maths[1]).eq("u");
996
+ expect(stateVariables["/_mathlist4"].stateValues.maths[2]).eq("v");
997
+ expect(stateVariables["/_mathlist5"].stateValues.maths[0]).eq("u");
998
+ expect(stateVariables["/_mathlist5"].stateValues.maths[1]).eq("v");
999
+ expect(stateVariables["/_mathlist6"].stateValues.maths[0]).eq("i");
1000
+ expect(stateVariables["/_mathlist6"].stateValues.maths[1]).eq("j");
1001
+ });
1002
+
1003
+ cy.log("change values");
1004
+
1005
+ cy.get(cesc("#\\/_mathinput1") + " textarea").type(
1006
+ "{end}{backspace}1{enter}",
1007
+ { force: true },
1008
+ );
1009
+ cy.get(cesc("#\\/_mathinput2") + " textarea").type(
1010
+ "{end}{backspace}2{enter}",
1011
+ { force: true },
1012
+ );
1013
+ cy.get(cesc("#\\/_mathinput3") + " textarea").type(
1014
+ "{end}{backspace}3{enter}",
1015
+ { force: true },
1016
+ );
1017
+ cy.get(cesc("#\\/_mathinput4") + " textarea").type(
1018
+ "{end}{backspace}4{enter}",
1019
+ { force: true },
1020
+ );
1021
+ cy.get(cesc("#\\/_mathinput5") + " textarea").type(
1022
+ "{end}{backspace}5{enter}",
1023
+ { force: true },
1024
+ );
1025
+ cy.get(cesc("#\\/_mathinput6") + " textarea").type(
1026
+ "{end}{backspace}6{enter}",
1027
+ { force: true },
1028
+ );
1029
+ cy.get(cesc("#\\/_mathinput7") + " textarea").type(
1030
+ "{end}{backspace}7{enter}",
1031
+ { force: true },
1032
+ );
1033
+ cy.get(cesc("#\\/_mathinput8") + " textarea").type(
1034
+ "{end}{backspace}8{enter}",
1035
+ { force: true },
1036
+ );
1037
+ cy.get(cesc("#\\/_mathinput9") + " textarea").type(
1038
+ "{end}{backspace}9{enter}",
1039
+ { force: true },
1040
+ );
1041
+
1042
+ cy.get(child8Anchor).should("contain.text", "9");
1043
+
1044
+ cy.log("Test value displayed in browser");
1045
+ cy.get(child0Anchor)
1046
+ .find(".mjx-mrow")
1047
+ .eq(0)
1048
+ .invoke("text")
1049
+ .then((text) => {
1050
+ expect(text.trim()).equal("1");
1051
+ });
1052
+ cy.get(child1Anchor)
1053
+ .find(".mjx-mrow")
1054
+ .eq(0)
1055
+ .invoke("text")
1056
+ .then((text) => {
1057
+ expect(text.trim()).equal("2");
1058
+ });
1059
+ cy.get(child2Anchor)
1060
+ .find(".mjx-mrow")
1061
+ .eq(0)
1062
+ .invoke("text")
1063
+ .then((text) => {
1064
+ expect(text.trim()).equal("3");
1065
+ });
1066
+ cy.get(cesc("#\\/_math1"))
1067
+ .find(".mjx-mrow")
1068
+ .eq(0)
1069
+ .invoke("text")
1070
+ .then((text) => {
1071
+ expect(text.trim()).equal("4");
1072
+ });
1073
+ cy.get(child4Anchor)
1074
+ .find(".mjx-mrow")
1075
+ .eq(0)
1076
+ .invoke("text")
1077
+ .then((text) => {
1078
+ expect(text.trim()).equal("5");
1079
+ });
1080
+ cy.get(child5Anchor)
1081
+ .find(".mjx-mrow")
1082
+ .eq(0)
1083
+ .invoke("text")
1084
+ .then((text) => {
1085
+ expect(text.trim()).equal("6");
1086
+ });
1087
+ cy.get(child6Anchor)
1088
+ .find(".mjx-mrow")
1089
+ .eq(0)
1090
+ .invoke("text")
1091
+ .then((text) => {
1092
+ expect(text.trim()).equal("7");
1093
+ });
1094
+ cy.get(child7Anchor)
1095
+ .find(".mjx-mrow")
1096
+ .eq(0)
1097
+ .invoke("text")
1098
+ .then((text) => {
1099
+ expect(text.trim()).equal("8");
1100
+ });
1101
+ cy.get(child8Anchor)
1102
+ .find(".mjx-mrow")
1103
+ .eq(0)
1104
+ .invoke("text")
1105
+ .then((text) => {
1106
+ expect(text.trim()).equal("9");
1107
+ });
1108
+
1109
+ cy.log("Test internal values are set to the correct values");
1110
+ cy.window().then(async (win) => {
1111
+ let stateVariables = await win.returnAllStateVariables1();
1112
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq(1);
1113
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq(2);
1114
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eq(3);
1115
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq(4);
1116
+ expect(stateVariables["/_mathlist1"].stateValues.maths[4]).eq(5);
1117
+ expect(stateVariables["/_mathlist1"].stateValues.maths[5]).eq(6);
1118
+ expect(stateVariables["/_mathlist1"].stateValues.maths[6]).eq(7);
1119
+ expect(stateVariables["/_mathlist1"].stateValues.maths[7]).eq(8);
1120
+ expect(stateVariables["/_mathlist1"].stateValues.maths[8]).eq(9);
1121
+ expect(stateVariables["/_mathlist2"].stateValues.maths[0]).eq(2);
1122
+ expect(stateVariables["/_mathlist2"].stateValues.maths[1]).eq(3);
1123
+ expect(stateVariables["/_mathlist3"].stateValues.maths[0]).eq(5);
1124
+ expect(stateVariables["/_mathlist3"].stateValues.maths[1]).eq(6);
1125
+ expect(stateVariables["/_mathlist3"].stateValues.maths[2]).eq(7);
1126
+ expect(stateVariables["/_mathlist3"].stateValues.maths[3]).eq(8);
1127
+ expect(stateVariables["/_mathlist3"].stateValues.maths[4]).eq(9);
1128
+ expect(stateVariables["/_mathlist4"].stateValues.maths[0]).eq(5);
1129
+ expect(stateVariables["/_mathlist4"].stateValues.maths[1]).eq(6);
1130
+ expect(stateVariables["/_mathlist4"].stateValues.maths[2]).eq(7);
1131
+ expect(stateVariables["/_mathlist5"].stateValues.maths[0]).eq(6);
1132
+ expect(stateVariables["/_mathlist5"].stateValues.maths[1]).eq(7);
1133
+ expect(stateVariables["/_mathlist6"].stateValues.maths[0]).eq(8);
1134
+ expect(stateVariables["/_mathlist6"].stateValues.maths[1]).eq(9);
1135
+ });
1136
+ });
1137
+ });
1138
+
1139
+ it("mathlist with self references", () => {
1140
+ cy.window().then(async (win) => {
1141
+ win.postMessage(
1142
+ {
1143
+ doenetML: `
1144
+ <text>a</text>
1145
+ <mathlist>
1146
+ <math>a</math>
1147
+ <mathlist>q r</mathlist>
1148
+ <copy prop="math3" target="_mathlist1" assignNames="m4" createComponentOfType="math" />
1149
+ <mathlist>
1150
+ <mathlist name="mid">
1151
+ <math><copy prop="math1" target="_mathlist1" createComponentOfType="math" /></math>
1152
+ <mathlist>u v</mathlist>
1153
+ </mathlist>
1154
+ <mathlist>
1155
+ <copy prop="math2" target="_mathlist1" assignNames="m8" createComponentOfType="math" />
1156
+ <copy prop="math5" target="_mathlist1" assignNames="m9" createComponentOfType="math" />
1157
+ </mathlist>
1158
+ </mathlist>
1159
+ <copy target="mid" assignNames="mid2" />
1160
+ </mathlist>
1161
+
1162
+ <mathinput bindValueTo="$(_mathlist1.math1)" />
1163
+ <mathinput bindValueTo="$(_mathlist1.math2)" />
1164
+ <mathinput bindValueTo="$(_mathlist1.math3)" />
1165
+ <mathinput bindValueTo="$(_mathlist1.math4)" />
1166
+ <mathinput bindValueTo="$(_mathlist1.math5)" />
1167
+ <mathinput bindValueTo="$(_mathlist1.math6)" />
1168
+ <mathinput bindValueTo="$(_mathlist1.math7)" />
1169
+ <mathinput bindValueTo="$(_mathlist1.math8)" />
1170
+ <mathinput bindValueTo="$(_mathlist1.math9)" />
1171
+ <mathinput bindValueTo="$(_mathlist1.math10)" />
1172
+ <mathinput bindValueTo="$(_mathlist1.math11)" />
1173
+ <mathinput bindValueTo="$(_mathlist1.math12)" />
1174
+
1175
+ `,
1176
+ },
1177
+ "*",
1178
+ );
1179
+ });
1180
+
1181
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
1182
+
1183
+ cy.window().then(async (win) => {
1184
+ let stateVariables = await win.returnAllStateVariables1();
1185
+ let child0Name = "/_math1";
1186
+ let ca0 = cesc2("#" + child0Name);
1187
+ let child1Name =
1188
+ stateVariables["/_mathlist2"].activeChildren[0].componentName;
1189
+ let ca1 = cesc2("#" + child1Name);
1190
+ let child2Name =
1191
+ stateVariables["/_mathlist2"].activeChildren[1].componentName;
1192
+ let ca2 = cesc2("#" + child2Name);
1193
+ let child3Name = "/m4";
1194
+ let ca3 = cesc2("#" + child3Name);
1195
+ let child4Name = "/_math2";
1196
+ let ca4 = cesc2("#" + child4Name);
1197
+ let child5Name =
1198
+ stateVariables["/_mathlist5"].activeChildren[0].componentName;
1199
+ let ca5 = cesc2("#" + child5Name);
1200
+ let child6Name =
1201
+ stateVariables["/_mathlist5"].activeChildren[1].componentName;
1202
+ let ca6 = cesc2("#" + child6Name);
1203
+ let child7Name = "/m8";
1204
+ let ca7 = cesc2("#" + child7Name);
1205
+ let child8Name = "/m9";
1206
+ let ca8 = cesc2("#" + child8Name);
1207
+ let child9Name = stateVariables["/mid2"].activeChildren[0].componentName;
1208
+ let ca9 = cesc2("#" + child9Name);
1209
+ let child10Name =
1210
+ stateVariables[stateVariables["/mid2"].activeChildren[1].componentName]
1211
+ .activeChildren[0].componentName;
1212
+ let ca10 = cesc2("#" + child10Name);
1213
+ let child11Name =
1214
+ stateVariables[stateVariables["/mid2"].activeChildren[1].componentName]
1215
+ .activeChildren[1].componentName;
1216
+ let ca11 = cesc2("#" + child11Name);
1217
+
1218
+ let childAnchors = [
1219
+ ca0,
1220
+ ca1,
1221
+ ca2,
1222
+ ca3,
1223
+ ca4,
1224
+ ca5,
1225
+ ca6,
1226
+ ca7,
1227
+ ca8,
1228
+ ca9,
1229
+ ca10,
1230
+ ca11,
1231
+ ];
1232
+ let vals = ["a", "q", "r", "u", "v"];
1233
+ let mapping = [0, 1, 2, 2, 0, 3, 4, 1, 0, 0, 3, 4];
1234
+ let mv = (i) => vals[mapping[i]];
1235
+
1236
+ let maths = stateVariables["/_mathlist1"].stateValues.maths;
1237
+
1238
+ let mathinputAnchors = [];
1239
+ for (let i in mapping) {
1240
+ mathinputAnchors.push(
1241
+ cesc(`#\\/_mathinput${Number(i) + 1}`) + ` textarea`,
1242
+ );
1243
+ }
1244
+
1245
+ cy.log("Test value displayed in browser");
1246
+
1247
+ for (let i in mapping) {
1248
+ cy.get(childAnchors[i])
1249
+ .find(".mjx-mrow")
1250
+ .eq(0)
1251
+ .invoke("text")
1252
+ .then((text) => {
1253
+ expect(text.trim()).equal(mv(i));
1254
+ });
1255
+ }
1256
+
1257
+ cy.log("Test internal values are set to the correct values");
1258
+ cy.window().then(async (win) => {
1259
+ for (let i in mapping) {
1260
+ expect(maths[i]).eq(mv(i));
1261
+ }
1262
+ });
1263
+
1264
+ cy.log("change values");
1265
+
1266
+ for (let changeInd in mapping) {
1267
+ cy.window().then(async (win) => {
1268
+ vals[mapping[changeInd]] = Number(changeInd);
1269
+ cy.get(mathinputAnchors[changeInd]).type(
1270
+ "{end}{backspace}" + changeInd + "{enter}",
1271
+ { force: true },
1272
+ );
1273
+ cy.get(childAnchors[changeInd]).should(
1274
+ "contain.text",
1275
+ String(mv(changeInd)),
1276
+ );
1277
+
1278
+ cy.log("Test value displayed in browser");
1279
+
1280
+ for (let i in mapping) {
1281
+ cy.get(childAnchors[i])
1282
+ .find(".mjx-mrow")
1283
+ .eq(0)
1284
+ .invoke("text")
1285
+ .then((text) => {
1286
+ expect(text.trim()).equal(String(mv(i)));
1287
+ });
1288
+ }
1289
+
1290
+ cy.log("Test internal values are set to the correct values");
1291
+ cy.window().then(async (win) => {
1292
+ let stateVariables = await win.returnAllStateVariables1();
1293
+ let maths = stateVariables["/_mathlist1"].stateValues.maths;
1294
+
1295
+ for (let i in mapping) {
1296
+ expect(maths[i]).eq(mv(i));
1297
+ }
1298
+ });
1299
+ });
1300
+ }
1301
+ });
1302
+ });
1303
+
1304
+ // TODO: address maximum number in rendered children of mathlist
1305
+ it("mathlist with maximum number", () => {
1306
+ cy.window().then(async (win) => {
1307
+ win.postMessage(
1308
+ {
1309
+ doenetML: `
1310
+ <text>a</text>
1311
+ <mathlist maxNumber="7">
1312
+ <math>a</math>
1313
+ <mathlist maxNumber="2">q r l k</mathlist>
1314
+ <math>h</math>
1315
+ <mathlist maxNumber="4">
1316
+ <mathlist maxNumber="2">
1317
+ <math>b</math>
1318
+ <mathlist>u v</mathlist>
1319
+ </mathlist>
1320
+ <mathlist>i j k</mathlist>
1321
+ </mathlist>
1322
+ </mathlist>
1323
+ `,
1324
+ },
1325
+ "*",
1326
+ );
1327
+ });
1328
+
1329
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
1330
+
1331
+ cy.window().then(async (win) => {
1332
+ // let stateVariables = await win.returnAllStateVariables1();
1333
+ // let child1Name = stateVariables['/_mathlist2'].activeChildren[0].componentName;
1334
+ // let child1Anchor = cesc2('#' + child1Name);
1335
+ // let child2Name = stateVariables['/_mathlist2'].activeChildren[1].componentName;
1336
+ // let child2Anchor = cesc2('#' + child2Name);
1337
+ // let child5Name = stateVariables['/_mathlist5'].activeChildren[0].componentName;
1338
+ // let child5Anchor = cesc2('#' + child5Name);
1339
+ // let child6Name = stateVariables['/_mathlist6'].activeChildren[0].componentName;
1340
+ // let child6Anchor = cesc2('#' + child6Name);
1341
+
1342
+ // cy.log('Test value displayed in browser')
1343
+ // cy.get(cesc('#\\/_math1')).find('.mjx-mrow').eq(0).invoke('text').then((text) => {
1344
+ // expect(text.trim()).equal('a')
1345
+ // })
1346
+ // cy.get(child1Anchor).find('.mjx-mrow').eq(0).invoke('text').then((text) => {
1347
+ // expect(text.trim()).equal('q')
1348
+ // })
1349
+ // cy.get(child2Anchor).find('.mjx-mrow').eq(0).invoke('text').then((text) => {
1350
+ // expect(text.trim()).equal('r')
1351
+ // })
1352
+ // cy.get(cesc('#\\/_math2')).find('.mjx-mrow').eq(0).invoke('text').then((text) => {
1353
+ // expect(text.trim()).equal('h')
1354
+ // })
1355
+ // cy.get(cesc('#\\/_math3')).find('.mjx-mrow').eq(0).invoke('text').then((text) => {
1356
+ // expect(text.trim()).equal('b')
1357
+ // })
1358
+ // cy.get(child5Anchor).find('.mjx-mrow').eq(0).invoke('text').then((text) => {
1359
+ // expect(text.trim()).equal('u')
1360
+ // })
1361
+ // cy.get(child6Anchor).find('.mjx-mrow').eq(0).invoke('text').then((text) => {
1362
+ // expect(text.trim()).equal('i')
1363
+ // })
1364
+
1365
+ cy.get(cesc("#\\/_document1"))
1366
+ .find(".mjx-mrow")
1367
+ .eq(0)
1368
+ .invoke("text")
1369
+ .then((text) => {
1370
+ expect(text.trim()).equal("a");
1371
+ });
1372
+ cy.get(cesc("#\\/_document1"))
1373
+ .find(".mjx-mrow")
1374
+ .eq(1)
1375
+ .invoke("text")
1376
+ .then((text) => {
1377
+ expect(text.trim()).equal("q");
1378
+ });
1379
+ cy.get(cesc("#\\/_document1"))
1380
+ .find(".mjx-mrow")
1381
+ .eq(2)
1382
+ .invoke("text")
1383
+ .then((text) => {
1384
+ expect(text.trim()).equal("r");
1385
+ });
1386
+ cy.get(cesc("#\\/_document1"))
1387
+ .find(".mjx-mrow")
1388
+ .eq(3)
1389
+ .invoke("text")
1390
+ .then((text) => {
1391
+ expect(text.trim()).equal("h");
1392
+ });
1393
+ cy.get(cesc("#\\/_document1"))
1394
+ .find(".mjx-mrow")
1395
+ .eq(4)
1396
+ .invoke("text")
1397
+ .then((text) => {
1398
+ expect(text.trim()).equal("b");
1399
+ });
1400
+ cy.get(cesc("#\\/_document1"))
1401
+ .find(".mjx-mrow")
1402
+ .eq(5)
1403
+ .invoke("text")
1404
+ .then((text) => {
1405
+ expect(text.trim()).equal("u");
1406
+ });
1407
+ cy.get(cesc("#\\/_document1"))
1408
+ .find(".mjx-mrow")
1409
+ .eq(6)
1410
+ .invoke("text")
1411
+ .then((text) => {
1412
+ expect(text.trim()).equal("i");
1413
+ });
1414
+ cy.get(cesc("#\\/_document1"))
1415
+ .find(".mjx-mrow")
1416
+ .eq(7)
1417
+ .should("not.exist");
1418
+
1419
+ cy.log("Test internal values are set to the correct values");
1420
+ cy.window().then(async (win) => {
1421
+ let stateVariables = await win.returnAllStateVariables1();
1422
+ expect(stateVariables["/_mathlist1"].stateValues.maths.length).eq(7);
1423
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("a");
1424
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq("q");
1425
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eq("r");
1426
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq("h");
1427
+ expect(stateVariables["/_mathlist1"].stateValues.maths[4]).eq("b");
1428
+ expect(stateVariables["/_mathlist1"].stateValues.maths[5]).eq("u");
1429
+ expect(stateVariables["/_mathlist1"].stateValues.maths[6]).eq("i");
1430
+ expect(stateVariables["/_mathlist2"].stateValues.maths.length).eq(2);
1431
+ expect(stateVariables["/_mathlist2"].stateValues.maths[0]).eq("q");
1432
+ expect(stateVariables["/_mathlist2"].stateValues.maths[1]).eq("r");
1433
+ expect(stateVariables["/_mathlist3"].stateValues.maths.length).eq(4);
1434
+ expect(stateVariables["/_mathlist3"].stateValues.maths[0]).eq("b");
1435
+ expect(stateVariables["/_mathlist3"].stateValues.maths[1]).eq("u");
1436
+ expect(stateVariables["/_mathlist3"].stateValues.maths[2]).eq("i");
1437
+ expect(stateVariables["/_mathlist3"].stateValues.maths[3]).eq("j");
1438
+ expect(stateVariables["/_mathlist4"].stateValues.maths.length).eq(2);
1439
+ expect(stateVariables["/_mathlist4"].stateValues.maths[0]).eq("b");
1440
+ expect(stateVariables["/_mathlist4"].stateValues.maths[1]).eq("u");
1441
+ expect(stateVariables["/_mathlist5"].stateValues.maths.length).eq(2);
1442
+ expect(stateVariables["/_mathlist5"].stateValues.maths[0]).eq("u");
1443
+ expect(stateVariables["/_mathlist5"].stateValues.maths[1]).eq("v");
1444
+ expect(stateVariables["/_mathlist6"].stateValues.maths.length).eq(3);
1445
+ expect(stateVariables["/_mathlist6"].stateValues.maths[0]).eq("i");
1446
+ expect(stateVariables["/_mathlist6"].stateValues.maths[1]).eq("j");
1447
+ expect(stateVariables["/_mathlist6"].stateValues.maths[2]).eq("k");
1448
+ });
1449
+ });
1450
+ });
1451
+
1452
+ it("copy mathlist and overwrite maximum number", () => {
1453
+ cy.window().then(async (win) => {
1454
+ win.postMessage(
1455
+ {
1456
+ doenetML: `
1457
+ <text>a</text>
1458
+ <p><mathlist name="ml1">a b c d e</mathlist></p>
1459
+ <p><copy target="ml1" maxNumber="3" assignNames="ml2" /></p>
1460
+ <p><copy target="ml2" maxNumber="" assignNames="ml3" /></p>
1461
+
1462
+ <p><mathlist name="ml4" maxNumber="3">a b c d e</mathlist></p>
1463
+ <p><copy target="ml4" maxNumber="4" assignNames="ml5" /></p>
1464
+ <p><copy target="ml5" maxNumber="" assignNames="ml6" /></p>
1465
+
1466
+ `,
1467
+ },
1468
+ "*",
1469
+ );
1470
+ });
1471
+
1472
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
1473
+
1474
+ cy.window().then(async (win) => {
1475
+ cy.get(cesc("#\\/_p1"))
1476
+ .find(".mjx-mrow")
1477
+ .eq(0)
1478
+ .invoke("text")
1479
+ .then((text) => {
1480
+ expect(text.trim()).equal("a");
1481
+ });
1482
+ cy.get(cesc("#\\/_p1"))
1483
+ .find(".mjx-mrow")
1484
+ .eq(1)
1485
+ .invoke("text")
1486
+ .then((text) => {
1487
+ expect(text.trim()).equal("b");
1488
+ });
1489
+ cy.get(cesc("#\\/_p1"))
1490
+ .find(".mjx-mrow")
1491
+ .eq(2)
1492
+ .invoke("text")
1493
+ .then((text) => {
1494
+ expect(text.trim()).equal("c");
1495
+ });
1496
+ cy.get(cesc("#\\/_p1"))
1497
+ .find(".mjx-mrow")
1498
+ .eq(3)
1499
+ .invoke("text")
1500
+ .then((text) => {
1501
+ expect(text.trim()).equal("d");
1502
+ });
1503
+ cy.get(cesc("#\\/_p1"))
1504
+ .find(".mjx-mrow")
1505
+ .eq(4)
1506
+ .invoke("text")
1507
+ .then((text) => {
1508
+ expect(text.trim()).equal("e");
1509
+ });
1510
+ cy.get(cesc("#\\/_p1")).find(".mjx-mrow").eq(5).should("not.exist");
1511
+
1512
+ cy.get(cesc("#\\/_p2"))
1513
+ .find(".mjx-mrow")
1514
+ .eq(0)
1515
+ .invoke("text")
1516
+ .then((text) => {
1517
+ expect(text.trim()).equal("a");
1518
+ });
1519
+ cy.get(cesc("#\\/_p2"))
1520
+ .find(".mjx-mrow")
1521
+ .eq(1)
1522
+ .invoke("text")
1523
+ .then((text) => {
1524
+ expect(text.trim()).equal("b");
1525
+ });
1526
+ cy.get(cesc("#\\/_p2"))
1527
+ .find(".mjx-mrow")
1528
+ .eq(2)
1529
+ .invoke("text")
1530
+ .then((text) => {
1531
+ expect(text.trim()).equal("c");
1532
+ });
1533
+ cy.get(cesc("#\\/_p2")).find(".mjx-mrow").eq(3).should("not.exist");
1534
+
1535
+ cy.get(cesc("#\\/_p3"))
1536
+ .find(".mjx-mrow")
1537
+ .eq(0)
1538
+ .invoke("text")
1539
+ .then((text) => {
1540
+ expect(text.trim()).equal("a");
1541
+ });
1542
+ cy.get(cesc("#\\/_p3"))
1543
+ .find(".mjx-mrow")
1544
+ .eq(1)
1545
+ .invoke("text")
1546
+ .then((text) => {
1547
+ expect(text.trim()).equal("b");
1548
+ });
1549
+ cy.get(cesc("#\\/_p3"))
1550
+ .find(".mjx-mrow")
1551
+ .eq(2)
1552
+ .invoke("text")
1553
+ .then((text) => {
1554
+ expect(text.trim()).equal("c");
1555
+ });
1556
+ cy.get(cesc("#\\/_p3"))
1557
+ .find(".mjx-mrow")
1558
+ .eq(3)
1559
+ .invoke("text")
1560
+ .then((text) => {
1561
+ expect(text.trim()).equal("d");
1562
+ });
1563
+ cy.get(cesc("#\\/_p3"))
1564
+ .find(".mjx-mrow")
1565
+ .eq(4)
1566
+ .invoke("text")
1567
+ .then((text) => {
1568
+ expect(text.trim()).equal("e");
1569
+ });
1570
+ cy.get(cesc("#\\/_p3")).find(".mjx-mrow").eq(5).should("not.exist");
1571
+
1572
+ cy.get(cesc("#\\/_p4"))
1573
+ .find(".mjx-mrow")
1574
+ .eq(0)
1575
+ .invoke("text")
1576
+ .then((text) => {
1577
+ expect(text.trim()).equal("a");
1578
+ });
1579
+ cy.get(cesc("#\\/_p4"))
1580
+ .find(".mjx-mrow")
1581
+ .eq(1)
1582
+ .invoke("text")
1583
+ .then((text) => {
1584
+ expect(text.trim()).equal("b");
1585
+ });
1586
+ cy.get(cesc("#\\/_p4"))
1587
+ .find(".mjx-mrow")
1588
+ .eq(2)
1589
+ .invoke("text")
1590
+ .then((text) => {
1591
+ expect(text.trim()).equal("c");
1592
+ });
1593
+ cy.get(cesc("#\\/_p4")).find(".mjx-mrow").eq(3).should("not.exist");
1594
+
1595
+ cy.get(cesc("#\\/_p5"))
1596
+ .find(".mjx-mrow")
1597
+ .eq(0)
1598
+ .invoke("text")
1599
+ .then((text) => {
1600
+ expect(text.trim()).equal("a");
1601
+ });
1602
+ cy.get(cesc("#\\/_p5"))
1603
+ .find(".mjx-mrow")
1604
+ .eq(1)
1605
+ .invoke("text")
1606
+ .then((text) => {
1607
+ expect(text.trim()).equal("b");
1608
+ });
1609
+ cy.get(cesc("#\\/_p5"))
1610
+ .find(".mjx-mrow")
1611
+ .eq(2)
1612
+ .invoke("text")
1613
+ .then((text) => {
1614
+ expect(text.trim()).equal("c");
1615
+ });
1616
+ cy.get(cesc("#\\/_p5"))
1617
+ .find(".mjx-mrow")
1618
+ .eq(3)
1619
+ .invoke("text")
1620
+ .then((text) => {
1621
+ expect(text.trim()).equal("d");
1622
+ });
1623
+ cy.get(cesc("#\\/_p5")).find(".mjx-mrow").eq(4).should("not.exist");
1624
+
1625
+ cy.get(cesc("#\\/_p6"))
1626
+ .find(".mjx-mrow")
1627
+ .eq(0)
1628
+ .invoke("text")
1629
+ .then((text) => {
1630
+ expect(text.trim()).equal("a");
1631
+ });
1632
+ cy.get(cesc("#\\/_p6"))
1633
+ .find(".mjx-mrow")
1634
+ .eq(1)
1635
+ .invoke("text")
1636
+ .then((text) => {
1637
+ expect(text.trim()).equal("b");
1638
+ });
1639
+ cy.get(cesc("#\\/_p6"))
1640
+ .find(".mjx-mrow")
1641
+ .eq(2)
1642
+ .invoke("text")
1643
+ .then((text) => {
1644
+ expect(text.trim()).equal("c");
1645
+ });
1646
+ cy.get(cesc("#\\/_p6"))
1647
+ .find(".mjx-mrow")
1648
+ .eq(3)
1649
+ .invoke("text")
1650
+ .then((text) => {
1651
+ expect(text.trim()).equal("d");
1652
+ });
1653
+ cy.get(cesc("#\\/_p6"))
1654
+ .find(".mjx-mrow")
1655
+ .eq(4)
1656
+ .invoke("text")
1657
+ .then((text) => {
1658
+ expect(text.trim()).equal("e");
1659
+ });
1660
+ cy.get(cesc("#\\/_p6")).find(".mjx-mrow").eq(5).should("not.exist");
1661
+
1662
+ cy.log("Test internal values are set to the correct values");
1663
+ cy.window().then(async (win) => {
1664
+ let stateVariables = await win.returnAllStateVariables1();
1665
+ expect(stateVariables["/ml1"].stateValues.maths).eqls([
1666
+ "a",
1667
+ "b",
1668
+ "c",
1669
+ "d",
1670
+ "e",
1671
+ ]);
1672
+ expect(stateVariables["/ml2"].stateValues.maths).eqls(["a", "b", "c"]);
1673
+ expect(stateVariables["/ml3"].stateValues.maths).eqls([
1674
+ "a",
1675
+ "b",
1676
+ "c",
1677
+ "d",
1678
+ "e",
1679
+ ]);
1680
+ expect(stateVariables["/ml4"].stateValues.maths).eqls(["a", "b", "c"]);
1681
+ expect(stateVariables["/ml5"].stateValues.maths).eqls([
1682
+ "a",
1683
+ "b",
1684
+ "c",
1685
+ "d",
1686
+ ]);
1687
+ expect(stateVariables["/ml6"].stateValues.maths).eqls([
1688
+ "a",
1689
+ "b",
1690
+ "c",
1691
+ "d",
1692
+ "e",
1693
+ ]);
1694
+ });
1695
+ });
1696
+ });
1697
+
1698
+ it("dynamic maximum number", () => {
1699
+ cy.window().then(async (win) => {
1700
+ win.postMessage(
1701
+ {
1702
+ doenetML: `
1703
+ <text>a</text>
1704
+ <p><mathlist name="ml1" maxNumber="$mn1" >x y z u v</mathlist></p>
1705
+ <p><copy target="ml1" maxNumber="$mn2" assignNames="ml2" /></p>
1706
+ <p>Maximum number 1: <mathinput name="mn1" prefill="2" /></p>
1707
+ <p>Maximum number 2: <mathinput name="mn2" /></p>
1708
+
1709
+ `,
1710
+ },
1711
+ "*",
1712
+ );
1713
+ });
1714
+
1715
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
1716
+
1717
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1718
+ .eq(0)
1719
+ .should("contain.text", "x");
1720
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1721
+ .eq(1)
1722
+ .should("contain.text", "y");
1723
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1724
+ .eq(2)
1725
+ .should("not.exist");
1726
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1727
+ .eq(0)
1728
+ .should("contain.text", "x");
1729
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1730
+ .eq(1)
1731
+ .should("contain.text", "y");
1732
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1733
+ .eq(2)
1734
+ .should("contain.text", "z");
1735
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1736
+ .eq(3)
1737
+ .should("contain.text", "u");
1738
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1739
+ .eq(4)
1740
+ .should("contain.text", "v");
1741
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1742
+ .eq(5)
1743
+ .should("not.exist");
1744
+
1745
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1746
+ .eq(0)
1747
+ .invoke("text")
1748
+ .then((text) => {
1749
+ expect(text.trim()).equal("x");
1750
+ });
1751
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1752
+ .eq(1)
1753
+ .invoke("text")
1754
+ .then((text) => {
1755
+ expect(text.trim()).equal("y");
1756
+ });
1757
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1758
+ .eq(0)
1759
+ .invoke("text")
1760
+ .then((text) => {
1761
+ expect(text.trim()).equal("x");
1762
+ });
1763
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1764
+ .eq(1)
1765
+ .invoke("text")
1766
+ .then((text) => {
1767
+ expect(text.trim()).equal("y");
1768
+ });
1769
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1770
+ .eq(2)
1771
+ .invoke("text")
1772
+ .then((text) => {
1773
+ expect(text.trim()).equal("z");
1774
+ });
1775
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1776
+ .eq(3)
1777
+ .invoke("text")
1778
+ .then((text) => {
1779
+ expect(text.trim()).equal("u");
1780
+ });
1781
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1782
+ .eq(4)
1783
+ .invoke("text")
1784
+ .then((text) => {
1785
+ expect(text.trim()).equal("v");
1786
+ });
1787
+
1788
+ cy.window().then(async (win) => {
1789
+ let stateVariables = await win.returnAllStateVariables1();
1790
+ expect(stateVariables["/ml1"].stateValues.maths).eqls(["x", "y"]);
1791
+ expect(stateVariables["/ml2"].stateValues.maths).eqls([
1792
+ "x",
1793
+ "y",
1794
+ "z",
1795
+ "u",
1796
+ "v",
1797
+ ]);
1798
+ });
1799
+
1800
+ cy.log("clear first maxnum");
1801
+ cy.get(cesc("#\\/mn1") + " textarea")
1802
+ .type("{end}{backspace}", { force: true })
1803
+ .blur();
1804
+
1805
+ cy.get(cesc("#\\/_p1")).should("contain.text", "v");
1806
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1807
+ .eq(0)
1808
+ .should("contain.text", "x");
1809
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1810
+ .eq(1)
1811
+ .should("contain.text", "y");
1812
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1813
+ .eq(2)
1814
+ .should("contain.text", "z");
1815
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1816
+ .eq(3)
1817
+ .should("contain.text", "u");
1818
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1819
+ .eq(4)
1820
+ .should("contain.text", "v");
1821
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1822
+ .eq(5)
1823
+ .should("not.exist");
1824
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1825
+ .eq(0)
1826
+ .should("contain.text", "x");
1827
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1828
+ .eq(1)
1829
+ .should("contain.text", "y");
1830
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1831
+ .eq(2)
1832
+ .should("contain.text", "z");
1833
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1834
+ .eq(3)
1835
+ .should("contain.text", "u");
1836
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1837
+ .eq(4)
1838
+ .should("contain.text", "v");
1839
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1840
+ .eq(5)
1841
+ .should("not.exist");
1842
+
1843
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1844
+ .eq(0)
1845
+ .invoke("text")
1846
+ .then((text) => {
1847
+ expect(text.trim()).equal("x");
1848
+ });
1849
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1850
+ .eq(1)
1851
+ .invoke("text")
1852
+ .then((text) => {
1853
+ expect(text.trim()).equal("y");
1854
+ });
1855
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1856
+ .eq(2)
1857
+ .invoke("text")
1858
+ .then((text) => {
1859
+ expect(text.trim()).equal("z");
1860
+ });
1861
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1862
+ .eq(3)
1863
+ .invoke("text")
1864
+ .then((text) => {
1865
+ expect(text.trim()).equal("u");
1866
+ });
1867
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1868
+ .eq(4)
1869
+ .invoke("text")
1870
+ .then((text) => {
1871
+ expect(text.trim()).equal("v");
1872
+ });
1873
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1874
+ .eq(0)
1875
+ .invoke("text")
1876
+ .then((text) => {
1877
+ expect(text.trim()).equal("x");
1878
+ });
1879
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1880
+ .eq(1)
1881
+ .invoke("text")
1882
+ .then((text) => {
1883
+ expect(text.trim()).equal("y");
1884
+ });
1885
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1886
+ .eq(2)
1887
+ .invoke("text")
1888
+ .then((text) => {
1889
+ expect(text.trim()).equal("z");
1890
+ });
1891
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1892
+ .eq(3)
1893
+ .invoke("text")
1894
+ .then((text) => {
1895
+ expect(text.trim()).equal("u");
1896
+ });
1897
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1898
+ .eq(4)
1899
+ .invoke("text")
1900
+ .then((text) => {
1901
+ expect(text.trim()).equal("v");
1902
+ });
1903
+
1904
+ cy.window().then(async (win) => {
1905
+ let stateVariables = await win.returnAllStateVariables1();
1906
+ expect(stateVariables["/ml1"].stateValues.maths).eqls([
1907
+ "x",
1908
+ "y",
1909
+ "z",
1910
+ "u",
1911
+ "v",
1912
+ ]);
1913
+ expect(stateVariables["/ml2"].stateValues.maths).eqls([
1914
+ "x",
1915
+ "y",
1916
+ "z",
1917
+ "u",
1918
+ "v",
1919
+ ]);
1920
+ });
1921
+
1922
+ cy.log("number in second maxnum");
1923
+ cy.get(cesc("#\\/mn2") + " textarea").type("3{enter}", { force: true });
1924
+
1925
+ cy.get(cesc("#\\/_p2")).should("not.contain.text", "v");
1926
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1927
+ .eq(3)
1928
+ .should("not.exist");
1929
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1930
+ .eq(0)
1931
+ .should("contain.text", "x");
1932
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1933
+ .eq(1)
1934
+ .should("contain.text", "y");
1935
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1936
+ .eq(2)
1937
+ .should("contain.text", "z");
1938
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1939
+ .eq(3)
1940
+ .should("contain.text", "u");
1941
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1942
+ .eq(4)
1943
+ .should("contain.text", "v");
1944
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1945
+ .eq(5)
1946
+ .should("not.exist");
1947
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1948
+ .eq(0)
1949
+ .should("contain.text", "x");
1950
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1951
+ .eq(1)
1952
+ .should("contain.text", "y");
1953
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1954
+ .eq(2)
1955
+ .should("contain.text", "z");
1956
+
1957
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1958
+ .eq(0)
1959
+ .invoke("text")
1960
+ .then((text) => {
1961
+ expect(text.trim()).equal("x");
1962
+ });
1963
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1964
+ .eq(1)
1965
+ .invoke("text")
1966
+ .then((text) => {
1967
+ expect(text.trim()).equal("y");
1968
+ });
1969
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1970
+ .eq(2)
1971
+ .invoke("text")
1972
+ .then((text) => {
1973
+ expect(text.trim()).equal("z");
1974
+ });
1975
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1976
+ .eq(3)
1977
+ .invoke("text")
1978
+ .then((text) => {
1979
+ expect(text.trim()).equal("u");
1980
+ });
1981
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
1982
+ .eq(4)
1983
+ .invoke("text")
1984
+ .then((text) => {
1985
+ expect(text.trim()).equal("v");
1986
+ });
1987
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1988
+ .eq(0)
1989
+ .invoke("text")
1990
+ .then((text) => {
1991
+ expect(text.trim()).equal("x");
1992
+ });
1993
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
1994
+ .eq(1)
1995
+ .invoke("text")
1996
+ .then((text) => {
1997
+ expect(text.trim()).equal("y");
1998
+ });
1999
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2000
+ .eq(2)
2001
+ .invoke("text")
2002
+ .then((text) => {
2003
+ expect(text.trim()).equal("z");
2004
+ });
2005
+
2006
+ cy.window().then(async (win) => {
2007
+ let stateVariables = await win.returnAllStateVariables1();
2008
+ expect(stateVariables["/ml1"].stateValues.maths).eqls([
2009
+ "x",
2010
+ "y",
2011
+ "z",
2012
+ "u",
2013
+ "v",
2014
+ ]);
2015
+ expect(stateVariables["/ml2"].stateValues.maths).eqls(["x", "y", "z"]);
2016
+ });
2017
+
2018
+ cy.log("number in first maxnum");
2019
+ cy.get(cesc("#\\/mn1") + " textarea").type("4{enter}", { force: true });
2020
+
2021
+ cy.get(cesc("#\\/_p1")).should("not.contain.text", "v");
2022
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2023
+ .eq(4)
2024
+ .should("not.exist");
2025
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2026
+ .eq(0)
2027
+ .should("contain.text", "x");
2028
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2029
+ .eq(1)
2030
+ .should("contain.text", "y");
2031
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2032
+ .eq(2)
2033
+ .should("contain.text", "z");
2034
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2035
+ .eq(3)
2036
+ .should("contain.text", "u");
2037
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2038
+ .eq(0)
2039
+ .should("contain.text", "x");
2040
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2041
+ .eq(1)
2042
+ .should("contain.text", "y");
2043
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2044
+ .eq(2)
2045
+ .should("contain.text", "z");
2046
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2047
+ .eq(3)
2048
+ .should("not.exist");
2049
+
2050
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2051
+ .eq(0)
2052
+ .invoke("text")
2053
+ .then((text) => {
2054
+ expect(text.trim()).equal("x");
2055
+ });
2056
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2057
+ .eq(1)
2058
+ .invoke("text")
2059
+ .then((text) => {
2060
+ expect(text.trim()).equal("y");
2061
+ });
2062
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2063
+ .eq(2)
2064
+ .invoke("text")
2065
+ .then((text) => {
2066
+ expect(text.trim()).equal("z");
2067
+ });
2068
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2069
+ .eq(3)
2070
+ .invoke("text")
2071
+ .then((text) => {
2072
+ expect(text.trim()).equal("u");
2073
+ });
2074
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2075
+ .eq(0)
2076
+ .invoke("text")
2077
+ .then((text) => {
2078
+ expect(text.trim()).equal("x");
2079
+ });
2080
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2081
+ .eq(1)
2082
+ .invoke("text")
2083
+ .then((text) => {
2084
+ expect(text.trim()).equal("y");
2085
+ });
2086
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2087
+ .eq(2)
2088
+ .invoke("text")
2089
+ .then((text) => {
2090
+ expect(text.trim()).equal("z");
2091
+ });
2092
+
2093
+ cy.window().then(async (win) => {
2094
+ let stateVariables = await win.returnAllStateVariables1();
2095
+ expect(stateVariables["/ml1"].stateValues.maths).eqls([
2096
+ "x",
2097
+ "y",
2098
+ "z",
2099
+ "u",
2100
+ ]);
2101
+ expect(stateVariables["/ml2"].stateValues.maths).eqls(["x", "y", "z"]);
2102
+ });
2103
+
2104
+ cy.log("change number in first maxnum");
2105
+ cy.get(cesc("#\\/mn1") + " textarea").type("{end}{backspace}1{enter}", {
2106
+ force: true,
2107
+ });
2108
+
2109
+ cy.get(cesc("#\\/_p1")).should("not.contain.text", "y");
2110
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2111
+ .eq(1)
2112
+ .should("not.exist");
2113
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2114
+ .eq(0)
2115
+ .should("contain.text", "x");
2116
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2117
+ .eq(0)
2118
+ .should("contain.text", "x");
2119
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2120
+ .eq(1)
2121
+ .should("contain.text", "y");
2122
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2123
+ .eq(2)
2124
+ .should("contain.text", "z");
2125
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2126
+ .eq(3)
2127
+ .should("not.exist");
2128
+
2129
+ cy.get(cesc("#\\/_p1") + " .mjx-mrow")
2130
+ .eq(0)
2131
+ .invoke("text")
2132
+ .then((text) => {
2133
+ expect(text.trim()).equal("x");
2134
+ });
2135
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2136
+ .eq(0)
2137
+ .invoke("text")
2138
+ .then((text) => {
2139
+ expect(text.trim()).equal("x");
2140
+ });
2141
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2142
+ .eq(1)
2143
+ .invoke("text")
2144
+ .then((text) => {
2145
+ expect(text.trim()).equal("y");
2146
+ });
2147
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow")
2148
+ .eq(2)
2149
+ .invoke("text")
2150
+ .then((text) => {
2151
+ expect(text.trim()).equal("z");
2152
+ });
2153
+
2154
+ cy.window().then(async (win) => {
2155
+ let stateVariables = await win.returnAllStateVariables1();
2156
+ expect(stateVariables["/ml1"].stateValues.maths).eqls(["x"]);
2157
+ expect(stateVariables["/ml2"].stateValues.maths).eqls(["x", "y", "z"]);
2158
+ });
2159
+ });
2160
+
2161
+ it("mathlist with merge math list", () => {
2162
+ cy.window().then(async (win) => {
2163
+ win.postMessage(
2164
+ {
2165
+ doenetML: `
2166
+ <text>a</text>
2167
+ <mathlist mergeMathLists="$_booleaninput1">
2168
+ <math>a</math>
2169
+ <math>b,c,d</math>
2170
+ <math>e,f</math>
2171
+ <math>g</math>
2172
+ </mathlist>
2173
+ <p>Merge math lists: <booleaninput /></p>
2174
+
2175
+ <p>Third math: <copy prop="math3" target="_mathlist1" /></p>
2176
+ <p>Fifth math: <copy prop="math5" target="_mathlist1" /></p>
2177
+
2178
+ <p>Change values:
2179
+ <mathinput name="mi1" bindValueTo="$_mathlist1.math1" />
2180
+ <mathinput name="mi2" bindValueTo="$_mathlist1.math2" />
2181
+ <mathinput name="mi3" bindValueTo="$_mathlist1.math3" />
2182
+ <mathinput name="mi4" bindValueTo="$_mathlist1.math4" />
2183
+ <mathinput name="mi5" bindValueTo="$_mathlist1.math5" />
2184
+ <mathinput name="mi6" bindValueTo="$_mathlist1.math6" />
2185
+ <mathinput name="mi7" bindValueTo="$_mathlist1.math7" />
2186
+ </p>
2187
+ `,
2188
+ },
2189
+ "*",
2190
+ );
2191
+ });
2192
+
2193
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
2194
+
2195
+ cy.log("Test value displayed in browser");
2196
+ cy.get(cesc("#\\/_math1"))
2197
+ .find(".mjx-mrow")
2198
+ .eq(0)
2199
+ .invoke("text")
2200
+ .then((text) => {
2201
+ expect(text.trim()).equal("a");
2202
+ });
2203
+ cy.get(cesc("#\\/_math2"))
2204
+ .find(".mjx-mrow")
2205
+ .eq(0)
2206
+ .invoke("text")
2207
+ .then((text) => {
2208
+ expect(text.trim()).equal("b,c,d");
2209
+ });
2210
+ cy.get(cesc("#\\/_math3"))
2211
+ .find(".mjx-mrow")
2212
+ .eq(0)
2213
+ .invoke("text")
2214
+ .then((text) => {
2215
+ expect(text.trim()).equal("e,f");
2216
+ });
2217
+ cy.get(cesc("#\\/_math4"))
2218
+ .find(".mjx-mrow")
2219
+ .eq(0)
2220
+ .invoke("text")
2221
+ .then((text) => {
2222
+ expect(text.trim()).equal("g");
2223
+ });
2224
+ cy.get(cesc("#\\/_p2"))
2225
+ .find(".mjx-mrow")
2226
+ .eq(0)
2227
+ .invoke("text")
2228
+ .then((text) => {
2229
+ expect(text.trim()).equal("e,f");
2230
+ });
2231
+ cy.get(cesc("#\\/_p3")).find(".mjx-mrow").should("not.exist");
2232
+
2233
+ cy.log("Test internal values are set to the correct values");
2234
+ cy.window().then(async (win) => {
2235
+ let stateVariables = await win.returnAllStateVariables1();
2236
+ expect(stateVariables["/_mathlist1"].stateValues.maths.length).eq(4);
2237
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("a");
2238
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eqls([
2239
+ "list",
2240
+ "b",
2241
+ "c",
2242
+ "d",
2243
+ ]);
2244
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eqls([
2245
+ "list",
2246
+ "e",
2247
+ "f",
2248
+ ]);
2249
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq("g");
2250
+ expect(stateVariables["/_mathlist1"].stateValues.math3).eqls([
2251
+ "list",
2252
+ "e",
2253
+ "f",
2254
+ ]);
2255
+ expect(stateVariables["/_mathlist1"].stateValues.math5).eq(undefined);
2256
+ });
2257
+
2258
+ cy.log("change values");
2259
+ cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}h{enter}", {
2260
+ force: true,
2261
+ });
2262
+ cy.get(cesc("#\\/mi2") + " textarea").type("{end}{backspace}i{enter}", {
2263
+ force: true,
2264
+ });
2265
+ cy.get(cesc("#\\/mi3") + " textarea").type("{end}{backspace}j{enter}", {
2266
+ force: true,
2267
+ });
2268
+ cy.get(cesc("#\\/mi4") + " textarea").type("{end}{backspace}k{enter}", {
2269
+ force: true,
2270
+ });
2271
+
2272
+ cy.log("Test value displayed in browser");
2273
+
2274
+ cy.get(cesc("#\\/_math4") + " .mjx-mrow").should("contain.text", "k");
2275
+
2276
+ cy.get(cesc("#\\/_math1"))
2277
+ .find(".mjx-mrow")
2278
+ .eq(0)
2279
+ .invoke("text")
2280
+ .then((text) => {
2281
+ expect(text.trim()).equal("h");
2282
+ });
2283
+ cy.get(cesc("#\\/_math2"))
2284
+ .find(".mjx-mrow")
2285
+ .eq(0)
2286
+ .invoke("text")
2287
+ .then((text) => {
2288
+ expect(text.trim()).equal("b,c,i");
2289
+ });
2290
+ cy.get(cesc("#\\/_math3"))
2291
+ .find(".mjx-mrow")
2292
+ .eq(0)
2293
+ .invoke("text")
2294
+ .then((text) => {
2295
+ expect(text.trim()).equal("e,j");
2296
+ });
2297
+ cy.get(cesc("#\\/_math4"))
2298
+ .find(".mjx-mrow")
2299
+ .eq(0)
2300
+ .invoke("text")
2301
+ .then((text) => {
2302
+ expect(text.trim()).equal("k");
2303
+ });
2304
+ cy.get(cesc("#\\/_p2"))
2305
+ .find(".mjx-mrow")
2306
+ .eq(0)
2307
+ .invoke("text")
2308
+ .then((text) => {
2309
+ expect(text.trim()).equal("e,j");
2310
+ });
2311
+ cy.get(cesc("#\\/_p3")).find(".mjx-mrow").should("not.exist");
2312
+
2313
+ cy.log("Test internal values are set to the correct values");
2314
+ cy.window().then(async (win) => {
2315
+ let stateVariables = await win.returnAllStateVariables1();
2316
+ expect(stateVariables["/_mathlist1"].stateValues.maths.length).eq(4);
2317
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("h");
2318
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eqls([
2319
+ "list",
2320
+ "b",
2321
+ "c",
2322
+ "i",
2323
+ ]);
2324
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eqls([
2325
+ "list",
2326
+ "e",
2327
+ "j",
2328
+ ]);
2329
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq("k");
2330
+ expect(stateVariables["/_mathlist1"].stateValues.math3).eqls([
2331
+ "list",
2332
+ "e",
2333
+ "j",
2334
+ ]);
2335
+ expect(stateVariables["/_mathlist1"].stateValues.math5).eq(undefined);
2336
+ });
2337
+
2338
+ cy.log("merge math lists");
2339
+ cy.get(cesc("#\\/_booleaninput1")).click();
2340
+
2341
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow").should("contain.text", "c");
2342
+
2343
+ cy.log("Test value displayed in browser");
2344
+ cy.get(cesc("#\\/_math1"))
2345
+ .find(".mjx-mrow")
2346
+ .eq(0)
2347
+ .invoke("text")
2348
+ .then((text) => {
2349
+ expect(text.trim()).equal("h");
2350
+ });
2351
+ cy.get(cesc("#\\/_math2"))
2352
+ .find(".mjx-mrow")
2353
+ .eq(0)
2354
+ .invoke("text")
2355
+ .then((text) => {
2356
+ expect(text.trim()).equal("b,c,i");
2357
+ });
2358
+ cy.get(cesc("#\\/_math3"))
2359
+ .find(".mjx-mrow")
2360
+ .eq(0)
2361
+ .invoke("text")
2362
+ .then((text) => {
2363
+ expect(text.trim()).equal("e,j");
2364
+ });
2365
+ cy.get(cesc("#\\/_math4"))
2366
+ .find(".mjx-mrow")
2367
+ .eq(0)
2368
+ .invoke("text")
2369
+ .then((text) => {
2370
+ expect(text.trim()).equal("k");
2371
+ });
2372
+ cy.get(cesc("#\\/_p2"))
2373
+ .find(".mjx-mrow")
2374
+ .eq(0)
2375
+ .invoke("text")
2376
+ .then((text) => {
2377
+ expect(text.trim()).equal("c");
2378
+ });
2379
+ cy.get(cesc("#\\/_p3"))
2380
+ .find(".mjx-mrow")
2381
+ .eq(0)
2382
+ .invoke("text")
2383
+ .then((text) => {
2384
+ expect(text.trim()).equal("e");
2385
+ });
2386
+
2387
+ cy.log("Test internal values are set to the correct values");
2388
+ cy.window().then(async (win) => {
2389
+ let stateVariables = await win.returnAllStateVariables1();
2390
+ expect(stateVariables["/_mathlist1"].stateValues.maths.length).eq(7);
2391
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("h");
2392
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq("b");
2393
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eq("c");
2394
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq("i");
2395
+ expect(stateVariables["/_mathlist1"].stateValues.maths[4]).eq("e");
2396
+ expect(stateVariables["/_mathlist1"].stateValues.maths[5]).eq("j");
2397
+ expect(stateVariables["/_mathlist1"].stateValues.maths[6]).eq("k");
2398
+ expect(stateVariables["/_mathlist1"].stateValues.math3).eq("c");
2399
+ expect(stateVariables["/_mathlist1"].stateValues.math5).eq("e");
2400
+ });
2401
+
2402
+ cy.log("change values");
2403
+ cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}l{enter}", {
2404
+ force: true,
2405
+ });
2406
+ cy.get(cesc("#\\/mi2") + " textarea").type("{end}{backspace}m{enter}", {
2407
+ force: true,
2408
+ });
2409
+ cy.get(cesc("#\\/mi3") + " textarea").type("{end}{backspace}n{enter}", {
2410
+ force: true,
2411
+ });
2412
+ cy.get(cesc("#\\/mi4") + " textarea").type("{end}{backspace}o{enter}", {
2413
+ force: true,
2414
+ });
2415
+ cy.get(cesc("#\\/mi5") + " textarea").type("{end}{backspace}p{enter}", {
2416
+ force: true,
2417
+ });
2418
+ cy.get(cesc("#\\/mi6") + " textarea").type("{end}{backspace}q{enter}", {
2419
+ force: true,
2420
+ });
2421
+ cy.get(cesc("#\\/mi7") + " textarea").type("{end}{backspace}r{enter}", {
2422
+ force: true,
2423
+ });
2424
+
2425
+ cy.log("Test value displayed in browser");
2426
+ cy.get(cesc("#\\/_math4") + " .mjx-mrow").should("contain.text", "r");
2427
+
2428
+ cy.get(cesc("#\\/_math1"))
2429
+ .find(".mjx-mrow")
2430
+ .eq(0)
2431
+ .invoke("text")
2432
+ .then((text) => {
2433
+ expect(text.trim()).equal("l");
2434
+ });
2435
+ cy.get(cesc("#\\/_math2"))
2436
+ .find(".mjx-mrow")
2437
+ .eq(0)
2438
+ .invoke("text")
2439
+ .then((text) => {
2440
+ expect(text.trim()).equal("m,n,o");
2441
+ });
2442
+ cy.get(cesc("#\\/_math3"))
2443
+ .find(".mjx-mrow")
2444
+ .eq(0)
2445
+ .invoke("text")
2446
+ .then((text) => {
2447
+ expect(text.trim()).equal("p,q");
2448
+ });
2449
+ cy.get(cesc("#\\/_math4"))
2450
+ .find(".mjx-mrow")
2451
+ .eq(0)
2452
+ .invoke("text")
2453
+ .then((text) => {
2454
+ expect(text.trim()).equal("r");
2455
+ });
2456
+ cy.get(cesc("#\\/_p2"))
2457
+ .find(".mjx-mrow")
2458
+ .eq(0)
2459
+ .invoke("text")
2460
+ .then((text) => {
2461
+ expect(text.trim()).equal("n");
2462
+ });
2463
+ cy.get(cesc("#\\/_p3"))
2464
+ .find(".mjx-mrow")
2465
+ .eq(0)
2466
+ .invoke("text")
2467
+ .then((text) => {
2468
+ expect(text.trim()).equal("p");
2469
+ });
2470
+
2471
+ cy.log("Test internal values are set to the correct values");
2472
+ cy.window().then(async (win) => {
2473
+ let stateVariables = await win.returnAllStateVariables1();
2474
+ expect(stateVariables["/_mathlist1"].stateValues.maths.length).eq(7);
2475
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("l");
2476
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq("m");
2477
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eq("n");
2478
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq("o");
2479
+ expect(stateVariables["/_mathlist1"].stateValues.maths[4]).eq("p");
2480
+ expect(stateVariables["/_mathlist1"].stateValues.maths[5]).eq("q");
2481
+ expect(stateVariables["/_mathlist1"].stateValues.maths[6]).eq("r");
2482
+ expect(stateVariables["/_mathlist1"].stateValues.math3).eq("n");
2483
+ expect(stateVariables["/_mathlist1"].stateValues.math5).eq("p");
2484
+ });
2485
+
2486
+ cy.log("stop merging again");
2487
+ cy.get(cesc("#\\/_booleaninput1")).click();
2488
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow").should("contain.text", "p,q");
2489
+
2490
+ cy.log("Test value displayed in browser");
2491
+ cy.get(cesc("#\\/_math1"))
2492
+ .find(".mjx-mrow")
2493
+ .eq(0)
2494
+ .invoke("text")
2495
+ .then((text) => {
2496
+ expect(text.trim()).equal("l");
2497
+ });
2498
+ cy.get(cesc("#\\/_math2"))
2499
+ .find(".mjx-mrow")
2500
+ .eq(0)
2501
+ .invoke("text")
2502
+ .then((text) => {
2503
+ expect(text.trim()).equal("m,n,o");
2504
+ });
2505
+ cy.get(cesc("#\\/_math3"))
2506
+ .find(".mjx-mrow")
2507
+ .eq(0)
2508
+ .invoke("text")
2509
+ .then((text) => {
2510
+ expect(text.trim()).equal("p,q");
2511
+ });
2512
+ cy.get(cesc("#\\/_math4"))
2513
+ .find(".mjx-mrow")
2514
+ .eq(0)
2515
+ .invoke("text")
2516
+ .then((text) => {
2517
+ expect(text.trim()).equal("r");
2518
+ });
2519
+ cy.get(cesc("#\\/_p2"))
2520
+ .find(".mjx-mrow")
2521
+ .eq(0)
2522
+ .invoke("text")
2523
+ .then((text) => {
2524
+ expect(text.trim()).equal("p,q");
2525
+ });
2526
+ cy.get(cesc("#\\/_p3")).find(".mjx-mrow").should("not.exist");
2527
+
2528
+ cy.log("Test internal values are set to the correct values");
2529
+ cy.window().then(async (win) => {
2530
+ let stateVariables = await win.returnAllStateVariables1();
2531
+ expect(stateVariables["/_mathlist1"].stateValues.maths.length).eq(4);
2532
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("l");
2533
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eqls([
2534
+ "list",
2535
+ "m",
2536
+ "n",
2537
+ "o",
2538
+ ]);
2539
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eqls([
2540
+ "list",
2541
+ "p",
2542
+ "q",
2543
+ ]);
2544
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq("r");
2545
+ expect(stateVariables["/_mathlist1"].stateValues.math3).eqls([
2546
+ "list",
2547
+ "p",
2548
+ "q",
2549
+ ]);
2550
+ expect(stateVariables["/_mathlist1"].stateValues.math5).eq(undefined);
2551
+ });
2552
+ });
2553
+
2554
+ it("always merge math lists when have one math child", () => {
2555
+ cy.window().then(async (win) => {
2556
+ win.postMessage(
2557
+ {
2558
+ doenetML: `
2559
+ <text>a</text>
2560
+ <mathlist>
2561
+ <math>a,b,c,d,e</math>
2562
+ </mathlist>
2563
+
2564
+ <p>Third math: <copy prop="math3" target="_mathlist1" /></p>
2565
+ <p>Fifth math: <copy prop="math5" target="_mathlist1" /></p>
2566
+
2567
+ <p>Change values:
2568
+ <mathinput name="mi1" bindValueTo="$_mathlist1.math1" />
2569
+ <mathinput name="mi2" bindValueTo="$_mathlist1.math2" />
2570
+ <mathinput name="mi3" bindValueTo="$_mathlist1.math3" />
2571
+ <mathinput name="mi4" bindValueTo="$_mathlist1.math4" />
2572
+ <mathinput name="mi5" bindValueTo="$_mathlist1.math5" />
2573
+ </p>
2574
+ `,
2575
+ },
2576
+ "*",
2577
+ );
2578
+ });
2579
+
2580
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
2581
+
2582
+ cy.log("Test value displayed in browser");
2583
+ cy.get(cesc("#\\/_math1"))
2584
+ .find(".mjx-mrow")
2585
+ .eq(0)
2586
+ .invoke("text")
2587
+ .then((text) => {
2588
+ expect(text.trim()).equal("a,b,c,d,e");
2589
+ });
2590
+ cy.get(cesc("#\\/_p1"))
2591
+ .find(".mjx-mrow")
2592
+ .eq(0)
2593
+ .invoke("text")
2594
+ .then((text) => {
2595
+ expect(text.trim()).equal("c");
2596
+ });
2597
+ cy.get(cesc("#\\/_p2"))
2598
+ .find(".mjx-mrow")
2599
+ .eq(0)
2600
+ .invoke("text")
2601
+ .then((text) => {
2602
+ expect(text.trim()).equal("e");
2603
+ });
2604
+
2605
+ cy.log("Test internal values are set to the correct values");
2606
+ cy.window().then(async (win) => {
2607
+ let stateVariables = await win.returnAllStateVariables1();
2608
+ expect(stateVariables["/_mathlist1"].stateValues.maths.length).eq(5);
2609
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("a");
2610
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq("b");
2611
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eq("c");
2612
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq("d");
2613
+ expect(stateVariables["/_mathlist1"].stateValues.maths[4]).eq("e");
2614
+ expect(stateVariables["/_mathlist1"].stateValues.math3).eq("c");
2615
+ expect(stateVariables["/_mathlist1"].stateValues.math5).eq("e");
2616
+ });
2617
+
2618
+ cy.log("change values");
2619
+ cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}f{enter}", {
2620
+ force: true,
2621
+ });
2622
+ cy.get(cesc("#\\/mi2") + " textarea").type("{end}{backspace}g{enter}", {
2623
+ force: true,
2624
+ });
2625
+ cy.get(cesc("#\\/mi3") + " textarea").type("{end}{backspace}h{enter}", {
2626
+ force: true,
2627
+ });
2628
+ cy.get(cesc("#\\/mi4") + " textarea").type("{end}{backspace}i{enter}", {
2629
+ force: true,
2630
+ });
2631
+ cy.get(cesc("#\\/mi5") + " textarea").type("{end}{backspace}j{enter}", {
2632
+ force: true,
2633
+ });
2634
+
2635
+ cy.log("Test value displayed in browser");
2636
+
2637
+ cy.get(cesc("#\\/_p2") + " .mjx-mrow").should("contain.text", "j");
2638
+ cy.get(cesc("#\\/_math1"))
2639
+ .find(".mjx-mrow")
2640
+ .eq(0)
2641
+ .invoke("text")
2642
+ .then((text) => {
2643
+ expect(text.trim()).equal("f,g,h,i,j");
2644
+ });
2645
+ cy.get(cesc("#\\/_p1"))
2646
+ .find(".mjx-mrow")
2647
+ .eq(0)
2648
+ .invoke("text")
2649
+ .then((text) => {
2650
+ expect(text.trim()).equal("h");
2651
+ });
2652
+ cy.get(cesc("#\\/_p2"))
2653
+ .find(".mjx-mrow")
2654
+ .eq(0)
2655
+ .invoke("text")
2656
+ .then((text) => {
2657
+ expect(text.trim()).equal("j");
2658
+ });
2659
+
2660
+ cy.log("Test internal values are set to the correct values");
2661
+ cy.window().then(async (win) => {
2662
+ let stateVariables = await win.returnAllStateVariables1();
2663
+ expect(stateVariables["/_mathlist1"].stateValues.maths.length).eq(5);
2664
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("f");
2665
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq("g");
2666
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eq("h");
2667
+ expect(stateVariables["/_mathlist1"].stateValues.maths[3]).eq("i");
2668
+ expect(stateVariables["/_mathlist1"].stateValues.maths[4]).eq("j");
2669
+ expect(stateVariables["/_mathlist1"].stateValues.math3).eq("h");
2670
+ expect(stateVariables["/_mathlist1"].stateValues.math5).eq("j");
2671
+ });
2672
+ });
2673
+
2674
+ // TODO: deal with hidden children of a mathlist
2675
+ it("mathlist within mathlists, with child hide", () => {
2676
+ cy.window().then(async (win) => {
2677
+ win.postMessage(
2678
+ {
2679
+ doenetML: `
2680
+ <text>a</text>
2681
+ <p><mathlist hide="true">a b c</mathlist></p>
2682
+
2683
+ <p><copy name="mathlist1a" hide="false" target="_mathlist1" /></p>
2684
+
2685
+ <p><mathlist>
2686
+ <math>x</math>
2687
+ <copy target="_mathlist1" hide="false" />
2688
+ <math hide>y</math>
2689
+ <copy target="mathlist1a" />
2690
+ </mathlist></p>
2691
+
2692
+ <p><copy name="mathlist3" maxNumber="6" target="_mathlist2" /></p>
2693
+
2694
+ `,
2695
+ },
2696
+ "*",
2697
+ );
2698
+ });
2699
+
2700
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
2701
+
2702
+ cy.log("Test value displayed in browser");
2703
+
2704
+ cy.get(cesc("#\\/_p1")).should("have.text", "");
2705
+
2706
+ cy.get(cesc("#\\/_p2"))
2707
+ .find(".mjx-mrow")
2708
+ .eq(0)
2709
+ .invoke("text")
2710
+ .then((text) => {
2711
+ expect(text.trim()).equal("a");
2712
+ });
2713
+ cy.get(cesc("#\\/_p2"))
2714
+ .find(".mjx-mrow")
2715
+ .eq(1)
2716
+ .invoke("text")
2717
+ .then((text) => {
2718
+ expect(text.trim()).equal("b");
2719
+ });
2720
+ cy.get(cesc("#\\/_p2"))
2721
+ .find(".mjx-mrow")
2722
+ .eq(2)
2723
+ .invoke("text")
2724
+ .then((text) => {
2725
+ expect(text.trim()).equal("c");
2726
+ });
2727
+ cy.get(cesc("#\\/_p2")).find(".mjx-mrow").eq(3).should("not.exist");
2728
+
2729
+ cy.get(cesc("#\\/_p3"))
2730
+ .find(".mjx-mrow")
2731
+ .eq(0)
2732
+ .invoke("text")
2733
+ .then((text) => {
2734
+ expect(text.trim()).equal("x");
2735
+ });
2736
+ cy.get(cesc("#\\/_p3"))
2737
+ .find(".mjx-mrow")
2738
+ .eq(1)
2739
+ .invoke("text")
2740
+ .then((text) => {
2741
+ expect(text.trim()).equal("a");
2742
+ });
2743
+ cy.get(cesc("#\\/_p3"))
2744
+ .find(".mjx-mrow")
2745
+ .eq(2)
2746
+ .invoke("text")
2747
+ .then((text) => {
2748
+ expect(text.trim()).equal("b");
2749
+ });
2750
+ cy.get(cesc("#\\/_p3"))
2751
+ .find(".mjx-mrow")
2752
+ .eq(3)
2753
+ .invoke("text")
2754
+ .then((text) => {
2755
+ expect(text.trim()).equal("c");
2756
+ });
2757
+ cy.get(cesc("#\\/_p3"))
2758
+ .find(".mjx-mrow")
2759
+ .eq(4)
2760
+ .invoke("text")
2761
+ .then((text) => {
2762
+ expect(text.trim()).equal("a");
2763
+ });
2764
+ cy.get(cesc("#\\/_p3"))
2765
+ .find(".mjx-mrow")
2766
+ .eq(5)
2767
+ .invoke("text")
2768
+ .then((text) => {
2769
+ expect(text.trim()).equal("b");
2770
+ });
2771
+ cy.get(cesc("#\\/_p3"))
2772
+ .find(".mjx-mrow")
2773
+ .eq(6)
2774
+ .invoke("text")
2775
+ .then((text) => {
2776
+ expect(text.trim()).equal("c");
2777
+ });
2778
+ cy.get(cesc("#\\/_p3")).find(".mjx-mrow").eq(7).should("not.exist");
2779
+
2780
+ cy.get(cesc("#\\/_p4"))
2781
+ .find(".mjx-mrow")
2782
+ .eq(0)
2783
+ .invoke("text")
2784
+ .then((text) => {
2785
+ expect(text.trim()).equal("x");
2786
+ });
2787
+ cy.get(cesc("#\\/_p4"))
2788
+ .find(".mjx-mrow")
2789
+ .eq(1)
2790
+ .invoke("text")
2791
+ .then((text) => {
2792
+ expect(text.trim()).equal("a");
2793
+ });
2794
+ cy.get(cesc("#\\/_p4"))
2795
+ .find(".mjx-mrow")
2796
+ .eq(2)
2797
+ .invoke("text")
2798
+ .then((text) => {
2799
+ expect(text.trim()).equal("b");
2800
+ });
2801
+ cy.get(cesc("#\\/_p4"))
2802
+ .find(".mjx-mrow")
2803
+ .eq(3)
2804
+ .invoke("text")
2805
+ .then((text) => {
2806
+ expect(text.trim()).equal("c");
2807
+ });
2808
+ cy.get(cesc("#\\/_p4"))
2809
+ .find(".mjx-mrow")
2810
+ .eq(4)
2811
+ .invoke("text")
2812
+ .then((text) => {
2813
+ expect(text.trim()).equal("a");
2814
+ });
2815
+ cy.get(cesc("#\\/_p4")).find(".mjx-mrow").eq(5).should("not.exist");
2816
+
2817
+ cy.log("Test internal values are set to the correct values");
2818
+ cy.window().then(async (win) => {
2819
+ let stateVariables = await win.returnAllStateVariables1();
2820
+ let mathlist1a =
2821
+ stateVariables[
2822
+ stateVariables["/mathlist1a"].replacements[0].componentName
2823
+ ];
2824
+ let mathlist3 =
2825
+ stateVariables[
2826
+ stateVariables["/mathlist3"].replacements[0].componentName
2827
+ ];
2828
+ expect(stateVariables["/_mathlist1"].stateValues.maths.length).eq(3);
2829
+ expect(stateVariables["/_mathlist1"].stateValues.maths[0]).eq("a");
2830
+ expect(stateVariables["/_mathlist1"].stateValues.maths[1]).eq("b");
2831
+ expect(stateVariables["/_mathlist1"].stateValues.maths[2]).eq("c");
2832
+ expect((await mathlist1a.stateValues.maths).length).eq(3);
2833
+ expect((await mathlist1a.stateValues.maths)[0]).eq("a");
2834
+ expect((await mathlist1a.stateValues.maths)[1]).eq("b");
2835
+ expect((await mathlist1a.stateValues.maths)[2]).eq("c");
2836
+ expect(stateVariables["/_mathlist2"].stateValues.maths.length).eq(8);
2837
+ expect(stateVariables["/_mathlist2"].stateValues.maths[0]).eq("x");
2838
+ expect(stateVariables["/_mathlist2"].stateValues.maths[1]).eq("a");
2839
+ expect(stateVariables["/_mathlist2"].stateValues.maths[2]).eq("b");
2840
+ expect(stateVariables["/_mathlist2"].stateValues.maths[3]).eq("c");
2841
+ expect(stateVariables["/_mathlist2"].stateValues.maths[4]).eq("y");
2842
+ expect(stateVariables["/_mathlist2"].stateValues.maths[5]).eq("a");
2843
+ expect(stateVariables["/_mathlist2"].stateValues.maths[6]).eq("b");
2844
+ expect(stateVariables["/_mathlist2"].stateValues.maths[7]).eq("c");
2845
+ expect((await mathlist3.stateValues.maths).length).eq(6);
2846
+ expect((await mathlist3.stateValues.maths)[0]).eq("x");
2847
+ expect((await mathlist3.stateValues.maths)[1]).eq("a");
2848
+ expect((await mathlist3.stateValues.maths)[2]).eq("b");
2849
+ expect((await mathlist3.stateValues.maths)[3]).eq("c");
2850
+ expect((await mathlist3.stateValues.maths)[4]).eq("y");
2851
+ expect((await mathlist3.stateValues.maths)[5]).eq("a");
2852
+ });
2853
+ });
2854
+
2855
+ it("mathlist does not force composite replacement, even in boolean", () => {
2856
+ cy.window().then(async (win) => {
2857
+ win.postMessage(
2858
+ {
2859
+ doenetML: `
2860
+ <text>a</text>
2861
+ <boolean>
2862
+ <mathlist>$nothing</mathlist> = <mathlist></mathlist>
2863
+ </boolean>
2864
+ `,
2865
+ },
2866
+ "*",
2867
+ );
2868
+ });
2869
+
2870
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
2871
+
2872
+ cy.log("Test value displayed in browser");
2873
+ cy.get(cesc("#\\/_boolean1")).should("have.text", "true");
2874
+ });
2875
+
2876
+ it("mathlist and rounding, from strings", () => {
2877
+ cy.window().then(async (win) => {
2878
+ win.postMessage(
2879
+ {
2880
+ doenetML: `
2881
+ <text>a</text>
2882
+ <p><mathlist displayDigits="4" ignoreDisplayDecimals>2345.1535268 3.52343 0.5 0.00000000000052523 0.000000000000000000006</mathList></p>
2883
+ <p><mathlist displayDigits="4" ignoreDisplayDecimals padZeros>2345.1535268 3.52343 0.5 0.00000000000052523 0.000000000000000000006</mathList></p>
2884
+ <p><mathlist displayDecimals="3" ignoreDisplayDigits>2345.1535268 3.52343 0.5 0.00000000000052523 0.000000000000000000006</mathList></p>
2885
+ <p><mathlist displayDecimals="3" ignoreDisplayDigits padZeros>2345.1535268 3.52343 0.5 0.00000000000052523 0.000000000000000000006</mathList></p>
2886
+ <p><mathlist displayDecimals="4" displaySmallAsZero="false">2345.1535268 3.52343 0.5 0.00000000000052523 0.000000000000000000006</mathList></p>
2887
+ <p><mathlist displayDecimals="4" displaySmallAsZero="false" padZeros>2345.1535268 3.52343 0.5 0.00000000000052523 0.000000000000000000006</mathList></p>
2888
+
2889
+ <p><mathlist name="ml1a" copySource="_mathlist1" /></p>
2890
+ <p><mathlist name="ml2a" copySource="_mathlist2" /></p>
2891
+ <p><mathlist name="ml3a" copySource="_mathlist3" /></p>
2892
+ <p><mathlist name="ml4a" copySource="_mathlist4" /></p>
2893
+ <p><mathlist name="ml5a" copySource="_mathlist5" /></p>
2894
+ <p><mathlist name="ml6a" copySource="_mathlist6" /></p>
2895
+
2896
+ <p name="pms1"><copy source="_mathlist1.maths" assignNames="m1_1 m1_2 m1_3 m1_4 m1_5" /></p>
2897
+ <p name="pms2"><copy source="_mathlist2.maths" assignNames="m2_1 m2_2 m2_3 m2_4 m2_5" /></p>
2898
+ <p name="pms3"><copy source="_mathlist3.maths" assignNames="m3_1 m3_2 m3_3 m3_4 m3_5" /></p>
2899
+ <p name="pms4"><copy source="_mathlist4.maths" assignNames="m4_1 m4_2 m4_3 m4_4 m4_5" /></p>
2900
+ <p name="pms5"><copy source="_mathlist5.maths" assignNames="m5_1 m5_2 m5_3 m5_4 m5_5" /></p>
2901
+ <p name="pms6"><copy source="_mathlist6.maths" assignNames="m6_1 m6_2 m6_3 m6_4 m6_5" /></p>
2902
+
2903
+ <p><mathlist name="ml1b" copySource="_mathlist1" link="false" /></p>
2904
+ <p><mathlist name="ml2b" copySource="_mathlist2" link="false" /></p>
2905
+ <p><mathlist name="ml3b" copySource="_mathlist3" link="false" /></p>
2906
+ <p><mathlist name="ml4b" copySource="_mathlist4" link="false" /></p>
2907
+ <p><mathlist name="ml5b" copySource="_mathlist5" link="false" /></p>
2908
+ <p><mathlist name="ml6b" copySource="_mathlist6" link="false" /></p>
2909
+
2910
+ <p name="pms1a"><copy source="_mathlist1.maths" assignNames="m1_1a m1_2a m1_3a m1_4a m1_5a" link="false" /></p>
2911
+ <p name="pms2a"><copy source="_mathlist2.maths" assignNames="m2_1a m2_2a m2_3a m2_4a m2_5a" link="false" /></p>
2912
+ <p name="pms3a"><copy source="_mathlist3.maths" assignNames="m3_1a m3_2a m3_3a m3_4a m3_5a" link="false" /></p>
2913
+ <p name="pms4a"><copy source="_mathlist4.maths" assignNames="m4_1a m4_2a m4_3a m4_4a m4_5a" link="false" /></p>
2914
+ <p name="pms5a"><copy source="_mathlist5.maths" assignNames="m5_1a m5_2a m5_3a m5_4a m5_5a" link="false" /></p>
2915
+ <p name="pms6a"><copy source="_mathlist6.maths" assignNames="m6_1a m6_2a m6_3a m6_4a m6_5a" link="false" /></p>
2916
+
2917
+ `,
2918
+ },
2919
+ "*",
2920
+ );
2921
+ });
2922
+
2923
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
2924
+
2925
+ cy.window().then(async (win) => {
2926
+ let stateVariables = await win.returnAllStateVariables1();
2927
+ for (let i = 0; i < 5; i++) {
2928
+ let maths1, maths2, maths3, maths4, maths5, maths6;
2929
+
2930
+ if (i === 0) {
2931
+ maths1 = stateVariables["/_mathlist1"].activeChildren.map(
2932
+ (x) => x.componentName,
2933
+ );
2934
+ maths2 = stateVariables["/_mathlist2"].activeChildren.map(
2935
+ (x) => x.componentName,
2936
+ );
2937
+ maths3 = stateVariables["/_mathlist3"].activeChildren.map(
2938
+ (x) => x.componentName,
2939
+ );
2940
+ maths4 = stateVariables["/_mathlist4"].activeChildren.map(
2941
+ (x) => x.componentName,
2942
+ );
2943
+ maths5 = stateVariables["/_mathlist5"].activeChildren.map(
2944
+ (x) => x.componentName,
2945
+ );
2946
+ maths6 = stateVariables["/_mathlist6"].activeChildren.map(
2947
+ (x) => x.componentName,
2948
+ );
2949
+ } else if (i === 1) {
2950
+ maths1 = stateVariables["/ml1a"].activeChildren.map(
2951
+ (x) => x.componentName,
2952
+ );
2953
+ maths2 = stateVariables["/ml2a"].activeChildren.map(
2954
+ (x) => x.componentName,
2955
+ );
2956
+ maths3 = stateVariables["/ml3a"].activeChildren.map(
2957
+ (x) => x.componentName,
2958
+ );
2959
+ maths4 = stateVariables["/ml4a"].activeChildren.map(
2960
+ (x) => x.componentName,
2961
+ );
2962
+ maths5 = stateVariables["/ml5a"].activeChildren.map(
2963
+ (x) => x.componentName,
2964
+ );
2965
+ maths6 = stateVariables["/ml6a"].activeChildren.map(
2966
+ (x) => x.componentName,
2967
+ );
2968
+ } else if (i === 2) {
2969
+ maths1 = stateVariables["/pms1"].activeChildren.map(
2970
+ (x) => x.componentName,
2971
+ );
2972
+ maths2 = stateVariables["/pms2"].activeChildren.map(
2973
+ (x) => x.componentName,
2974
+ );
2975
+ maths3 = stateVariables["/pms3"].activeChildren.map(
2976
+ (x) => x.componentName,
2977
+ );
2978
+ maths4 = stateVariables["/pms4"].activeChildren.map(
2979
+ (x) => x.componentName,
2980
+ );
2981
+ maths5 = stateVariables["/pms5"].activeChildren.map(
2982
+ (x) => x.componentName,
2983
+ );
2984
+ maths6 = stateVariables["/pms6"].activeChildren.map(
2985
+ (x) => x.componentName,
2986
+ );
2987
+ } else if (i === 3) {
2988
+ maths1 = stateVariables["/ml1b"].activeChildren.map(
2989
+ (x) => x.componentName,
2990
+ );
2991
+ maths2 = stateVariables["/ml2b"].activeChildren.map(
2992
+ (x) => x.componentName,
2993
+ );
2994
+ maths3 = stateVariables["/ml3b"].activeChildren.map(
2995
+ (x) => x.componentName,
2996
+ );
2997
+ maths4 = stateVariables["/ml4b"].activeChildren.map(
2998
+ (x) => x.componentName,
2999
+ );
3000
+ maths5 = stateVariables["/ml5b"].activeChildren.map(
3001
+ (x) => x.componentName,
3002
+ );
3003
+ maths6 = stateVariables["/ml6b"].activeChildren.map(
3004
+ (x) => x.componentName,
3005
+ );
3006
+ } else {
3007
+ maths1 = stateVariables["/pms1a"].activeChildren.map(
3008
+ (x) => x.componentName,
3009
+ );
3010
+ maths2 = stateVariables["/pms2a"].activeChildren.map(
3011
+ (x) => x.componentName,
3012
+ );
3013
+ maths3 = stateVariables["/pms3a"].activeChildren.map(
3014
+ (x) => x.componentName,
3015
+ );
3016
+ maths4 = stateVariables["/pms4a"].activeChildren.map(
3017
+ (x) => x.componentName,
3018
+ );
3019
+ maths5 = stateVariables["/pms5a"].activeChildren.map(
3020
+ (x) => x.componentName,
3021
+ );
3022
+ maths6 = stateVariables["/pms6a"].activeChildren.map(
3023
+ (x) => x.componentName,
3024
+ );
3025
+ }
3026
+
3027
+ cy.get(cesc2("#" + maths1[0]) + " .mjx-mrow")
3028
+ .eq(0)
3029
+ .invoke("text")
3030
+ .then((text) => {
3031
+ expect(text).eq("2345");
3032
+ });
3033
+ cy.get(cesc2("#" + maths1[1]) + " .mjx-mrow")
3034
+ .eq(0)
3035
+ .invoke("text")
3036
+ .then((text) => {
3037
+ expect(text).eq("3.523");
3038
+ });
3039
+ cy.get(cesc2("#" + maths1[2]) + " .mjx-mrow")
3040
+ .eq(0)
3041
+ .invoke("text")
3042
+ .then((text) => {
3043
+ expect(text).eq("0.5");
3044
+ });
3045
+ cy.get(cesc2("#" + maths1[3]) + " .mjx-mrow")
3046
+ .eq(0)
3047
+ .invoke("text")
3048
+ .then((text) => {
3049
+ expect(text).eq("5.252⋅10−13");
3050
+ });
3051
+ cy.get(cesc2("#" + maths1[4]) + " .mjx-mrow")
3052
+ .eq(0)
3053
+ .invoke("text")
3054
+ .then((text) => {
3055
+ expect(text).eq("0");
3056
+ });
3057
+
3058
+ cy.get(cesc2("#" + maths2[0]) + " .mjx-mrow")
3059
+ .eq(0)
3060
+ .invoke("text")
3061
+ .then((text) => {
3062
+ expect(text).eq("2345");
3063
+ });
3064
+ cy.get(cesc2("#" + maths2[1]) + " .mjx-mrow")
3065
+ .eq(0)
3066
+ .invoke("text")
3067
+ .then((text) => {
3068
+ expect(text).eq("3.523");
3069
+ });
3070
+ cy.get(cesc2("#" + maths2[2]) + " .mjx-mrow")
3071
+ .eq(0)
3072
+ .invoke("text")
3073
+ .then((text) => {
3074
+ expect(text).eq("0.5000");
3075
+ });
3076
+ cy.get(cesc2("#" + maths2[3]) + " .mjx-mrow")
3077
+ .eq(0)
3078
+ .invoke("text")
3079
+ .then((text) => {
3080
+ expect(text).eq("5.252⋅10−13");
3081
+ });
3082
+ cy.get(cesc2("#" + maths2[4]) + " .mjx-mrow")
3083
+ .eq(0)
3084
+ .invoke("text")
3085
+ .then((text) => {
3086
+ expect(text).eq("0.000");
3087
+ });
3088
+
3089
+ cy.get(cesc2("#" + maths3[0]) + " .mjx-mrow")
3090
+ .eq(0)
3091
+ .invoke("text")
3092
+ .then((text) => {
3093
+ expect(text).eq("2345.154");
3094
+ });
3095
+ cy.get(cesc2("#" + maths3[1]) + " .mjx-mrow")
3096
+ .eq(0)
3097
+ .invoke("text")
3098
+ .then((text) => {
3099
+ expect(text).eq("3.523");
3100
+ });
3101
+ cy.get(cesc2("#" + maths3[2]) + " .mjx-mrow")
3102
+ .eq(0)
3103
+ .invoke("text")
3104
+ .then((text) => {
3105
+ expect(text).eq("0.5");
3106
+ });
3107
+ cy.get(cesc2("#" + maths3[3]) + " .mjx-mrow")
3108
+ .eq(0)
3109
+ .invoke("text")
3110
+ .then((text) => {
3111
+ expect(text).eq("0");
3112
+ });
3113
+ cy.get(cesc2("#" + maths3[4]) + " .mjx-mrow")
3114
+ .eq(0)
3115
+ .invoke("text")
3116
+ .then((text) => {
3117
+ expect(text).eq("0");
3118
+ });
3119
+
3120
+ cy.get(cesc2("#" + maths4[0]) + " .mjx-mrow")
3121
+ .eq(0)
3122
+ .invoke("text")
3123
+ .then((text) => {
3124
+ expect(text).eq("2345.154");
3125
+ });
3126
+ cy.get(cesc2("#" + maths4[1]) + " .mjx-mrow")
3127
+ .eq(0)
3128
+ .invoke("text")
3129
+ .then((text) => {
3130
+ expect(text).eq("3.523");
3131
+ });
3132
+ cy.get(cesc2("#" + maths4[2]) + " .mjx-mrow")
3133
+ .eq(0)
3134
+ .invoke("text")
3135
+ .then((text) => {
3136
+ expect(text).eq("0.500");
3137
+ });
3138
+ cy.get(cesc2("#" + maths4[3]) + " .mjx-mrow")
3139
+ .eq(0)
3140
+ .invoke("text")
3141
+ .then((text) => {
3142
+ expect(text).eq("0.000");
3143
+ });
3144
+ cy.get(cesc2("#" + maths4[4]) + " .mjx-mrow")
3145
+ .eq(0)
3146
+ .invoke("text")
3147
+ .then((text) => {
3148
+ expect(text).eq("0.000");
3149
+ });
3150
+
3151
+ cy.get(cesc2("#" + maths5[0]) + " .mjx-mrow")
3152
+ .eq(0)
3153
+ .invoke("text")
3154
+ .then((text) => {
3155
+ expect(text).eq("2345.1535");
3156
+ });
3157
+ cy.get(cesc2("#" + maths5[1]) + " .mjx-mrow")
3158
+ .eq(0)
3159
+ .invoke("text")
3160
+ .then((text) => {
3161
+ expect(text).eq("3.5234");
3162
+ });
3163
+ cy.get(cesc2("#" + maths5[2]) + " .mjx-mrow")
3164
+ .eq(0)
3165
+ .invoke("text")
3166
+ .then((text) => {
3167
+ expect(text).eq("0.5");
3168
+ });
3169
+ cy.get(cesc2("#" + maths5[3]) + " .mjx-mrow")
3170
+ .eq(0)
3171
+ .invoke("text")
3172
+ .then((text) => {
3173
+ expect(text).eq("5.25⋅10−13");
3174
+ });
3175
+ cy.get(cesc2("#" + maths5[4]) + " .mjx-mrow")
3176
+ .eq(0)
3177
+ .invoke("text")
3178
+ .then((text) => {
3179
+ expect(text).eq("6⋅10−21");
3180
+ });
3181
+
3182
+ cy.get(cesc2("#" + maths6[0]) + " .mjx-mrow")
3183
+ .eq(0)
3184
+ .invoke("text")
3185
+ .then((text) => {
3186
+ expect(text).eq("2345.1535");
3187
+ });
3188
+ cy.get(cesc2("#" + maths6[1]) + " .mjx-mrow")
3189
+ .eq(0)
3190
+ .invoke("text")
3191
+ .then((text) => {
3192
+ expect(text).eq("3.5234");
3193
+ });
3194
+ cy.get(cesc2("#" + maths6[2]) + " .mjx-mrow")
3195
+ .eq(0)
3196
+ .invoke("text")
3197
+ .then((text) => {
3198
+ expect(text).eq("0.5000");
3199
+ });
3200
+ cy.get(cesc2("#" + maths6[3]) + " .mjx-mrow")
3201
+ .eq(0)
3202
+ .invoke("text")
3203
+ .then((text) => {
3204
+ expect(text).eq("5.25⋅10−13");
3205
+ });
3206
+ cy.get(cesc2("#" + maths6[4]) + " .mjx-mrow")
3207
+ .eq(0)
3208
+ .invoke("text")
3209
+ .then((text) => {
3210
+ expect(text).eq("6.00⋅10−21");
3211
+ });
3212
+ }
3213
+ });
3214
+ });
3215
+
3216
+ it("mathlist and rounding, override math children", () => {
3217
+ cy.window().then(async (win) => {
3218
+ win.postMessage(
3219
+ {
3220
+ doenetML: `
3221
+ <text>a</text>
3222
+ <p><mathlist name="ml1">
3223
+ <math displayDigits="5" ignoreDisplayDecimals>2345.1535268</math>
3224
+ <math displayDecimals="4">3.52343</math>
3225
+ <math displayDigits="5" padZeros>5</math>
3226
+ <math displaySmallAsZero="false">0.00000000000000052523</math>
3227
+ <math>0.000000000000000000006</math>
3228
+ </mathList></p>
3229
+ <p><mathlist name="ml2" displayDigits="4">
3230
+ <math displayDigits="5" ignoreDisplayDecimals>2345.1535268</math>
3231
+ <math displayDecimals="4">3.52343</math>
3232
+ <math displayDigits="5" padZeros>5</math>
3233
+ <math displaySmallAsZero="false">0.00000000000000052523</math>
3234
+ <math>0.000000000000000000006</math>
3235
+ </mathList></p>
3236
+ <p><mathlist name="ml3" displayDigits="4" padZeros>
3237
+ <math displayDigits="5" ignoreDisplayDecimals>2345.1535268</math>
3238
+ <math displayDecimals="4">3.52343</math>
3239
+ <math displayDigits="5" padZeros>5</math>
3240
+ <math displaySmallAsZero="false">0.00000000000000052523</math>
3241
+ <math>0.000000000000000000006</math>
3242
+ </mathList></p>
3243
+ <p><mathlist name="ml4" displayDigits="4" padZeros="false">
3244
+ <math displayDigits="5" ignoreDisplayDecimals>2345.1535268</math>
3245
+ <math displayDecimals="4">3.52343</math>
3246
+ <math displayDigits="5" padZeros>5</math>
3247
+ <math displaySmallAsZero="false">0.00000000000000052523</math>
3248
+ <math>0.000000000000000000006</math>
3249
+ </mathList></p>
3250
+ <p><mathlist name="ml5" displayDecimals="4" ignoreDisplayDigits>
3251
+ <math displayDigits="5" ignoreDisplayDecimals>2345.1535268</math>
3252
+ <math displayDecimals="4">3.52343</math>
3253
+ <math displayDigits="5" padZeros>5</math>
3254
+ <math displaySmallAsZero="false">0.00000000000000052523</math>
3255
+ <math>0.000000000000000000006</math>
3256
+ </mathList></p>
3257
+ <p><mathlist name="ml6" displayDecimals="4" ignoreDisplayDigits padZeros>
3258
+ <math displayDigits="5" ignoreDisplayDecimals>2345.1535268</math>
3259
+ <math displayDecimals="4">3.52343</math>
3260
+ <math displayDigits="5" padZeros>5</math>
3261
+ <math displaySmallAsZero="false">0.00000000000000052523</math>
3262
+ <math>0.000000000000000000006</math>
3263
+ </mathList></p>
3264
+ <p><mathlist name="ml7" displayDecimals="4" ignoreDisplayDigits padZeros="false">
3265
+ <math displayDigits="5" ignoreDisplayDecimals>2345.1535268</math>
3266
+ <math displayDecimals="4">3.52343</math>
3267
+ <math displayDigits="5" padZeros>5</math>
3268
+ <math displaySmallAsZero="false">0.00000000000000052523</math>
3269
+ <math>0.000000000000000000006</math>
3270
+ </mathList></p>
3271
+ <p><mathlist name="ml8" displayDigits="4" displaySmallAsZero>
3272
+ <math displayDigits="5" ignoreDisplayDecimals>2345.1535268</math>
3273
+ <math displayDecimals="4">3.52343</math>
3274
+ <math displayDigits="5" padZeros>5</math>
3275
+ <math displaySmallAsZero="false">0.00000000000000052523</math>
3276
+ <math>0.000000000000000000006</math>
3277
+ </mathList></p>
3278
+ <p><mathlist name="ml9" displayDigits="4" displaySmallAsZero="false">
3279
+ <math displayDigits="5" ignoreDisplayDecimals>2345.1535268</math>
3280
+ <math displayDecimals="4">3.52343</math>
3281
+ <math displayDigits="5" padZeros>5</math>
3282
+ <math displaySmallAsZero="false">0.00000000000000052523</math>
3283
+ <math>0.000000000000000000006</math>
3284
+ </mathList></p>
3285
+ `,
3286
+ },
3287
+ "*",
3288
+ );
3289
+ });
3290
+
3291
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
3292
+
3293
+ cy.window().then(async (win) => {
3294
+ let stateVariables = await win.returnAllStateVariables1();
3295
+
3296
+ let maths1 = stateVariables["/ml1"].activeChildren.map(
3297
+ (x) => x.componentName,
3298
+ );
3299
+ let maths2 = stateVariables["/ml2"].activeChildren.map(
3300
+ (x) => x.componentName,
3301
+ );
3302
+ let maths3 = stateVariables["/ml3"].activeChildren.map(
3303
+ (x) => x.componentName,
3304
+ );
3305
+ let maths4 = stateVariables["/ml4"].activeChildren.map(
3306
+ (x) => x.componentName,
3307
+ );
3308
+ let maths5 = stateVariables["/ml5"].activeChildren.map(
3309
+ (x) => x.componentName,
3310
+ );
3311
+ let maths6 = stateVariables["/ml6"].activeChildren.map(
3312
+ (x) => x.componentName,
3313
+ );
3314
+ let maths7 = stateVariables["/ml7"].activeChildren.map(
3315
+ (x) => x.componentName,
3316
+ );
3317
+ let maths8 = stateVariables["/ml8"].activeChildren.map(
3318
+ (x) => x.componentName,
3319
+ );
3320
+ let maths9 = stateVariables["/ml9"].activeChildren.map(
3321
+ (x) => x.componentName,
3322
+ );
3323
+
3324
+ cy.get(cesc2("#" + maths1[0]) + " .mjx-mrow")
3325
+ .eq(0)
3326
+ .invoke("text")
3327
+ .then((text) => {
3328
+ expect(text).eq("2345.2");
3329
+ });
3330
+ cy.get(cesc2("#" + maths1[1]) + " .mjx-mrow")
3331
+ .eq(0)
3332
+ .invoke("text")
3333
+ .then((text) => {
3334
+ expect(text).eq("3.5234");
3335
+ });
3336
+ cy.get(cesc2("#" + maths1[2]) + " .mjx-mrow")
3337
+ .eq(0)
3338
+ .invoke("text")
3339
+ .then((text) => {
3340
+ expect(text).eq("5.0000");
3341
+ });
3342
+ cy.get(cesc2("#" + maths1[3]) + " .mjx-mrow")
3343
+ .eq(0)
3344
+ .invoke("text")
3345
+ .then((text) => {
3346
+ expect(text).eq("5.25⋅10−16");
3347
+ });
3348
+ cy.get(cesc2("#" + maths1[4]) + " .mjx-mrow")
3349
+ .eq(0)
3350
+ .invoke("text")
3351
+ .then((text) => {
3352
+ expect(text).eq("0");
3353
+ });
3354
+
3355
+ cy.get(cesc2("#" + maths2[0]) + " .mjx-mrow")
3356
+ .eq(0)
3357
+ .invoke("text")
3358
+ .then((text) => {
3359
+ expect(text).eq("2345");
3360
+ });
3361
+ cy.get(cesc2("#" + maths2[1]) + " .mjx-mrow")
3362
+ .eq(0)
3363
+ .invoke("text")
3364
+ .then((text) => {
3365
+ expect(text).eq("3.5234");
3366
+ });
3367
+ cy.get(cesc2("#" + maths2[2]) + " .mjx-mrow")
3368
+ .eq(0)
3369
+ .invoke("text")
3370
+ .then((text) => {
3371
+ expect(text).eq("5.000");
3372
+ });
3373
+ cy.get(cesc2("#" + maths2[3]) + " .mjx-mrow")
3374
+ .eq(0)
3375
+ .invoke("text")
3376
+ .then((text) => {
3377
+ expect(text).eq("5.252⋅10−16");
3378
+ });
3379
+ cy.get(cesc2("#" + maths2[4]) + " .mjx-mrow")
3380
+ .eq(0)
3381
+ .invoke("text")
3382
+ .then((text) => {
3383
+ expect(text).eq("0");
3384
+ });
3385
+
3386
+ cy.get(cesc2("#" + maths3[0]) + " .mjx-mrow")
3387
+ .eq(0)
3388
+ .invoke("text")
3389
+ .then((text) => {
3390
+ expect(text).eq("2345");
3391
+ });
3392
+ cy.get(cesc2("#" + maths3[1]) + " .mjx-mrow")
3393
+ .eq(0)
3394
+ .invoke("text")
3395
+ .then((text) => {
3396
+ expect(text).eq("3.5234");
3397
+ });
3398
+ cy.get(cesc2("#" + maths3[2]) + " .mjx-mrow")
3399
+ .eq(0)
3400
+ .invoke("text")
3401
+ .then((text) => {
3402
+ expect(text).eq("5.000");
3403
+ });
3404
+ cy.get(cesc2("#" + maths3[3]) + " .mjx-mrow")
3405
+ .eq(0)
3406
+ .invoke("text")
3407
+ .then((text) => {
3408
+ expect(text).eq("5.252⋅10−16");
3409
+ });
3410
+ cy.get(cesc2("#" + maths3[4]) + " .mjx-mrow")
3411
+ .eq(0)
3412
+ .invoke("text")
3413
+ .then((text) => {
3414
+ expect(text).eq("0.000");
3415
+ });
3416
+
3417
+ cy.get(cesc2("#" + maths4[0]) + " .mjx-mrow")
3418
+ .eq(0)
3419
+ .invoke("text")
3420
+ .then((text) => {
3421
+ expect(text).eq("2345");
3422
+ });
3423
+ cy.get(cesc2("#" + maths4[1]) + " .mjx-mrow")
3424
+ .eq(0)
3425
+ .invoke("text")
3426
+ .then((text) => {
3427
+ expect(text).eq("3.5234");
3428
+ });
3429
+ cy.get(cesc2("#" + maths4[2]) + " .mjx-mrow")
3430
+ .eq(0)
3431
+ .invoke("text")
3432
+ .then((text) => {
3433
+ expect(text).eq("5");
3434
+ });
3435
+ cy.get(cesc2("#" + maths4[3]) + " .mjx-mrow")
3436
+ .eq(0)
3437
+ .invoke("text")
3438
+ .then((text) => {
3439
+ expect(text).eq("5.252⋅10−16");
3440
+ });
3441
+ cy.get(cesc2("#" + maths4[4]) + " .mjx-mrow")
3442
+ .eq(0)
3443
+ .invoke("text")
3444
+ .then((text) => {
3445
+ expect(text).eq("0");
3446
+ });
3447
+
3448
+ cy.get(cesc2("#" + maths5[0]) + " .mjx-mrow")
3449
+ .eq(0)
3450
+ .invoke("text")
3451
+ .then((text) => {
3452
+ expect(text).eq("2345.1535");
3453
+ });
3454
+ cy.get(cesc2("#" + maths5[1]) + " .mjx-mrow")
3455
+ .eq(0)
3456
+ .invoke("text")
3457
+ .then((text) => {
3458
+ expect(text).eq("3.5234");
3459
+ });
3460
+ cy.get(cesc2("#" + maths5[2]) + " .mjx-mrow")
3461
+ .eq(0)
3462
+ .invoke("text")
3463
+ .then((text) => {
3464
+ expect(text).eq("5.0000");
3465
+ });
3466
+ cy.get(cesc2("#" + maths5[3]) + " .mjx-mrow")
3467
+ .eq(0)
3468
+ .invoke("text")
3469
+ .then((text) => {
3470
+ expect(text).eq("0");
3471
+ });
3472
+ cy.get(cesc2("#" + maths5[4]) + " .mjx-mrow")
3473
+ .eq(0)
3474
+ .invoke("text")
3475
+ .then((text) => {
3476
+ expect(text).eq("0");
3477
+ });
3478
+
3479
+ cy.get(cesc2("#" + maths6[0]) + " .mjx-mrow")
3480
+ .eq(0)
3481
+ .invoke("text")
3482
+ .then((text) => {
3483
+ expect(text).eq("2345.1535");
3484
+ });
3485
+ cy.get(cesc2("#" + maths6[1]) + " .mjx-mrow")
3486
+ .eq(0)
3487
+ .invoke("text")
3488
+ .then((text) => {
3489
+ expect(text).eq("3.5234");
3490
+ });
3491
+ cy.get(cesc2("#" + maths6[2]) + " .mjx-mrow")
3492
+ .eq(0)
3493
+ .invoke("text")
3494
+ .then((text) => {
3495
+ expect(text).eq("5.0000");
3496
+ });
3497
+ cy.get(cesc2("#" + maths6[3]) + " .mjx-mrow")
3498
+ .eq(0)
3499
+ .invoke("text")
3500
+ .then((text) => {
3501
+ expect(text).eq("0.0000");
3502
+ });
3503
+ cy.get(cesc2("#" + maths6[4]) + " .mjx-mrow")
3504
+ .eq(0)
3505
+ .invoke("text")
3506
+ .then((text) => {
3507
+ expect(text).eq("0.0000");
3508
+ });
3509
+
3510
+ cy.get(cesc2("#" + maths7[0]) + " .mjx-mrow")
3511
+ .eq(0)
3512
+ .invoke("text")
3513
+ .then((text) => {
3514
+ expect(text).eq("2345.1535");
3515
+ });
3516
+ cy.get(cesc2("#" + maths7[1]) + " .mjx-mrow")
3517
+ .eq(0)
3518
+ .invoke("text")
3519
+ .then((text) => {
3520
+ expect(text).eq("3.5234");
3521
+ });
3522
+ cy.get(cesc2("#" + maths7[2]) + " .mjx-mrow")
3523
+ .eq(0)
3524
+ .invoke("text")
3525
+ .then((text) => {
3526
+ expect(text).eq("5");
3527
+ });
3528
+ cy.get(cesc2("#" + maths7[3]) + " .mjx-mrow")
3529
+ .eq(0)
3530
+ .invoke("text")
3531
+ .then((text) => {
3532
+ expect(text).eq("0");
3533
+ });
3534
+ cy.get(cesc2("#" + maths7[4]) + " .mjx-mrow")
3535
+ .eq(0)
3536
+ .invoke("text")
3537
+ .then((text) => {
3538
+ expect(text).eq("0");
3539
+ });
3540
+
3541
+ cy.get(cesc2("#" + maths8[0]) + " .mjx-mrow")
3542
+ .eq(0)
3543
+ .invoke("text")
3544
+ .then((text) => {
3545
+ expect(text).eq("2345");
3546
+ });
3547
+ cy.get(cesc2("#" + maths8[1]) + " .mjx-mrow")
3548
+ .eq(0)
3549
+ .invoke("text")
3550
+ .then((text) => {
3551
+ expect(text).eq("3.5234");
3552
+ });
3553
+ cy.get(cesc2("#" + maths8[2]) + " .mjx-mrow")
3554
+ .eq(0)
3555
+ .invoke("text")
3556
+ .then((text) => {
3557
+ expect(text).eq("5.000");
3558
+ });
3559
+ cy.get(cesc2("#" + maths8[3]) + " .mjx-mrow")
3560
+ .eq(0)
3561
+ .invoke("text")
3562
+ .then((text) => {
3563
+ expect(text).eq("0");
3564
+ });
3565
+ cy.get(cesc2("#" + maths8[4]) + " .mjx-mrow")
3566
+ .eq(0)
3567
+ .invoke("text")
3568
+ .then((text) => {
3569
+ expect(text).eq("0");
3570
+ });
3571
+
3572
+ cy.get(cesc2("#" + maths9[0]) + " .mjx-mrow")
3573
+ .eq(0)
3574
+ .invoke("text")
3575
+ .then((text) => {
3576
+ expect(text).eq("2345");
3577
+ });
3578
+ cy.get(cesc2("#" + maths9[1]) + " .mjx-mrow")
3579
+ .eq(0)
3580
+ .invoke("text")
3581
+ .then((text) => {
3582
+ expect(text).eq("3.5234");
3583
+ });
3584
+ cy.get(cesc2("#" + maths9[2]) + " .mjx-mrow")
3585
+ .eq(0)
3586
+ .invoke("text")
3587
+ .then((text) => {
3588
+ expect(text).eq("5.000");
3589
+ });
3590
+ cy.get(cesc2("#" + maths9[3]) + " .mjx-mrow")
3591
+ .eq(0)
3592
+ .invoke("text")
3593
+ .then((text) => {
3594
+ expect(text).eq("5.252⋅10−16");
3595
+ });
3596
+ cy.get(cesc2("#" + maths9[4]) + " .mjx-mrow")
3597
+ .eq(0)
3598
+ .invoke("text")
3599
+ .then((text) => {
3600
+ expect(text).eq("6⋅10−21");
3601
+ });
3602
+ });
3603
+ });
3604
+
3605
+ it("mathlist and rounding, override number children", () => {
3606
+ cy.window().then(async (win) => {
3607
+ win.postMessage(
3608
+ {
3609
+ doenetML: `
3610
+ <text>a</text>
3611
+ <p><mathlist name="ml1">
3612
+ <number name="n11" displayDigits="5" ignoreDisplayDecimals>2345.1535268</number>
3613
+ <number name="n12" displayDecimals="4">3.52343</number>
3614
+ <number name="n13" displayDigits="5" padZeros>5</number>
3615
+ <number name="n14" displaySmallAsZero="false">0.00000000000000052523</number>
3616
+ <number name="n15">0.000000000000000000006</number>
3617
+ </mathList></p>
3618
+ <p><mathlist name="ml2" displayDigits="4">
3619
+ <number name="n21" displayDigits="5" ignoreDisplayDecimals>2345.1535268</number>
3620
+ <number name="n22" displayDecimals="4">3.52343</number>
3621
+ <number name="n23" displayDigits="5" padZeros>5</number>
3622
+ <number name="n24" displaySmallAsZero="false">0.00000000000000052523</number>
3623
+ <number name="n25">0.000000000000000000006</number>
3624
+ </mathList></p>
3625
+ <p><mathlist name="ml3" displayDigits="4" padZeros>
3626
+ <number name="n31" displayDigits="5" ignoreDisplayDecimals>2345.1535268</number>
3627
+ <number name="n32" displayDecimals="4">3.52343</number>
3628
+ <number name="n33" displayDigits="5" padZeros>5</number>
3629
+ <number name="n34" displaySmallAsZero="false">0.00000000000000052523</number>
3630
+ <number name="n35">0.000000000000000000006</number>
3631
+ </mathList></p>
3632
+ <p><mathlist name="ml4" displayDigits="4" padZeros="false">
3633
+ <number name="n41" displayDigits="5" ignoreDisplayDecimals>2345.1535268</number>
3634
+ <number name="n42" displayDecimals="4">3.52343</number>
3635
+ <number name="n43" displayDigits="5" padZeros>5</number>
3636
+ <number name="n44" displaySmallAsZero="false">0.00000000000000052523</number>
3637
+ <number name="n45">0.000000000000000000006</number>
3638
+ </mathList></p>
3639
+ <p><mathlist name="ml5" displayDecimals="4" ignoreDisplayDigits>
3640
+ <number name="n51" displayDigits="5" ignoreDisplayDecimals>2345.1535268</number>
3641
+ <number name="n52" displayDecimals="4">3.52343</number>
3642
+ <number name="n53" displayDigits="5" padZeros>5</number>
3643
+ <number name="n54" displaySmallAsZero="false">0.00000000000000052523</number>
3644
+ <number name="n55">0.000000000000000000006</number>
3645
+ </mathList></p>
3646
+ <p><mathlist name="ml6" displayDecimals="4" padZeros ignoreDisplayDigits>
3647
+ <number name="n61" displayDigits="5" ignoreDisplayDecimals>2345.1535268</number>
3648
+ <number name="n62" displayDecimals="4">3.52343</number>
3649
+ <number name="n63" displayDigits="5" padZeros>5</number>
3650
+ <number name="n64" displaySmallAsZero="false">0.00000000000000052523</number>
3651
+ <number name="n65">0.000000000000000000006</number>
3652
+ </mathList></p>
3653
+ <p><mathlist name="ml7" displayDecimals="4" padZeros="false" ignoreDisplayDigits>
3654
+ <number name="n71" displayDigits="5" ignoreDisplayDecimals>2345.1535268</number>
3655
+ <number name="n72" displayDecimals="4">3.52343</number>
3656
+ <number name="n73" displayDigits="5" padZeros>5</number>
3657
+ <number name="n74" displaySmallAsZero="false">0.00000000000000052523</number>
3658
+ <number name="n75">0.000000000000000000006</number>
3659
+ </mathList></p>
3660
+ <p><mathlist name="ml8" displayDigits="4" displaySmallAsZero>
3661
+ <number name="n81" displayDigits="5" ignoreDisplayDecimals>2345.1535268</number>
3662
+ <number name="n82" displayDecimals="4">3.52343</number>
3663
+ <number name="n83" displayDigits="5" padZeros>5</number>
3664
+ <number name="n84" displaySmallAsZero="false">0.00000000000000052523</number>
3665
+ <number name="n85">0.000000000000000000006</number>
3666
+ </mathList></p>
3667
+ <p><mathlist name="ml9" displayDigits="4" displaySmallAsZero="false">
3668
+ <number name="n91" displayDigits="5" ignoreDisplayDecimals>2345.1535268</number>
3669
+ <number name="n92" displayDecimals="4">3.52343</number>
3670
+ <number name="n93" displayDigits="5" padZeros>5</number>
3671
+ <number name="n94" displaySmallAsZero="false">0.00000000000000052523</number>
3672
+ <number name="n95">0.000000000000000000006</number>
3673
+ </mathList></p>
3674
+ `,
3675
+ },
3676
+ "*",
3677
+ );
3678
+ });
3679
+
3680
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
3681
+
3682
+ cy.get(cesc2("#/n11") + " .mjx-mrow")
3683
+ .eq(0)
3684
+ .invoke("text")
3685
+ .then((text) => {
3686
+ expect(text).eq("2345.2");
3687
+ });
3688
+ cy.get(cesc2("#/n12") + " .mjx-mrow")
3689
+ .eq(0)
3690
+ .invoke("text")
3691
+ .then((text) => {
3692
+ expect(text).eq("3.5234");
3693
+ });
3694
+ cy.get(cesc2("#/n13") + " .mjx-mrow")
3695
+ .eq(0)
3696
+ .invoke("text")
3697
+ .then((text) => {
3698
+ expect(text).eq("5.0000");
3699
+ });
3700
+ cy.get(cesc2("#/n14") + " .mjx-mrow")
3701
+ .eq(0)
3702
+ .invoke("text")
3703
+ .then((text) => {
3704
+ expect(text).eq("5.25⋅10−16");
3705
+ });
3706
+ cy.get(cesc2("#/n15") + " .mjx-mrow")
3707
+ .eq(0)
3708
+ .invoke("text")
3709
+ .then((text) => {
3710
+ expect(text).eq("0");
3711
+ });
3712
+
3713
+ cy.get(cesc2("#/n21") + " .mjx-mrow")
3714
+ .eq(0)
3715
+ .invoke("text")
3716
+ .then((text) => {
3717
+ expect(text).eq("2345");
3718
+ });
3719
+ cy.get(cesc2("#/n22") + " .mjx-mrow")
3720
+ .eq(0)
3721
+ .invoke("text")
3722
+ .then((text) => {
3723
+ expect(text).eq("3.5234");
3724
+ });
3725
+ cy.get(cesc2("#/n23") + " .mjx-mrow")
3726
+ .eq(0)
3727
+ .invoke("text")
3728
+ .then((text) => {
3729
+ expect(text).eq("5.000");
3730
+ });
3731
+ cy.get(cesc2("#/n24") + " .mjx-mrow")
3732
+ .eq(0)
3733
+ .invoke("text")
3734
+ .then((text) => {
3735
+ expect(text).eq("5.252⋅10−16");
3736
+ });
3737
+ cy.get(cesc2("#/n25") + " .mjx-mrow")
3738
+ .eq(0)
3739
+ .invoke("text")
3740
+ .then((text) => {
3741
+ expect(text).eq("0");
3742
+ });
3743
+
3744
+ cy.get(cesc2("#/n31") + " .mjx-mrow")
3745
+ .eq(0)
3746
+ .invoke("text")
3747
+ .then((text) => {
3748
+ expect(text).eq("2345");
3749
+ });
3750
+ cy.get(cesc2("#/n32") + " .mjx-mrow")
3751
+ .eq(0)
3752
+ .invoke("text")
3753
+ .then((text) => {
3754
+ expect(text).eq("3.5234");
3755
+ });
3756
+ cy.get(cesc2("#/n33") + " .mjx-mrow")
3757
+ .eq(0)
3758
+ .invoke("text")
3759
+ .then((text) => {
3760
+ expect(text).eq("5.000");
3761
+ });
3762
+ cy.get(cesc2("#/n34") + " .mjx-mrow")
3763
+ .eq(0)
3764
+ .invoke("text")
3765
+ .then((text) => {
3766
+ expect(text).eq("5.252⋅10−16");
3767
+ });
3768
+ cy.get(cesc2("#/n35") + " .mjx-mrow")
3769
+ .eq(0)
3770
+ .invoke("text")
3771
+ .then((text) => {
3772
+ expect(text).eq("0.000");
3773
+ });
3774
+
3775
+ cy.get(cesc2("#/n41") + " .mjx-mrow")
3776
+ .eq(0)
3777
+ .invoke("text")
3778
+ .then((text) => {
3779
+ expect(text).eq("2345");
3780
+ });
3781
+ cy.get(cesc2("#/n42") + " .mjx-mrow")
3782
+ .eq(0)
3783
+ .invoke("text")
3784
+ .then((text) => {
3785
+ expect(text).eq("3.5234");
3786
+ });
3787
+ cy.get(cesc2("#/n43") + " .mjx-mrow")
3788
+ .eq(0)
3789
+ .invoke("text")
3790
+ .then((text) => {
3791
+ expect(text).eq("5");
3792
+ });
3793
+ cy.get(cesc2("#/n44") + " .mjx-mrow")
3794
+ .eq(0)
3795
+ .invoke("text")
3796
+ .then((text) => {
3797
+ expect(text).eq("5.252⋅10−16");
3798
+ });
3799
+ cy.get(cesc2("#/n45") + " .mjx-mrow")
3800
+ .eq(0)
3801
+ .invoke("text")
3802
+ .then((text) => {
3803
+ expect(text).eq("0");
3804
+ });
3805
+
3806
+ cy.get(cesc2("#/n51") + " .mjx-mrow")
3807
+ .eq(0)
3808
+ .invoke("text")
3809
+ .then((text) => {
3810
+ expect(text).eq("2345.1535");
3811
+ });
3812
+ cy.get(cesc2("#/n52") + " .mjx-mrow")
3813
+ .eq(0)
3814
+ .invoke("text")
3815
+ .then((text) => {
3816
+ expect(text).eq("3.5234");
3817
+ });
3818
+ cy.get(cesc2("#/n53") + " .mjx-mrow")
3819
+ .eq(0)
3820
+ .invoke("text")
3821
+ .then((text) => {
3822
+ expect(text).eq("5.0000");
3823
+ });
3824
+ cy.get(cesc2("#/n54") + " .mjx-mrow")
3825
+ .eq(0)
3826
+ .invoke("text")
3827
+ .then((text) => {
3828
+ expect(text).eq("0");
3829
+ });
3830
+ cy.get(cesc2("#/n55") + " .mjx-mrow")
3831
+ .eq(0)
3832
+ .invoke("text")
3833
+ .then((text) => {
3834
+ expect(text).eq("0");
3835
+ });
3836
+
3837
+ cy.get(cesc2("#/n61") + " .mjx-mrow")
3838
+ .eq(0)
3839
+ .invoke("text")
3840
+ .then((text) => {
3841
+ expect(text).eq("2345.1535");
3842
+ });
3843
+ cy.get(cesc2("#/n62") + " .mjx-mrow")
3844
+ .eq(0)
3845
+ .invoke("text")
3846
+ .then((text) => {
3847
+ expect(text).eq("3.5234");
3848
+ });
3849
+ cy.get(cesc2("#/n63") + " .mjx-mrow")
3850
+ .eq(0)
3851
+ .invoke("text")
3852
+ .then((text) => {
3853
+ expect(text).eq("5.0000");
3854
+ });
3855
+ cy.get(cesc2("#/n64") + " .mjx-mrow")
3856
+ .eq(0)
3857
+ .invoke("text")
3858
+ .then((text) => {
3859
+ expect(text).eq("0.0000");
3860
+ });
3861
+ cy.get(cesc2("#/n65") + " .mjx-mrow")
3862
+ .eq(0)
3863
+ .invoke("text")
3864
+ .then((text) => {
3865
+ expect(text).eq("0.0000");
3866
+ });
3867
+
3868
+ cy.get(cesc2("#/n71") + " .mjx-mrow")
3869
+ .eq(0)
3870
+ .invoke("text")
3871
+ .then((text) => {
3872
+ expect(text).eq("2345.1535");
3873
+ });
3874
+ cy.get(cesc2("#/n72") + " .mjx-mrow")
3875
+ .eq(0)
3876
+ .invoke("text")
3877
+ .then((text) => {
3878
+ expect(text).eq("3.5234");
3879
+ });
3880
+ cy.get(cesc2("#/n73") + " .mjx-mrow")
3881
+ .eq(0)
3882
+ .invoke("text")
3883
+ .then((text) => {
3884
+ expect(text).eq("5");
3885
+ });
3886
+ cy.get(cesc2("#/n74") + " .mjx-mrow")
3887
+ .eq(0)
3888
+ .invoke("text")
3889
+ .then((text) => {
3890
+ expect(text).eq("0");
3891
+ });
3892
+ cy.get(cesc2("#/n75") + " .mjx-mrow")
3893
+ .eq(0)
3894
+ .invoke("text")
3895
+ .then((text) => {
3896
+ expect(text).eq("0");
3897
+ });
3898
+
3899
+ cy.get(cesc2("#/n81") + " .mjx-mrow")
3900
+ .eq(0)
3901
+ .invoke("text")
3902
+ .then((text) => {
3903
+ expect(text).eq("2345");
3904
+ });
3905
+ cy.get(cesc2("#/n82") + " .mjx-mrow")
3906
+ .eq(0)
3907
+ .invoke("text")
3908
+ .then((text) => {
3909
+ expect(text).eq("3.5234");
3910
+ });
3911
+ cy.get(cesc2("#/n83") + " .mjx-mrow")
3912
+ .eq(0)
3913
+ .invoke("text")
3914
+ .then((text) => {
3915
+ expect(text).eq("5.000");
3916
+ });
3917
+ cy.get(cesc2("#/n84") + " .mjx-mrow")
3918
+ .eq(0)
3919
+ .invoke("text")
3920
+ .then((text) => {
3921
+ expect(text).eq("0");
3922
+ });
3923
+ cy.get(cesc2("#/n85") + " .mjx-mrow")
3924
+ .eq(0)
3925
+ .invoke("text")
3926
+ .then((text) => {
3927
+ expect(text).eq("0");
3928
+ });
3929
+
3930
+ cy.get(cesc2("#/n91") + " .mjx-mrow")
3931
+ .eq(0)
3932
+ .invoke("text")
3933
+ .then((text) => {
3934
+ expect(text).eq("2345");
3935
+ });
3936
+ cy.get(cesc2("#/n92") + " .mjx-mrow")
3937
+ .eq(0)
3938
+ .invoke("text")
3939
+ .then((text) => {
3940
+ expect(text).eq("3.5234");
3941
+ });
3942
+ cy.get(cesc2("#/n93") + " .mjx-mrow")
3943
+ .eq(0)
3944
+ .invoke("text")
3945
+ .then((text) => {
3946
+ expect(text).eq("5.000");
3947
+ });
3948
+ cy.get(cesc2("#/n94") + " .mjx-mrow")
3949
+ .eq(0)
3950
+ .invoke("text")
3951
+ .then((text) => {
3952
+ expect(text).eq("5.252⋅10−16");
3953
+ });
3954
+ cy.get(cesc2("#/n95") + " .mjx-mrow")
3955
+ .eq(0)
3956
+ .invoke("text")
3957
+ .then((text) => {
3958
+ expect(text).eq("6⋅10−21");
3959
+ });
3960
+ });
3961
+
3962
+ it("mathlist and rounding, copy and override", () => {
3963
+ cy.window().then(async (win) => {
3964
+ win.postMessage(
3965
+ {
3966
+ doenetML: `
3967
+ <text>a</text>
3968
+ <p><mathList name="ml1">34.245023482352345 <math displayDigits="7">245.23823402358234234</math></mathList></p>
3969
+ <p><mathList name="ml1Dig6" copySource="ml1" displayDigits="6" /></p>
3970
+ <p><mathList name="ml1Dec6" copySource="ml1" displayDecimals="6" /></p>
3971
+ <p><mathList name="ml1Dig6a" copySource="ml1Dec6" displayDigits="6" ignoreDisplayDecimals /></p>
3972
+ <p><mathList name="ml1Dec6a" copySource="ml1Dig6" displayDecimals="6" /></p>
3973
+ `,
3974
+ },
3975
+ "*",
3976
+ );
3977
+ });
3978
+
3979
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
3980
+
3981
+ cy.get(cesc("#\\/ml1") + " .mjx-mrow")
3982
+ .eq(0)
3983
+ .should("have.text", "34.25");
3984
+ cy.get(cesc("#\\/ml1") + " .mjx-mrow")
3985
+ .eq(1)
3986
+ .should("have.text", "245.2382");
3987
+
3988
+ cy.get(cesc("#\\/ml1Dig6") + " .mjx-mrow")
3989
+ .eq(0)
3990
+ .should("have.text", "34.245");
3991
+ cy.get(cesc("#\\/ml1Dig6") + " .mjx-mrow")
3992
+ .eq(1)
3993
+ .should("have.text", "245.238");
3994
+ cy.get(cesc("#\\/ml1Dig6a") + " .mjx-mrow")
3995
+ .eq(0)
3996
+ .should("have.text", "34.245");
3997
+ cy.get(cesc("#\\/ml1Dig6a") + " .mjx-mrow")
3998
+ .eq(1)
3999
+ .should("have.text", "245.238");
4000
+
4001
+ cy.get(cesc("#\\/ml1Dec6") + " .mjx-mrow")
4002
+ .eq(0)
4003
+ .should("have.text", "34.245023");
4004
+ cy.get(cesc("#\\/ml1Dec6") + " .mjx-mrow")
4005
+ .eq(1)
4006
+ .should("have.text", "245.238234");
4007
+ cy.get(cesc("#\\/ml1Dec6a") + " .mjx-mrow")
4008
+ .eq(0)
4009
+ .should("have.text", "34.245023");
4010
+ cy.get(cesc("#\\/ml1Dec6a") + " .mjx-mrow")
4011
+ .eq(1)
4012
+ .should("have.text", "245.238234");
4013
+ });
4014
+
4015
+ it("mathlist adapts to math and text", () => {
4016
+ cy.window().then(async (win) => {
4017
+ win.postMessage(
4018
+ {
4019
+ doenetML: `
4020
+ <text>a</text>
4021
+ <mathlist><math>a</math> <math>b</math><math>c</math></mathlist>
4022
+
4023
+ <p>Math list as math: <math>$_mathlist1</math></p>
4024
+ <p>Math list as text: <text>$_mathlist1</text></p>
4025
+
4026
+ `,
4027
+ },
4028
+ "*",
4029
+ );
4030
+ });
4031
+
4032
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
4033
+
4034
+ cy.log("Test value displayed in browser");
4035
+ cy.get(cesc("#\\/_math1") + " .mjx-mrow")
4036
+ .eq(0)
4037
+ .invoke("text")
4038
+ .then((text) => {
4039
+ expect(text.trim()).equal("a");
4040
+ });
4041
+ cy.get(cesc("#\\/_math2") + " .mjx-mrow")
4042
+ .eq(0)
4043
+ .invoke("text")
4044
+ .then((text) => {
4045
+ expect(text.trim()).equal("b");
4046
+ });
4047
+ cy.get(cesc("#\\/_math3") + " .mjx-mrow")
4048
+ .eq(0)
4049
+ .invoke("text")
4050
+ .then((text) => {
4051
+ expect(text.trim()).equal("c");
4052
+ });
4053
+ cy.get(cesc("#\\/_math4") + " .mjx-mrow")
4054
+ .eq(0)
4055
+ .invoke("text")
4056
+ .then((text) => {
4057
+ expect(text.trim()).equal("a,b,c");
4058
+ });
4059
+ cy.get(cesc("#\\/_text2")).should("have.text", "a, b, c");
4060
+
4061
+ cy.log("Test internal values are set to the correct values");
4062
+ cy.window().then(async (win) => {
4063
+ let stateVariables = await win.returnAllStateVariables1();
4064
+ expect(stateVariables["/_math4"].stateValues.value).eqls([
4065
+ "list",
4066
+ "a",
4067
+ "b",
4068
+ "c",
4069
+ ]);
4070
+ expect(stateVariables["/_text2"].stateValues.value).eq("a, b, c");
4071
+ });
4072
+ });
4073
+ });