dceky 1.0.5-beta.ky-declarations.13 → 1.0.5

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 (237) hide show
  1. package/README.md +45 -29
  2. package/lib/commands/assertDoesNotHaveClass.d.ts +18 -0
  3. package/lib/commands/assertDoesNotHaveClass.js +17 -0
  4. package/lib/commands/assertDoesNotHaveClass.js.map +1 -0
  5. package/lib/commands/assertHasClass.d.ts +18 -0
  6. package/lib/commands/assertHasClass.js +17 -0
  7. package/lib/commands/assertHasClass.js.map +1 -0
  8. package/lib/commands/assertNumElements.d.ts +18 -0
  9. package/lib/commands/assertNumElements.js +17 -0
  10. package/lib/commands/assertNumElements.js.map +1 -0
  11. package/lib/commands/clickWithRetry.d.ts +19 -0
  12. package/lib/commands/clickWithRetry.js +29 -0
  13. package/lib/commands/clickWithRetry.js.map +1 -0
  14. package/lib/commands/genTextOfLength.d.ts +20 -0
  15. package/lib/commands/genTextOfLength.js +20 -0
  16. package/lib/commands/genTextOfLength.js.map +1 -0
  17. package/lib/commands/getAttribute.d.ts +20 -0
  18. package/lib/commands/getAttribute.js +22 -0
  19. package/lib/commands/getAttribute.js.map +1 -0
  20. package/lib/commands/getClassName.d.ts +15 -0
  21. package/lib/commands/getClassName.js +21 -0
  22. package/lib/commands/getClassName.js.map +1 -0
  23. package/lib/commands/getCurrentDateInfo.d.ts +21 -0
  24. package/lib/commands/getCurrentDateInfo.js +25 -0
  25. package/lib/commands/getCurrentDateInfo.js.map +1 -0
  26. package/lib/commands/getId.d.ts +15 -0
  27. package/lib/commands/getId.js +21 -0
  28. package/lib/commands/getId.js.map +1 -0
  29. package/lib/commands/getNumElements.d.ts +14 -0
  30. package/lib/commands/getNumElements.js +19 -0
  31. package/lib/commands/getNumElements.js.map +1 -0
  32. package/lib/commands/getSpecialChars.d.ts +14 -0
  33. package/lib/commands/getSpecialChars.js +16 -0
  34. package/lib/commands/getSpecialChars.js.map +1 -0
  35. package/lib/commands/getTitle.d.ts +13 -0
  36. package/lib/commands/getTitle.js +20 -0
  37. package/lib/commands/getTitle.js.map +1 -0
  38. package/lib/commands/handleHarvardKey.d.ts +18 -0
  39. package/lib/commands/handleHarvardKey.js +56 -0
  40. package/lib/commands/handleHarvardKey.js.map +1 -0
  41. package/lib/commands/handleHarvardKey2.d.ts +14 -0
  42. package/lib/commands/handleHarvardKey2.js +88 -0
  43. package/lib/commands/handleHarvardKey2.js.map +1 -0
  44. package/lib/commands/launchAs.d.ts +20 -0
  45. package/lib/commands/launchAs.js +60 -0
  46. package/lib/commands/launchAs.js.map +1 -0
  47. package/lib/commands/launchLTIUsingToken.d.ts +19 -0
  48. package/lib/commands/launchLTIUsingToken.js +74 -0
  49. package/lib/commands/launchLTIUsingToken.js.map +1 -0
  50. package/lib/commands/listSelectLabels.d.ts +15 -0
  51. package/lib/commands/listSelectLabels.js +24 -0
  52. package/lib/commands/listSelectLabels.js.map +1 -0
  53. package/lib/commands/listSelectValues.d.ts +15 -0
  54. package/lib/commands/listSelectValues.js +26 -0
  55. package/lib/commands/listSelectValues.js.map +1 -0
  56. package/lib/commands/navigateToHref.d.ts +19 -0
  57. package/lib/commands/navigateToHref.js +23 -0
  58. package/lib/commands/navigateToHref.js.map +1 -0
  59. package/lib/commands/padWithZeros.d.ts +20 -0
  60. package/lib/commands/padWithZeros.js +24 -0
  61. package/lib/commands/padWithZeros.js.map +1 -0
  62. package/lib/commands/runScript.d.ts +16 -0
  63. package/lib/commands/runScript.js +25 -0
  64. package/lib/commands/runScript.js.map +1 -0
  65. package/lib/commands/typeInto.d.ts +20 -0
  66. package/lib/commands/typeInto.js +28 -0
  67. package/lib/commands/typeInto.js.map +1 -0
  68. package/lib/commands/uniquify.d.ts +15 -0
  69. package/lib/commands/uniquify.js +25 -0
  70. package/lib/commands/uniquify.js.map +1 -0
  71. package/lib/commands/visitCanvasEndpoint.d.ts +27 -0
  72. package/lib/commands/visitCanvasEndpoint.js +35 -0
  73. package/lib/commands/visitCanvasEndpoint.js.map +1 -0
  74. package/lib/commands/visitCanvasGETEndpoint.d.ts +20 -0
  75. package/lib/commands/visitCanvasGETEndpoint.js +26 -0
  76. package/lib/commands/visitCanvasGETEndpoint.js.map +1 -0
  77. package/lib/commands/waitForAtLeastOneElementPresent.d.ts +23 -0
  78. package/lib/commands/waitForAtLeastOneElementPresent.js +27 -0
  79. package/lib/commands/waitForAtLeastOneElementPresent.js.map +1 -0
  80. package/lib/commands/waitForElementVisible.d.ts +14 -0
  81. package/lib/commands/waitForElementVisible.js +20 -0
  82. package/lib/commands/waitForElementVisible.js.map +1 -0
  83. package/lib/index.js.map +1 -0
  84. package/lib/init.d.ts +6 -0
  85. package/lib/init.js +69 -0
  86. package/lib/init.js.map +1 -0
  87. package/lib/src/commands/extractDataFromClass.d.ts +7 -4
  88. package/lib/src/commands/extractDataFromClass.js +2 -1
  89. package/lib/src/commands/extractDataFromClass.js.map +1 -1
  90. package/lib/src/commands/extractDataFromClassByContents.d.ts +9 -5
  91. package/lib/src/commands/extractDataFromClassByContents.js +2 -1
  92. package/lib/src/commands/extractDataFromClassByContents.js.map +1 -1
  93. package/lib/src/commands/genTextOfLength.d.ts +20 -0
  94. package/lib/src/commands/genTextOfLength.js +20 -0
  95. package/lib/src/commands/genTextOfLength.js.map +1 -0
  96. package/lib/src/commands/getAttribute.d.ts +20 -0
  97. package/lib/src/commands/getAttribute.js +22 -0
  98. package/lib/src/commands/getAttribute.js.map +1 -0
  99. package/lib/src/commands/getClassName.d.ts +15 -0
  100. package/lib/src/commands/getClassName.js +21 -0
  101. package/lib/src/commands/getClassName.js.map +1 -0
  102. package/lib/src/commands/getCurrentDateInfo.d.ts +21 -0
  103. package/lib/src/commands/getCurrentDateInfo.js +25 -0
  104. package/lib/src/commands/getCurrentDateInfo.js.map +1 -0
  105. package/lib/src/commands/getId.d.ts +15 -0
  106. package/lib/src/commands/getId.js +21 -0
  107. package/lib/src/commands/getId.js.map +1 -0
  108. package/lib/src/commands/getJSON.d.ts +0 -1
  109. package/lib/src/commands/getJSON.js +1 -4
  110. package/lib/src/commands/getJSON.js.map +1 -1
  111. package/lib/src/commands/getSpecialChars.d.ts +14 -0
  112. package/lib/src/commands/getSpecialChars.js +16 -0
  113. package/lib/src/commands/getSpecialChars.js.map +1 -0
  114. package/lib/src/commands/getTitle.d.ts +13 -0
  115. package/lib/src/commands/getTitle.js +20 -0
  116. package/lib/src/commands/getTitle.js.map +1 -0
  117. package/lib/src/commands/index.js +29 -5
  118. package/lib/src/commands/index.js.map +1 -1
  119. package/lib/src/commands/launchLTIUsingToken.js +12 -4
  120. package/lib/src/commands/launchLTIUsingToken.js.map +1 -1
  121. package/lib/src/commands/listSelectLabels.d.ts +15 -0
  122. package/lib/src/commands/listSelectLabels.js +24 -0
  123. package/lib/src/commands/listSelectLabels.js.map +1 -0
  124. package/lib/src/commands/listSelectValues.d.ts +15 -0
  125. package/lib/src/commands/listSelectValues.js +27 -0
  126. package/lib/src/commands/listSelectValues.js.map +1 -0
  127. package/lib/src/commands/padWithZeros.d.ts +20 -0
  128. package/lib/src/commands/padWithZeros.js +24 -0
  129. package/lib/src/commands/padWithZeros.js.map +1 -0
  130. package/lib/src/commands/uniquify.d.ts +15 -0
  131. package/lib/src/commands/uniquify.js +26 -0
  132. package/lib/src/commands/uniquify.js.map +1 -0
  133. package/lib/src/commands/visitCanvasEndpoint.d.ts +26 -0
  134. package/lib/src/commands/visitCanvasEndpoint.js +36 -0
  135. package/lib/src/commands/visitCanvasEndpoint.js.map +1 -0
  136. package/lib/src/commands/waitForAtLeastOneElementPresent.d.ts +23 -0
  137. package/lib/src/commands/waitForAtLeastOneElementPresent.js +28 -0
  138. package/lib/src/commands/waitForAtLeastOneElementPresent.js.map +1 -0
  139. package/lib/src/init.js +28 -2
  140. package/lib/src/init.js.map +1 -1
  141. package/lib/start/constants/DEFAULT_THREADS_PER_COMBO.d.ts +6 -0
  142. package/lib/start/constants/DEFAULT_THREADS_PER_COMBO.js +9 -0
  143. package/lib/start/constants/DEFAULT_THREADS_PER_COMBO.js.map +1 -0
  144. package/lib/start/helpers/collectPngFiles.d.ts +9 -0
  145. package/lib/start/helpers/collectPngFiles.js +31 -0
  146. package/lib/start/helpers/collectPngFiles.js.map +1 -0
  147. package/lib/start/helpers/executeAllHeadlessCombinations.d.ts +15 -0
  148. package/lib/start/helpers/executeAllHeadlessCombinations.js +116 -0
  149. package/lib/start/helpers/executeAllHeadlessCombinations.js.map +1 -0
  150. package/lib/start/helpers/executeCypress.d.ts +17 -0
  151. package/lib/start/helpers/executeCypress.js +103 -0
  152. package/lib/start/helpers/executeCypress.js.map +1 -0
  153. package/lib/start/helpers/generateHtmlReport.d.ts +14 -0
  154. package/lib/start/helpers/generateHtmlReport.js +54 -0
  155. package/lib/start/helpers/generateHtmlReport.js.map +1 -0
  156. package/lib/start/helpers/generateReportHomepage.d.ts +9 -0
  157. package/lib/start/helpers/generateReportHomepage.js +142 -0
  158. package/lib/start/helpers/generateReportHomepage.js.map +1 -0
  159. package/lib/start/helpers/generateReporterConfig.d.ts +17 -0
  160. package/lib/start/helpers/generateReporterConfig.js +32 -0
  161. package/lib/start/helpers/generateReporterConfig.js.map +1 -0
  162. package/lib/start/helpers/getDateLabeledDir.d.ts +7 -0
  163. package/lib/start/helpers/getDateLabeledDir.js +38 -0
  164. package/lib/start/helpers/getDateLabeledDir.js.map +1 -0
  165. package/lib/start/helpers/mergeAllReportsAndGenerateHtml.d.ts +11 -0
  166. package/lib/start/helpers/mergeAllReportsAndGenerateHtml.js +121 -0
  167. package/lib/start/helpers/mergeAllReportsAndGenerateHtml.js.map +1 -0
  168. package/lib/start/helpers/mergeReports.d.ts +14 -0
  169. package/lib/start/helpers/mergeReports.js +63 -0
  170. package/lib/start/helpers/mergeReports.js.map +1 -0
  171. package/lib/start/helpers/reportHomepage.ejs +272 -0
  172. package/lib/start/helpers/runCypressHeadless.d.ts +18 -0
  173. package/lib/start/helpers/runCypressHeadless.js +138 -0
  174. package/lib/start/helpers/runCypressHeadless.js.map +1 -0
  175. package/lib/start/helpers/runCypressVisible.d.ts +8 -0
  176. package/lib/start/helpers/runCypressVisible.js +53 -0
  177. package/lib/start/helpers/runCypressVisible.js.map +1 -0
  178. package/lib/start/index.js +23 -5
  179. package/lib/start/index.js.map +1 -1
  180. package/lib/start/types/MochawesomeReporterConfig.d.ts +15 -0
  181. package/lib/start/types/MochawesomeReporterConfig.js +3 -0
  182. package/lib/start/types/MochawesomeReporterConfig.js.map +1 -0
  183. package/lib/start/types/Profile.d.ts +9 -0
  184. package/lib/start/types/Profile.js +3 -0
  185. package/lib/start/types/Profile.js.map +1 -0
  186. package/lib/start/types/ReportInfo.d.ts +14 -0
  187. package/lib/start/types/ReportInfo.js +3 -0
  188. package/lib/start/types/ReportInfo.js.map +1 -0
  189. package/lib/start/types/RunResult.d.ts +12 -0
  190. package/lib/start/types/RunResult.js +3 -0
  191. package/lib/start/types/RunResult.js.map +1 -0
  192. package/lib/start/types/ScreenshotInfo.d.ts +10 -0
  193. package/lib/start/types/ScreenshotInfo.js +3 -0
  194. package/lib/start/types/ScreenshotInfo.js.map +1 -0
  195. package/lib/start/types/TemplateReportInfo.d.ts +12 -0
  196. package/lib/start/types/TemplateReportInfo.js +3 -0
  197. package/lib/start/types/TemplateReportInfo.js.map +1 -0
  198. package/package.json +10 -8
  199. package/src/commands/extractDataFromClass.ts +17 -6
  200. package/src/commands/extractDataFromClassByContents.ts +21 -8
  201. package/src/commands/genTextOfLength.ts +54 -0
  202. package/src/commands/getAttribute.ts +58 -0
  203. package/src/commands/getClassName.ts +44 -0
  204. package/src/commands/getCurrentDateInfo.ts +57 -0
  205. package/src/commands/getId.ts +44 -0
  206. package/src/commands/getJSON.ts +0 -4
  207. package/src/commands/getSpecialChars.ts +34 -0
  208. package/src/commands/getTitle.ts +39 -0
  209. package/src/commands/index.ts +29 -5
  210. package/src/commands/launchLTIUsingToken.ts +12 -4
  211. package/src/commands/listSelectLabels.ts +47 -0
  212. package/src/commands/listSelectValues.ts +50 -0
  213. package/src/commands/padWithZeros.ts +53 -0
  214. package/src/commands/uniquify.ts +49 -0
  215. package/src/commands/visitCanvasEndpoint.ts +75 -0
  216. package/src/commands/waitForAtLeastOneElementPresent.ts +64 -0
  217. package/start/constants/DEFAULT_THREADS_PER_COMBO.ts +7 -0
  218. package/start/helpers/collectPngFiles.ts +25 -0
  219. package/start/helpers/executeAllHeadlessCombinations.ts +92 -0
  220. package/start/helpers/executeCypress.ts +66 -0
  221. package/start/helpers/generateHtmlReport.ts +71 -0
  222. package/start/helpers/generateReportHomepage.ts +148 -0
  223. package/start/helpers/generateReporterConfig.ts +39 -0
  224. package/start/helpers/getDateLabeledDir.ts +43 -0
  225. package/start/helpers/mergeAllReportsAndGenerateHtml.ts +150 -0
  226. package/start/helpers/mergeReports.ts +82 -0
  227. package/start/helpers/reportHomepage.ejs +272 -0
  228. package/start/helpers/runCypressHeadless.ts +164 -0
  229. package/start/helpers/runCypressVisible.ts +45 -0
  230. package/start/index.ts +23 -5
  231. package/start/types/MochawesomeReporterConfig.ts +23 -0
  232. package/start/types/Profile.ts +12 -0
  233. package/start/types/ReportInfo.ts +22 -0
  234. package/start/types/RunResult.ts +18 -0
  235. package/start/types/ScreenshotInfo.ts +13 -0
  236. package/start/types/TemplateReportInfo.ts +16 -0
  237. package/src/commands/visitCanvasGETEndpoint.ts +0 -61
@@ -0,0 +1,58 @@
1
+ /// <reference types="cypress" />
2
+
3
+ /*----------------------------------------*/
4
+ /* ---------------- Type ---------------- */
5
+ /*----------------------------------------*/
6
+
7
+ declare global {
8
+ namespace Cypress {
9
+ interface Chainable {
10
+ /**
11
+ * Get the attribute of an element
12
+ * @author Allison Zhang
13
+ * @param opts options object
14
+ * @param opts.selector the CSS selector of the element
15
+ * @param opts.attribute the attribute to retrieve
16
+ * @returns the attribute of the element
17
+ */
18
+ getAttribute(
19
+ opts: {
20
+ selector: string,
21
+ attribute: string,
22
+ },
23
+ ): Chainable<string>;
24
+ }
25
+ }
26
+ }
27
+
28
+ /*----------------------------------------*/
29
+ /* --------------- Command -------------- */
30
+ /*----------------------------------------*/
31
+
32
+ const getAttribute = () => {
33
+ Cypress.Commands.add('getAttribute', (
34
+ opts: {
35
+ selector: string,
36
+ attribute: string,
37
+ },
38
+ ) => {
39
+ const {
40
+ selector,
41
+ attribute,
42
+ } = opts;
43
+ return (
44
+ cy
45
+ .get(selector)
46
+ .invoke('attr', attribute)
47
+ .then((attr) => {
48
+ return attr;
49
+ })
50
+ );
51
+ });
52
+ };
53
+
54
+ /*----------------------------------------*/
55
+ /* --------------- Export --------------- */
56
+ /*----------------------------------------*/
57
+
58
+ export default getAttribute;
@@ -0,0 +1,44 @@
1
+ /// <reference types="cypress" />
2
+
3
+ /*----------------------------------------*/
4
+ /* ---------------- Type ---------------- */
5
+ /*----------------------------------------*/
6
+
7
+ declare global {
8
+ namespace Cypress {
9
+ interface Chainable {
10
+ /**
11
+ * Get the class attribute of an element
12
+ * @author Allison Zhang
13
+ * @param selector the CSS selector of the element
14
+ * @returns the class of the element, if multiple classes exist, they are space-separated
15
+ */
16
+ getClassName(
17
+ selector: string,
18
+ ): Chainable<string>;
19
+ }
20
+ }
21
+ }
22
+
23
+ /*----------------------------------------*/
24
+ /* --------------- Command -------------- */
25
+ /*----------------------------------------*/
26
+
27
+ const getClassName = () => {
28
+ Cypress.Commands.add('getClassName', (selector: string) => {
29
+ return (
30
+ cy
31
+ .get(selector)
32
+ .invoke('attr', 'class')
33
+ .then((attr) => {
34
+ return attr;
35
+ })
36
+ );
37
+ });
38
+ };
39
+
40
+ /*----------------------------------------*/
41
+ /* --------------- Export --------------- */
42
+ /*----------------------------------------*/
43
+
44
+ export default getClassName;
@@ -0,0 +1,57 @@
1
+ /// <reference types="cypress" />
2
+
3
+ /*----------------------------------------*/
4
+ /* ---------------- Type ---------------- */
5
+ /*----------------------------------------*/
6
+
7
+ declare global {
8
+ namespace Cypress {
9
+ interface Chainable {
10
+ /**
11
+ * Get the current day
12
+ * @author Allison Zhang
13
+ * @returns the current month as a number (1-31)
14
+ */
15
+ getCurrentDateInfo(): Chainable<{
16
+ minute: number,
17
+ hour: number,
18
+ day: number,
19
+ month: number,
20
+ year: number,
21
+ dateString: string,
22
+ }>;
23
+ }
24
+ }
25
+ }
26
+
27
+ /*----------------------------------------*/
28
+ /* --------------- Command -------------- */
29
+ /*----------------------------------------*/
30
+
31
+ const getCurrentDateInfo = () => {
32
+ Cypress.Commands.add('getCurrentDateInfo', () => {
33
+ const current = new Date();
34
+ const dateInfo: {
35
+ minute: number,
36
+ hour: number,
37
+ day: number,
38
+ month: number,
39
+ year: number,
40
+ dateString: string,
41
+ } = {
42
+ minute: current.getMinutes(),
43
+ hour: current.getHours(),
44
+ day: current.getDate(),
45
+ month: current.getMonth() + 1,
46
+ year: current.getFullYear(),
47
+ dateString: current.toDateString(),
48
+ };
49
+ return cy.wrap(dateInfo);
50
+ });
51
+ };
52
+
53
+ /*----------------------------------------*/
54
+ /* --------------- Export --------------- */
55
+ /*----------------------------------------*/
56
+
57
+ export default getCurrentDateInfo;
@@ -0,0 +1,44 @@
1
+ /// <reference types="cypress" />
2
+
3
+ /*----------------------------------------*/
4
+ /* ---------------- Type ---------------- */
5
+ /*----------------------------------------*/
6
+
7
+ declare global {
8
+ namespace Cypress {
9
+ interface Chainable {
10
+ /**
11
+ * Get the id of an element
12
+ * @author Allison Zhang
13
+ * @param selector the CSS selector of the element
14
+ * @returns the id of the element
15
+ */
16
+ getId(
17
+ selector: string,
18
+ ): Chainable<string>;
19
+ }
20
+ }
21
+ }
22
+
23
+ /*----------------------------------------*/
24
+ /* --------------- Command -------------- */
25
+ /*----------------------------------------*/
26
+
27
+ const getId = () => {
28
+ Cypress.Commands.add('getId', (selector: string) => {
29
+ return (
30
+ cy
31
+ .get(selector)
32
+ .invoke('attr', 'id')
33
+ .then((attr) => {
34
+ return attr;
35
+ })
36
+ );
37
+ });
38
+ };
39
+
40
+ /*----------------------------------------*/
41
+ /* --------------- Export --------------- */
42
+ /*----------------------------------------*/
43
+
44
+ export default getId;
@@ -12,7 +12,6 @@ declare global {
12
12
  * @author Allison Zhang
13
13
  * @param url the URL to fetch the JSON data from
14
14
  * @returns the JSON data
15
- * @example cy.getJSON('https://api.example.com/data').then((data) => { ... })
16
15
  */
17
16
  getJSON(
18
17
  url: string,
@@ -31,9 +30,6 @@ const getJSON = () => {
31
30
  cy
32
31
  .request(url)
33
32
  .its('body')
34
- .then((body) => {
35
- return body;
36
- })
37
33
  );
38
34
  });
39
35
  };
@@ -0,0 +1,34 @@
1
+ /// <reference types="cypress" />
2
+
3
+ /*----------------------------------------*/
4
+ /* ---------------- Type ---------------- */
5
+ /*----------------------------------------*/
6
+
7
+ declare global {
8
+ namespace Cypress {
9
+ interface Chainable {
10
+ /**
11
+ * Generate all printable special characters for Cypress tests
12
+ * @author Allison Zhang
13
+ * @returns a string containing all special characters
14
+ */
15
+ getSpecialChars(): Chainable<string>;
16
+ }
17
+ }
18
+ }
19
+
20
+ /*----------------------------------------*/
21
+ /* --------------- Command -------------- */
22
+ /*----------------------------------------*/
23
+
24
+ const getSpecialChars = () => {
25
+ Cypress.Commands.add('getSpecialChars', () => {
26
+ return cy.wrap('!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ≤≥≠÷…£¢∞§¶•º');
27
+ });
28
+ };
29
+
30
+ /*----------------------------------------*/
31
+ /* --------------- Export --------------- */
32
+ /*----------------------------------------*/
33
+
34
+ export default getSpecialChars;
@@ -0,0 +1,39 @@
1
+ /// <reference types="cypress" />
2
+
3
+ /*----------------------------------------*/
4
+ /* ---------------- Type ---------------- */
5
+ /*----------------------------------------*/
6
+
7
+ declare global {
8
+ namespace Cypress {
9
+ interface Chainable {
10
+ /**
11
+ * Get the current title of the page
12
+ * @author Gardenia Liu
13
+ */
14
+ getTitle(): Chainable<string>;
15
+ }
16
+ }
17
+ }
18
+
19
+ /*----------------------------------------*/
20
+ /* --------------- Command -------------- */
21
+ /*----------------------------------------*/
22
+
23
+ const getTitle = () => {
24
+ Cypress.Commands.add('getTitle', () => {
25
+ return (
26
+ cy
27
+ .title()
28
+ .then((title) => {
29
+ return title;
30
+ })
31
+ );
32
+ });
33
+ };
34
+
35
+ /*----------------------------------------*/
36
+ /* --------------- Export --------------- */
37
+ /*----------------------------------------*/
38
+
39
+ export default getTitle;
@@ -4,15 +4,27 @@ import assertHasClass from './assertHasClass';
4
4
  import assertNumElements from './assertNumElements';
5
5
  import extractDataFromClass from './extractDataFromClass';
6
6
  import extractDataFromClassByContents from './extractDataFromClassByContents';
7
+ import genTextOfLength from './genTextOfLength';
8
+ import getAttribute from './getAttribute';
9
+ import getClassName from './getClassName';
10
+ import getCurrentDateInfo from './getCurrentDateInfo';
11
+ import getId from './getId';
7
12
  import getJSON from './getJSON';
8
13
  import getNumElements from './getNumElements';
14
+ import getSpecialChars from './getSpecialChars';
15
+ import getTitle from './getTitle';
9
16
  import handleHarvardKey from './handleHarvardKey';
10
17
  import launchAs from './launchAs';
11
18
  import launchLTIUsingToken from './launchLTIUsingToken';
19
+ import listSelectLabels from './listSelectLabels';
20
+ import listSelectValues from './listSelectValues';
12
21
  import navigateToHref from './navigateToHref';
22
+ import padWithZeros from './padWithZeros';
13
23
  import runScript from './runScript';
14
24
  import typeInto from './typeInto';
15
- import visitCanvasGETEndpoint from './visitCanvasGETEndpoint';
25
+ import uniquify from './uniquify';
26
+ import visitCanvasEndpoint from './visitCanvasEndpoint';
27
+ import waitForAtLeastOneElementPresent from './waitForAtLeastOneElementPresent';
16
28
  import waitForElementVisible from './waitForElementVisible';
17
29
 
18
30
  /**
@@ -24,18 +36,30 @@ const commands = () => {
24
36
  assertDoesNotHaveClass();
25
37
  assertHasClass();
26
38
  assertNumElements();
39
+ extractDataFromClass();
40
+ extractDataFromClassByContents();
41
+ genTextOfLength();
42
+ getAttribute();
43
+ getClassName();
44
+ getCurrentDateInfo();
45
+ getId();
46
+ getJSON();
27
47
  getNumElements();
48
+ getSpecialChars();
49
+ getTitle();
28
50
  handleHarvardKey();
29
51
  launchAs();
30
52
  launchLTIUsingToken();
53
+ listSelectLabels();
54
+ listSelectValues();
31
55
  navigateToHref();
56
+ padWithZeros();
32
57
  runScript();
33
58
  typeInto();
34
- visitCanvasGETEndpoint();
59
+ uniquify();
60
+ visitCanvasEndpoint();
61
+ waitForAtLeastOneElementPresent();
35
62
  waitForElementVisible();
36
- extractDataFromClass();
37
- extractDataFromClassByContents();
38
- getJSON();
39
63
  };
40
64
 
41
65
  export default commands;
@@ -59,9 +59,13 @@ const launchLTIUsingToken = () => {
59
59
  cy.log(`Launch LTI app "${appName}" in course ${courseId} using access token`);
60
60
 
61
61
  // Get the external tools for the course
62
- cy.visitCanvasGETEndpoint({
63
- path: `/courses/${courseId}/external_tools`,
62
+ cy.visitCanvasEndpoint({
63
+ method: 'GET',
64
+ path: `/api/v1/courses/${courseId}/external_tools`,
64
65
  accessToken,
66
+ params: {
67
+ per_page: 200,
68
+ },
65
69
  }).then((externalTools: { [key: string]: any }[]) => {
66
70
  cy.log(`Found ${externalTools.length} external tools`);
67
71
 
@@ -93,9 +97,13 @@ const launchLTIUsingToken = () => {
93
97
  }
94
98
 
95
99
  // Get a sessionless launch URL
96
- cy.visitCanvasGETEndpoint({
97
- path: `/courses/${courseId}/external_tools/sessionless_launch?id=${toolId}`,
100
+ cy.visitCanvasEndpoint({
101
+ method: 'GET',
102
+ path: `/api/v1/courses/${courseId}/external_tools/sessionless_launch?id=${toolId}`,
98
103
  accessToken,
104
+ params: {
105
+ per_page: 200,
106
+ },
99
107
  }).then((sessionlessLaunchInfo) => {
100
108
  const launchURL = sessionlessLaunchInfo.url;
101
109
  cy.log(`Launching LTI app at: ${launchURL}`);
@@ -0,0 +1,47 @@
1
+ /// <reference types="cypress" />
2
+
3
+ /*----------------------------------------*/
4
+ /* ---------------- Type ---------------- */
5
+ /*----------------------------------------*/
6
+
7
+ declare global {
8
+ namespace Cypress {
9
+ interface Chainable {
10
+ /**
11
+ * Get the labels of all the options within a select element
12
+ * @author Allison Zhang
13
+ * @param selector the CSS selector of the select element
14
+ * @returns an array of strings representing the labels of the options
15
+ */
16
+ listSelectLabels(
17
+ selector: string,
18
+ ): Chainable<String[]>;
19
+ }
20
+ }
21
+ }
22
+
23
+ /*----------------------------------------*/
24
+ /* --------------- Command -------------- */
25
+ /*----------------------------------------*/
26
+
27
+ const listSelectLabels = () => {
28
+ Cypress.Commands.add('listSelectLabels', (selector: string) => {
29
+ const labels: string[] = [];
30
+ return (
31
+ cy
32
+ .get(`${selector} option`)
33
+ .each((option) => {
34
+ labels.push(option.attr('label') || option.text());
35
+ })
36
+ .then(() => {
37
+ return labels;
38
+ })
39
+ );
40
+ });
41
+ };
42
+
43
+ /*----------------------------------------*/
44
+ /* --------------- Export --------------- */
45
+ /*----------------------------------------*/
46
+
47
+ export default listSelectLabels;
@@ -0,0 +1,50 @@
1
+ /// <reference types="cypress" />
2
+
3
+ /*----------------------------------------*/
4
+ /* ---------------- Type ---------------- */
5
+ /*----------------------------------------*/
6
+
7
+ declare global {
8
+ namespace Cypress {
9
+ interface Chainable {
10
+ /**
11
+ * Get the values of all the options within a select element
12
+ * @author Allison Zhang
13
+ * @param selector the CSS selector of the select element
14
+ * @returns an array of strings representing the values of the options
15
+ */
16
+ listSelectValues(
17
+ selector: string,
18
+ ): Chainable<String[]>;
19
+ }
20
+ }
21
+ }
22
+
23
+ /*----------------------------------------*/
24
+ /* --------------- Command -------------- */
25
+ /*----------------------------------------*/
26
+
27
+ const listSelectValues = () => {
28
+ Cypress.Commands.add('listSelectValues', (selector: string) => {
29
+ const vals: string[] = [];
30
+ return (
31
+ cy
32
+ .get(`${selector} option`)
33
+ .each((option) => {
34
+ cy.wrap(option).invoke('attr', 'value')
35
+ .then((value) => {
36
+ vals.push(value || option.text());
37
+ });
38
+ })
39
+ .then(() => {
40
+ return vals;
41
+ })
42
+ );
43
+ });
44
+ };
45
+
46
+ /*----------------------------------------*/
47
+ /* --------------- Export --------------- */
48
+ /*----------------------------------------*/
49
+
50
+ export default listSelectValues;
@@ -0,0 +1,53 @@
1
+ /// <reference types="cypress" />
2
+
3
+ /*----------------------------------------*/
4
+ /* ---------------- Type ---------------- */
5
+ /*----------------------------------------*/
6
+
7
+ declare global {
8
+ namespace Cypress {
9
+ interface Chainable {
10
+ /**
11
+ * Pads a number with leading zeros to a user-defined length.
12
+ * @author Allison Zhang
13
+ * @param opts options object
14
+ * @param opts.length the desired total length of the output string, must be larger than the length of the number
15
+ * @param opts.number the number to be padded with leading zeros
16
+ * @returns padded string with leading zeros
17
+ */
18
+ padWithZeros(opts: {
19
+ length: number,
20
+ number: number,
21
+ }): Chainable<string>;
22
+ }
23
+ }
24
+ }
25
+
26
+ /*----------------------------------------*/
27
+ /* --------------- Command -------------- */
28
+ /*----------------------------------------*/
29
+
30
+ const padWithZeros = () => {
31
+ Cypress.Commands.add('padWithZeros', (opts: { length: number, number: number }) => {
32
+ const {
33
+ length,
34
+ number,
35
+ } = opts;
36
+ return (
37
+ cy
38
+ .then(() => {
39
+ let numberString = number.toString();
40
+ while (numberString.length < length) {
41
+ numberString = `0${numberString}`;
42
+ }
43
+ return numberString;
44
+ })
45
+ );
46
+ });
47
+ };
48
+
49
+ /*----------------------------------------*/
50
+ /* --------------- Export --------------- */
51
+ /*----------------------------------------*/
52
+
53
+ export default padWithZeros;
@@ -0,0 +1,49 @@
1
+ /// <reference types="cypress" />
2
+
3
+ /*----------------------------------------*/
4
+ /* ---------------- Type ---------------- */
5
+ /*----------------------------------------*/
6
+
7
+ declare global {
8
+ namespace Cypress {
9
+ interface Chainable {
10
+ /**
11
+ * Makes a string unique by appending a timestamp and a counter.
12
+ * @author Allison Zhang
13
+ * @param text the original string
14
+ * @returns the uniquified string
15
+ */
16
+ uniquify(text: string): string;
17
+ }
18
+ }
19
+ }
20
+
21
+ /*----------------------------------------*/
22
+ /* --------------- Helpers -------------- */
23
+ /*----------------------------------------*/
24
+
25
+ let uniqueCounter = 1;
26
+
27
+ const shorten = (num: number): string => {
28
+ return Number(num).toString(36);
29
+ };
30
+
31
+ const id = shorten(Math.floor(Math.random() * 10000));
32
+
33
+ /*----------------------------------------*/
34
+ /* --------------- Command -------------- */
35
+ /*----------------------------------------*/
36
+
37
+ const uniquify = () => {
38
+ Cypress.Commands.add('uniquify', (text: string) => {
39
+ const thisCounter = uniqueCounter;
40
+ uniqueCounter += 1;
41
+ return `${text} [${shorten(Number.parseInt(`${Date.now()}${thisCounter}${id}`, 10))}]`;
42
+ });
43
+ };
44
+
45
+ /*----------------------------------------*/
46
+ /* --------------- Export --------------- */
47
+ /*----------------------------------------*/
48
+
49
+ export default uniquify;
@@ -0,0 +1,75 @@
1
+ /// <reference types="cypress" />
2
+
3
+ /*----------------------------------------*/
4
+ /* ---------------- Type ---------------- */
5
+ /*----------------------------------------*/
6
+
7
+ declare global {
8
+ namespace Cypress {
9
+ interface Chainable {
10
+ /**
11
+ * Send a request to a Canvas API endpoint.
12
+ * @author Allison Zhang
13
+ * @param opts options object
14
+ * @param opts.method the HTTP method (e.g., 'GET', 'POST', 'DELETE')
15
+ * @param opts.path the API endpoint path excluding 'https://canvas.harvard.edu', (e.g., '/api/v1/courses/123')
16
+ * @param opts.accessToken the access token for authentication
17
+ * @param opts.params the request params (if any)
18
+ * @returns Cypress chainable containing the Canvas API response body
19
+ */
20
+ visitCanvasEndpoint(
21
+ opts: {
22
+ method: string,
23
+ path: string,
24
+ accessToken: string,
25
+ params?: { [k: string]: any },
26
+ },
27
+ ): Chainable<any>;
28
+ }
29
+ }
30
+ }
31
+
32
+ /*----------------------------------------*/
33
+ /* --------------- Command -------------- */
34
+ /*----------------------------------------*/
35
+
36
+ const visitCanvasEndpoint = () => {
37
+ Cypress.Commands.add('visitCanvasEndpoint', (
38
+ opts: {
39
+ method: string,
40
+ path: string,
41
+ accessToken: string,
42
+ params: {
43
+ [k: string]: any
44
+ }
45
+ },
46
+ ) => {
47
+ const {
48
+ method,
49
+ path,
50
+ accessToken,
51
+ params,
52
+ } = opts;
53
+ cy.log(`Visiting Canvas ${method} endpoint`);
54
+ cy.log(`Canvas API: ${path}`);
55
+
56
+ return (
57
+ cy
58
+ .request({
59
+ method,
60
+ url: `https://canvas.harvard.edu${path}`,
61
+ body: {
62
+ ...(params || {}),
63
+ access_token: accessToken,
64
+ },
65
+ })
66
+ .its('body')
67
+ );
68
+ });
69
+ };
70
+
71
+ /*----------------------------------------*/
72
+ /* --------------- Export --------------- */
73
+ /*----------------------------------------*/
74
+
75
+ export default visitCanvasEndpoint;