@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,3288 @@
1
+ import me from "math-expressions";
2
+ import { cesc } from "../../../../src/utils/url";
3
+
4
+ describe("UpdateValue Tag Tests", function () {
5
+ beforeEach(() => {
6
+ cy.clearIndexedDB();
7
+ cy.visit("/src/Tools/cypressTest/");
8
+ });
9
+
10
+ it("incrementing graph of line segments", () => {
11
+ cy.window().then(async (win) => {
12
+ win.postMessage(
13
+ {
14
+ doenetML: `
15
+ <text>a</text>
16
+ <number name="step">20/<copy target="count" /></number>
17
+ <number name="count">2</number>
18
+ <graph>
19
+ <map assignNames="l1 l2 l3 l4 l5 l6 l7 l8 l9 l10 l11 l12 l13 l14 l15 l16" >
20
+ <template newNamespace>
21
+ <linesegment endpoints="($x, sin($x)) ($x+$(../step), sin($x+$(../step)))" />
22
+ </template>
23
+ <sources alias="x">
24
+ <sequence from="-10" to="10-$step" length="$count" />
25
+ </sources>
26
+ </map>
27
+ </graph>
28
+ <p></p>
29
+ <updatevalue target="count" newValue="2$count" >
30
+ <label>double</label>
31
+ </updateValue>
32
+ `,
33
+ },
34
+ "*",
35
+ );
36
+ });
37
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
38
+
39
+ let left = -10;
40
+
41
+ cy.log(`check internal values`);
42
+ cy.window().then(async (win) => {
43
+ let stateVariables = await win.returnAllStateVariables1();
44
+
45
+ let count = 2;
46
+ let step = 20 / count;
47
+
48
+ expect(stateVariables["/count"].stateValues.value).eq(count);
49
+ expect(stateVariables["/step"].stateValues.value).eq(step);
50
+
51
+ for (let ind = 1; ind <= count; ind++) {
52
+ expect(
53
+ me
54
+ .fromAst(
55
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
56
+ .endpoints[0][0],
57
+ )
58
+ .evaluate_to_constant(),
59
+ ).closeTo(left + (ind - 1) * step, 1e-12);
60
+ expect(
61
+ me
62
+ .fromAst(
63
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
64
+ .endpoints[0][1],
65
+ )
66
+ .evaluate_to_constant(),
67
+ ).closeTo(Math.sin(left + (ind - 1) * step), 1e-12);
68
+ expect(
69
+ me
70
+ .fromAst(
71
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
72
+ .endpoints[1][0],
73
+ )
74
+ .evaluate_to_constant(),
75
+ ).closeTo(left + ind * step, 1e-12);
76
+ expect(
77
+ me
78
+ .fromAst(
79
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
80
+ .endpoints[1][1],
81
+ )
82
+ .evaluate_to_constant(),
83
+ ).closeTo(Math.sin(left + ind * step), 1e-12);
84
+ }
85
+ });
86
+
87
+ cy.log("double number");
88
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
89
+ cy.get(cesc("#\\/count")).should("have.text", "4");
90
+ cy.window().then(async (win) => {
91
+ let stateVariables = await win.returnAllStateVariables1();
92
+
93
+ let count = 4;
94
+ let step = 20 / count;
95
+
96
+ expect(stateVariables["/count"].stateValues.value).eq(count);
97
+ expect(stateVariables["/step"].stateValues.value).eq(step);
98
+
99
+ for (let ind = 1; ind <= count; ind++) {
100
+ expect(
101
+ me
102
+ .fromAst(
103
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
104
+ .endpoints[0][0],
105
+ )
106
+ .evaluate_to_constant(),
107
+ ).closeTo(left + (ind - 1) * step, 1e-12);
108
+ expect(
109
+ me
110
+ .fromAst(
111
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
112
+ .endpoints[0][1],
113
+ )
114
+ .evaluate_to_constant(),
115
+ ).closeTo(Math.sin(left + (ind - 1) * step), 1e-12);
116
+ expect(
117
+ me
118
+ .fromAst(
119
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
120
+ .endpoints[1][0],
121
+ )
122
+ .evaluate_to_constant(),
123
+ ).closeTo(left + ind * step, 1e-12);
124
+ expect(
125
+ me
126
+ .fromAst(
127
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
128
+ .endpoints[1][1],
129
+ )
130
+ .evaluate_to_constant(),
131
+ ).closeTo(Math.sin(left + ind * step), 1e-12);
132
+ }
133
+ });
134
+
135
+ cy.log("double number a second time");
136
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
137
+ cy.get(cesc("#\\/count")).should("have.text", "8");
138
+ cy.window().then(async (win) => {
139
+ let stateVariables = await win.returnAllStateVariables1();
140
+
141
+ let count = 8;
142
+ let step = 20 / count;
143
+
144
+ expect(stateVariables["/count"].stateValues.value).eq(count);
145
+ expect(stateVariables["/step"].stateValues.value).eq(step);
146
+
147
+ for (let ind = 1; ind <= count; ind++) {
148
+ expect(
149
+ me
150
+ .fromAst(
151
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
152
+ .endpoints[0][0],
153
+ )
154
+ .evaluate_to_constant(),
155
+ ).closeTo(left + (ind - 1) * step, 1e-12);
156
+ expect(
157
+ me
158
+ .fromAst(
159
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
160
+ .endpoints[0][1],
161
+ )
162
+ .evaluate_to_constant(),
163
+ ).closeTo(Math.sin(left + (ind - 1) * step), 1e-12);
164
+ expect(
165
+ me
166
+ .fromAst(
167
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
168
+ .endpoints[1][0],
169
+ )
170
+ .evaluate_to_constant(),
171
+ ).closeTo(left + ind * step, 1e-12);
172
+ expect(
173
+ me
174
+ .fromAst(
175
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
176
+ .endpoints[1][1],
177
+ )
178
+ .evaluate_to_constant(),
179
+ ).closeTo(Math.sin(left + ind * step), 1e-12);
180
+ }
181
+ });
182
+
183
+ cy.log("double number a third time");
184
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
185
+ cy.get(cesc("#\\/count")).should("have.text", "16");
186
+ cy.window().then(async (win) => {
187
+ let stateVariables = await win.returnAllStateVariables1();
188
+
189
+ let count = 16;
190
+ let step = 20 / count;
191
+
192
+ expect(stateVariables["/count"].stateValues.value).eq(count);
193
+ expect(stateVariables["/step"].stateValues.value).eq(step);
194
+
195
+ for (let ind = 1; ind <= count; ind++) {
196
+ expect(
197
+ me
198
+ .fromAst(
199
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
200
+ .endpoints[0][0],
201
+ )
202
+ .evaluate_to_constant(),
203
+ ).closeTo(left + (ind - 1) * step, 1e-12);
204
+ expect(
205
+ me
206
+ .fromAst(
207
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
208
+ .endpoints[0][1],
209
+ )
210
+ .evaluate_to_constant(),
211
+ ).closeTo(Math.sin(left + (ind - 1) * step), 1e-12);
212
+ expect(
213
+ me
214
+ .fromAst(
215
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
216
+ .endpoints[1][0],
217
+ )
218
+ .evaluate_to_constant(),
219
+ ).closeTo(left + ind * step, 1e-12);
220
+ expect(
221
+ me
222
+ .fromAst(
223
+ stateVariables["/l" + ind + "/_linesegment1"].stateValues
224
+ .endpoints[1][1],
225
+ )
226
+ .evaluate_to_constant(),
227
+ ).closeTo(Math.sin(left + ind * step), 1e-12);
228
+ }
229
+ });
230
+ });
231
+
232
+ it("update boolean", () => {
233
+ cy.window().then(async (win) => {
234
+ win.postMessage(
235
+ {
236
+ doenetML: `
237
+ <text>a</text>
238
+ <boolean name="b" />
239
+ <updateValue target="b" newValue="not$b" type="boolean" >
240
+ <label>change mind</label>
241
+ </updateValue>
242
+ `,
243
+ },
244
+ "*",
245
+ );
246
+ });
247
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
248
+
249
+ cy.get(cesc("#\\/b")).should("have.text", "false");
250
+
251
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
252
+ cy.get(cesc("#\\/b")).should("have.text", "true");
253
+
254
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
255
+ cy.get(cesc("#\\/b")).should("have.text", "false");
256
+ });
257
+
258
+ // catch bug where componentWithSelectableType wasn't
259
+ // converting strings to booleans correctly
260
+ it("update boolean using string value", () => {
261
+ cy.window().then(async (win) => {
262
+ win.postMessage(
263
+ {
264
+ doenetML: `
265
+ <text>a</text>
266
+ <boolean name="b" />
267
+ <updateValue name="setTrue" target="b" newValue="true" type="boolean" >
268
+ <label>set true</label>
269
+ </updateValue>
270
+ <updateValue name="setFalse" target="b" newValue="false" type="boolean" >
271
+ <label>set false</label>
272
+ </updateValue>
273
+ `,
274
+ },
275
+ "*",
276
+ );
277
+ });
278
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
279
+
280
+ cy.get(cesc("#\\/b")).should("have.text", "false");
281
+
282
+ cy.get(cesc("#\\/setTrue_button")).click();
283
+ cy.get(cesc("#\\/b")).should("have.text", "true");
284
+
285
+ cy.get(cesc("#\\/setTrue_button")).click();
286
+ cy.get(cesc("#\\/b")).should("have.text", "true");
287
+
288
+ cy.get(cesc("#\\/setFalse_button")).click();
289
+ cy.get(cesc("#\\/b")).should("have.text", "false");
290
+
291
+ cy.get(cesc("#\\/setFalse_button")).click();
292
+ cy.get(cesc("#\\/b")).should("have.text", "false");
293
+
294
+ cy.get(cesc("#\\/setTrue_button")).click();
295
+ cy.get(cesc("#\\/b")).should("have.text", "true");
296
+ });
297
+
298
+ it("update number using string value with operator", () => {
299
+ cy.window().then(async (win) => {
300
+ win.postMessage(
301
+ {
302
+ doenetML: `
303
+ <text>a</text>
304
+ <number name="n" >1</number>
305
+ <updateValue name="setToSum" target="n" newValue="1+1" type="number" >
306
+ <label>set to 1+1</label>
307
+ </updateValue>
308
+ `,
309
+ },
310
+ "*",
311
+ );
312
+ });
313
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
314
+
315
+ cy.get(cesc("#\\/n")).should("have.text", "1");
316
+
317
+ cy.get(cesc("#\\/setToSum_button")).click();
318
+ cy.get(cesc("#\\/n")).should("have.text", "2");
319
+ });
320
+
321
+ it("update property", () => {
322
+ cy.window().then(async (win) => {
323
+ win.postMessage(
324
+ {
325
+ doenetML: `
326
+ <text>a</text>
327
+ <point name="P">(1,2)</point>
328
+
329
+ <updateValue target="P" prop="x" newValue="2$(P.x)" >
330
+ <label>double</label>
331
+ </updateValue>
332
+ <updateValue target="P.x" newValue="2$(P.x)" >
333
+ <label>also double</label>
334
+ </updateValue>
335
+ `,
336
+ },
337
+ "*",
338
+ );
339
+ });
340
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
341
+
342
+ cy.get(cesc("#\\/P"))
343
+ .find(".mjx-mrow")
344
+ .eq(0)
345
+ .invoke("text")
346
+ .then((text) => {
347
+ expect(text.trim()).equal("(1,2)");
348
+ });
349
+
350
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
351
+ cy.waitUntil(() =>
352
+ cy
353
+ .get(cesc("#\\/P"))
354
+ .find(".mjx-mrow")
355
+ .eq(0)
356
+ .invoke("text")
357
+ .then((text) => text.trim() === "(2,2)"),
358
+ );
359
+
360
+ cy.get(cesc("#\\/_updatevalue2_button")).click();
361
+ cy.waitUntil(() =>
362
+ cy
363
+ .get(cesc("#\\/P"))
364
+ .find(".mjx-mrow")
365
+ .eq(0)
366
+ .invoke("text")
367
+ .then((text) => text.trim() === "(4,2)"),
368
+ );
369
+ });
370
+
371
+ it("update componentIndex", () => {
372
+ cy.window().then(async (win) => {
373
+ win.postMessage(
374
+ {
375
+ doenetML: `
376
+ <text>a</text>
377
+ <group name="grp">
378
+ <point name="p">(3,2)</point>
379
+ <point name="p2">(1,5)</point>
380
+ <point name="p3">(7,0)</point>
381
+ </group>
382
+
383
+ <collect componentTypes="point" source="grp" name="col" />
384
+
385
+ <updateValue target="col" prop="x" newValue="2$(p.x)" componentIndex="2" />
386
+ <updateValue target="col[3].x" newValue="2$(p.x)" />
387
+ <p><booleaninput name="bi" /><copy prop="value" source="bi" assignNames="b" /></p>
388
+ `,
389
+ },
390
+ "*",
391
+ );
392
+ });
393
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
394
+
395
+ cy.get(cesc("#\\/p"))
396
+ .find(".mjx-mrow")
397
+ .eq(0)
398
+ .invoke("text")
399
+ .then((text) => {
400
+ expect(text.trim()).equal("(3,2)");
401
+ });
402
+ cy.get(cesc("#\\/p2"))
403
+ .find(".mjx-mrow")
404
+ .eq(0)
405
+ .invoke("text")
406
+ .then((text) => {
407
+ expect(text.trim()).equal("(1,5)");
408
+ });
409
+ cy.get(cesc("#\\/p3"))
410
+ .find(".mjx-mrow")
411
+ .eq(0)
412
+ .invoke("text")
413
+ .then((text) => {
414
+ expect(text.trim()).equal("(7,0)");
415
+ });
416
+
417
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
418
+ cy.waitUntil(() =>
419
+ cy
420
+ .get(cesc("#\\/p2"))
421
+ .find(".mjx-mrow")
422
+ .eq(0)
423
+ .invoke("text")
424
+ .then((text) => text.trim() === "(6,5)"),
425
+ );
426
+ cy.get(cesc("#\\/p"))
427
+ .find(".mjx-mrow")
428
+ .eq(0)
429
+ .invoke("text")
430
+ .then((text) => {
431
+ expect(text.trim()).equal("(3,2)");
432
+ });
433
+ cy.get(cesc("#\\/p2"))
434
+ .find(".mjx-mrow")
435
+ .eq(0)
436
+ .invoke("text")
437
+ .then((text) => {
438
+ expect(text.trim()).equal("(6,5)");
439
+ });
440
+ cy.get(cesc("#\\/p3"))
441
+ .find(".mjx-mrow")
442
+ .eq(0)
443
+ .invoke("text")
444
+ .then((text) => {
445
+ expect(text.trim()).equal("(7,0)");
446
+ });
447
+
448
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
449
+ // nothing has changed even after wait for core to respond to booleaninput
450
+ cy.get(cesc("#\\/bi")).click();
451
+ cy.get(cesc("#\\/b")).should("have.text", "true");
452
+ cy.get(cesc("#\\/p"))
453
+ .find(".mjx-mrow")
454
+ .eq(0)
455
+ .invoke("text")
456
+ .then((text) => {
457
+ expect(text.trim()).equal("(3,2)");
458
+ });
459
+ cy.get(cesc("#\\/p2"))
460
+ .find(".mjx-mrow")
461
+ .eq(0)
462
+ .invoke("text")
463
+ .then((text) => {
464
+ expect(text.trim()).equal("(6,5)");
465
+ });
466
+ cy.get(cesc("#\\/p3"))
467
+ .find(".mjx-mrow")
468
+ .eq(0)
469
+ .invoke("text")
470
+ .then((text) => {
471
+ expect(text.trim()).equal("(7,0)");
472
+ });
473
+
474
+ cy.get(cesc("#\\/_updatevalue2_button")).click();
475
+ cy.waitUntil(() =>
476
+ cy
477
+ .get(cesc("#\\/p2"))
478
+ .find(".mjx-mrow")
479
+ .eq(0)
480
+ .invoke("text")
481
+ .then((text) => text.trim() === "(6,5)"),
482
+ );
483
+ cy.get(cesc("#\\/p"))
484
+ .find(".mjx-mrow")
485
+ .eq(0)
486
+ .invoke("text")
487
+ .then((text) => {
488
+ expect(text.trim()).equal("(3,2)");
489
+ });
490
+ cy.get(cesc("#\\/p2"))
491
+ .find(".mjx-mrow")
492
+ .eq(0)
493
+ .invoke("text")
494
+ .then((text) => {
495
+ expect(text.trim()).equal("(6,5)");
496
+ });
497
+ cy.get(cesc("#\\/p3"))
498
+ .find(".mjx-mrow")
499
+ .eq(0)
500
+ .invoke("text")
501
+ .then((text) => {
502
+ expect(text.trim()).equal("(6,0)");
503
+ });
504
+
505
+ cy.get(cesc("#\\/_updatevalue2_button")).click();
506
+ // nothing has changed even after wait for core to respond to booleaninput
507
+ cy.get(cesc("#\\/bi")).click();
508
+ cy.get(cesc("#\\/b")).should("have.text", "false");
509
+ cy.get(cesc("#\\/p"))
510
+ .find(".mjx-mrow")
511
+ .eq(0)
512
+ .invoke("text")
513
+ .then((text) => {
514
+ expect(text.trim()).equal("(3,2)");
515
+ });
516
+ cy.get(cesc("#\\/p2"))
517
+ .find(".mjx-mrow")
518
+ .eq(0)
519
+ .invoke("text")
520
+ .then((text) => {
521
+ expect(text.trim()).equal("(6,5)");
522
+ });
523
+ cy.get(cesc("#\\/p3"))
524
+ .find(".mjx-mrow")
525
+ .eq(0)
526
+ .invoke("text")
527
+ .then((text) => {
528
+ expect(text.trim()).equal("(6,0)");
529
+ });
530
+ });
531
+
532
+ it("update propIndex", () => {
533
+ cy.window().then(async (win) => {
534
+ win.postMessage(
535
+ {
536
+ doenetML: `
537
+ <text>a</text>
538
+ <point name="p">(3,2,1)</point>
539
+
540
+ <collect componentTypes="point" target="grp" name="col" />
541
+
542
+ <updateValue target="p" prop="xs" newValue="2$(p.x)" propIndex="2" />
543
+ <updateValue target="p.xs[3]" newValue="2$(p.x)" />
544
+ <p><booleaninput name="bi" /><copy prop="value" target="bi" assignNames="b" /></p>
545
+ `,
546
+ },
547
+ "*",
548
+ );
549
+ });
550
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
551
+
552
+ cy.get(cesc("#\\/p"))
553
+ .find(".mjx-mrow")
554
+ .eq(0)
555
+ .invoke("text")
556
+ .then((text) => {
557
+ expect(text.trim()).equal("(3,2,1)");
558
+ });
559
+
560
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
561
+ cy.waitUntil(() =>
562
+ cy
563
+ .get(cesc("#\\/p"))
564
+ .find(".mjx-mrow")
565
+ .eq(0)
566
+ .invoke("text")
567
+ .then((text) => text.trim() === "(3,6,1)"),
568
+ );
569
+
570
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
571
+ // nothing has changed even after wait for core to respond to booleaninput
572
+ cy.get(cesc("#\\/bi")).click();
573
+ cy.get(cesc("#\\/b")).should("have.text", "true");
574
+ cy.get(cesc("#\\/p"))
575
+ .find(".mjx-mrow")
576
+ .eq(0)
577
+ .invoke("text")
578
+ .then((text) => {
579
+ expect(text.trim()).equal("(3,6,1)");
580
+ });
581
+
582
+ cy.get(cesc("#\\/_updatevalue2_button")).click();
583
+ cy.waitUntil(() =>
584
+ cy
585
+ .get(cesc("#\\/p"))
586
+ .find(".mjx-mrow")
587
+ .eq(0)
588
+ .invoke("text")
589
+ .then((text) => text.trim() === "(3,6,6)"),
590
+ );
591
+
592
+ cy.get(cesc("#\\/_updatevalue2_button")).click();
593
+ // nothing has changed even after wait for core to respond to booleaninput
594
+ cy.get(cesc("#\\/bi")).click();
595
+ cy.get(cesc("#\\/b")).should("have.text", "false");
596
+ cy.get(cesc("#\\/p"))
597
+ .find(".mjx-mrow")
598
+ .eq(0)
599
+ .invoke("text")
600
+ .then((text) => {
601
+ expect(text.trim()).equal("(3,6,6)");
602
+ });
603
+ });
604
+
605
+ it("update multiple components", () => {
606
+ cy.window().then(async (win) => {
607
+ win.postMessage(
608
+ {
609
+ doenetML: `
610
+ <text>a</text>
611
+ <group name="grp">
612
+ <point name="p">(3,2)</point>
613
+ <point name="p2">(1,5)</point>
614
+ <point name="p3">(7,0)</point>
615
+ </group>
616
+
617
+ <collect componentTypes="point" target="grp" name="col" />
618
+
619
+ <updateValue target="col" prop="x" newValue="2$(p.x)" />
620
+ <updateValue target="col.x" newValue="2$(p.x)" />
621
+ `,
622
+ },
623
+ "*",
624
+ );
625
+ });
626
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
627
+
628
+ cy.get(cesc("#\\/p"))
629
+ .find(".mjx-mrow")
630
+ .eq(0)
631
+ .invoke("text")
632
+ .then((text) => {
633
+ expect(text.trim()).equal("(3,2)");
634
+ });
635
+ cy.get(cesc("#\\/p2"))
636
+ .find(".mjx-mrow")
637
+ .eq(0)
638
+ .invoke("text")
639
+ .then((text) => {
640
+ expect(text.trim()).equal("(1,5)");
641
+ });
642
+ cy.get(cesc("#\\/p3"))
643
+ .find(".mjx-mrow")
644
+ .eq(0)
645
+ .invoke("text")
646
+ .then((text) => {
647
+ expect(text.trim()).equal("(7,0)");
648
+ });
649
+
650
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
651
+ cy.waitUntil(() =>
652
+ cy
653
+ .get(cesc("#\\/p"))
654
+ .find(".mjx-mrow")
655
+ .eq(0)
656
+ .invoke("text")
657
+ .then((text) => text.trim() === "(6,2)"),
658
+ );
659
+ cy.get(cesc("#\\/p"))
660
+ .find(".mjx-mrow")
661
+ .eq(0)
662
+ .invoke("text")
663
+ .then((text) => {
664
+ expect(text.trim()).equal("(6,2)");
665
+ });
666
+ cy.get(cesc("#\\/p2"))
667
+ .find(".mjx-mrow")
668
+ .eq(0)
669
+ .invoke("text")
670
+ .then((text) => {
671
+ expect(text.trim()).equal("(6,5)");
672
+ });
673
+ cy.get(cesc("#\\/p3"))
674
+ .find(".mjx-mrow")
675
+ .eq(0)
676
+ .invoke("text")
677
+ .then((text) => {
678
+ expect(text.trim()).equal("(6,0)");
679
+ });
680
+
681
+ cy.get(cesc("#\\/_updatevalue2_button")).click();
682
+ cy.waitUntil(() =>
683
+ cy
684
+ .get(cesc("#\\/p"))
685
+ .find(".mjx-mrow")
686
+ .eq(0)
687
+ .invoke("text")
688
+ .then((text) => text.trim() === "(12,2)"),
689
+ );
690
+ cy.get(cesc("#\\/p"))
691
+ .find(".mjx-mrow")
692
+ .eq(0)
693
+ .invoke("text")
694
+ .then((text) => {
695
+ expect(text.trim()).equal("(12,2)");
696
+ });
697
+ cy.get(cesc("#\\/p2"))
698
+ .find(".mjx-mrow")
699
+ .eq(0)
700
+ .invoke("text")
701
+ .then((text) => {
702
+ expect(text.trim()).equal("(12,5)");
703
+ });
704
+ cy.get(cesc("#\\/p3"))
705
+ .find(".mjx-mrow")
706
+ .eq(0)
707
+ .invoke("text")
708
+ .then((text) => {
709
+ expect(text.trim()).equal("(12,0)");
710
+ });
711
+ });
712
+
713
+ it("update property of property", () => {
714
+ cy.window().then(async (win) => {
715
+ win.postMessage(
716
+ {
717
+ doenetML: `
718
+ <text>a</text>
719
+ <line through="$P $Q" name="l" />
720
+ <point name="P">(1,2)</point>
721
+ <point name="Q">(3,4)</point>
722
+
723
+ <updateValue target="l.point1.x" newValue="2$(P.x)" >
724
+ <label>double</label>
725
+ </updateValue>
726
+ <updateValue target="l.points[1].x" newValue="2$(P.x)" >
727
+ <label>also double</label>
728
+ </updateValue>
729
+ <updateValue target="l.points[1]" newValue="(3,7)" >
730
+ <label>set point</label>
731
+ </updateValue>
732
+ `,
733
+ },
734
+ "*",
735
+ );
736
+ });
737
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
738
+
739
+ cy.get(cesc("#\\/P"))
740
+ .find(".mjx-mrow")
741
+ .eq(0)
742
+ .invoke("text")
743
+ .then((text) => {
744
+ expect(text.trim()).equal("(1,2)");
745
+ });
746
+
747
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
748
+ cy.waitUntil(() =>
749
+ cy
750
+ .get(cesc("#\\/P"))
751
+ .find(".mjx-mrow")
752
+ .eq(0)
753
+ .invoke("text")
754
+ .then((text) => text.trim() === "(2,2)"),
755
+ );
756
+
757
+ cy.get(cesc("#\\/_updatevalue2_button")).click();
758
+ cy.waitUntil(() =>
759
+ cy
760
+ .get(cesc("#\\/P"))
761
+ .find(".mjx-mrow")
762
+ .eq(0)
763
+ .invoke("text")
764
+ .then((text) => text.trim() === "(4,2)"),
765
+ );
766
+
767
+ cy.get(cesc("#\\/_updatevalue3_button")).click();
768
+ cy.waitUntil(() =>
769
+ cy
770
+ .get(cesc("#\\/P"))
771
+ .find(".mjx-mrow")
772
+ .eq(0)
773
+ .invoke("text")
774
+ .then((text) => text.trim() === "(3,7)"),
775
+ );
776
+
777
+ cy.get(cesc("#\\/_updatevalue1_button")).click();
778
+ cy.waitUntil(() =>
779
+ cy
780
+ .get(cesc("#\\/P"))
781
+ .find(".mjx-mrow")
782
+ .eq(0)
783
+ .invoke("text")
784
+ .then((text) => text.trim() === "(6,7)"),
785
+ );
786
+
787
+ cy.get(cesc("#\\/_updatevalue2_button")).click();
788
+ cy.waitUntil(() =>
789
+ cy
790
+ .get(cesc("#\\/P"))
791
+ .find(".mjx-mrow")
792
+ .eq(0)
793
+ .invoke("text")
794
+ .then((text) => text.trim() === "(12,7)"),
795
+ );
796
+ });
797
+
798
+ it("chained updates", () => {
799
+ cy.window().then(async (win) => {
800
+ win.postMessage(
801
+ {
802
+ doenetML: `
803
+ <text>a</text>
804
+ <math name="x">x</math>
805
+ <math name="y">y</math>
806
+
807
+ <updateValue name="trip" target="x" newValue="3$x" simplify >
808
+ <label>update</label>
809
+ </updateValue>
810
+ <updateValue name="quad" target="y" newValue="4$y" triggerWith="trip" simplify />
811
+ `,
812
+ },
813
+ "*",
814
+ );
815
+ });
816
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
817
+
818
+ cy.get(cesc("#\\/x"))
819
+ .find(".mjx-mrow")
820
+ .eq(0)
821
+ .invoke("text")
822
+ .then((text) => {
823
+ expect(text.trim()).equal("x");
824
+ });
825
+ cy.get(cesc("#\\/y"))
826
+ .find(".mjx-mrow")
827
+ .eq(0)
828
+ .invoke("text")
829
+ .then((text) => {
830
+ expect(text.trim()).equal("y");
831
+ });
832
+
833
+ cy.get(cesc("#\\/quad")).should("not.exist");
834
+
835
+ cy.get(cesc("#\\/trip_button")).click();
836
+ cy.get(cesc("#\\/x")).should("contain.text", "3x");
837
+ cy.get(cesc("#\\/y")).should("contain.text", "4y");
838
+ cy.get(cesc("#\\/x"))
839
+ .find(".mjx-mrow")
840
+ .eq(0)
841
+ .invoke("text")
842
+ .then((text) => {
843
+ expect(text.trim()).equal("3x");
844
+ });
845
+ cy.get(cesc("#\\/y"))
846
+ .find(".mjx-mrow")
847
+ .eq(0)
848
+ .invoke("text")
849
+ .then((text) => {
850
+ expect(text.trim()).equal("4y");
851
+ });
852
+
853
+ cy.get(cesc("#\\/trip_button")).click();
854
+
855
+ cy.get(cesc("#\\/x")).should("contain.text", "9x");
856
+ cy.get(cesc("#\\/y")).should("contain.text", "16y");
857
+
858
+ cy.get(cesc("#\\/x"))
859
+ .find(".mjx-mrow")
860
+ .eq(0)
861
+ .invoke("text")
862
+ .then((text) => {
863
+ expect(text.trim()).equal("9x");
864
+ });
865
+ cy.get(cesc("#\\/y"))
866
+ .find(".mjx-mrow")
867
+ .eq(0)
868
+ .invoke("text")
869
+ .then((text) => {
870
+ expect(text.trim()).equal("16y");
871
+ });
872
+ });
873
+
874
+ it("chained updates on multiple sources", () => {
875
+ cy.window().then(async (win) => {
876
+ win.postMessage(
877
+ {
878
+ doenetML: `
879
+ <text>a</text>
880
+ <math name="x">x</math>
881
+ <math name="y">y</math>
882
+ <math name="z">z</math>
883
+
884
+ <updateValue name="doub" target="z" newValue="2$z" simplify >
885
+ <label>update</label>
886
+ </updateValue>
887
+ <updateValue name="trip" target="x" newValue="3$x" simplify >
888
+ <label>update</label>
889
+ </updateValue>
890
+ <updateValue name="quad" target="y" newValue="4$y" triggerWith="doub trip" simplify />
891
+ `,
892
+ },
893
+ "*",
894
+ );
895
+ });
896
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
897
+
898
+ cy.get(cesc("#\\/x"))
899
+ .find(".mjx-mrow")
900
+ .eq(0)
901
+ .invoke("text")
902
+ .then((text) => {
903
+ expect(text.trim()).equal("x");
904
+ });
905
+ cy.get(cesc("#\\/y"))
906
+ .find(".mjx-mrow")
907
+ .eq(0)
908
+ .invoke("text")
909
+ .then((text) => {
910
+ expect(text.trim()).equal("y");
911
+ });
912
+ cy.get(cesc("#\\/z"))
913
+ .find(".mjx-mrow")
914
+ .eq(0)
915
+ .invoke("text")
916
+ .then((text) => {
917
+ expect(text.trim()).equal("z");
918
+ });
919
+
920
+ cy.get(cesc("#\\/quad")).should("not.exist");
921
+
922
+ cy.get(cesc("#\\/trip_button")).click();
923
+ cy.get(cesc("#\\/x")).should("contain.text", "3x");
924
+ cy.get(cesc("#\\/y")).should("contain.text", "4y");
925
+
926
+ cy.get(cesc("#\\/x"))
927
+ .find(".mjx-mrow")
928
+ .eq(0)
929
+ .invoke("text")
930
+ .then((text) => {
931
+ expect(text.trim()).equal("3x");
932
+ });
933
+ cy.get(cesc("#\\/z"))
934
+ .find(".mjx-mrow")
935
+ .eq(0)
936
+ .invoke("text")
937
+ .then((text) => {
938
+ expect(text.trim()).equal("z");
939
+ });
940
+ cy.get(cesc("#\\/y"))
941
+ .find(".mjx-mrow")
942
+ .eq(0)
943
+ .invoke("text")
944
+ .then((text) => {
945
+ expect(text.trim()).equal("4y");
946
+ });
947
+
948
+ cy.get(cesc("#\\/doub_button")).click();
949
+ cy.get(cesc("#\\/z")).should("contain.text", "2z");
950
+ cy.get(cesc("#\\/y")).should("contain.text", "16y");
951
+ cy.get(cesc("#\\/x"))
952
+ .find(".mjx-mrow")
953
+ .eq(0)
954
+ .invoke("text")
955
+ .then((text) => {
956
+ expect(text.trim()).equal("3x");
957
+ });
958
+ cy.get(cesc("#\\/z"))
959
+ .find(".mjx-mrow")
960
+ .eq(0)
961
+ .invoke("text")
962
+ .then((text) => {
963
+ expect(text.trim()).equal("2z");
964
+ });
965
+ cy.get(cesc("#\\/y"))
966
+ .find(".mjx-mrow")
967
+ .eq(0)
968
+ .invoke("text")
969
+ .then((text) => {
970
+ expect(text.trim()).equal("16y");
971
+ });
972
+
973
+ cy.get(cesc("#\\/trip_button")).click();
974
+ cy.get(cesc("#\\/x")).should("contain.text", "9x");
975
+ cy.get(cesc("#\\/y")).should("contain.text", "64y");
976
+
977
+ cy.get(cesc("#\\/x"))
978
+ .find(".mjx-mrow")
979
+ .eq(0)
980
+ .invoke("text")
981
+ .then((text) => {
982
+ expect(text.trim()).equal("9x");
983
+ });
984
+ cy.get(cesc("#\\/z"))
985
+ .find(".mjx-mrow")
986
+ .eq(0)
987
+ .invoke("text")
988
+ .then((text) => {
989
+ expect(text.trim()).equal("2z");
990
+ });
991
+ cy.get(cesc("#\\/y"))
992
+ .find(".mjx-mrow")
993
+ .eq(0)
994
+ .invoke("text")
995
+ .then((text) => {
996
+ expect(text.trim()).equal("64y");
997
+ });
998
+ });
999
+
1000
+ it("update based on trigger", () => {
1001
+ cy.window().then(async (win) => {
1002
+ win.postMessage(
1003
+ {
1004
+ doenetML: `
1005
+ <text>a</text>
1006
+ <graph>
1007
+ <point name="P">(-1,2)</point>
1008
+ </graph>
1009
+ <math name="x">x</math>
1010
+
1011
+ <updateValue name="trip" target="x" newValue="3$x" simplify triggerWhen="$(P.x)>0 and $(P.y)>0" />
1012
+ `,
1013
+ },
1014
+ "*",
1015
+ );
1016
+ });
1017
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1018
+
1019
+ cy.get(cesc("#\\/x"))
1020
+ .find(".mjx-mrow")
1021
+ .eq(0)
1022
+ .invoke("text")
1023
+ .then((text) => {
1024
+ expect(text.trim()).equal("x");
1025
+ });
1026
+
1027
+ cy.get(cesc("#\\/trip")).should("not.exist");
1028
+
1029
+ cy.window().then(async (win) => {
1030
+ await win.callAction1({
1031
+ actionName: "movePoint",
1032
+ componentName: "/P",
1033
+ args: { x: -1, y: -7 },
1034
+ });
1035
+ cy.get(cesc("#\\/x"))
1036
+ .find(".mjx-mrow")
1037
+ .eq(0)
1038
+ .invoke("text")
1039
+ .then((text) => {
1040
+ expect(text.trim()).equal("x");
1041
+ });
1042
+ });
1043
+
1044
+ cy.window().then(async (win) => {
1045
+ await win.callAction1({
1046
+ actionName: "movePoint",
1047
+ componentName: "/P",
1048
+ args: { x: 3, y: -4 },
1049
+ });
1050
+ cy.get(cesc("#\\/x"))
1051
+ .find(".mjx-mrow")
1052
+ .eq(0)
1053
+ .invoke("text")
1054
+ .then((text) => {
1055
+ expect(text.trim()).equal("x");
1056
+ });
1057
+ });
1058
+
1059
+ cy.window().then(async (win) => {
1060
+ await win.callAction1({
1061
+ actionName: "movePoint",
1062
+ componentName: "/P",
1063
+ args: { x: 1, y: 7 },
1064
+ });
1065
+ cy.get(cesc("#\\/x")).should("contain.text", "3x");
1066
+ cy.get(cesc("#\\/x"))
1067
+ .find(".mjx-mrow")
1068
+ .eq(0)
1069
+ .invoke("text")
1070
+ .then((text) => {
1071
+ expect(text.trim()).equal("3x");
1072
+ });
1073
+ });
1074
+
1075
+ cy.window().then(async (win) => {
1076
+ await win.callAction1({
1077
+ actionName: "movePoint",
1078
+ componentName: "/P",
1079
+ args: { x: 5, y: 9 },
1080
+ });
1081
+ cy.get(cesc("#\\/x"))
1082
+ .find(".mjx-mrow")
1083
+ .eq(0)
1084
+ .invoke("text")
1085
+ .then((text) => {
1086
+ expect(text.trim()).equal("3x");
1087
+ });
1088
+ });
1089
+
1090
+ cy.window().then(async (win) => {
1091
+ await win.callAction1({
1092
+ actionName: "movePoint",
1093
+ componentName: "/P",
1094
+ args: { x: -3, y: 4 },
1095
+ });
1096
+ cy.get(cesc("#\\/x"))
1097
+ .find(".mjx-mrow")
1098
+ .eq(0)
1099
+ .invoke("text")
1100
+ .then((text) => {
1101
+ expect(text.trim()).equal("3x");
1102
+ });
1103
+ });
1104
+
1105
+ cy.window().then(async (win) => {
1106
+ await win.callAction1({
1107
+ actionName: "movePoint",
1108
+ componentName: "/P",
1109
+ args: { x: -6, y: 5 },
1110
+ });
1111
+ cy.get(cesc("#\\/x"))
1112
+ .find(".mjx-mrow")
1113
+ .eq(0)
1114
+ .invoke("text")
1115
+ .then((text) => {
1116
+ expect(text.trim()).equal("3x");
1117
+ });
1118
+ });
1119
+
1120
+ cy.window().then(async (win) => {
1121
+ await win.callAction1({
1122
+ actionName: "movePoint",
1123
+ componentName: "/P",
1124
+ args: { x: 4, y: 2 },
1125
+ });
1126
+ cy.get(cesc("#\\/x")).should("contain.text", "9x");
1127
+ cy.get(cesc("#\\/x"))
1128
+ .find(".mjx-mrow")
1129
+ .eq(0)
1130
+ .invoke("text")
1131
+ .then((text) => {
1132
+ expect(text.trim()).equal("9x");
1133
+ });
1134
+ });
1135
+
1136
+ cy.window().then(async (win) => {
1137
+ await win.callAction1({
1138
+ actionName: "movePoint",
1139
+ componentName: "/P",
1140
+ args: { x: 9, y: 7 },
1141
+ });
1142
+ cy.get(cesc("#\\/x"))
1143
+ .find(".mjx-mrow")
1144
+ .eq(0)
1145
+ .invoke("text")
1146
+ .then((text) => {
1147
+ expect(text.trim()).equal("9x");
1148
+ });
1149
+ });
1150
+ });
1151
+
1152
+ it("update triggered when click", () => {
1153
+ cy.window().then(async (win) => {
1154
+ win.postMessage(
1155
+ {
1156
+ doenetML: `
1157
+ <text>a</text>
1158
+ <graph>
1159
+ <point name="P">(-1,2)</point>
1160
+ </graph>
1161
+ <math name="x">x</math>
1162
+
1163
+ <updateValue name="trip" target="x" newValue="3$x" simplify triggerWhenObjectsClicked="P" />
1164
+ `,
1165
+ },
1166
+ "*",
1167
+ );
1168
+ });
1169
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1170
+
1171
+ cy.get(cesc("#\\/x"))
1172
+ .find(".mjx-mrow")
1173
+ .eq(0)
1174
+ .invoke("text")
1175
+ .then((text) => {
1176
+ expect(text.trim()).equal("x");
1177
+ });
1178
+
1179
+ cy.get(cesc("#\\/trip")).should("not.exist");
1180
+
1181
+ cy.window().then(async (win) => {
1182
+ await win.callAction1({
1183
+ actionName: "movePoint",
1184
+ componentName: "/P",
1185
+ args: { x: -1, y: -7 },
1186
+ });
1187
+ cy.get(cesc("#\\/x"))
1188
+ .find(".mjx-mrow")
1189
+ .eq(0)
1190
+ .invoke("text")
1191
+ .then((text) => {
1192
+ expect(text.trim()).equal("x");
1193
+ });
1194
+ });
1195
+
1196
+ cy.window().then(async (win) => {
1197
+ await win.callAction1({
1198
+ actionName: "pointClicked",
1199
+ componentName: "/P",
1200
+ args: { name: "/P" },
1201
+ });
1202
+ cy.get(cesc("#\\/x")).should("contain.text", "3x");
1203
+ cy.get(cesc("#\\/x"))
1204
+ .find(".mjx-mrow")
1205
+ .eq(0)
1206
+ .invoke("text")
1207
+ .then((text) => {
1208
+ expect(text.trim()).equal("3x");
1209
+ });
1210
+ });
1211
+
1212
+ cy.window().then(async (win) => {
1213
+ await win.callAction1({
1214
+ actionName: "movePoint",
1215
+ componentName: "/P",
1216
+ args: { x: 5, y: 9 },
1217
+ });
1218
+ cy.get(cesc("#\\/x"))
1219
+ .find(".mjx-mrow")
1220
+ .eq(0)
1221
+ .invoke("text")
1222
+ .then((text) => {
1223
+ expect(text.trim()).equal("3x");
1224
+ });
1225
+ });
1226
+
1227
+ cy.window().then(async (win) => {
1228
+ await win.callAction1({
1229
+ actionName: "pointClicked",
1230
+ componentName: "/P",
1231
+ args: { name: "/P" },
1232
+ });
1233
+ cy.get(cesc("#\\/x")).should("contain.text", "9x");
1234
+ cy.get(cesc("#\\/x"))
1235
+ .find(".mjx-mrow")
1236
+ .eq(0)
1237
+ .invoke("text")
1238
+ .then((text) => {
1239
+ expect(text.trim()).equal("9x");
1240
+ });
1241
+ });
1242
+
1243
+ cy.window().then(async (win) => {
1244
+ await win.callAction1({
1245
+ actionName: "movePoint",
1246
+ componentName: "/P",
1247
+ args: { x: 9, y: 7 },
1248
+ });
1249
+ cy.get(cesc("#\\/x"))
1250
+ .find(".mjx-mrow")
1251
+ .eq(0)
1252
+ .invoke("text")
1253
+ .then((text) => {
1254
+ expect(text.trim()).equal("9x");
1255
+ });
1256
+ });
1257
+ });
1258
+
1259
+ it("update triggered when object focused", () => {
1260
+ cy.window().then(async (win) => {
1261
+ win.postMessage(
1262
+ {
1263
+ doenetML: `
1264
+ <text>a</text>
1265
+ <graph>
1266
+ <point name="P">(-1,2)</point>
1267
+ </graph>
1268
+ <math name="x">x</math>
1269
+
1270
+ <updateValue name="trip" target="x" newValue="3$x" simplify triggerWhenObjectsFocused="P" />
1271
+ `,
1272
+ },
1273
+ "*",
1274
+ );
1275
+ });
1276
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1277
+
1278
+ cy.get(cesc("#\\/x"))
1279
+ .find(".mjx-mrow")
1280
+ .eq(0)
1281
+ .invoke("text")
1282
+ .then((text) => {
1283
+ expect(text.trim()).equal("x");
1284
+ });
1285
+
1286
+ cy.get(cesc("#\\/trip")).should("not.exist");
1287
+
1288
+ cy.window().then(async (win) => {
1289
+ await win.callAction1({
1290
+ actionName: "movePoint",
1291
+ componentName: "/P",
1292
+ args: { x: -1, y: -7 },
1293
+ });
1294
+ cy.get(cesc("#\\/x"))
1295
+ .find(".mjx-mrow")
1296
+ .eq(0)
1297
+ .invoke("text")
1298
+ .then((text) => {
1299
+ expect(text.trim()).equal("x");
1300
+ });
1301
+ });
1302
+
1303
+ cy.window().then(async (win) => {
1304
+ await win.callAction1({
1305
+ actionName: "pointFocused",
1306
+ componentName: "/P",
1307
+ args: { name: "/P" },
1308
+ });
1309
+ cy.get(cesc("#\\/x")).should("contain.text", "3x");
1310
+ cy.get(cesc("#\\/x"))
1311
+ .find(".mjx-mrow")
1312
+ .eq(0)
1313
+ .invoke("text")
1314
+ .then((text) => {
1315
+ expect(text.trim()).equal("3x");
1316
+ });
1317
+ });
1318
+
1319
+ cy.window().then(async (win) => {
1320
+ await win.callAction1({
1321
+ actionName: "movePoint",
1322
+ componentName: "/P",
1323
+ args: { x: 5, y: 9 },
1324
+ });
1325
+ cy.get(cesc("#\\/x"))
1326
+ .find(".mjx-mrow")
1327
+ .eq(0)
1328
+ .invoke("text")
1329
+ .then((text) => {
1330
+ expect(text.trim()).equal("3x");
1331
+ });
1332
+ });
1333
+
1334
+ cy.window().then(async (win) => {
1335
+ await win.callAction1({
1336
+ actionName: "pointFocused",
1337
+ componentName: "/P",
1338
+ args: { name: "/P" },
1339
+ });
1340
+ cy.get(cesc("#\\/x")).should("contain.text", "9x");
1341
+ cy.get(cesc("#\\/x"))
1342
+ .find(".mjx-mrow")
1343
+ .eq(0)
1344
+ .invoke("text")
1345
+ .then((text) => {
1346
+ expect(text.trim()).equal("9x");
1347
+ });
1348
+ });
1349
+
1350
+ cy.window().then(async (win) => {
1351
+ await win.callAction1({
1352
+ actionName: "movePoint",
1353
+ componentName: "/P",
1354
+ args: { x: 9, y: 7 },
1355
+ });
1356
+ cy.get(cesc("#\\/x"))
1357
+ .find(".mjx-mrow")
1358
+ .eq(0)
1359
+ .invoke("text")
1360
+ .then((text) => {
1361
+ expect(text.trim()).equal("9x");
1362
+ });
1363
+ });
1364
+ });
1365
+
1366
+ it("chained updates based on trigger", () => {
1367
+ cy.window().then(async (win) => {
1368
+ win.postMessage(
1369
+ {
1370
+ doenetML: `
1371
+ <text>a</text>
1372
+ <graph>
1373
+ <point name="P">(-1,2)</point>
1374
+ </graph>
1375
+ <math name="x">x</math>
1376
+ <math name="y">y</math>
1377
+
1378
+ <updateValue name="trip" target="x" newValue="3$x" simplify triggerWhen="$(P.x)>0 and $(P.y)>0" />
1379
+ <updateValue name="quad" target="y" newValue="4$y" simplify triggerWith="trip" />
1380
+ `,
1381
+ },
1382
+ "*",
1383
+ );
1384
+ });
1385
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1386
+
1387
+ cy.get(cesc("#\\/x"))
1388
+ .find(".mjx-mrow")
1389
+ .eq(0)
1390
+ .invoke("text")
1391
+ .then((text) => {
1392
+ expect(text.trim()).equal("x");
1393
+ });
1394
+ cy.get(cesc("#\\/y"))
1395
+ .find(".mjx-mrow")
1396
+ .eq(0)
1397
+ .invoke("text")
1398
+ .then((text) => {
1399
+ expect(text.trim()).equal("y");
1400
+ });
1401
+
1402
+ cy.get(cesc("#\\/trip")).should("not.exist");
1403
+ cy.get(cesc("#\\/quad")).should("not.exist");
1404
+
1405
+ cy.window().then(async (win) => {
1406
+ await win.callAction1({
1407
+ actionName: "movePoint",
1408
+ componentName: "/P",
1409
+ args: { x: -1, y: -7 },
1410
+ });
1411
+ cy.get(cesc("#\\/x"))
1412
+ .find(".mjx-mrow")
1413
+ .eq(0)
1414
+ .invoke("text")
1415
+ .then((text) => {
1416
+ expect(text.trim()).equal("x");
1417
+ });
1418
+ cy.get(cesc("#\\/y"))
1419
+ .find(".mjx-mrow")
1420
+ .eq(0)
1421
+ .invoke("text")
1422
+ .then((text) => {
1423
+ expect(text.trim()).equal("y");
1424
+ });
1425
+ });
1426
+
1427
+ cy.window().then(async (win) => {
1428
+ await win.callAction1({
1429
+ actionName: "movePoint",
1430
+ componentName: "/P",
1431
+ args: { x: 3, y: -4 },
1432
+ });
1433
+ cy.get(cesc("#\\/x"))
1434
+ .find(".mjx-mrow")
1435
+ .eq(0)
1436
+ .invoke("text")
1437
+ .then((text) => {
1438
+ expect(text.trim()).equal("x");
1439
+ });
1440
+ cy.get(cesc("#\\/y"))
1441
+ .find(".mjx-mrow")
1442
+ .eq(0)
1443
+ .invoke("text")
1444
+ .then((text) => {
1445
+ expect(text.trim()).equal("y");
1446
+ });
1447
+ });
1448
+
1449
+ cy.window().then(async (win) => {
1450
+ await win.callAction1({
1451
+ actionName: "movePoint",
1452
+ componentName: "/P",
1453
+ args: { x: 1, y: 7 },
1454
+ });
1455
+ cy.get(cesc("#\\/x")).should("contain.text", "3x");
1456
+ cy.get(cesc("#\\/y")).should("contain.text", "4y");
1457
+
1458
+ cy.get(cesc("#\\/x"))
1459
+ .find(".mjx-mrow")
1460
+ .eq(0)
1461
+ .invoke("text")
1462
+ .then((text) => {
1463
+ expect(text.trim()).equal("3x");
1464
+ });
1465
+ cy.get(cesc("#\\/y"))
1466
+ .find(".mjx-mrow")
1467
+ .eq(0)
1468
+ .invoke("text")
1469
+ .then((text) => {
1470
+ expect(text.trim()).equal("4y");
1471
+ });
1472
+ });
1473
+
1474
+ cy.window().then(async (win) => {
1475
+ await win.callAction1({
1476
+ actionName: "movePoint",
1477
+ componentName: "/P",
1478
+ args: { x: 5, y: 9 },
1479
+ });
1480
+ cy.get(cesc("#\\/x"))
1481
+ .find(".mjx-mrow")
1482
+ .eq(0)
1483
+ .invoke("text")
1484
+ .then((text) => {
1485
+ expect(text.trim()).equal("3x");
1486
+ });
1487
+ cy.get(cesc("#\\/y"))
1488
+ .find(".mjx-mrow")
1489
+ .eq(0)
1490
+ .invoke("text")
1491
+ .then((text) => {
1492
+ expect(text.trim()).equal("4y");
1493
+ });
1494
+ });
1495
+
1496
+ cy.window().then(async (win) => {
1497
+ await win.callAction1({
1498
+ actionName: "movePoint",
1499
+ componentName: "/P",
1500
+ args: { x: -3, y: 4 },
1501
+ });
1502
+ cy.get(cesc("#\\/x"))
1503
+ .find(".mjx-mrow")
1504
+ .eq(0)
1505
+ .invoke("text")
1506
+ .then((text) => {
1507
+ expect(text.trim()).equal("3x");
1508
+ });
1509
+ cy.get(cesc("#\\/y"))
1510
+ .find(".mjx-mrow")
1511
+ .eq(0)
1512
+ .invoke("text")
1513
+ .then((text) => {
1514
+ expect(text.trim()).equal("4y");
1515
+ });
1516
+ });
1517
+
1518
+ cy.window().then(async (win) => {
1519
+ await win.callAction1({
1520
+ actionName: "movePoint",
1521
+ componentName: "/P",
1522
+ args: { x: -6, y: 5 },
1523
+ });
1524
+ cy.get(cesc("#\\/x"))
1525
+ .find(".mjx-mrow")
1526
+ .eq(0)
1527
+ .invoke("text")
1528
+ .then((text) => {
1529
+ expect(text.trim()).equal("3x");
1530
+ });
1531
+ cy.get(cesc("#\\/y"))
1532
+ .find(".mjx-mrow")
1533
+ .eq(0)
1534
+ .invoke("text")
1535
+ .then((text) => {
1536
+ expect(text.trim()).equal("4y");
1537
+ });
1538
+ });
1539
+
1540
+ cy.window().then(async (win) => {
1541
+ await win.callAction1({
1542
+ actionName: "movePoint",
1543
+ componentName: "/P",
1544
+ args: { x: 4, y: 2 },
1545
+ });
1546
+
1547
+ cy.get(cesc("#\\/x")).should("contain.text", "9x");
1548
+ cy.get(cesc("#\\/y")).should("contain.text", "16y");
1549
+
1550
+ cy.get(cesc("#\\/x"))
1551
+ .find(".mjx-mrow")
1552
+ .eq(0)
1553
+ .invoke("text")
1554
+ .then((text) => {
1555
+ expect(text.trim()).equal("9x");
1556
+ });
1557
+ cy.get(cesc("#\\/y"))
1558
+ .find(".mjx-mrow")
1559
+ .eq(0)
1560
+ .invoke("text")
1561
+ .then((text) => {
1562
+ expect(text.trim()).equal("16y");
1563
+ });
1564
+ });
1565
+
1566
+ cy.window().then(async (win) => {
1567
+ await win.callAction1({
1568
+ actionName: "movePoint",
1569
+ componentName: "/P",
1570
+ args: { x: 9, y: 7 },
1571
+ });
1572
+ cy.get(cesc("#\\/x"))
1573
+ .find(".mjx-mrow")
1574
+ .eq(0)
1575
+ .invoke("text")
1576
+ .then((text) => {
1577
+ expect(text.trim()).equal("9x");
1578
+ });
1579
+ cy.get(cesc("#\\/y"))
1580
+ .find(".mjx-mrow")
1581
+ .eq(0)
1582
+ .invoke("text")
1583
+ .then((text) => {
1584
+ expect(text.trim()).equal("16y");
1585
+ });
1586
+ });
1587
+ });
1588
+
1589
+ it("chained updates based on trigger on same object", () => {
1590
+ cy.window().then(async (win) => {
1591
+ win.postMessage(
1592
+ {
1593
+ doenetML: `
1594
+ <text>a</text>
1595
+ <graph>
1596
+ <point name="P">(-1,2)</point>
1597
+ </graph>
1598
+ <math name="x">x</math>
1599
+
1600
+ <updateValue name="trip" target="x" newValue="3$x" simplify triggerWhen="$(P.x)>0 and $(P.y)>0" />
1601
+ <updateValue name="quad" target="x" newValue="4$x" simplify triggerWith="trip" />
1602
+ `,
1603
+ },
1604
+ "*",
1605
+ );
1606
+ });
1607
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1608
+
1609
+ cy.get(cesc("#\\/x"))
1610
+ .find(".mjx-mrow")
1611
+ .eq(0)
1612
+ .invoke("text")
1613
+ .then((text) => {
1614
+ expect(text.trim()).equal("x");
1615
+ });
1616
+
1617
+ cy.get(cesc("#\\/trip")).should("not.exist");
1618
+ cy.get(cesc("#\\/quad")).should("not.exist");
1619
+
1620
+ cy.window().then(async (win) => {
1621
+ await win.callAction1({
1622
+ actionName: "movePoint",
1623
+ componentName: "/P",
1624
+ args: { x: -1, y: -7 },
1625
+ });
1626
+ cy.get(cesc("#\\/x"))
1627
+ .find(".mjx-mrow")
1628
+ .eq(0)
1629
+ .invoke("text")
1630
+ .then((text) => {
1631
+ expect(text.trim()).equal("x");
1632
+ });
1633
+ });
1634
+
1635
+ cy.window().then(async (win) => {
1636
+ await win.callAction1({
1637
+ actionName: "movePoint",
1638
+ componentName: "/P",
1639
+ args: { x: 3, y: -4 },
1640
+ });
1641
+ cy.get(cesc("#\\/x"))
1642
+ .find(".mjx-mrow")
1643
+ .eq(0)
1644
+ .invoke("text")
1645
+ .then((text) => {
1646
+ expect(text.trim()).equal("x");
1647
+ });
1648
+ });
1649
+
1650
+ cy.window().then(async (win) => {
1651
+ await win.callAction1({
1652
+ actionName: "movePoint",
1653
+ componentName: "/P",
1654
+ args: { x: 1, y: 7 },
1655
+ });
1656
+ // since second change could be asynchronous, use other form so that cypress will wait
1657
+ cy.get(cesc("#\\/x")).find(".mjx-mrow").should("have.text", "12x");
1658
+ cy.get(cesc("#\\/x"))
1659
+ .find(".mjx-mrow")
1660
+ .eq(0)
1661
+ .invoke("text")
1662
+ .then((text) => {
1663
+ expect(text.trim()).equal("12x");
1664
+ });
1665
+ });
1666
+
1667
+ cy.window().then(async (win) => {
1668
+ await win.callAction1({
1669
+ actionName: "movePoint",
1670
+ componentName: "/P",
1671
+ args: { x: 5, y: 9 },
1672
+ });
1673
+ cy.get(cesc("#\\/x"))
1674
+ .find(".mjx-mrow")
1675
+ .eq(0)
1676
+ .invoke("text")
1677
+ .then((text) => {
1678
+ expect(text.trim()).equal("12x");
1679
+ });
1680
+ });
1681
+
1682
+ cy.window().then(async (win) => {
1683
+ await win.callAction1({
1684
+ actionName: "movePoint",
1685
+ componentName: "/P",
1686
+ args: { x: -3, y: 4 },
1687
+ });
1688
+ cy.get(cesc("#\\/x"))
1689
+ .find(".mjx-mrow")
1690
+ .eq(0)
1691
+ .invoke("text")
1692
+ .then((text) => {
1693
+ expect(text.trim()).equal("12x");
1694
+ });
1695
+ });
1696
+
1697
+ cy.window().then(async (win) => {
1698
+ await win.callAction1({
1699
+ actionName: "movePoint",
1700
+ componentName: "/P",
1701
+ args: { x: -6, y: 5 },
1702
+ });
1703
+ cy.get(cesc("#\\/x"))
1704
+ .find(".mjx-mrow")
1705
+ .eq(0)
1706
+ .invoke("text")
1707
+ .then((text) => {
1708
+ expect(text.trim()).equal("12x");
1709
+ });
1710
+ });
1711
+
1712
+ cy.window().then(async (win) => {
1713
+ await win.callAction1({
1714
+ actionName: "movePoint",
1715
+ componentName: "/P",
1716
+ args: { x: 4, y: 2 },
1717
+ });
1718
+ // since second change could be asynchronous, use other form so that cypress will wait
1719
+ // (keep other form of test to make it clear we aren't actually changing anything)
1720
+ cy.get(cesc("#\\/x")).find(".mjx-mrow").should("have.text", "144x");
1721
+ cy.get(cesc("#\\/x"))
1722
+ .find(".mjx-mrow")
1723
+ .eq(0)
1724
+ .invoke("text")
1725
+ .then((text) => {
1726
+ expect(text.trim()).equal("144x");
1727
+ });
1728
+ });
1729
+
1730
+ cy.window().then(async (win) => {
1731
+ await win.callAction1({
1732
+ actionName: "movePoint",
1733
+ componentName: "/P",
1734
+ args: { x: 9, y: 7 },
1735
+ });
1736
+ cy.get(cesc("#\\/x"))
1737
+ .find(".mjx-mrow")
1738
+ .eq(0)
1739
+ .invoke("text")
1740
+ .then((text) => {
1741
+ expect(text.trim()).equal("144x");
1742
+ });
1743
+ });
1744
+ });
1745
+
1746
+ it("triggerWhen supercedes chaining", () => {
1747
+ cy.window().then(async (win) => {
1748
+ win.postMessage(
1749
+ {
1750
+ doenetML: `
1751
+ <text>a</text>
1752
+ <graph>
1753
+ <point name="P">(-1,2)</point>
1754
+ </graph>
1755
+ <math name="x">x</math>
1756
+ <math name="y">y</math>
1757
+
1758
+ <updateValue name="trip" target="x" newValue="3$x" simplify triggerWhen="$(P.x)>0 and $(P.y)>0" />
1759
+ <updateValue name="quad" target="y" newValue="4$y" simplify triggerWith="trip" triggerWhen="$(P.x)<0 and $(P.y)<0" />
1760
+ `,
1761
+ },
1762
+ "*",
1763
+ );
1764
+ });
1765
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1766
+
1767
+ cy.get(cesc("#\\/x"))
1768
+ .find(".mjx-mrow")
1769
+ .eq(0)
1770
+ .invoke("text")
1771
+ .then((text) => {
1772
+ expect(text.trim()).equal("x");
1773
+ });
1774
+ cy.get(cesc("#\\/y"))
1775
+ .find(".mjx-mrow")
1776
+ .eq(0)
1777
+ .invoke("text")
1778
+ .then((text) => {
1779
+ expect(text.trim()).equal("y");
1780
+ });
1781
+
1782
+ cy.get(cesc("#\\/trip")).should("not.exist");
1783
+ cy.get(cesc("#\\/quad")).should("not.exist");
1784
+
1785
+ cy.window().then(async (win) => {
1786
+ await win.callAction1({
1787
+ actionName: "movePoint",
1788
+ componentName: "/P",
1789
+ args: { x: -1, y: -7 },
1790
+ });
1791
+ cy.get(cesc("#\\/y")).should("contain.text", "4y");
1792
+ cy.get(cesc("#\\/x"))
1793
+ .find(".mjx-mrow")
1794
+ .eq(0)
1795
+ .invoke("text")
1796
+ .then((text) => {
1797
+ expect(text.trim()).equal("x");
1798
+ });
1799
+ cy.get(cesc("#\\/y"))
1800
+ .find(".mjx-mrow")
1801
+ .eq(0)
1802
+ .invoke("text")
1803
+ .then((text) => {
1804
+ expect(text.trim()).equal("4y");
1805
+ });
1806
+ });
1807
+
1808
+ cy.window().then(async (win) => {
1809
+ await win.callAction1({
1810
+ actionName: "movePoint",
1811
+ componentName: "/P",
1812
+ args: { x: 3, y: -4 },
1813
+ });
1814
+ cy.get(cesc("#\\/x"))
1815
+ .find(".mjx-mrow")
1816
+ .eq(0)
1817
+ .invoke("text")
1818
+ .then((text) => {
1819
+ expect(text.trim()).equal("x");
1820
+ });
1821
+ cy.get(cesc("#\\/y"))
1822
+ .find(".mjx-mrow")
1823
+ .eq(0)
1824
+ .invoke("text")
1825
+ .then((text) => {
1826
+ expect(text.trim()).equal("4y");
1827
+ });
1828
+ });
1829
+
1830
+ cy.window().then(async (win) => {
1831
+ await win.callAction1({
1832
+ actionName: "movePoint",
1833
+ componentName: "/P",
1834
+ args: { x: 1, y: 7 },
1835
+ });
1836
+ cy.get(cesc("#\\/x")).should("contain.text", "3x");
1837
+ cy.get(cesc("#\\/x"))
1838
+ .find(".mjx-mrow")
1839
+ .eq(0)
1840
+ .invoke("text")
1841
+ .then((text) => {
1842
+ expect(text.trim()).equal("3x");
1843
+ });
1844
+ cy.get(cesc("#\\/y"))
1845
+ .find(".mjx-mrow")
1846
+ .eq(0)
1847
+ .invoke("text")
1848
+ .then((text) => {
1849
+ expect(text.trim()).equal("4y");
1850
+ });
1851
+ });
1852
+
1853
+ cy.window().then(async (win) => {
1854
+ await win.callAction1({
1855
+ actionName: "movePoint",
1856
+ componentName: "/P",
1857
+ args: { x: 5, y: 9 },
1858
+ });
1859
+ cy.get(cesc("#\\/x"))
1860
+ .find(".mjx-mrow")
1861
+ .eq(0)
1862
+ .invoke("text")
1863
+ .then((text) => {
1864
+ expect(text.trim()).equal("3x");
1865
+ });
1866
+ cy.get(cesc("#\\/y"))
1867
+ .find(".mjx-mrow")
1868
+ .eq(0)
1869
+ .invoke("text")
1870
+ .then((text) => {
1871
+ expect(text.trim()).equal("4y");
1872
+ });
1873
+ });
1874
+
1875
+ cy.window().then(async (win) => {
1876
+ await win.callAction1({
1877
+ actionName: "movePoint",
1878
+ componentName: "/P",
1879
+ args: { x: -3, y: -4 },
1880
+ });
1881
+ cy.get(cesc("#\\/y")).should("contain.text", "16y");
1882
+ cy.get(cesc("#\\/x"))
1883
+ .find(".mjx-mrow")
1884
+ .eq(0)
1885
+ .invoke("text")
1886
+ .then((text) => {
1887
+ expect(text.trim()).equal("3x");
1888
+ });
1889
+ cy.get(cesc("#\\/y"))
1890
+ .find(".mjx-mrow")
1891
+ .eq(0)
1892
+ .invoke("text")
1893
+ .then((text) => {
1894
+ expect(text.trim()).equal("16y");
1895
+ });
1896
+ });
1897
+
1898
+ cy.window().then(async (win) => {
1899
+ await win.callAction1({
1900
+ actionName: "movePoint",
1901
+ componentName: "/P",
1902
+ args: { x: -6, y: -5 },
1903
+ });
1904
+ cy.get(cesc("#\\/x"))
1905
+ .find(".mjx-mrow")
1906
+ .eq(0)
1907
+ .invoke("text")
1908
+ .then((text) => {
1909
+ expect(text.trim()).equal("3x");
1910
+ });
1911
+ cy.get(cesc("#\\/y"))
1912
+ .find(".mjx-mrow")
1913
+ .eq(0)
1914
+ .invoke("text")
1915
+ .then((text) => {
1916
+ expect(text.trim()).equal("16y");
1917
+ });
1918
+ });
1919
+
1920
+ cy.window().then(async (win) => {
1921
+ await win.callAction1({
1922
+ actionName: "movePoint",
1923
+ componentName: "/P",
1924
+ args: { x: 4, y: 2 },
1925
+ });
1926
+ cy.get(cesc("#\\/x")).should("contain.text", "9x");
1927
+ cy.get(cesc("#\\/x"))
1928
+ .find(".mjx-mrow")
1929
+ .eq(0)
1930
+ .invoke("text")
1931
+ .then((text) => {
1932
+ expect(text.trim()).equal("9x");
1933
+ });
1934
+ cy.get(cesc("#\\/y"))
1935
+ .find(".mjx-mrow")
1936
+ .eq(0)
1937
+ .invoke("text")
1938
+ .then((text) => {
1939
+ expect(text.trim()).equal("16y");
1940
+ });
1941
+ });
1942
+
1943
+ cy.window().then(async (win) => {
1944
+ await win.callAction1({
1945
+ actionName: "movePoint",
1946
+ componentName: "/P",
1947
+ args: { x: 9, y: 7 },
1948
+ });
1949
+ cy.get(cesc("#\\/x"))
1950
+ .find(".mjx-mrow")
1951
+ .eq(0)
1952
+ .invoke("text")
1953
+ .then((text) => {
1954
+ expect(text.trim()).equal("9x");
1955
+ });
1956
+ cy.get(cesc("#\\/y"))
1957
+ .find(".mjx-mrow")
1958
+ .eq(0)
1959
+ .invoke("text")
1960
+ .then((text) => {
1961
+ expect(text.trim()).equal("16y");
1962
+ });
1963
+ });
1964
+ });
1965
+
1966
+ it("triggerSet", () => {
1967
+ cy.window().then(async (win) => {
1968
+ win.postMessage(
1969
+ {
1970
+ doenetML: `
1971
+ <text>a</text>
1972
+ <p>Boolean to swap: <boolean name="b" /></p>
1973
+ <p>Say hello: <text name="hello"></text></p>
1974
+ <p>Count: <number name="n">1</number></p>
1975
+
1976
+ <triggerSet >
1977
+ <label>perform updates</label>
1978
+ <updateValue target="b" newValue="not$b" type="boolean" />
1979
+ <updateValue target="hello" newValue="$hello hello" type="text" />
1980
+ <updateValue target="n" newValue="$n+1" type="number" />
1981
+
1982
+ </triggerSet>
1983
+ `,
1984
+ },
1985
+ "*",
1986
+ );
1987
+ });
1988
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1989
+
1990
+ cy.get(cesc("#\\/b")).should("have.text", "false");
1991
+ cy.get(cesc("#\\/hello")).should("have.text", "");
1992
+ cy.get(cesc("#\\/n")).should("have.text", "1");
1993
+
1994
+ cy.get(cesc("#\\/_triggerset1_button")).click();
1995
+ cy.get(cesc("#\\/b")).should("have.text", "true");
1996
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
1997
+ cy.get(cesc("#\\/n")).should("have.text", "2");
1998
+
1999
+ cy.get(cesc("#\\/_triggerset1_button")).click();
2000
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2001
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello");
2002
+ cy.get(cesc("#\\/n")).should("have.text", "3");
2003
+
2004
+ cy.get(cesc("#\\/_triggerset1_button")).click();
2005
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2006
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello hello");
2007
+ cy.get(cesc("#\\/n")).should("have.text", "4");
2008
+ });
2009
+
2010
+ it("triggerSet and chain to updatevalue", () => {
2011
+ cy.window().then(async (win) => {
2012
+ win.postMessage(
2013
+ {
2014
+ doenetML: `
2015
+ <text>a</text>
2016
+ <p>Boolean to swap: <boolean name="b" /></p>
2017
+ <p>Say hello: <text name="hello"></text></p>
2018
+ <p>Count: <number name="n">1</number></p>
2019
+
2020
+ <triggerSet >
2021
+ <label>perform updates</label>
2022
+ <updateValue target="b" newValue="not$b" type="boolean" />
2023
+ <updateValue target="hello" newValue="$hello hello" type="text" />
2024
+
2025
+ </triggerSet>
2026
+
2027
+ <updateValue target="n" newValue="$n+1" type="number" triggerWith="_triggerset1" />
2028
+
2029
+ `,
2030
+ },
2031
+ "*",
2032
+ );
2033
+ });
2034
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2035
+
2036
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2037
+ cy.get(cesc("#\\/hello")).should("have.text", "");
2038
+ cy.get(cesc("#\\/n")).should("have.text", "1");
2039
+
2040
+ cy.get(cesc("#\\/_triggerset1_button")).click();
2041
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2042
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2043
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2044
+
2045
+ cy.get(cesc("#\\/_triggerset1_button")).click();
2046
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2047
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello");
2048
+ cy.get(cesc("#\\/n")).should("have.text", "3");
2049
+
2050
+ cy.get(cesc("#\\/_triggerset1_button")).click();
2051
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2052
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello hello");
2053
+ cy.get(cesc("#\\/n")).should("have.text", "4");
2054
+ });
2055
+
2056
+ it("triggerSet and chain to triggerset", () => {
2057
+ cy.window().then(async (win) => {
2058
+ win.postMessage(
2059
+ {
2060
+ doenetML: `
2061
+ <text>a</text>
2062
+ <p>Boolean to swap: <boolean name="b" /></p>
2063
+ <p>Say hello: <text name="hello"></text></p>
2064
+ <p>Count: <number name="n">1</number></p>
2065
+ <p>Count down: <number name="m">5</number></p>
2066
+
2067
+ <triggerSet >
2068
+ <label>perform updates</label>
2069
+ <updateValue target="b" newValue="not$b" type="boolean" />
2070
+ <updateValue target="hello" newValue="$hello hello" type="text" />
2071
+ </triggerSet>
2072
+
2073
+ <triggerSet triggerWith="_triggerset1" >
2074
+ <label>perform updates</label>
2075
+ <updateValue target="n" newValue="$n+1" type="number" />
2076
+ <updateValue target="m" newValue="$m-1" type="number" />
2077
+ </triggerSet>
2078
+
2079
+ `,
2080
+ },
2081
+ "*",
2082
+ );
2083
+ });
2084
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2085
+
2086
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2087
+ cy.get(cesc("#\\/hello")).should("have.text", "");
2088
+ cy.get(cesc("#\\/n")).should("have.text", "1");
2089
+ cy.get(cesc("#\\/m")).should("have.text", "5");
2090
+ cy.get(cesc("#\\/_triggerset2")).should("not.exist");
2091
+
2092
+ cy.get(cesc("#\\/_triggerset1_button")).click();
2093
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2094
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2095
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2096
+ cy.get(cesc("#\\/m")).should("have.text", "4");
2097
+
2098
+ cy.get(cesc("#\\/_triggerset1_button")).click();
2099
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2100
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello");
2101
+ cy.get(cesc("#\\/n")).should("have.text", "3");
2102
+ cy.get(cesc("#\\/m")).should("have.text", "3");
2103
+
2104
+ cy.get(cesc("#\\/_triggerset1_button")).click();
2105
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2106
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello hello");
2107
+ cy.get(cesc("#\\/n")).should("have.text", "4");
2108
+ cy.get(cesc("#\\/m")).should("have.text", "2");
2109
+ });
2110
+
2111
+ it("triggerSet based on trigger", () => {
2112
+ cy.window().then(async (win) => {
2113
+ win.postMessage(
2114
+ {
2115
+ doenetML: `
2116
+ <text>a</text>
2117
+ <graph>
2118
+ <point name="P">(-1,2)</point>
2119
+ </graph>
2120
+ <math name="x">x</math>
2121
+ <math name="y">y</math>
2122
+
2123
+ <triggerSet triggerWhen="$(P.x)>0 and $(P.y)>0" >
2124
+ <updateValue name="trip" target="x" newValue="3$x" simplify />
2125
+ <updateValue name="quad" target="y" newValue="4$y" simplify />
2126
+ </triggerSet>
2127
+ `,
2128
+ },
2129
+ "*",
2130
+ );
2131
+ });
2132
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2133
+
2134
+ cy.get(cesc("#\\/x"))
2135
+ .find(".mjx-mrow")
2136
+ .eq(0)
2137
+ .invoke("text")
2138
+ .then((text) => {
2139
+ expect(text.trim()).equal("x");
2140
+ });
2141
+ cy.get(cesc("#\\/y"))
2142
+ .find(".mjx-mrow")
2143
+ .eq(0)
2144
+ .invoke("text")
2145
+ .then((text) => {
2146
+ expect(text.trim()).equal("y");
2147
+ });
2148
+
2149
+ cy.get(cesc("#\\/trip")).should("not.exist");
2150
+ cy.get(cesc("#\\/quad")).should("not.exist");
2151
+
2152
+ cy.window().then(async (win) => {
2153
+ await win.callAction1({
2154
+ actionName: "movePoint",
2155
+ componentName: "/P",
2156
+ args: { x: -1, y: -7 },
2157
+ });
2158
+ cy.get(cesc("#\\/x"))
2159
+ .find(".mjx-mrow")
2160
+ .eq(0)
2161
+ .invoke("text")
2162
+ .then((text) => {
2163
+ expect(text.trim()).equal("x");
2164
+ });
2165
+ cy.get(cesc("#\\/y"))
2166
+ .find(".mjx-mrow")
2167
+ .eq(0)
2168
+ .invoke("text")
2169
+ .then((text) => {
2170
+ expect(text.trim()).equal("y");
2171
+ });
2172
+ });
2173
+
2174
+ cy.window().then(async (win) => {
2175
+ await win.callAction1({
2176
+ actionName: "movePoint",
2177
+ componentName: "/P",
2178
+ args: { x: 3, y: -4 },
2179
+ });
2180
+ cy.get(cesc("#\\/x"))
2181
+ .find(".mjx-mrow")
2182
+ .eq(0)
2183
+ .invoke("text")
2184
+ .then((text) => {
2185
+ expect(text.trim()).equal("x");
2186
+ });
2187
+ cy.get(cesc("#\\/y"))
2188
+ .find(".mjx-mrow")
2189
+ .eq(0)
2190
+ .invoke("text")
2191
+ .then((text) => {
2192
+ expect(text.trim()).equal("y");
2193
+ });
2194
+ });
2195
+
2196
+ cy.window().then(async (win) => {
2197
+ await win.callAction1({
2198
+ actionName: "movePoint",
2199
+ componentName: "/P",
2200
+ args: { x: 1, y: 7 },
2201
+ });
2202
+ cy.get(cesc("#\\/x")).should("contain.text", "3x");
2203
+ cy.get(cesc("#\\/y")).should("contain.text", "4y");
2204
+ cy.get(cesc("#\\/x"))
2205
+ .find(".mjx-mrow")
2206
+ .eq(0)
2207
+ .invoke("text")
2208
+ .then((text) => {
2209
+ expect(text.trim()).equal("3x");
2210
+ });
2211
+ cy.get(cesc("#\\/y"))
2212
+ .find(".mjx-mrow")
2213
+ .eq(0)
2214
+ .invoke("text")
2215
+ .then((text) => {
2216
+ expect(text.trim()).equal("4y");
2217
+ });
2218
+ });
2219
+
2220
+ cy.window().then(async (win) => {
2221
+ await win.callAction1({
2222
+ actionName: "movePoint",
2223
+ componentName: "/P",
2224
+ args: { x: 5, y: 9 },
2225
+ });
2226
+ cy.get(cesc("#\\/x"))
2227
+ .find(".mjx-mrow")
2228
+ .eq(0)
2229
+ .invoke("text")
2230
+ .then((text) => {
2231
+ expect(text.trim()).equal("3x");
2232
+ });
2233
+ cy.get(cesc("#\\/y"))
2234
+ .find(".mjx-mrow")
2235
+ .eq(0)
2236
+ .invoke("text")
2237
+ .then((text) => {
2238
+ expect(text.trim()).equal("4y");
2239
+ });
2240
+ });
2241
+
2242
+ cy.window().then(async (win) => {
2243
+ await win.callAction1({
2244
+ actionName: "movePoint",
2245
+ componentName: "/P",
2246
+ args: { x: -3, y: 4 },
2247
+ });
2248
+ cy.get(cesc("#\\/x"))
2249
+ .find(".mjx-mrow")
2250
+ .eq(0)
2251
+ .invoke("text")
2252
+ .then((text) => {
2253
+ expect(text.trim()).equal("3x");
2254
+ });
2255
+ cy.get(cesc("#\\/y"))
2256
+ .find(".mjx-mrow")
2257
+ .eq(0)
2258
+ .invoke("text")
2259
+ .then((text) => {
2260
+ expect(text.trim()).equal("4y");
2261
+ });
2262
+ });
2263
+
2264
+ cy.window().then(async (win) => {
2265
+ await win.callAction1({
2266
+ actionName: "movePoint",
2267
+ componentName: "/P",
2268
+ args: { x: -6, y: 5 },
2269
+ });
2270
+ cy.get(cesc("#\\/x"))
2271
+ .find(".mjx-mrow")
2272
+ .eq(0)
2273
+ .invoke("text")
2274
+ .then((text) => {
2275
+ expect(text.trim()).equal("3x");
2276
+ });
2277
+ cy.get(cesc("#\\/y"))
2278
+ .find(".mjx-mrow")
2279
+ .eq(0)
2280
+ .invoke("text")
2281
+ .then((text) => {
2282
+ expect(text.trim()).equal("4y");
2283
+ });
2284
+ });
2285
+
2286
+ cy.window().then(async (win) => {
2287
+ await win.callAction1({
2288
+ actionName: "movePoint",
2289
+ componentName: "/P",
2290
+ args: { x: 4, y: 2 },
2291
+ });
2292
+ cy.get(cesc("#\\/x")).should("contain.text", "9x");
2293
+ cy.get(cesc("#\\/y")).should("contain.text", "16y");
2294
+ cy.get(cesc("#\\/x"))
2295
+ .find(".mjx-mrow")
2296
+ .eq(0)
2297
+ .invoke("text")
2298
+ .then((text) => {
2299
+ expect(text.trim()).equal("9x");
2300
+ });
2301
+ cy.get(cesc("#\\/y"))
2302
+ .find(".mjx-mrow")
2303
+ .eq(0)
2304
+ .invoke("text")
2305
+ .then((text) => {
2306
+ expect(text.trim()).equal("16y");
2307
+ });
2308
+ });
2309
+
2310
+ cy.window().then(async (win) => {
2311
+ await win.callAction1({
2312
+ actionName: "movePoint",
2313
+ componentName: "/P",
2314
+ args: { x: 9, y: 7 },
2315
+ });
2316
+ cy.get(cesc("#\\/x"))
2317
+ .find(".mjx-mrow")
2318
+ .eq(0)
2319
+ .invoke("text")
2320
+ .then((text) => {
2321
+ expect(text.trim()).equal("9x");
2322
+ });
2323
+ cy.get(cesc("#\\/y"))
2324
+ .find(".mjx-mrow")
2325
+ .eq(0)
2326
+ .invoke("text")
2327
+ .then((text) => {
2328
+ expect(text.trim()).equal("16y");
2329
+ });
2330
+ });
2331
+ });
2332
+
2333
+ it("triggerWhen supercedes chaining for triggerset", () => {
2334
+ cy.window().then(async (win) => {
2335
+ win.postMessage(
2336
+ {
2337
+ doenetML: `
2338
+ <text>a</text>
2339
+ <graph>
2340
+ <point name="P">(-1,2)</point>
2341
+ </graph>
2342
+
2343
+ <p>Boolean to swap: <boolean name="b" /></p>
2344
+ <p>Say hello: <text name="hello"></text></p>
2345
+ <p>Count: <number name="n">1</number></p>
2346
+ <p>Count down: <number name="m">5</number></p>
2347
+
2348
+ <triggerSet triggerWhen="$(P.x)>0 and $(P.y)>0">
2349
+ <label>perform updates</label>
2350
+ <updateValue target="b" newValue="not$b" type="boolean" />
2351
+ <updateValue target="hello" newValue="$hello hello" type="text" />
2352
+ </triggerSet>
2353
+
2354
+ <triggerSet triggerWith="_triggerset1" triggerWhen="$(P.x)<0 and $(P.y)<0" >
2355
+ <label>perform updates</label>
2356
+ <updateValue target="n" newValue="$n+1" type="number" />
2357
+ <updateValue target="m" newValue="$m-1" type="number" />
2358
+ </triggerSet>
2359
+
2360
+ `,
2361
+ },
2362
+ "*",
2363
+ );
2364
+ });
2365
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2366
+
2367
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2368
+ cy.get(cesc("#\\/hello")).should("have.text", "");
2369
+ cy.get(cesc("#\\/n")).should("have.text", "1");
2370
+ cy.get(cesc("#\\/m")).should("have.text", "5");
2371
+ cy.get(cesc("#\\/_triggerset1")).should("not.exist");
2372
+ cy.get(cesc("#\\/_triggerset2")).should("not.exist");
2373
+
2374
+ cy.window().then(async (win) => {
2375
+ await win.callAction1({
2376
+ actionName: "movePoint",
2377
+ componentName: "/P",
2378
+ args: { x: -1, y: -7 },
2379
+ });
2380
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2381
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2382
+ cy.get(cesc("#\\/hello")).should("have.text", "");
2383
+ cy.get(cesc("#\\/m")).should("have.text", "4");
2384
+ });
2385
+
2386
+ cy.window().then(async (win) => {
2387
+ await win.callAction1({
2388
+ actionName: "movePoint",
2389
+ componentName: "/P",
2390
+ args: { x: 3, y: -4 },
2391
+ });
2392
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2393
+ cy.get(cesc("#\\/hello")).should("have.text", "");
2394
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2395
+ cy.get(cesc("#\\/m")).should("have.text", "4");
2396
+ });
2397
+
2398
+ cy.window().then(async (win) => {
2399
+ await win.callAction1({
2400
+ actionName: "movePoint",
2401
+ componentName: "/P",
2402
+ args: { x: 1, y: 7 },
2403
+ });
2404
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2405
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2406
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2407
+ cy.get(cesc("#\\/m")).should("have.text", "4");
2408
+ });
2409
+
2410
+ cy.window().then(async (win) => {
2411
+ await win.callAction1({
2412
+ actionName: "movePoint",
2413
+ componentName: "/P",
2414
+ args: { x: 5, y: 9 },
2415
+ });
2416
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2417
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2418
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2419
+ cy.get(cesc("#\\/m")).should("have.text", "4");
2420
+ });
2421
+
2422
+ cy.window().then(async (win) => {
2423
+ await win.callAction1({
2424
+ actionName: "movePoint",
2425
+ componentName: "/P",
2426
+ args: { x: -3, y: -4 },
2427
+ });
2428
+ cy.get(cesc("#\\/n")).should("have.text", "3");
2429
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2430
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2431
+ cy.get(cesc("#\\/m")).should("have.text", "3");
2432
+ });
2433
+
2434
+ cy.window().then(async (win) => {
2435
+ await win.callAction1({
2436
+ actionName: "movePoint",
2437
+ componentName: "/P",
2438
+ args: { x: -6, y: -5 },
2439
+ });
2440
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2441
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2442
+ cy.get(cesc("#\\/n")).should("have.text", "3");
2443
+ cy.get(cesc("#\\/m")).should("have.text", "3");
2444
+ });
2445
+
2446
+ cy.window().then(async (win) => {
2447
+ await win.callAction1({
2448
+ actionName: "movePoint",
2449
+ componentName: "/P",
2450
+ args: { x: 4, y: 2 },
2451
+ });
2452
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2453
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello");
2454
+ cy.get(cesc("#\\/n")).should("have.text", "3");
2455
+ cy.get(cesc("#\\/m")).should("have.text", "3");
2456
+ });
2457
+
2458
+ cy.window().then(async (win) => {
2459
+ await win.callAction1({
2460
+ actionName: "movePoint",
2461
+ componentName: "/P",
2462
+ args: { x: 9, y: 7 },
2463
+ });
2464
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2465
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello");
2466
+ cy.get(cesc("#\\/n")).should("have.text", "3");
2467
+ cy.get(cesc("#\\/m")).should("have.text", "3");
2468
+ });
2469
+ });
2470
+
2471
+ it("triggerset supercedes triggerWhen for updateValue children", () => {
2472
+ cy.window().then(async (win) => {
2473
+ win.postMessage(
2474
+ {
2475
+ doenetML: `
2476
+ <text>a</text>
2477
+ <graph>
2478
+ <point name="P">(-1,2)</point>
2479
+ </graph>
2480
+
2481
+ <p>Boolean to swap: <boolean name="b" /></p>
2482
+ <p>Say hello: <text name="hello"></text></p>
2483
+ <p>Count: <number name="n">1</number></p>
2484
+
2485
+ <triggerSet triggerWhen="$(P.x)>0 and $(P.y)>0">
2486
+ <label>perform updates</label>
2487
+ <updateValue target="b" newValue="not$b" type="boolean" />
2488
+ <updateValue target="hello" newValue="$hello hello" type="text" />
2489
+ <updateValue target="n" newValue="$n+1" type="number" triggerWhen="$(P.x)<0 and $(P.y)<0" />
2490
+ </triggerSet>
2491
+
2492
+ `,
2493
+ },
2494
+ "*",
2495
+ );
2496
+ });
2497
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2498
+
2499
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2500
+ cy.get(cesc("#\\/hello")).should("have.text", "");
2501
+ cy.get(cesc("#\\/n")).should("have.text", "1");
2502
+
2503
+ cy.window().then(async (win) => {
2504
+ await win.callAction1({
2505
+ actionName: "movePoint",
2506
+ componentName: "/P",
2507
+ args: { x: -1, y: -7 },
2508
+ });
2509
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2510
+ cy.get(cesc("#\\/hello")).should("have.text", "");
2511
+ cy.get(cesc("#\\/n")).should("have.text", "1");
2512
+ });
2513
+
2514
+ cy.window().then(async (win) => {
2515
+ await win.callAction1({
2516
+ actionName: "movePoint",
2517
+ componentName: "/P",
2518
+ args: { x: 3, y: -4 },
2519
+ });
2520
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2521
+ cy.get(cesc("#\\/hello")).should("have.text", "");
2522
+ cy.get(cesc("#\\/n")).should("have.text", "1");
2523
+ });
2524
+
2525
+ cy.window().then(async (win) => {
2526
+ await win.callAction1({
2527
+ actionName: "movePoint",
2528
+ componentName: "/P",
2529
+ args: { x: 1, y: 7 },
2530
+ });
2531
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2532
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2533
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2534
+ });
2535
+
2536
+ cy.window().then(async (win) => {
2537
+ await win.callAction1({
2538
+ actionName: "movePoint",
2539
+ componentName: "/P",
2540
+ args: { x: 5, y: 9 },
2541
+ });
2542
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2543
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2544
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2545
+ });
2546
+
2547
+ cy.window().then(async (win) => {
2548
+ await win.callAction1({
2549
+ actionName: "movePoint",
2550
+ componentName: "/P",
2551
+ args: { x: -3, y: -4 },
2552
+ });
2553
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2554
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2555
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2556
+ });
2557
+
2558
+ cy.window().then(async (win) => {
2559
+ await win.callAction1({
2560
+ actionName: "movePoint",
2561
+ componentName: "/P",
2562
+ args: { x: -6, y: -5 },
2563
+ });
2564
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2565
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2566
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2567
+ });
2568
+
2569
+ cy.window().then(async (win) => {
2570
+ await win.callAction1({
2571
+ actionName: "movePoint",
2572
+ componentName: "/P",
2573
+ args: { x: 4, y: 2 },
2574
+ });
2575
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2576
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello");
2577
+ cy.get(cesc("#\\/n")).should("have.text", "3");
2578
+ });
2579
+
2580
+ cy.window().then(async (win) => {
2581
+ await win.callAction1({
2582
+ actionName: "movePoint",
2583
+ componentName: "/P",
2584
+ args: { x: 9, y: 7 },
2585
+ });
2586
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2587
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello");
2588
+ cy.get(cesc("#\\/n")).should("have.text", "3");
2589
+ });
2590
+ });
2591
+
2592
+ it("triggerset supercedes chaining for updateValue children", () => {
2593
+ cy.window().then(async (win) => {
2594
+ win.postMessage(
2595
+ {
2596
+ doenetML: `
2597
+ <text>a</text>
2598
+ <graph>
2599
+ <point name="P">(-1,2)</point>
2600
+ </graph>
2601
+
2602
+ <p>Boolean to swap: <boolean name="b" /></p>
2603
+ <p>Say hello: <text name="hello"></text></p>
2604
+ <p>Count: <number name="n">1</number></p>
2605
+ <p>Count down: <number name="m">5</number></p>
2606
+
2607
+ <triggerSet triggerWhen="$(P.x)>0 and $(P.y)>0">
2608
+ <label>perform updates</label>
2609
+ <updateValue target="b" newValue="not$b" type="boolean" />
2610
+ <updateValue target="hello" newValue="$hello hello" type="text" />
2611
+ <updateValue target="n" newValue="$n+1" type="number" triggerWith="uv" />
2612
+ </triggerSet>
2613
+
2614
+ <updateValue name="uv" target="m" newValue="$m-1" type="number" triggerWhen="$(P.x)<0 and $(P.y)<0" />
2615
+
2616
+ `,
2617
+ },
2618
+ "*",
2619
+ );
2620
+ });
2621
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2622
+
2623
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2624
+ cy.get(cesc("#\\/hello")).should("have.text", "");
2625
+ cy.get(cesc("#\\/n")).should("have.text", "1");
2626
+ cy.get(cesc("#\\/m")).should("have.text", "5");
2627
+ cy.get(cesc("#\\/_triggerset1")).should("not.exist");
2628
+ cy.get(cesc("#\\/uv")).should("not.exist");
2629
+
2630
+ cy.window().then(async (win) => {
2631
+ await win.callAction1({
2632
+ actionName: "movePoint",
2633
+ componentName: "/P",
2634
+ args: { x: -1, y: -7 },
2635
+ });
2636
+ cy.get(cesc("#\\/m")).should("have.text", "4");
2637
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2638
+ cy.get(cesc("#\\/hello")).should("have.text", "");
2639
+ cy.get(cesc("#\\/n")).should("have.text", "1");
2640
+ });
2641
+
2642
+ cy.window().then(async (win) => {
2643
+ await win.callAction1({
2644
+ actionName: "movePoint",
2645
+ componentName: "/P",
2646
+ args: { x: 3, y: -4 },
2647
+ });
2648
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2649
+ cy.get(cesc("#\\/hello")).should("have.text", "");
2650
+ cy.get(cesc("#\\/n")).should("have.text", "1");
2651
+ cy.get(cesc("#\\/m")).should("have.text", "4");
2652
+ });
2653
+
2654
+ cy.window().then(async (win) => {
2655
+ await win.callAction1({
2656
+ actionName: "movePoint",
2657
+ componentName: "/P",
2658
+ args: { x: 1, y: 7 },
2659
+ });
2660
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2661
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2662
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2663
+ cy.get(cesc("#\\/m")).should("have.text", "4");
2664
+ });
2665
+
2666
+ cy.window().then(async (win) => {
2667
+ await win.callAction1({
2668
+ actionName: "movePoint",
2669
+ componentName: "/P",
2670
+ args: { x: 5, y: 9 },
2671
+ });
2672
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2673
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2674
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2675
+ cy.get(cesc("#\\/m")).should("have.text", "4");
2676
+ });
2677
+
2678
+ cy.window().then(async (win) => {
2679
+ await win.callAction1({
2680
+ actionName: "movePoint",
2681
+ componentName: "/P",
2682
+ args: { x: -3, y: -4 },
2683
+ });
2684
+ cy.get(cesc("#\\/m")).should("have.text", "3");
2685
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2686
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2687
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2688
+ });
2689
+
2690
+ cy.window().then(async (win) => {
2691
+ await win.callAction1({
2692
+ actionName: "movePoint",
2693
+ componentName: "/P",
2694
+ args: { x: -6, y: -5 },
2695
+ });
2696
+ cy.get(cesc("#\\/b")).should("have.text", "true");
2697
+ cy.get(cesc("#\\/hello")).should("have.text", " hello");
2698
+ cy.get(cesc("#\\/n")).should("have.text", "2");
2699
+ cy.get(cesc("#\\/m")).should("have.text", "3");
2700
+ });
2701
+
2702
+ cy.window().then(async (win) => {
2703
+ await win.callAction1({
2704
+ actionName: "movePoint",
2705
+ componentName: "/P",
2706
+ args: { x: 4, y: 2 },
2707
+ });
2708
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2709
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello");
2710
+ cy.get(cesc("#\\/n")).should("have.text", "3");
2711
+ cy.get(cesc("#\\/m")).should("have.text", "3");
2712
+ });
2713
+
2714
+ cy.window().then(async (win) => {
2715
+ await win.callAction1({
2716
+ actionName: "movePoint",
2717
+ componentName: "/P",
2718
+ args: { x: 9, y: 7 },
2719
+ });
2720
+ cy.get(cesc("#\\/b")).should("have.text", "false");
2721
+ cy.get(cesc("#\\/hello")).should("have.text", " hello hello");
2722
+ cy.get(cesc("#\\/n")).should("have.text", "3");
2723
+ cy.get(cesc("#\\/m")).should("have.text", "3");
2724
+ });
2725
+ });
2726
+
2727
+ it("update value to blank string", () => {
2728
+ cy.window().then(async (win) => {
2729
+ win.postMessage(
2730
+ {
2731
+ doenetML: `
2732
+ <text>a</text>
2733
+ <text name="t">something</text>
2734
+ <updatevalue name="toBlank" type="text" target="t" newValue="" >
2735
+ <label>setToBlank</label>
2736
+ </updateValue>
2737
+
2738
+ `,
2739
+ },
2740
+ "*",
2741
+ );
2742
+ });
2743
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2744
+
2745
+ cy.get(cesc("#\\/t")).should("have.text", "something");
2746
+ cy.get(cesc("#\\/toBlank_button")).click();
2747
+ cy.get(cesc("#\\/t")).should("have.text", "");
2748
+ });
2749
+
2750
+ // TODO: what is supposed to happen here?
2751
+ it.skip("update value set to ignore read only flag", () => {
2752
+ let doenetML = `
2753
+ <text>a</text>
2754
+ <p>m = <number name="m" >1</number></p>
2755
+ <p>n = <number name="n" >10</number></p>
2756
+
2757
+ <p><updateValue name="incm" target="m" newValue="$m+1" >
2758
+ <label>increment m</label>
2759
+ </updateValue></p>
2760
+ <p><updateValue name="incn" target="n" newValue="$n+10" disabledIgnoresParentReadOnly >
2761
+ <label>increment n</label>
2762
+ </updateValue></p>
2763
+
2764
+ `;
2765
+ cy.get("#testRunner_toggleControls").click();
2766
+ cy.get("#testRunner_allowLocalState").click();
2767
+ cy.wait(100);
2768
+ cy.get("#testRunner_toggleControls").click();
2769
+
2770
+ cy.window().then(async (win) => {
2771
+ win.postMessage(
2772
+ {
2773
+ doenetML,
2774
+ },
2775
+ "*",
2776
+ );
2777
+ });
2778
+
2779
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2780
+
2781
+ cy.get(cesc("#\\/m")).should("have.text", "1");
2782
+ cy.get(cesc("#\\/n")).should("have.text", "10");
2783
+
2784
+ cy.get(cesc("#\\/incm_button")).click();
2785
+ cy.get(cesc("#\\/incn_button")).click();
2786
+
2787
+ cy.get(cesc("#\\/m")).should("have.text", "2");
2788
+ cy.get(cesc("#\\/n")).should("have.text", "20");
2789
+
2790
+ cy.wait(2000); // wait to make sure 1 second debounce occurred
2791
+
2792
+ cy.get("#testRunner_toggleControls").click();
2793
+ cy.get("#testRunner_readOnly").click();
2794
+ cy.wait(100);
2795
+ cy.get("#testRunner_toggleControls").click();
2796
+
2797
+ cy.reload();
2798
+
2799
+ cy.window().then(async (win) => {
2800
+ win.postMessage(
2801
+ {
2802
+ doenetML,
2803
+ },
2804
+ "*",
2805
+ );
2806
+ });
2807
+
2808
+ cy.get(cesc("#\\/incm_button")).should("be.disabled");
2809
+ cy.get(cesc("#\\/incn_button")).should("not.be.disabled");
2810
+
2811
+ cy.get(cesc("#\\/m")).should("have.text", "2");
2812
+ cy.get(cesc("#\\/n")).should("have.text", "20");
2813
+
2814
+ cy.get(cesc("#\\/incm_button")).click();
2815
+ cy.get(cesc("#\\/incn_button")).click();
2816
+
2817
+ cy.get(cesc("#\\/m")).should("have.text", "2");
2818
+ cy.get(cesc("#\\/n")).should("have.text", "30");
2819
+ });
2820
+
2821
+ it("math in label", () => {
2822
+ cy.window().then(async (win) => {
2823
+ win.postMessage(
2824
+ {
2825
+ doenetML: `
2826
+ <text>a</text>
2827
+ <boolean name="b" />
2828
+ <updateValue target="b" newValue="not$b" type="boolean" name="update">
2829
+ <label>we have <m>\\prod_{i=1}^3 y_i</m></label>
2830
+ </updateValue>
2831
+ `,
2832
+ },
2833
+ "*",
2834
+ );
2835
+ });
2836
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2837
+
2838
+ cy.get(cesc("#\\/update")).should("contain.text", "we have ∏3i=1yi");
2839
+
2840
+ cy.window().then(async (win) => {
2841
+ let stateVariables = await win.returnAllStateVariables1();
2842
+ expect(stateVariables["/update"].stateValues.label).eq(
2843
+ "we have \\(\\prod_{i=1}^3 y_i\\)",
2844
+ );
2845
+ });
2846
+ });
2847
+
2848
+ it("label is name", () => {
2849
+ cy.window().then(async (win) => {
2850
+ win.postMessage(
2851
+ {
2852
+ doenetML: `
2853
+ <text>a</text>
2854
+ <boolean name="b" />
2855
+ <updateValue target="b" newValue="not$b" type="boolean" name="SwapIt" labelIsName />
2856
+ `,
2857
+ },
2858
+ "*",
2859
+ );
2860
+ });
2861
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2862
+
2863
+ cy.get(cesc("#\\/SwapIt")).should("contain.text", "Swap It");
2864
+
2865
+ cy.window().then(async (win) => {
2866
+ let stateVariables = await win.returnAllStateVariables1();
2867
+ expect(stateVariables["/SwapIt"].stateValues.label).eq("Swap It");
2868
+ });
2869
+ });
2870
+
2871
+ it("update essential label value", () => {
2872
+ cy.window().then(async (win) => {
2873
+ win.postMessage(
2874
+ {
2875
+ doenetML: `
2876
+ <updateValue target="uv.label" newValue="Hello!" type="text" name="uv" />
2877
+ `,
2878
+ },
2879
+ "*",
2880
+ );
2881
+ });
2882
+
2883
+ cy.get(cesc("#\\/uv")).should("contain.text", "Button");
2884
+
2885
+ cy.window().then(async (win) => {
2886
+ let stateVariables = await win.returnAllStateVariables1();
2887
+ expect(stateVariables["/uv"].stateValues.label).eq("");
2888
+ });
2889
+
2890
+ cy.get(cesc("#\\/uv")).click();
2891
+
2892
+ cy.get(cesc("#\\/uv")).should("contain.text", "Hello!");
2893
+
2894
+ cy.window().then(async (win) => {
2895
+ let stateVariables = await win.returnAllStateVariables1();
2896
+ expect(stateVariables["/uv"].stateValues.label).eq("Hello!");
2897
+ });
2898
+ });
2899
+
2900
+ it("bug fix: no duplicate name error, #1921", () => {
2901
+ cy.window().then(async (win) => {
2902
+ win.postMessage(
2903
+ {
2904
+ doenetML: `
2905
+ <updateValue target="v.tail.coords" newValue="(3,4)"><label>Move tail</label></updateValue>
2906
+ <triggerSet>
2907
+ <label>Move both</label>
2908
+ <updateValue target="v.head.coords" newValue="(5,6)" />
2909
+ <updateValue target="v.tail.coords" newValue="(7,2)" />
2910
+ </triggerSet><graph>
2911
+ <vector name="v" />
2912
+ </graph><copy source="v.tail" assignNames="vt" /><copy source="v.head" assignNames="vh" />
2913
+ `,
2914
+ },
2915
+ "*",
2916
+ );
2917
+ });
2918
+
2919
+ cy.get(cesc("#\\/_updatevalue1")).should("contain.text", "Move tail");
2920
+ cy.get(cesc("#\\/_triggerset1")).should("contain.text", "Move both");
2921
+ cy.get(cesc("#\\/vh") + " .mjx-mrow")
2922
+ .eq(0)
2923
+ .should("have.text", "(1,0)");
2924
+ cy.get(cesc("#\\/vt") + " .mjx-mrow")
2925
+ .eq(0)
2926
+ .should("have.text", "(0,0)");
2927
+
2928
+ cy.get(cesc("#\\/_updatevalue1")).click();
2929
+
2930
+ cy.get(cesc("#\\/vt") + " .mjx-mrow").should("contain.text", "(3,4)");
2931
+
2932
+ cy.get(cesc("#\\/vt") + " .mjx-mrow")
2933
+ .eq(0)
2934
+ .should("have.text", "(3,4)");
2935
+ cy.get(cesc("#\\/vh") + " .mjx-mrow")
2936
+ .eq(0)
2937
+ .should("have.text", "(4,4)");
2938
+
2939
+ cy.get(cesc("#\\/_triggerset1")).click();
2940
+ cy.get(cesc("#\\/vt") + " .mjx-mrow").should("contain.text", "(7,2)");
2941
+
2942
+ cy.get(cesc("#\\/vt") + " .mjx-mrow")
2943
+ .eq(0)
2944
+ .should("have.text", "(7,2)");
2945
+ cy.get(cesc("#\\/vh") + " .mjx-mrow")
2946
+ .eq(0)
2947
+ .should("have.text", "(9,4)");
2948
+ });
2949
+
2950
+ it("updatevalue in graph", () => {
2951
+ cy.window().then(async (win) => {
2952
+ win.postMessage(
2953
+ {
2954
+ doenetML: `
2955
+ <text>a</text>
2956
+ <p>n: <number name="n">1</number></p>
2957
+ <graph >
2958
+ <updatevalue anchor="$anchorCoords1" name="updatevalue1" positionFromAnchor="$positionFromAnchor1" draggable="$draggable1" disabled="$disabled1" fixed="$fixed1" fixLocation="$fixLocation1" target="n" newValue="$n+1"><label>increment</label></updatevalue>
2959
+ <updatevalue name="updatevalue2" target="n" newValue="$n-1"><label>decrement</label></updatevalue>
2960
+ </graph>
2961
+
2962
+ <p name="pAnchor1">Anchor 1 coordinates: $updatevalue1.anchor</p>
2963
+ <p name="pAnchor2">Anchor 2 coordinates: $updatevalue2.anchor</p>
2964
+ <p name="pChangeAnchor1">Change anchor 1 coordinates: <mathinput name="anchorCoords1" prefill="(1,3)" /></p>
2965
+ <p name="pChangeAnchor2">Change anchor 2 coordinates: <mathinput name="anchorCoords2" bindValueTo="$updatevalue2.anchor" /></p>
2966
+ <p name="pPositionFromAnchor1">Position from anchor 1: $updatevalue1.positionFromAnchor</p>
2967
+ <p name="pPositionFromAnchor2">Position from anchor 2: $updatevalue2.positionFromAnchor</p>
2968
+ <p>Change position from anchor 1
2969
+ <choiceinput inline preselectChoice="1" name="positionFromAnchor1">
2970
+ <choice>upperRight</choice>
2971
+ <choice>upperLeft</choice>
2972
+ <choice>lowerRight</choice>
2973
+ <choice>lowerLeft</choice>
2974
+ <choice>left</choice>
2975
+ <choice>right</choice>
2976
+ <choice>top</choice>
2977
+ <choice>bottom</choice>
2978
+ <choice>center</choice>
2979
+ </choiceinput>
2980
+ </p>
2981
+ <p>Change position from anchor 2
2982
+ <choiceinput inline name="positionFromAnchor2" bindValueTo="$updatevalue2.positionFromAnchor">
2983
+ <choice>upperRight</choice>
2984
+ <choice>upperLeft</choice>
2985
+ <choice>lowerRight</choice>
2986
+ <choice>lowerLeft</choice>
2987
+ <choice>left</choice>
2988
+ <choice>right</choice>
2989
+ <choice>top</choice>
2990
+ <choice>bottom</choice>
2991
+ <choice>center</choice>
2992
+ </choiceinput>
2993
+ </p>
2994
+ <p name="pDraggable1">Draggable 1: $draggable1</p>
2995
+ <p name="pDraggable2">Draggable 2: $draggable2</p>
2996
+ <p>Change draggable 1 <booleanInput name="draggable1" prefill="true" /></p>
2997
+ <p>Change draggable 2 <booleanInput name="draggable2" bindValueTo="$updatevalue2.draggable" /></p>
2998
+ <p name="pDisabled1">Disabled 1: $disabled1</p>
2999
+ <p name="pDisabled2">Disabled 2: $disabled2</p>
3000
+ <p>Change disabled 1 <booleanInput name="disabled1" prefill="true" /></p>
3001
+ <p>Change disabled 2 <booleanInput name="disabled2" bindValueTo="$updatevalue2.disabled" /></p>
3002
+ <p name="pFixed1">Fixed 1: $fixed1</p>
3003
+ <p name="pFixed2">Fixed 2: $fixed2</p>
3004
+ <p>Change fixed 1 <booleanInput name="fixed1" prefill="false" /></p>
3005
+ <p>Change fixed 2 <booleanInput name="fixed2" bindValueTo="$updatevalue2.fixed" /></p>
3006
+ <p name="pFixLocation1">FixLocation 1: $fixLocation1</p>
3007
+ <p name="pFixLocation2">FixLocation 2: $fixLocation2</p>
3008
+ <p>Change fixLocation 1 <booleanInput name="fixLocation1" prefill="false" /></p>
3009
+ <p>Change fixLocation 2 <booleanInput name="fixLocation2" bindValueTo="$updatevalue2.fixLocation" /></p>
3010
+ <p><booleaninput name="bi" /> <boolean name="b" copySource="bi" /></p>
3011
+
3012
+ `,
3013
+ },
3014
+ "*",
3015
+ );
3016
+ });
3017
+
3018
+ // TODO: how to click on the buttons and test if they are disabled?
3019
+
3020
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait until loaded
3021
+
3022
+ cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
3023
+ .eq(0)
3024
+ .should("have.text", "(1,3)");
3025
+ cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
3026
+ .eq(0)
3027
+ .should("have.text", "(0,0)");
3028
+
3029
+ cy.get(cesc("#\\/pPositionFromAnchor1")).should(
3030
+ "have.text",
3031
+ "Position from anchor 1: upperright",
3032
+ );
3033
+ cy.get(cesc("#\\/pPositionFromAnchor2")).should(
3034
+ "have.text",
3035
+ "Position from anchor 2: center",
3036
+ );
3037
+ cy.get(cesc("#\\/positionFromAnchor1")).should("have.value", "1");
3038
+ cy.get(cesc("#\\/positionFromAnchor2")).should("have.value", "9");
3039
+ cy.get(cesc("#\\/pDraggable1")).should("have.text", "Draggable 1: true");
3040
+ cy.get(cesc("#\\/pDraggable2")).should("have.text", "Draggable 2: true");
3041
+
3042
+ cy.log("move updatevalues by dragging");
3043
+
3044
+ cy.window().then(async (win) => {
3045
+ win.callAction1({
3046
+ actionName: "moveButton",
3047
+ componentName: "/updatevalue1",
3048
+ args: { x: -2, y: 3 },
3049
+ });
3050
+ win.callAction1({
3051
+ actionName: "moveButton",
3052
+ componentName: "/updatevalue2",
3053
+ args: { x: 4, y: -5 },
3054
+ });
3055
+ });
3056
+
3057
+ cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow").should(
3058
+ "contain.text",
3059
+ "(4,−5)",
3060
+ );
3061
+
3062
+ cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
3063
+ .eq(0)
3064
+ .should("have.text", "(−2,3)");
3065
+ cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
3066
+ .eq(0)
3067
+ .should("have.text", "(4,−5)");
3068
+
3069
+ cy.log("move updatevalues by entering coordinates");
3070
+
3071
+ cy.get(cesc("#\\/anchorCoords1") + " textarea").type(
3072
+ "{home}{shift+end}{backspace}(6,7){enter}",
3073
+ { force: true },
3074
+ );
3075
+ cy.get(cesc("#\\/anchorCoords2") + " textarea").type(
3076
+ "{home}{shift+end}{backspace}(8,9){enter}",
3077
+ { force: true },
3078
+ );
3079
+
3080
+ cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow").should("contain.text", "(8,9)");
3081
+
3082
+ cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
3083
+ .eq(0)
3084
+ .should("have.text", "(6,7)");
3085
+ cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
3086
+ .eq(0)
3087
+ .should("have.text", "(8,9)");
3088
+
3089
+ cy.log("change position from anchor");
3090
+ cy.get(cesc("#\\/positionFromAnchor1")).select("lowerLeft");
3091
+ cy.get(cesc("#\\/positionFromAnchor2")).select("lowerRight");
3092
+
3093
+ cy.get(cesc("#\\/pPositionFromAnchor1")).should(
3094
+ "have.text",
3095
+ "Position from anchor 1: lowerleft",
3096
+ );
3097
+ cy.get(cesc("#\\/pPositionFromAnchor2")).should(
3098
+ "have.text",
3099
+ "Position from anchor 2: lowerright",
3100
+ );
3101
+
3102
+ cy.log("make not draggable");
3103
+
3104
+ cy.get(cesc("#\\/draggable1")).click();
3105
+ cy.get(cesc("#\\/draggable2")).click();
3106
+ cy.get(cesc("#\\/pDraggable1")).should("have.text", "Draggable 1: false");
3107
+ cy.get(cesc("#\\/pDraggable2")).should("have.text", "Draggable 2: false");
3108
+
3109
+ cy.log("cannot move updatevalues by dragging");
3110
+ cy.window().then(async (win) => {
3111
+ win.callAction1({
3112
+ actionName: "moveButton",
3113
+ componentName: "/updatevalue1",
3114
+ args: { x: -10, y: -9 },
3115
+ });
3116
+ win.callAction1({
3117
+ actionName: "moveButton",
3118
+ componentName: "/updatevalue2",
3119
+ args: { x: -8, y: -7 },
3120
+ });
3121
+ });
3122
+
3123
+ // since nothing will change, wait for boolean input to change to know core has responded
3124
+ cy.get(cesc("#\\/bi")).click();
3125
+ cy.get(cesc("#\\/b")).should("have.text", "true");
3126
+
3127
+ cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
3128
+ .eq(0)
3129
+ .should("have.text", "(6,7)");
3130
+ cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
3131
+ .eq(0)
3132
+ .should("have.text", "(8,9)");
3133
+
3134
+ cy.log("make draggable again");
3135
+
3136
+ cy.get(cesc("#\\/draggable1")).click();
3137
+ cy.get(cesc("#\\/draggable2")).click();
3138
+ cy.get(cesc("#\\/pDraggable1")).should("have.text", "Draggable 1: true");
3139
+ cy.get(cesc("#\\/pDraggable2")).should("have.text", "Draggable 2: true");
3140
+
3141
+ cy.window().then(async (win) => {
3142
+ win.callAction1({
3143
+ actionName: "moveButton",
3144
+ componentName: "/updatevalue1",
3145
+ args: { x: -10, y: -9 },
3146
+ });
3147
+ win.callAction1({
3148
+ actionName: "moveButton",
3149
+ componentName: "/updatevalue2",
3150
+ args: { x: -8, y: -7 },
3151
+ });
3152
+ });
3153
+
3154
+ cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow").should(
3155
+ "contain.text",
3156
+ "(−8,−7)",
3157
+ );
3158
+
3159
+ cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
3160
+ .eq(0)
3161
+ .should("have.text", "(−10,−9)");
3162
+ cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
3163
+ .eq(0)
3164
+ .should("have.text", "(−8,−7)");
3165
+
3166
+ cy.log("fix location");
3167
+
3168
+ cy.get(cesc("#\\/fixLocation1")).click();
3169
+ cy.get(cesc("#\\/fixLocation2")).click();
3170
+ cy.get(cesc("#\\/pFixLocation1")).should(
3171
+ "have.text",
3172
+ "FixLocation 1: true",
3173
+ );
3174
+ cy.get(cesc("#\\/pFixLocation2")).should(
3175
+ "have.text",
3176
+ "FixLocation 2: true",
3177
+ );
3178
+
3179
+ cy.log("can change coordinates entering coordinates only for button 1");
3180
+
3181
+ cy.get(cesc("#\\/anchorCoords2") + " textarea").type(
3182
+ "{home}{shift+end}{backspace}(3,4){enter}",
3183
+ { force: true },
3184
+ );
3185
+ cy.get(cesc("#\\/anchorCoords1") + " textarea").type(
3186
+ "{home}{shift+end}{backspace}(1,2){enter}",
3187
+ { force: true },
3188
+ );
3189
+
3190
+ cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow").should("contain.text", "(1,2)");
3191
+
3192
+ cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
3193
+ .eq(0)
3194
+ .should("have.text", "(1,2)");
3195
+ cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
3196
+ .eq(0)
3197
+ .should("have.text", "(−8,−7)");
3198
+
3199
+ cy.log("cannot move updatevalues by dragging");
3200
+ cy.window().then(async (win) => {
3201
+ win.callAction1({
3202
+ actionName: "moveButton",
3203
+ componentName: "/updatevalue1",
3204
+ args: { x: 4, y: 6 },
3205
+ });
3206
+ win.callAction1({
3207
+ actionName: "moveButton",
3208
+ componentName: "/updatevalue2",
3209
+ args: { x: 7, y: 8 },
3210
+ });
3211
+ });
3212
+
3213
+ // since nothing will change, wait for boolean input to change to know core has responded
3214
+ cy.get(cesc("#\\/bi")).click();
3215
+ cy.get(cesc("#\\/b")).should("have.text", "false");
3216
+
3217
+ cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
3218
+ .eq(0)
3219
+ .should("have.text", "(1,2)");
3220
+ cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
3221
+ .eq(0)
3222
+ .should("have.text", "(−8,−7)");
3223
+
3224
+ cy.log("can change position from anchor only for button 1");
3225
+ cy.get(cesc("#\\/positionFromAnchor2")).select("bottom");
3226
+ cy.get(cesc("#\\/positionFromAnchor1")).select("top");
3227
+
3228
+ cy.get(cesc("#\\/pPositionFromAnchor1")).should(
3229
+ "have.text",
3230
+ "Position from anchor 1: top",
3231
+ );
3232
+ cy.get(cesc("#\\/pPositionFromAnchor2")).should(
3233
+ "have.text",
3234
+ "Position from anchor 2: lowerright",
3235
+ );
3236
+
3237
+ cy.log("can change disabled attribute");
3238
+ cy.get(cesc("#\\/disabled1")).click();
3239
+ cy.get(cesc("#\\/disabled2")).click();
3240
+ cy.get(cesc("#\\/pDisabled1")).should("have.text", "Disabled 1: false");
3241
+ cy.get(cesc("#\\/pDisabled2")).should("have.text", "Disabled 2: true");
3242
+
3243
+ cy.log("make completely fixed");
3244
+ cy.get(cesc("#\\/fixed1")).click();
3245
+ cy.get(cesc("#\\/fixed2")).click();
3246
+ cy.get(cesc("#\\/pFixed1")).should("have.text", "Fixed 1: true");
3247
+ cy.get(cesc("#\\/pFixed2")).should("have.text", "Fixed 2: true");
3248
+
3249
+ cy.log("can change coordinates entering coordinates only for button 1");
3250
+
3251
+ cy.get(cesc("#\\/anchorCoords2") + " textarea").type(
3252
+ "{home}{shift+end}{backspace}(7,8){enter}",
3253
+ { force: true },
3254
+ );
3255
+ cy.get(cesc("#\\/anchorCoords1") + " textarea").type(
3256
+ "{home}{shift+end}{backspace}(5,6){enter}",
3257
+ { force: true },
3258
+ );
3259
+
3260
+ cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow").should("contain.text", "(5,6)");
3261
+
3262
+ cy.get(cesc("#\\/pAnchor1") + " .mjx-mrow")
3263
+ .eq(0)
3264
+ .should("have.text", "(5,6)");
3265
+ cy.get(cesc("#\\/pAnchor2") + " .mjx-mrow")
3266
+ .eq(0)
3267
+ .should("have.text", "(−8,−7)");
3268
+
3269
+ cy.log("can change position from anchor only for button 1");
3270
+ cy.get(cesc("#\\/positionFromAnchor2")).select("left");
3271
+ cy.get(cesc("#\\/positionFromAnchor1")).select("right");
3272
+
3273
+ cy.get(cesc("#\\/pPositionFromAnchor1")).should(
3274
+ "have.text",
3275
+ "Position from anchor 1: right",
3276
+ );
3277
+ cy.get(cesc("#\\/pPositionFromAnchor2")).should(
3278
+ "have.text",
3279
+ "Position from anchor 2: lowerright",
3280
+ );
3281
+
3282
+ cy.log("can change disabled attribute only for button 1");
3283
+ cy.get(cesc("#\\/disabled2")).click();
3284
+ cy.get(cesc("#\\/disabled1")).click();
3285
+ cy.get(cesc("#\\/pDisabled1")).should("have.text", "Disabled 1: true");
3286
+ cy.get(cesc("#\\/pDisabled2")).should("have.text", "Disabled 2: true");
3287
+ });
3288
+ });