dceky 1.0.5-beta.ky-declarations.13 → 1.0.6
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.
- package/README.md +45 -29
- package/lib/commands/assertDoesNotHaveClass.d.ts +18 -0
- package/lib/commands/assertDoesNotHaveClass.js +17 -0
- package/lib/commands/assertDoesNotHaveClass.js.map +1 -0
- package/lib/commands/assertHasClass.d.ts +18 -0
- package/lib/commands/assertHasClass.js +17 -0
- package/lib/commands/assertHasClass.js.map +1 -0
- package/lib/commands/assertNumElements.d.ts +18 -0
- package/lib/commands/assertNumElements.js +17 -0
- package/lib/commands/assertNumElements.js.map +1 -0
- package/lib/commands/clickWithRetry.d.ts +19 -0
- package/lib/commands/clickWithRetry.js +29 -0
- package/lib/commands/clickWithRetry.js.map +1 -0
- package/lib/commands/genTextOfLength.d.ts +20 -0
- package/lib/commands/genTextOfLength.js +20 -0
- package/lib/commands/genTextOfLength.js.map +1 -0
- package/lib/commands/getAttribute.d.ts +20 -0
- package/lib/commands/getAttribute.js +22 -0
- package/lib/commands/getAttribute.js.map +1 -0
- package/lib/commands/getClassName.d.ts +15 -0
- package/lib/commands/getClassName.js +21 -0
- package/lib/commands/getClassName.js.map +1 -0
- package/lib/commands/getCurrentDateInfo.d.ts +21 -0
- package/lib/commands/getCurrentDateInfo.js +25 -0
- package/lib/commands/getCurrentDateInfo.js.map +1 -0
- package/lib/commands/getId.d.ts +15 -0
- package/lib/commands/getId.js +21 -0
- package/lib/commands/getId.js.map +1 -0
- package/lib/commands/getNumElements.d.ts +14 -0
- package/lib/commands/getNumElements.js +19 -0
- package/lib/commands/getNumElements.js.map +1 -0
- package/lib/commands/getSpecialChars.d.ts +14 -0
- package/lib/commands/getSpecialChars.js +16 -0
- package/lib/commands/getSpecialChars.js.map +1 -0
- package/lib/commands/getTitle.d.ts +13 -0
- package/lib/commands/getTitle.js +20 -0
- package/lib/commands/getTitle.js.map +1 -0
- package/lib/commands/handleHarvardKey.d.ts +18 -0
- package/lib/commands/handleHarvardKey.js +56 -0
- package/lib/commands/handleHarvardKey.js.map +1 -0
- package/lib/commands/handleHarvardKey2.d.ts +14 -0
- package/lib/commands/handleHarvardKey2.js +88 -0
- package/lib/commands/handleHarvardKey2.js.map +1 -0
- package/lib/commands/launchAs.d.ts +20 -0
- package/lib/commands/launchAs.js +60 -0
- package/lib/commands/launchAs.js.map +1 -0
- package/lib/commands/launchLTIUsingToken.d.ts +19 -0
- package/lib/commands/launchLTIUsingToken.js +74 -0
- package/lib/commands/launchLTIUsingToken.js.map +1 -0
- package/lib/commands/listSelectLabels.d.ts +15 -0
- package/lib/commands/listSelectLabels.js +24 -0
- package/lib/commands/listSelectLabels.js.map +1 -0
- package/lib/commands/listSelectValues.d.ts +15 -0
- package/lib/commands/listSelectValues.js +26 -0
- package/lib/commands/listSelectValues.js.map +1 -0
- package/lib/commands/navigateToHref.d.ts +19 -0
- package/lib/commands/navigateToHref.js +23 -0
- package/lib/commands/navigateToHref.js.map +1 -0
- package/lib/commands/padWithZeros.d.ts +20 -0
- package/lib/commands/padWithZeros.js +24 -0
- package/lib/commands/padWithZeros.js.map +1 -0
- package/lib/commands/runScript.d.ts +16 -0
- package/lib/commands/runScript.js +25 -0
- package/lib/commands/runScript.js.map +1 -0
- package/lib/commands/typeInto.d.ts +20 -0
- package/lib/commands/typeInto.js +28 -0
- package/lib/commands/typeInto.js.map +1 -0
- package/lib/commands/uniquify.d.ts +15 -0
- package/lib/commands/uniquify.js +25 -0
- package/lib/commands/uniquify.js.map +1 -0
- package/lib/commands/visitCanvasEndpoint.d.ts +27 -0
- package/lib/commands/visitCanvasEndpoint.js +35 -0
- package/lib/commands/visitCanvasEndpoint.js.map +1 -0
- package/lib/commands/visitCanvasGETEndpoint.d.ts +20 -0
- package/lib/commands/visitCanvasGETEndpoint.js +26 -0
- package/lib/commands/visitCanvasGETEndpoint.js.map +1 -0
- package/lib/commands/waitForAtLeastOneElementPresent.d.ts +23 -0
- package/lib/commands/waitForAtLeastOneElementPresent.js +27 -0
- package/lib/commands/waitForAtLeastOneElementPresent.js.map +1 -0
- package/lib/commands/waitForElementVisible.d.ts +14 -0
- package/lib/commands/waitForElementVisible.js +20 -0
- package/lib/commands/waitForElementVisible.js.map +1 -0
- package/lib/index.js.map +1 -0
- package/lib/init.d.ts +6 -0
- package/lib/init.js +69 -0
- package/lib/init.js.map +1 -0
- package/lib/setup/checkRequiredFiles/index.js +7 -0
- package/lib/setup/checkRequiredFiles/index.js.map +1 -1
- package/lib/src/commands/extractDataFromClass.d.ts +7 -4
- package/lib/src/commands/extractDataFromClass.js +2 -1
- package/lib/src/commands/extractDataFromClass.js.map +1 -1
- package/lib/src/commands/extractDataFromClassByContents.d.ts +9 -5
- package/lib/src/commands/extractDataFromClassByContents.js +2 -1
- package/lib/src/commands/extractDataFromClassByContents.js.map +1 -1
- package/lib/src/commands/genTextOfLength.d.ts +20 -0
- package/lib/src/commands/genTextOfLength.js +20 -0
- package/lib/src/commands/genTextOfLength.js.map +1 -0
- package/lib/src/commands/getAttribute.d.ts +20 -0
- package/lib/src/commands/getAttribute.js +22 -0
- package/lib/src/commands/getAttribute.js.map +1 -0
- package/lib/src/commands/getClassName.d.ts +15 -0
- package/lib/src/commands/getClassName.js +21 -0
- package/lib/src/commands/getClassName.js.map +1 -0
- package/lib/src/commands/getCurrentDateInfo.d.ts +21 -0
- package/lib/src/commands/getCurrentDateInfo.js +25 -0
- package/lib/src/commands/getCurrentDateInfo.js.map +1 -0
- package/lib/src/commands/getId.d.ts +15 -0
- package/lib/src/commands/getId.js +21 -0
- package/lib/src/commands/getId.js.map +1 -0
- package/lib/src/commands/getJSON.d.ts +0 -1
- package/lib/src/commands/getJSON.js +1 -4
- package/lib/src/commands/getJSON.js.map +1 -1
- package/lib/src/commands/getSpecialChars.d.ts +14 -0
- package/lib/src/commands/getSpecialChars.js +16 -0
- package/lib/src/commands/getSpecialChars.js.map +1 -0
- package/lib/src/commands/getTitle.d.ts +13 -0
- package/lib/src/commands/getTitle.js +20 -0
- package/lib/src/commands/getTitle.js.map +1 -0
- package/lib/src/commands/index.js +29 -5
- package/lib/src/commands/index.js.map +1 -1
- package/lib/src/commands/launchLTIUsingToken.js +12 -4
- package/lib/src/commands/launchLTIUsingToken.js.map +1 -1
- package/lib/src/commands/listSelectLabels.d.ts +15 -0
- package/lib/src/commands/listSelectLabels.js +24 -0
- package/lib/src/commands/listSelectLabels.js.map +1 -0
- package/lib/src/commands/listSelectValues.d.ts +15 -0
- package/lib/src/commands/listSelectValues.js +27 -0
- package/lib/src/commands/listSelectValues.js.map +1 -0
- package/lib/src/commands/padWithZeros.d.ts +20 -0
- package/lib/src/commands/padWithZeros.js +24 -0
- package/lib/src/commands/padWithZeros.js.map +1 -0
- package/lib/src/commands/uniquify.d.ts +15 -0
- package/lib/src/commands/uniquify.js +26 -0
- package/lib/src/commands/uniquify.js.map +1 -0
- package/lib/src/commands/visitCanvasEndpoint.d.ts +26 -0
- package/lib/src/commands/visitCanvasEndpoint.js +36 -0
- package/lib/src/commands/visitCanvasEndpoint.js.map +1 -0
- package/lib/src/commands/waitForAtLeastOneElementPresent.d.ts +23 -0
- package/lib/src/commands/waitForAtLeastOneElementPresent.js +28 -0
- package/lib/src/commands/waitForAtLeastOneElementPresent.js.map +1 -0
- package/lib/src/genConfiguration/index.js +21 -3
- package/lib/src/genConfiguration/index.js.map +1 -1
- package/lib/src/init.js +28 -2
- package/lib/src/init.js.map +1 -1
- package/lib/start/constants/DEFAULT_THREADS_PER_COMBO.d.ts +6 -0
- package/lib/start/constants/DEFAULT_THREADS_PER_COMBO.js +9 -0
- package/lib/start/constants/DEFAULT_THREADS_PER_COMBO.js.map +1 -0
- package/lib/start/helpers/collectPngFiles.d.ts +9 -0
- package/lib/start/helpers/collectPngFiles.js +31 -0
- package/lib/start/helpers/collectPngFiles.js.map +1 -0
- package/lib/start/helpers/executeAllHeadlessCombinations.d.ts +15 -0
- package/lib/start/helpers/executeAllHeadlessCombinations.js +116 -0
- package/lib/start/helpers/executeAllHeadlessCombinations.js.map +1 -0
- package/lib/start/helpers/executeCypress.d.ts +17 -0
- package/lib/start/helpers/executeCypress.js +103 -0
- package/lib/start/helpers/executeCypress.js.map +1 -0
- package/lib/start/helpers/generateHtmlReport.d.ts +14 -0
- package/lib/start/helpers/generateHtmlReport.js +54 -0
- package/lib/start/helpers/generateHtmlReport.js.map +1 -0
- package/lib/start/helpers/generateReportHomepage.d.ts +9 -0
- package/lib/start/helpers/generateReportHomepage.js +142 -0
- package/lib/start/helpers/generateReportHomepage.js.map +1 -0
- package/lib/start/helpers/generateReporterConfig.d.ts +17 -0
- package/lib/start/helpers/generateReporterConfig.js +32 -0
- package/lib/start/helpers/generateReporterConfig.js.map +1 -0
- package/lib/start/helpers/getDateLabeledDir.d.ts +7 -0
- package/lib/start/helpers/getDateLabeledDir.js +38 -0
- package/lib/start/helpers/getDateLabeledDir.js.map +1 -0
- package/lib/start/helpers/mergeAllReportsAndGenerateHtml.d.ts +11 -0
- package/lib/start/helpers/mergeAllReportsAndGenerateHtml.js +121 -0
- package/lib/start/helpers/mergeAllReportsAndGenerateHtml.js.map +1 -0
- package/lib/start/helpers/mergeReports.d.ts +14 -0
- package/lib/start/helpers/mergeReports.js +63 -0
- package/lib/start/helpers/mergeReports.js.map +1 -0
- package/lib/start/helpers/reportHomepage.ejs +272 -0
- package/lib/start/helpers/runCypressHeadless.d.ts +18 -0
- package/lib/start/helpers/runCypressHeadless.js +138 -0
- package/lib/start/helpers/runCypressHeadless.js.map +1 -0
- package/lib/start/helpers/runCypressVisible.d.ts +8 -0
- package/lib/start/helpers/runCypressVisible.js +53 -0
- package/lib/start/helpers/runCypressVisible.js.map +1 -0
- package/lib/start/index.js +23 -5
- package/lib/start/index.js.map +1 -1
- package/lib/start/types/MochawesomeReporterConfig.d.ts +15 -0
- package/lib/start/types/MochawesomeReporterConfig.js +3 -0
- package/lib/start/types/MochawesomeReporterConfig.js.map +1 -0
- package/lib/start/types/Profile.d.ts +9 -0
- package/lib/start/types/Profile.js +3 -0
- package/lib/start/types/Profile.js.map +1 -0
- package/lib/start/types/ReportInfo.d.ts +14 -0
- package/lib/start/types/ReportInfo.js +3 -0
- package/lib/start/types/ReportInfo.js.map +1 -0
- package/lib/start/types/RunResult.d.ts +12 -0
- package/lib/start/types/RunResult.js +3 -0
- package/lib/start/types/RunResult.js.map +1 -0
- package/lib/start/types/ScreenshotInfo.d.ts +10 -0
- package/lib/start/types/ScreenshotInfo.js +3 -0
- package/lib/start/types/ScreenshotInfo.js.map +1 -0
- package/lib/start/types/TemplateReportInfo.d.ts +12 -0
- package/lib/start/types/TemplateReportInfo.js +3 -0
- package/lib/start/types/TemplateReportInfo.js.map +1 -0
- package/package.json +10 -8
- package/setup/checkRequiredFiles/index.ts +7 -0
- package/src/commands/extractDataFromClass.ts +17 -6
- package/src/commands/extractDataFromClassByContents.ts +21 -8
- package/src/commands/genTextOfLength.ts +54 -0
- package/src/commands/getAttribute.ts +58 -0
- package/src/commands/getClassName.ts +44 -0
- package/src/commands/getCurrentDateInfo.ts +57 -0
- package/src/commands/getId.ts +44 -0
- package/src/commands/getJSON.ts +0 -4
- package/src/commands/getSpecialChars.ts +34 -0
- package/src/commands/getTitle.ts +39 -0
- package/src/commands/index.ts +29 -5
- package/src/commands/launchLTIUsingToken.ts +12 -4
- package/src/commands/listSelectLabels.ts +47 -0
- package/src/commands/listSelectValues.ts +50 -0
- package/src/commands/padWithZeros.ts +53 -0
- package/src/commands/uniquify.ts +49 -0
- package/src/commands/visitCanvasEndpoint.ts +75 -0
- package/src/commands/waitForAtLeastOneElementPresent.ts +64 -0
- package/src/genConfiguration/index.ts +20 -2
- package/start/constants/DEFAULT_THREADS_PER_COMBO.ts +7 -0
- package/start/helpers/collectPngFiles.ts +25 -0
- package/start/helpers/executeAllHeadlessCombinations.ts +92 -0
- package/start/helpers/executeCypress.ts +66 -0
- package/start/helpers/generateHtmlReport.ts +71 -0
- package/start/helpers/generateReportHomepage.ts +148 -0
- package/start/helpers/generateReporterConfig.ts +39 -0
- package/start/helpers/getDateLabeledDir.ts +43 -0
- package/start/helpers/mergeAllReportsAndGenerateHtml.ts +150 -0
- package/start/helpers/mergeReports.ts +82 -0
- package/start/helpers/reportHomepage.ejs +272 -0
- package/start/helpers/runCypressHeadless.ts +164 -0
- package/start/helpers/runCypressVisible.ts +45 -0
- package/start/index.ts +23 -5
- package/start/types/MochawesomeReporterConfig.ts +23 -0
- package/start/types/Profile.ts +12 -0
- package/start/types/ReportInfo.ts +22 -0
- package/start/types/RunResult.ts +18 -0
- package/start/types/ScreenshotInfo.ts +13 -0
- package/start/types/TemplateReportInfo.ts +16 -0
- package/src/commands/visitCanvasGETEndpoint.ts +0 -61
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunResult.js","sourceRoot":"","sources":["../../../start/types/RunResult.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScreenshotInfo.js","sourceRoot":"","sources":["../../../start/types/ScreenshotInfo.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ReportInfo from './ReportInfo';
|
|
2
|
+
import ScreenshotInfo from './ScreenshotInfo';
|
|
3
|
+
/**
|
|
4
|
+
* Extended version of ReportInfo with additional computed fields
|
|
5
|
+
* needed for rendering the EJS report homepage template
|
|
6
|
+
* @author Yuen Ler Chow
|
|
7
|
+
*/
|
|
8
|
+
type TemplateReportInfo = ReportInfo & {
|
|
9
|
+
relativeReportPath: string | null;
|
|
10
|
+
screenshots: ScreenshotInfo[];
|
|
11
|
+
};
|
|
12
|
+
export default TemplateReportInfo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateReportInfo.js","sourceRoot":"","sources":["../../../start/types/TemplateReportInfo.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dceky",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Cypress toolkit for Harvard DCE",
|
|
5
5
|
"main": "./lib/src/index.js",
|
|
6
6
|
"types": "./lib/src/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsc --project ./tsconfig.json",
|
|
8
|
+
"build": "tsc --project ./tsconfig.json && cp start/helpers/reportHomepage.ejs lib/start/helpers/",
|
|
9
9
|
"ky:start": "npx tsx ./start/index.ts",
|
|
10
10
|
"ky:setup": "npx tsx ./setup/index.ts",
|
|
11
11
|
"ky:dev": "npm run ky:setup && npm run ky:start",
|
|
@@ -28,16 +28,17 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/harvard-edtech/dceky#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"@types/clear": "^0.1.4",
|
|
32
|
+
"@types/ejs": "^3.1.5",
|
|
33
|
+
"@types/node": "^22.7.0",
|
|
34
|
+
"@types/prompt-sync": "^4.2.3",
|
|
31
35
|
"child_process": "^1.0.2",
|
|
32
36
|
"clear": "^0.1.0",
|
|
33
37
|
"deepmerge": "4.3.1",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"@types/clear": "^0.1.4",
|
|
37
|
-
"@types/node": "^22.7.0"
|
|
38
|
+
"ejs": "^3.1.10",
|
|
39
|
+
"prompt-sync": "^4.2.0"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
|
-
"typescript": "^5.9.3",
|
|
41
42
|
"@types/deepmerge": "2.1.0",
|
|
42
43
|
"@types/node": "^24.6.1",
|
|
43
44
|
"cross-env": "^10.1.0",
|
|
@@ -46,7 +47,8 @@
|
|
|
46
47
|
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
47
48
|
"eslint-plugin-import": "^2.32.0",
|
|
48
49
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
49
|
-
"eslint-plugin-react": "^7.37.5"
|
|
50
|
+
"eslint-plugin-react": "^7.37.5",
|
|
51
|
+
"typescript": "^5.9.3"
|
|
50
52
|
},
|
|
51
53
|
"peerDependencies": {
|
|
52
54
|
"cypress": "^x.x.x"
|
|
@@ -26,6 +26,7 @@ const checkRequiredFiles = (): void => {
|
|
|
26
26
|
|
|
27
27
|
// Determine profile file name (default is stage)
|
|
28
28
|
const profileName = process.env.CYPRESS_PROFILE || 'Stage';
|
|
29
|
+
const defaultProfileName = 'Default';
|
|
29
30
|
const requiredProfile = `${profileName}.Profile.ts`;
|
|
30
31
|
|
|
31
32
|
// Check global files
|
|
@@ -44,6 +45,12 @@ const checkRequiredFiles = (): void => {
|
|
|
44
45
|
if (!profileFound) {
|
|
45
46
|
genEmptyProfileFile(profileName);
|
|
46
47
|
}
|
|
48
|
+
// Check default profile file
|
|
49
|
+
const defaultProfileFilePath = path.join(profilesPath, `${defaultProfileName}.Profile.ts`);
|
|
50
|
+
const defaultProfileFound = existsSync(defaultProfileFilePath);
|
|
51
|
+
if (!defaultProfileFound) {
|
|
52
|
+
genEmptyProfileFile(defaultProfileName);
|
|
53
|
+
}
|
|
47
54
|
};
|
|
48
55
|
|
|
49
56
|
export default checkRequiredFiles;
|
|
@@ -11,14 +11,16 @@ declare global {
|
|
|
11
11
|
* Obtain data from a class attribute that starts with a specific prefix
|
|
12
12
|
* and return it
|
|
13
13
|
* @author Allison Zhang
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
14
|
+
* @param opts the options object
|
|
15
|
+
* @param opts.selector the css selector for finding the element
|
|
16
|
+
* @param opts.classPrefix the prefix to look for in the class attribute
|
|
16
17
|
* @returns the extracted data
|
|
17
|
-
* @example cy.extractDataFromClass('.item', 'data-').then((data) => { ... })
|
|
18
18
|
*/
|
|
19
19
|
extractDataFromClass(
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
opts: {
|
|
21
|
+
selector: string,
|
|
22
|
+
classPrefix: string,
|
|
23
|
+
},
|
|
22
24
|
): Chainable<string[]>;
|
|
23
25
|
}
|
|
24
26
|
}
|
|
@@ -29,7 +31,16 @@ declare global {
|
|
|
29
31
|
/*----------------------------------------*/
|
|
30
32
|
|
|
31
33
|
const extractDataFromClass = () => {
|
|
32
|
-
Cypress.Commands.add('extractDataFromClass', (
|
|
34
|
+
Cypress.Commands.add('extractDataFromClass', (
|
|
35
|
+
opts: {
|
|
36
|
+
selector: string,
|
|
37
|
+
classPrefix: string,
|
|
38
|
+
},
|
|
39
|
+
) => {
|
|
40
|
+
const {
|
|
41
|
+
selector,
|
|
42
|
+
classPrefix,
|
|
43
|
+
} = opts;
|
|
33
44
|
return (
|
|
34
45
|
cy
|
|
35
46
|
.get(selector)
|
|
@@ -11,16 +11,18 @@ declare global {
|
|
|
11
11
|
* Obtain data from a class attribute that starts with a specific prefix
|
|
12
12
|
* and with specific contents, and return it
|
|
13
13
|
* @author Allison Zhang
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
14
|
+
* @param opts the options object
|
|
15
|
+
* @param opts.contents the contents of the element to find
|
|
16
|
+
* @param opts.selector the css selector for finding the element
|
|
17
|
+
* @param opts.classPrefix the prefix to look for in the class attribute
|
|
17
18
|
* @returns the extracted data
|
|
18
|
-
* @example cy.extractDataFromClassByContents('Submit', '.button', 'btn-').then((data) => { ... })
|
|
19
19
|
*/
|
|
20
20
|
extractDataFromClassByContents(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
opts: {
|
|
22
|
+
contents: string,
|
|
23
|
+
selector: string,
|
|
24
|
+
classPrefix: string,
|
|
25
|
+
},
|
|
24
26
|
): Chainable<string[]>;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
@@ -31,7 +33,18 @@ declare global {
|
|
|
31
33
|
/*----------------------------------------*/
|
|
32
34
|
|
|
33
35
|
const extractDataFromClassByContents = () => {
|
|
34
|
-
Cypress.Commands.add('extractDataFromClassByContents', (
|
|
36
|
+
Cypress.Commands.add('extractDataFromClassByContents', (
|
|
37
|
+
opts: {
|
|
38
|
+
contents: string,
|
|
39
|
+
selector: string,
|
|
40
|
+
classPrefix: string,
|
|
41
|
+
},
|
|
42
|
+
) => {
|
|
43
|
+
const {
|
|
44
|
+
contents,
|
|
45
|
+
selector,
|
|
46
|
+
classPrefix,
|
|
47
|
+
} = opts;
|
|
35
48
|
return (
|
|
36
49
|
cy
|
|
37
50
|
.get(selector)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
/*----------------------------------------*/
|
|
4
|
+
/* ---------------- Type ---------------- */
|
|
5
|
+
/*----------------------------------------*/
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
namespace Cypress {
|
|
9
|
+
interface Chainable {
|
|
10
|
+
/**
|
|
11
|
+
* Generate a string of specified length for Cypress tests
|
|
12
|
+
* @author Gardenia Liu, Allison Zhang
|
|
13
|
+
* @param opts options object
|
|
14
|
+
* @param opts.length the desired length of the string
|
|
15
|
+
* @param opts.text optional text to repeat to form the string; defaults to '123456789x' if not provided
|
|
16
|
+
* @returns a string of the specified length, if the length is not a multiple of the text length, it is truncated
|
|
17
|
+
*/
|
|
18
|
+
genTextOfLength(
|
|
19
|
+
opts: {
|
|
20
|
+
length: number,
|
|
21
|
+
text?: string,
|
|
22
|
+
},
|
|
23
|
+
): Chainable<string>;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*----------------------------------------*/
|
|
29
|
+
/* --------------- Command -------------- */
|
|
30
|
+
/*----------------------------------------*/
|
|
31
|
+
|
|
32
|
+
const genTextOfLength = () => {
|
|
33
|
+
Cypress.Commands.add('genTextOfLength', (
|
|
34
|
+
opts: {
|
|
35
|
+
length: number,
|
|
36
|
+
text?: string,
|
|
37
|
+
},
|
|
38
|
+
) => {
|
|
39
|
+
const {
|
|
40
|
+
length,
|
|
41
|
+
text,
|
|
42
|
+
} = opts;
|
|
43
|
+
const textToUse = text || '123456789x';
|
|
44
|
+
const lengthOfTextToUse = Math.ceil(length / textToUse.length);
|
|
45
|
+
const result = textToUse.repeat(lengthOfTextToUse).substring(0, length);
|
|
46
|
+
return cy.wrap(result);
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/*----------------------------------------*/
|
|
51
|
+
/* --------------- Export --------------- */
|
|
52
|
+
/*----------------------------------------*/
|
|
53
|
+
|
|
54
|
+
export default genTextOfLength;
|
|
@@ -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;
|
package/src/commands/getJSON.ts
CHANGED
|
@@ -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;
|
package/src/commands/index.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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.
|
|
63
|
-
|
|
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.
|
|
97
|
-
|
|
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}`);
|