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,45 @@
1
+ /* eslint-disable no-console */
2
+ import { spawn } from 'child_process';
3
+
4
+ // Import helpers
5
+ import getRootPath from './getRootPath';
6
+
7
+ /**
8
+ * Run Cypress in visible/interactive mode with a profile
9
+ * @author Yuen Ler Chow
10
+ * @param profileName - The profile name to use
11
+ * @returns Promise that resolves when Cypress closes
12
+ */
13
+ const runCypressVisible = (profileName: string): Promise<void> => {
14
+ return new Promise((resolve, reject) => {
15
+ const root = getRootPath();
16
+ const env = {
17
+ ...process.env,
18
+ CYPRESS_PROFILE: profileName,
19
+ };
20
+
21
+ console.log(`\n🚀 Launching Cypress in interactive mode with profile: ${profileName}`);
22
+ console.log(` CYPRESS_PROFILE=${profileName}\n`);
23
+
24
+ const cypressProcess = spawn('npx', ['cypress', 'open'], {
25
+ cwd: root,
26
+ env,
27
+ stdio: 'inherit',
28
+ shell: true,
29
+ });
30
+
31
+ cypressProcess.on('close', (code) => {
32
+ if (code === 0) {
33
+ resolve();
34
+ } else {
35
+ reject(new Error(`Cypress exited with code ${code}`));
36
+ }
37
+ });
38
+
39
+ cypressProcess.on('error', (error) => {
40
+ reject(error);
41
+ });
42
+ });
43
+ };
44
+
45
+ export default runCypressVisible;
package/start/index.ts CHANGED
@@ -17,9 +17,11 @@ import findProfilesByNames from './helpers/findProfilesByNames';
17
17
  import validateBrowsers from './helpers/validateBrowsers';
18
18
  import extractArgValue from './helpers/extractArgValue';
19
19
  import getRootPath from './helpers/getRootPath';
20
+ import executeCypress from './helpers/executeCypress';
20
21
 
21
22
  // Import constants
22
23
  import AVAILABLE_BROWSERS from './constants/AVAILABLE_BROWSERS';
24
+ import DEFAULT_THREADS_PER_COMBO from './constants/DEFAULT_THREADS_PER_COMBO';
23
25
 
24
26
  // Get the project directory
25
27
  const pwd = getRootPath();
@@ -86,6 +88,20 @@ const headlessFlagValue = extractArgValue(args, '--headless');
86
88
  const hasHeadlessFlag = headlessFlagValue !== undefined;
87
89
  isHeadless = !!(envHeadlessRaw && envHeadlessRaw.toLowerCase() !== 'false') || hasHeadlessFlag;
88
90
 
91
+ // Check for THREADS_PER_COMBO (env var or CLI arg)
92
+ const envThreadsRaw = process.env.THREADS_PER_COMBO;
93
+ const argThreadsRaw = extractArgValue(args, '--threadsPerCombo');
94
+ const threadsRaw = envThreadsRaw || argThreadsRaw;
95
+ let threadsPerCombo: number | undefined;
96
+ if (threadsRaw) {
97
+ const parsed = Number.parseInt(threadsRaw, 10);
98
+ if (!Number.isNaN(parsed) && parsed > 0) {
99
+ threadsPerCombo = parsed;
100
+ } else {
101
+ console.warn(`⚠️ Invalid THREADS_PER_COMBO value: "${threadsRaw}". Using default (${DEFAULT_THREADS_PER_COMBO}).`);
102
+ }
103
+ }
104
+
89
105
  // If headless wasn't specified, ask the user to choose
90
106
  if (!envHeadlessRaw && !hasHeadlessFlag) {
91
107
  const choices = showChooser({
@@ -157,8 +173,10 @@ if (
157
173
  selectedProfiles = choices.map((choice) => { return profiles[choice.index]; });
158
174
  }
159
175
 
160
- // Execute commands for each combination of profile and browser (not yet implemented)
161
- console.log('Starting Cypress with the following configuration:');
162
- console.log(`Profiles: ${selectedProfiles.map((p) => { return p.profileName; }).join(', ')}`);
163
- console.log(`Browsers: ${selectedBrowsers.join(', ')}`);
164
- console.log(`Headless: ${isHeadless}`);
176
+ // Execute Cypress with selected configuration
177
+ executeCypress({
178
+ selectedProfiles,
179
+ selectedBrowsers,
180
+ isHeadless,
181
+ threadsPerCombo,
182
+ });
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Mochawesome reporter configuration
3
+ * @author Yuen Ler Chow
4
+ */
5
+ type MochawesomeReporterConfig = {
6
+ // The reporter(s) to enable (e.g., "mochawesome")
7
+ reporterEnabled: string;
8
+ // Options for the mochawesome reporter
9
+ mochawesomeReporterOptions: {
10
+ // Directory where report files will be saved
11
+ reportDir: string;
12
+ // Filename pattern for report files (supports [name] placeholder)
13
+ reportFilename: string;
14
+ // Whether to overwrite existing report files
15
+ overwrite: boolean;
16
+ // Whether to generate HTML reports
17
+ html: boolean;
18
+ // Whether to generate JSON reports
19
+ json: boolean;
20
+ };
21
+ };
22
+
23
+ export default MochawesomeReporterConfig;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Profile configuration
3
+ * @author Yuen Ler Chow
4
+ */
5
+ type Profile = {
6
+ // The filename of the profile (e.g., "prod.Profile.ts")
7
+ file: string;
8
+ // The name of the profile extracted from the filename (e.g., "prod")
9
+ profileName: string;
10
+ };
11
+
12
+ export default Profile;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Information about a generated report
3
+ * @author Yuen Ler Chow
4
+ */
5
+ type ReportInfo = {
6
+ // The name of the profile (e.g., "prod", "stage")
7
+ profileName: string;
8
+ // The browser used (e.g., "chrome", "edge")
9
+ browser: string;
10
+ // Path to the generated HTML report file
11
+ reportPath: string;
12
+ // True if the test run was successful
13
+ success: boolean;
14
+ // Human-readable timestamp of when the report was generated
15
+ timestamp: string;
16
+ // Total number of tests in the report
17
+ totalTests?: number;
18
+ // Number of tests that passed
19
+ passedTests?: number;
20
+ };
21
+
22
+ export default ReportInfo;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Result from a Cypress headless run
3
+ * @author Yuen Ler Chow
4
+ */
5
+ type RunResult = {
6
+ // The name of the profile used for this run (e.g., "prod", "stage")
7
+ profileName: string;
8
+ // The browser used for this run (e.g., "chrome", "edge")
9
+ browser: string;
10
+ // Whether the test run completed successfully (all tests passed and report generated)
11
+ success: boolean;
12
+ // The output directory for this specific profile+browser combination
13
+ outputDir: string;
14
+ // Path to the generated HTML report file, undefined if report generation failed
15
+ reportPath?: string;
16
+ };
17
+
18
+ export default RunResult;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Information about a screenshot captured during a Cypress test run,
3
+ * used for linking screenshots in the report homepage
4
+ * @author Yuen Ler Chow
5
+ */
6
+ type ScreenshotInfo = {
7
+ // Relative URL path to the screenshot file from the report homepage
8
+ href: string;
9
+ // Display name for the screenshot (typically the relative file path)
10
+ name: string;
11
+ };
12
+
13
+ export default ScreenshotInfo;
@@ -0,0 +1,16 @@
1
+ import ReportInfo from './ReportInfo';
2
+ import ScreenshotInfo from './ScreenshotInfo';
3
+
4
+ /**
5
+ * Extended version of ReportInfo with additional computed fields
6
+ * needed for rendering the EJS report homepage template
7
+ * @author Yuen Ler Chow
8
+ */
9
+ type TemplateReportInfo = ReportInfo & {
10
+ // Relative URL path to the HTML report file, or null if report doesn't exist
11
+ relativeReportPath: string | null;
12
+ // List of screenshots captured during this test run
13
+ screenshots: ScreenshotInfo[];
14
+ };
15
+
16
+ export default TemplateReportInfo;
@@ -1,61 +0,0 @@
1
- /// <reference types="cypress" />
2
-
3
- /*----------------------------------------*/
4
- /* ---------------- Type ---------------- */
5
- /*----------------------------------------*/
6
-
7
- declare global {
8
- namespace Cypress {
9
- interface Chainable {
10
- /**
11
- * Makes a GET request to Canvas API endpoint
12
- * @author Yuen Ler Chow
13
- * @param opts object containing all arguments
14
- * @param opts.path The API path (e.g., '/courses', '/users/self')
15
- * @param opts.accessToken The Canvas access token
16
- * @return Cypress chainable containing the Canvas API response body
17
- */
18
- visitCanvasGETEndpoint(
19
- opts: {
20
- path: string,
21
- accessToken: string,
22
- }
23
- ): Chainable<any>;
24
- }
25
- }
26
- }
27
-
28
- /*----------------------------------------*/
29
- /* --------------- Command -------------- */
30
- /*----------------------------------------*/
31
-
32
- const visitCanvasGETEndpoint = () => {
33
- Cypress.Commands.add(
34
- 'visitCanvasGETEndpoint',
35
- (
36
- opts: {
37
- path: string,
38
- accessToken: string,
39
- },
40
- ) => {
41
- cy.log('Visiting Canvas GET endpoint');
42
- const { path, accessToken } = opts;
43
-
44
- cy.log(`Canvas API: ${path}`);
45
- return cy.request({
46
- method: 'GET',
47
- url: `https://canvas.harvard.edu/api/v1${path}`,
48
- qs: {
49
- per_page: 200,
50
- access_token: accessToken,
51
- },
52
- }).its('body');
53
- },
54
- );
55
- };
56
-
57
- /*----------------------------------------*/
58
- /* --------------- Export --------------- */
59
- /*----------------------------------------*/
60
-
61
- export default visitCanvasGETEndpoint;