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