dceky 1.0.0-beta-auto-import.3 → 1.0.0-beta-yuenler.3
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/lib/commands/assertNumElements.d.ts +0 -1
- package/lib/commands/assertNumElements.js.map +1 -1
- package/lib/commands/extractDataFromClass.d.ts +18 -0
- package/lib/commands/extractDataFromClass.js +25 -0
- package/lib/commands/extractDataFromClass.js.map +1 -0
- package/lib/commands/extractDataFromClassByContents.d.ts +19 -0
- package/lib/commands/extractDataFromClassByContents.js +26 -0
- package/lib/commands/extractDataFromClassByContents.js.map +1 -0
- package/lib/commands/getJSON.d.ts +16 -0
- package/lib/commands/getJSON.js +20 -0
- package/lib/commands/getJSON.js.map +1 -0
- package/lib/commands/getNumElements.d.ts +1 -1
- package/lib/commands/handleHarvardKey.d.ts +2 -7
- package/lib/commands/handleHarvardKey.js +1 -3
- package/lib/commands/handleHarvardKey.js.map +1 -1
- package/lib/commands/navigateToHref.js +5 -4
- package/lib/commands/navigateToHref.js.map +1 -1
- package/lib/commands/runScript.d.ts +1 -3
- package/lib/commands/runScript.js +2 -3
- package/lib/commands/runScript.js.map +1 -1
- package/lib/commands/typeInto.js +5 -2
- package/lib/commands/typeInto.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/init.d.ts +5 -1
- package/lib/init.js +37 -71
- package/lib/init.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/assertNumElements.ts +0 -1
- package/src/commands/extractDataFromClass.ts +52 -0
- package/src/commands/extractDataFromClassByContents.ts +55 -0
- package/src/commands/getJSON.ts +44 -0
- package/src/commands/getNumElements.ts +1 -1
- package/src/commands/handleHarvardKey.ts +3 -14
- package/src/commands/navigateToHref.ts +5 -4
- package/src/commands/runScript.ts +3 -6
- package/src/commands/typeInto.ts +6 -3
- package/src/index.ts +3 -2
- package/src/init.ts +38 -80
- package/lib/genCommandPaths.d.ts +0 -8
- package/lib/genCommandPaths.js +0 -96
- package/lib/genCommandPaths.js.map +0 -1
- package/src/genCommandPaths.ts +0 -80
|
@@ -7,7 +7,6 @@ declare global {
|
|
|
7
7
|
* @param opts object containing all arguments
|
|
8
8
|
* @param opts.item a CSS selector corresponding to the item
|
|
9
9
|
* @param opts.num the precise number of elements expected
|
|
10
|
-
* @return Cypress chainable
|
|
11
10
|
*/
|
|
12
11
|
assertNumElements(opts: {
|
|
13
12
|
item: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertNumElements.js","sourceRoot":"","sources":["../../src/commands/assertNumElements.ts"],"names":[],"mappings":";AAAA,iCAAiC;;
|
|
1
|
+
{"version":3,"file":"assertNumElements.js","sourceRoot":"","sources":["../../src/commands/assertNumElements.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AA0BjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,iBAAiB,GAAG;IACxB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,mBAAmB,EACnB,UACE,IAGC;QAED,EAAE,CAAC,GAAG,CAAC,iBAAU,IAAI,CAAC,GAAG,6BAAmB,IAAI,CAAC,IAAI,CAAE,CAAC,CAAC;QACzD,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace Cypress {
|
|
3
|
+
interface Chainable {
|
|
4
|
+
/**
|
|
5
|
+
* Obtain data from a class attribute that starts with a specific prefix
|
|
6
|
+
* and return it
|
|
7
|
+
* @author Allison Zhang
|
|
8
|
+
* @param selector the css selector for finding the element
|
|
9
|
+
* @param classPrefix the prefix to look for in the class attribute
|
|
10
|
+
* @returns the extracted data
|
|
11
|
+
* @example cy.extractDataFromClass('.item', 'data-').then((data) => { ... })
|
|
12
|
+
*/
|
|
13
|
+
extractDataFromClass(selector: string, classPrefix: string): Chainable<string[]>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
declare const extractDataFromClass: () => void;
|
|
18
|
+
export default extractDataFromClass;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference types="cypress" />
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
/*----------------------------------------*/
|
|
5
|
+
/* --------------- Command -------------- */
|
|
6
|
+
/*----------------------------------------*/
|
|
7
|
+
var extractDataFromClass = function () {
|
|
8
|
+
Cypress.Commands.add('extractDataFromClass', function (selector, classPrefix) {
|
|
9
|
+
return (cy
|
|
10
|
+
.get(selector)
|
|
11
|
+
.invoke('attr', 'class')
|
|
12
|
+
.then(function (classAttr) {
|
|
13
|
+
var classList = classAttr.split(' ');
|
|
14
|
+
var data = classList
|
|
15
|
+
.filter(function (className) { return className.startsWith(classPrefix); })
|
|
16
|
+
.map(function (className) { return className.replace(classPrefix, ''); });
|
|
17
|
+
return data;
|
|
18
|
+
}));
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
/*----------------------------------------*/
|
|
22
|
+
/* --------------- Export --------------- */
|
|
23
|
+
/*----------------------------------------*/
|
|
24
|
+
exports.default = extractDataFromClass;
|
|
25
|
+
//# sourceMappingURL=extractDataFromClass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractDataFromClass.js","sourceRoot":"","sources":["../../src/commands/extractDataFromClass.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AA0BjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,oBAAoB,GAAG;IAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,sBAAsB,EAAE,UAAC,QAAgB,EAAE,WAAmB;QACjF,OAAO,CACL,EAAE;aACC,GAAG,CAAC,QAAQ,CAAC;aACb,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;aACvB,IAAI,CAAC,UAAC,SAAiB;YACtB,IAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACvC,IAAM,IAAI,GAAG,SAAS;iBACnB,MAAM,CAAC,UAAC,SAAS,IAAO,OAAO,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;iBACpE,GAAG,CAAC,UAAC,SAAS,IAAO,OAAO,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACtE,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CACL,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace Cypress {
|
|
3
|
+
interface Chainable {
|
|
4
|
+
/**
|
|
5
|
+
* Obtain data from a class attribute that starts with a specific prefix
|
|
6
|
+
* and with specific contents, and return it
|
|
7
|
+
* @author Allison Zhang
|
|
8
|
+
* @param contents the contents of the element to find
|
|
9
|
+
* @param selector the css selector for finding the element
|
|
10
|
+
* @param classPrefix the prefix to look for in the class attribute
|
|
11
|
+
* @returns the extracted data
|
|
12
|
+
* @example cy.extractDataFromClassByContents('Submit', '.button', 'btn-').then((data) => { ... })
|
|
13
|
+
*/
|
|
14
|
+
extractDataFromClassByContents(contents: string, selector: string, classPrefix: string): Chainable<string[]>;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
declare const extractDataFromClassByContents: () => void;
|
|
19
|
+
export default extractDataFromClassByContents;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference types="cypress" />
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
/*----------------------------------------*/
|
|
5
|
+
/* --------------- Command -------------- */
|
|
6
|
+
/*----------------------------------------*/
|
|
7
|
+
var extractDataFromClassByContents = function () {
|
|
8
|
+
Cypress.Commands.add('extractDataFromClassByContents', function (contents, selector, classPrefix) {
|
|
9
|
+
return (cy
|
|
10
|
+
.get(selector)
|
|
11
|
+
.contains(contents)
|
|
12
|
+
.invoke('attr', 'class')
|
|
13
|
+
.then(function (classAttr) {
|
|
14
|
+
var classList = classAttr.split(' ');
|
|
15
|
+
var data = classList
|
|
16
|
+
.filter(function (className) { return className.startsWith(classPrefix); })
|
|
17
|
+
.map(function (className) { return className.replace(classPrefix, ''); });
|
|
18
|
+
return data;
|
|
19
|
+
}));
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
/*----------------------------------------*/
|
|
23
|
+
/* --------------- Export --------------- */
|
|
24
|
+
/*----------------------------------------*/
|
|
25
|
+
exports.default = extractDataFromClassByContents;
|
|
26
|
+
//# sourceMappingURL=extractDataFromClassByContents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractDataFromClassByContents.js","sourceRoot":"","sources":["../../src/commands/extractDataFromClassByContents.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AA4BjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,8BAA8B,GAAG;IACrC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,gCAAgC,EAAE,UAAC,QAAgB,EAAE,QAAgB,EAAE,WAAmB;QAC7G,OAAO,CACL,EAAE;aACC,GAAG,CAAC,QAAQ,CAAC;aACb,QAAQ,CAAC,QAAQ,CAAC;aAClB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;aACvB,IAAI,CAAC,UAAC,SAAiB;YACtB,IAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACvC,IAAM,IAAI,GAAG,SAAS;iBACnB,MAAM,CAAC,UAAC,SAAS,IAAO,OAAO,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;iBACpE,GAAG,CAAC,UAAC,SAAS,IAAO,OAAO,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACtE,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CACL,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace Cypress {
|
|
3
|
+
interface Chainable {
|
|
4
|
+
/**
|
|
5
|
+
* Obtain JSON data from a request and return it.
|
|
6
|
+
* @author Allison Zhang
|
|
7
|
+
* @param url the URL to fetch the JSON data from
|
|
8
|
+
* @returns the JSON data
|
|
9
|
+
* @example cy.getJSON('https://api.example.com/data').then((data) => { ... })
|
|
10
|
+
*/
|
|
11
|
+
getJSON(url: string): Chainable<any>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
declare const getJSON: () => void;
|
|
16
|
+
export default getJSON;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference types="cypress" />
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
/*----------------------------------------*/
|
|
5
|
+
/* --------------- Command -------------- */
|
|
6
|
+
/*----------------------------------------*/
|
|
7
|
+
var getJSON = function () {
|
|
8
|
+
Cypress.Commands.add('getJSON', function (url) {
|
|
9
|
+
return (cy
|
|
10
|
+
.request(url)
|
|
11
|
+
.then(function (response) {
|
|
12
|
+
return response.body;
|
|
13
|
+
}));
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
/*----------------------------------------*/
|
|
17
|
+
/* --------------- Export --------------- */
|
|
18
|
+
/*----------------------------------------*/
|
|
19
|
+
exports.default = getJSON;
|
|
20
|
+
//# sourceMappingURL=getJSON.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getJSON.js","sourceRoot":"","sources":["../../src/commands/getJSON.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAuBjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,OAAO,GAAG;IACd,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,UAAC,GAAW;QAC1C,OAAO,CACL,EAAE;aACC,OAAO,CAAC,GAAG,CAAC;aACZ,IAAI,CAAC,UAAC,QAAQ;YACb,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC,CAAC,CACL,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,OAAO,CAAC"}
|
|
@@ -4,7 +4,7 @@ declare global {
|
|
|
4
4
|
/**
|
|
5
5
|
* Get number of elements
|
|
6
6
|
* @author Yuen Ler Chow
|
|
7
|
-
* @param selector a CSS selector corresponding to the item
|
|
7
|
+
* @param selector a CSS selector corresponding to the item to count
|
|
8
8
|
* @return Cypress chainable containing the number of elements matching the selector
|
|
9
9
|
*/
|
|
10
10
|
getNumElements(selector: string): Chainable<number>;
|
|
@@ -4,15 +4,10 @@ declare global {
|
|
|
4
4
|
/**
|
|
5
5
|
* Handle a HarvardKey login page for a user
|
|
6
6
|
* @author Yuen Ler Chow
|
|
7
|
-
* @param
|
|
8
|
-
* @param opts.url the URL to visit for HarvardKey authentication
|
|
9
|
-
* @param opts.name the name of the user environment variable
|
|
7
|
+
* @param name the name of the user environment variable
|
|
10
8
|
* @return Cypress chainable (void) - performs authentication flow, no return value
|
|
11
9
|
*/
|
|
12
|
-
handleHarvardKey(
|
|
13
|
-
url: string;
|
|
14
|
-
name: string;
|
|
15
|
-
}): Chainable<void>;
|
|
10
|
+
handleHarvardKey(name: string): Chainable<void>;
|
|
16
11
|
}
|
|
17
12
|
}
|
|
18
13
|
}
|
|
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
/* --------------- Command -------------- */
|
|
6
6
|
/*----------------------------------------*/
|
|
7
7
|
var handleHarvardKey = function () {
|
|
8
|
-
Cypress.Commands.add('handleHarvardKey', function (
|
|
9
|
-
var url = opts.url, name = opts.name;
|
|
8
|
+
Cypress.Commands.add('handleHarvardKey', function (name) {
|
|
10
9
|
cy.log('Handling HarvardKey authentication');
|
|
11
10
|
var userInfo = Cypress.env(name);
|
|
12
11
|
if (!userInfo) {
|
|
@@ -15,7 +14,6 @@ var handleHarvardKey = function () {
|
|
|
15
14
|
// Destructure the user info object to get the username and password
|
|
16
15
|
var username = userInfo.username;
|
|
17
16
|
var password = userInfo.password;
|
|
18
|
-
cy.visit(url);
|
|
19
17
|
// Get the Harvard login URL using originWithKaixa with auto-initialized functions
|
|
20
18
|
cy.origin('https://apps.cirrusidentity.com', function () {
|
|
21
19
|
Cypress.require('dceky');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleHarvardKey.js","sourceRoot":"","sources":["../../src/commands/handleHarvardKey.ts"],"names":[],"mappings":";AAAA,iCAAiC;;
|
|
1
|
+
{"version":3,"file":"handleHarvardKey.js","sourceRoot":"","sources":["../../src/commands/handleHarvardKey.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAsBjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,gBAAgB,GAAG;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,kBAAkB,EAClB,UACE,IAAY;QAEZ,EAAE,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;QAE7C,IAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,yBAAkB,IAAI,8BAA2B,CAAC,CAAC;QACrE,CAAC;QAED,oEAAoE;QAC5D,IAAA,QAAQ,GAAK,QAAQ,SAAb,CAAc;QACtB,IAAA,QAAQ,GAAK,QAAQ,SAAb,CAAc;QAE9B,kFAAkF;QAClF,EAAE,CAAC,MAAM,CAAC,iCAAiC,EAAE;YAC3C,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACzB,4FAA4F;YAC5F,OAAO,EAAE,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC,IAAI,CAAC,UAAC,OAAe;YACxB,2DAA2D;YACzD,EAAE,CAAC,MAAM,CAAC,wCAAwC,EAAE;gBAClD,IAAI,EAAE,EAAE,QAAQ,UAAA,EAAE,QAAQ,UAAA,EAAE,OAAO,SAAA,EAAE;aACtC,EAAE,UAAC,IAAI;gBACN,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAEvB,IAAU,eAAe,GAGvB,IAAI,SAHmB,EACf,eAAe,GAEvB,IAAI,SAFmB,EAChB,eAAe,GACtB,IAAI,QADkB,CACjB;gBAET,EAAE,CAAC,EAAE,CAAC,oBAAoB,EAAE,UAAC,CAAQ;oBACnC,iCAAiC;oBACjC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;wBAChD,MAAM,CAAC,CAAC;oBACV,CAAC;oBACD,OAAO,KAAK,CAAC;gBACf,CAAC,CAAC,CAAC;gBAEH,+BAA+B;gBAC/B,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;gBAE1B,sCAAsC;gBACtC,EAAE,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;gBACtC,EAAE,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;gBAEtC,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;gBAC1D,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;gBAE1D,kBAAkB;gBAClB,EAAE,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC,KAAK,EAAE,CAAC;YAC9E,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,gBAAgB,CAAC"}
|
|
@@ -7,9 +7,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
var navigateToHref = function () {
|
|
8
8
|
Cypress.Commands.add('navigateToHref', function (item) {
|
|
9
9
|
cy.waitForElementVisible(item);
|
|
10
|
-
// get
|
|
11
|
-
var
|
|
12
|
-
|
|
10
|
+
// get origin (protocol + '//' + host) from current URL
|
|
11
|
+
var origin = cy.url().then(function (url) {
|
|
12
|
+
var _a = new URL(url), protocol = _a.protocol, host = _a.host;
|
|
13
|
+
return "".concat(protocol, "//").concat(host);
|
|
13
14
|
});
|
|
14
15
|
return cy
|
|
15
16
|
.get(item)
|
|
@@ -17,7 +18,7 @@ var navigateToHref = function () {
|
|
|
17
18
|
.then(function (href) {
|
|
18
19
|
// If the href is a relative URL, prepend the hostname
|
|
19
20
|
if (href.startsWith('/')) {
|
|
20
|
-
return
|
|
21
|
+
return origin + href;
|
|
21
22
|
}
|
|
22
23
|
return href;
|
|
23
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigateToHref.js","sourceRoot":"","sources":["../../src/commands/navigateToHref.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAoBjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,cAAc,GAAG;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,gBAAgB,EAChB,UACE,IAAY;QAEZ,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAE/B,
|
|
1
|
+
{"version":3,"file":"navigateToHref.js","sourceRoot":"","sources":["../../src/commands/navigateToHref.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAoBjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,cAAc,GAAG;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,gBAAgB,EAChB,UACE,IAAY;QAEZ,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAE/B,uDAAuD;QACvD,IAAM,MAAM,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAC,GAAW;YACjC,IAAA,KAAqB,IAAI,GAAG,CAAC,GAAG,CAAC,EAA/B,QAAQ,cAAA,EAAE,IAAI,UAAiB,CAAC;YACxC,OAAO,UAAG,QAAQ,eAAK,IAAI,CAAE,CAAC;QAChC,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE;aACN,GAAG,CAAC,IAAI,CAAC;aACT,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;aACtB,IAAI,CAAC,UAAC,IAAY;YACjB,sDAAsD;YACtD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,OAAO,MAAM,GAAG,IAAI,CAAC;YACvB,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,cAAc,CAAC"}
|
|
@@ -4,9 +4,7 @@ declare global {
|
|
|
4
4
|
/**
|
|
5
5
|
* Run a script on the page
|
|
6
6
|
* @author Yuen Ler Chow
|
|
7
|
-
* @param
|
|
8
|
-
* If multiple script arguments are included, each argument will be considered a
|
|
9
|
-
* new line of the script.
|
|
7
|
+
* @param script the script to run
|
|
10
8
|
* @return Cypress chainable containing the return value from executing the script
|
|
11
9
|
*/
|
|
12
10
|
runScript(scriptLines: string): Chainable<any>;
|
|
@@ -5,11 +5,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
/* --------------- Command -------------- */
|
|
6
6
|
/*----------------------------------------*/
|
|
7
7
|
var runScript = function () {
|
|
8
|
-
Cypress.Commands.add('runScript', function (
|
|
8
|
+
Cypress.Commands.add('runScript', function (script) {
|
|
9
9
|
cy.log('Running script');
|
|
10
|
-
var fullScript = scriptLines;
|
|
11
10
|
return cy.window().then(function (win) {
|
|
12
|
-
var result = win.eval(
|
|
11
|
+
var result = win.eval(script);
|
|
13
12
|
return cy.wrap(result);
|
|
14
13
|
});
|
|
15
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runScript.js","sourceRoot":"","sources":["../../src/commands/runScript.ts"],"names":[],"mappings":";AAAA,iCAAiC;;
|
|
1
|
+
{"version":3,"file":"runScript.js","sourceRoot":"","sources":["../../src/commands/runScript.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAoBjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,SAAS,GAAG;IAChB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,WAAW,EACX,UACE,MAAc;QAEd,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QACzB,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,UAAC,GAAG;YAC1B,IAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAChC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,SAAS,CAAC"}
|
package/lib/commands/typeInto.js
CHANGED
|
@@ -7,9 +7,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
var typeInto = function () {
|
|
8
8
|
Cypress.Commands.add('typeInto', function (opts) {
|
|
9
9
|
var item = opts.item, text = opts.text, pressEnter = opts.pressEnter, append = opts.append;
|
|
10
|
-
cy.log("Type \"".concat(text, "\" into ").concat(item));
|
|
11
10
|
// Check if the text contains an enter key press
|
|
12
11
|
var enterAtEndOfText = text.charAt(text.length - 1) === '\n';
|
|
12
|
+
var willPressEnter = pressEnter || enterAtEndOfText;
|
|
13
|
+
var action = append ? 'Append' : 'Type';
|
|
14
|
+
var enterSuffix = willPressEnter ? ' and then press enter' : '';
|
|
15
|
+
cy.log("".concat(action, " \"").concat(text, "\" into ").concat(item).concat(enterSuffix));
|
|
13
16
|
// Type the text without a trailing enter if there was one
|
|
14
17
|
var textWithoutTrailingEnter = (enterAtEndOfText
|
|
15
18
|
? text.substring(0, text.length - 1)
|
|
@@ -26,7 +29,7 @@ var typeInto = function () {
|
|
|
26
29
|
.type(textWithoutTrailingEnter);
|
|
27
30
|
}
|
|
28
31
|
// Press enter if explicitly requested or if text ended with newline
|
|
29
|
-
if (
|
|
32
|
+
if (willPressEnter) {
|
|
30
33
|
cy.get(item).type('{enter}');
|
|
31
34
|
}
|
|
32
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeInto.js","sourceRoot":"","sources":["../../src/commands/typeInto.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AA+BjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,QAAQ,GAAG;IACf,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,UAAU,EACV,UACE,IAKC;QAGC,IAAA,IAAI,GACF,IAAI,KADF,EAAE,IAAI,GACR,IAAI,KADI,EAAE,UAAU,GACpB,IAAI,WADgB,EAAE,MAAM,GAC5B,IAAI,OADwB,CACvB;QACT,
|
|
1
|
+
{"version":3,"file":"typeInto.js","sourceRoot":"","sources":["../../src/commands/typeInto.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AA+BjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,QAAQ,GAAG;IACf,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,UAAU,EACV,UACE,IAKC;QAGC,IAAA,IAAI,GACF,IAAI,KADF,EAAE,IAAI,GACR,IAAI,KADI,EAAE,UAAU,GACpB,IAAI,WADgB,EAAE,MAAM,GAC5B,IAAI,OADwB,CACvB;QACT,gDAAgD;QAChD,IAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;QAC/D,IAAM,cAAc,GAAG,UAAU,IAAI,gBAAgB,CAAC;QAEtD,IAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;QAC1C,IAAM,WAAW,GAAG,cAAc,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,EAAE,CAAC,GAAG,CAAC,UAAG,MAAM,gBAAK,IAAI,qBAAU,IAAI,SAAG,WAAW,CAAE,CAAC,CAAC;QAEzD,0DAA0D;QAC1D,IAAM,wBAAwB,GAAG,CAC/B,gBAAgB;YACd,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YACpC,CAAC,CAAC,IAAI,CACT,CAAC;QAEF,IAAI,MAAM,EAAE,CAAC;YACX,EAAE;iBACC,GAAG,CAAC,IAAI,CAAC;iBACT,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,EAAE;iBACC,GAAG,CAAC,IAAI,CAAC;iBACT,KAAK,EAAE;iBACP,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACpC,CAAC;QAED,oEAAoE;QACpE,IAAI,cAAc,EAAE,CAAC;YACnB,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,QAAQ,CAAC"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.init = exports.
|
|
6
|
+
exports.init = exports.genConfiguration = void 0;
|
|
7
7
|
// Import helpers
|
|
8
8
|
var init_1 = __importDefault(require("./init"));
|
|
9
9
|
exports.init = init_1.default;
|
|
10
10
|
var genConfiguration_1 = __importDefault(require("./genConfiguration"));
|
|
11
11
|
exports.genConfiguration = genConfiguration_1.default;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
// Automatically initialize upon importing the library
|
|
13
|
+
(0, init_1.default)();
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,iBAAiB;AACjB,gDAA0B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,iBAAiB;AACjB,gDAA0B;AASxB,eATK,cAAI,CASL;AARN,wEAAkD;AAOhD,2BAPK,0BAAgB,CAOL;AALlB,sDAAsD;AACtD,IAAA,cAAI,GAAE,CAAC"}
|
package/lib/init.d.ts
CHANGED
package/lib/init.js
CHANGED
|
@@ -3,77 +3,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// // try {
|
|
44
|
-
// // CypressRequire(`cypress/commands/${file}`);
|
|
45
|
-
// // } catch (error) {
|
|
46
|
-
// // // eslint-disable-next-line no-console
|
|
47
|
-
// // console.error(`Error loading command from ${file}:`, error);
|
|
48
|
-
// // }
|
|
49
|
-
// // });
|
|
50
|
-
// CypressRequire('../commands/playVideo.ts').default();
|
|
51
|
-
// } catch (error) {
|
|
52
|
-
// // eslint-disable-next-line no-console
|
|
53
|
-
// console.warn(
|
|
54
|
-
// `Could not load consumer commands. Make sure to call genCommandPaths() in your cypress.config.js: ${error}`,
|
|
55
|
-
// );
|
|
56
|
-
// }
|
|
57
|
-
// };
|
|
58
|
-
// export default init;
|
|
59
|
-
var init = function (CypressRequire, c) {
|
|
60
|
-
c.log('dceky init called!');
|
|
61
|
-
try {
|
|
62
|
-
// const pwd = (process.env.PWD || process.env.CWD);
|
|
63
|
-
var pwd = __dirname;
|
|
64
|
-
c.log('pwd:', pwd);
|
|
65
|
-
var playVideoPath = path_1.default.join(pwd, './../../../cypress/commands/playVideo.ts');
|
|
66
|
-
c.log('playVideoPath:', playVideoPath);
|
|
67
|
-
c.log('About to require playVideo...');
|
|
68
|
-
var playVideoModule = CypressRequire(playVideoPath);
|
|
69
|
-
c.log('playVideo module:', playVideoModule);
|
|
70
|
-
playVideoModule.default();
|
|
71
|
-
c.log('playVideo.default() called successfully');
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
c.log('Error in dceky init:', error.message);
|
|
75
|
-
c.log("Could not load consumer commands. Make sure to call genCommandPaths() in your cypress.config.js: ".concat(error));
|
|
76
|
-
}
|
|
6
|
+
// Import all commands
|
|
7
|
+
var assertDoesNotHaveClass_1 = __importDefault(require("./commands/assertDoesNotHaveClass"));
|
|
8
|
+
var assertHasClass_1 = __importDefault(require("./commands/assertHasClass"));
|
|
9
|
+
var assertNumElements_1 = __importDefault(require("./commands/assertNumElements"));
|
|
10
|
+
var extractDataFromClass_1 = __importDefault(require("./commands/extractDataFromClass"));
|
|
11
|
+
var extractDataFromClassByContents_1 = __importDefault(require("./commands/extractDataFromClassByContents"));
|
|
12
|
+
var getJSON_1 = __importDefault(require("./commands/getJSON"));
|
|
13
|
+
var getNumElements_1 = __importDefault(require("./commands/getNumElements"));
|
|
14
|
+
var handleHarvardKey_1 = __importDefault(require("./commands/handleHarvardKey"));
|
|
15
|
+
var launchAs_1 = __importDefault(require("./commands/launchAs"));
|
|
16
|
+
var launchLTIUsingToken_1 = __importDefault(require("./commands/launchLTIUsingToken"));
|
|
17
|
+
var navigateToHref_1 = __importDefault(require("./commands/navigateToHref"));
|
|
18
|
+
var runScript_1 = __importDefault(require("./commands/runScript"));
|
|
19
|
+
var typeInto_1 = __importDefault(require("./commands/typeInto"));
|
|
20
|
+
var visitCanvasGETEndpoint_1 = __importDefault(require("./commands/visitCanvasGETEndpoint"));
|
|
21
|
+
var waitForElementVisible_1 = __importDefault(require("./commands/waitForElementVisible"));
|
|
22
|
+
/**
|
|
23
|
+
* Initialize custom commands
|
|
24
|
+
* @author Gabe Abrams
|
|
25
|
+
*/
|
|
26
|
+
var init = function () {
|
|
27
|
+
// Execute each command adder
|
|
28
|
+
(0, assertDoesNotHaveClass_1.default)();
|
|
29
|
+
(0, assertHasClass_1.default)();
|
|
30
|
+
(0, assertNumElements_1.default)();
|
|
31
|
+
(0, getNumElements_1.default)();
|
|
32
|
+
(0, handleHarvardKey_1.default)();
|
|
33
|
+
(0, launchAs_1.default)();
|
|
34
|
+
(0, launchLTIUsingToken_1.default)();
|
|
35
|
+
(0, navigateToHref_1.default)();
|
|
36
|
+
(0, runScript_1.default)();
|
|
37
|
+
(0, typeInto_1.default)();
|
|
38
|
+
(0, visitCanvasGETEndpoint_1.default)();
|
|
39
|
+
(0, waitForElementVisible_1.default)();
|
|
40
|
+
(0, extractDataFromClass_1.default)();
|
|
41
|
+
(0, extractDataFromClassByContents_1.default)();
|
|
42
|
+
(0, getJSON_1.default)();
|
|
77
43
|
};
|
|
78
44
|
exports.default = init;
|
|
79
45
|
//# sourceMappingURL=init.js.map
|
package/lib/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;AAAA,sBAAsB;AACtB,6FAAuE;AACvE,6EAAuD;AACvD,mFAA6D;AAC7D,yFAAmE;AACnE,6GAAuF;AACvF,+DAAyC;AACzC,6EAAuD;AACvD,iFAA2D;AAC3D,iEAA2C;AAC3C,uFAAiE;AACjE,6EAAuD;AACvD,mEAA6C;AAC7C,iEAA2C;AAC3C,6FAAuE;AACvE,2FAAqE;AAErE;;;GAGG;AACH,IAAM,IAAI,GAAG;IACX,6BAA6B;IAC7B,IAAA,gCAAsB,GAAE,CAAC;IACzB,IAAA,wBAAc,GAAE,CAAC;IACjB,IAAA,2BAAiB,GAAE,CAAC;IACpB,IAAA,wBAAc,GAAE,CAAC;IACjB,IAAA,0BAAgB,GAAE,CAAC;IACnB,IAAA,kBAAQ,GAAE,CAAC;IACX,IAAA,6BAAmB,GAAE,CAAC;IACtB,IAAA,wBAAc,GAAE,CAAC;IACjB,IAAA,mBAAS,GAAE,CAAC;IACZ,IAAA,kBAAQ,GAAE,CAAC;IACX,IAAA,gCAAsB,GAAE,CAAC;IACzB,IAAA,+BAAqB,GAAE,CAAC;IACxB,IAAA,8BAAoB,GAAE,CAAC;IACvB,IAAA,wCAA8B,GAAE,CAAC;IACjC,IAAA,iBAAO,GAAE,CAAC;AACZ,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
/*----------------------------------------*/
|
|
4
|
+
/* ---------------- Type ---------------- */
|
|
5
|
+
/*----------------------------------------*/
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
namespace Cypress {
|
|
9
|
+
interface Chainable {
|
|
10
|
+
/**
|
|
11
|
+
* Obtain data from a class attribute that starts with a specific prefix
|
|
12
|
+
* and return it
|
|
13
|
+
* @author Allison Zhang
|
|
14
|
+
* @param selector the css selector for finding the element
|
|
15
|
+
* @param classPrefix the prefix to look for in the class attribute
|
|
16
|
+
* @returns the extracted data
|
|
17
|
+
* @example cy.extractDataFromClass('.item', 'data-').then((data) => { ... })
|
|
18
|
+
*/
|
|
19
|
+
extractDataFromClass(
|
|
20
|
+
selector: string,
|
|
21
|
+
classPrefix: string,
|
|
22
|
+
): Chainable<string[]>;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/*----------------------------------------*/
|
|
28
|
+
/* --------------- Command -------------- */
|
|
29
|
+
/*----------------------------------------*/
|
|
30
|
+
|
|
31
|
+
const extractDataFromClass = () => {
|
|
32
|
+
Cypress.Commands.add('extractDataFromClass', (selector: string, classPrefix: string) => {
|
|
33
|
+
return (
|
|
34
|
+
cy
|
|
35
|
+
.get(selector)
|
|
36
|
+
.invoke('attr', 'class')
|
|
37
|
+
.then((classAttr: string) => {
|
|
38
|
+
const classList = classAttr.split(' ');
|
|
39
|
+
const data = classList
|
|
40
|
+
.filter((className) => { return className.startsWith(classPrefix); })
|
|
41
|
+
.map((className) => { return className.replace(classPrefix, ''); });
|
|
42
|
+
return data;
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/*----------------------------------------*/
|
|
49
|
+
/* --------------- Export --------------- */
|
|
50
|
+
/*----------------------------------------*/
|
|
51
|
+
|
|
52
|
+
export default extractDataFromClass;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
/*----------------------------------------*/
|
|
4
|
+
/* ---------------- Type ---------------- */
|
|
5
|
+
/*----------------------------------------*/
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
namespace Cypress {
|
|
9
|
+
interface Chainable {
|
|
10
|
+
/**
|
|
11
|
+
* Obtain data from a class attribute that starts with a specific prefix
|
|
12
|
+
* and with specific contents, and return it
|
|
13
|
+
* @author Allison Zhang
|
|
14
|
+
* @param contents the contents of the element to find
|
|
15
|
+
* @param selector the css selector for finding the element
|
|
16
|
+
* @param classPrefix the prefix to look for in the class attribute
|
|
17
|
+
* @returns the extracted data
|
|
18
|
+
* @example cy.extractDataFromClassByContents('Submit', '.button', 'btn-').then((data) => { ... })
|
|
19
|
+
*/
|
|
20
|
+
extractDataFromClassByContents(
|
|
21
|
+
contents: string,
|
|
22
|
+
selector: string,
|
|
23
|
+
classPrefix: string,
|
|
24
|
+
): Chainable<string[]>;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*----------------------------------------*/
|
|
30
|
+
/* --------------- Command -------------- */
|
|
31
|
+
/*----------------------------------------*/
|
|
32
|
+
|
|
33
|
+
const extractDataFromClassByContents = () => {
|
|
34
|
+
Cypress.Commands.add('extractDataFromClassByContents', (contents: string, selector: string, classPrefix: string) => {
|
|
35
|
+
return (
|
|
36
|
+
cy
|
|
37
|
+
.get(selector)
|
|
38
|
+
.contains(contents)
|
|
39
|
+
.invoke('attr', 'class')
|
|
40
|
+
.then((classAttr: string) => {
|
|
41
|
+
const classList = classAttr.split(' ');
|
|
42
|
+
const data = classList
|
|
43
|
+
.filter((className) => { return className.startsWith(classPrefix); })
|
|
44
|
+
.map((className) => { return className.replace(classPrefix, ''); });
|
|
45
|
+
return data;
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/*----------------------------------------*/
|
|
52
|
+
/* --------------- Export --------------- */
|
|
53
|
+
/*----------------------------------------*/
|
|
54
|
+
|
|
55
|
+
export default extractDataFromClassByContents;
|
|
@@ -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
|
+
* Obtain JSON data from a request and return it.
|
|
12
|
+
* @author Allison Zhang
|
|
13
|
+
* @param url the URL to fetch the JSON data from
|
|
14
|
+
* @returns the JSON data
|
|
15
|
+
* @example cy.getJSON('https://api.example.com/data').then((data) => { ... })
|
|
16
|
+
*/
|
|
17
|
+
getJSON(
|
|
18
|
+
url: string,
|
|
19
|
+
): Chainable<any>;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/*----------------------------------------*/
|
|
25
|
+
/* --------------- Command -------------- */
|
|
26
|
+
/*----------------------------------------*/
|
|
27
|
+
|
|
28
|
+
const getJSON = () => {
|
|
29
|
+
Cypress.Commands.add('getJSON', (url: string) => {
|
|
30
|
+
return (
|
|
31
|
+
cy
|
|
32
|
+
.request(url)
|
|
33
|
+
.then((response) => {
|
|
34
|
+
return response.body;
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/*----------------------------------------*/
|
|
41
|
+
/* --------------- Export --------------- */
|
|
42
|
+
/*----------------------------------------*/
|
|
43
|
+
|
|
44
|
+
export default getJSON;
|
|
@@ -10,7 +10,7 @@ declare global {
|
|
|
10
10
|
/**
|
|
11
11
|
* Get number of elements
|
|
12
12
|
* @author Yuen Ler Chow
|
|
13
|
-
* @param selector a CSS selector corresponding to the item
|
|
13
|
+
* @param selector a CSS selector corresponding to the item to count
|
|
14
14
|
* @return Cypress chainable containing the number of elements matching the selector
|
|
15
15
|
*/
|
|
16
16
|
getNumElements(
|
|
@@ -10,16 +10,11 @@ declare global {
|
|
|
10
10
|
/**
|
|
11
11
|
* Handle a HarvardKey login page for a user
|
|
12
12
|
* @author Yuen Ler Chow
|
|
13
|
-
* @param
|
|
14
|
-
* @param opts.url the URL to visit for HarvardKey authentication
|
|
15
|
-
* @param opts.name the name of the user environment variable
|
|
13
|
+
* @param name the name of the user environment variable
|
|
16
14
|
* @return Cypress chainable (void) - performs authentication flow, no return value
|
|
17
15
|
*/
|
|
18
16
|
handleHarvardKey(
|
|
19
|
-
|
|
20
|
-
url: string,
|
|
21
|
-
name: string,
|
|
22
|
-
}
|
|
17
|
+
name: string,
|
|
23
18
|
): Chainable<void>;
|
|
24
19
|
}
|
|
25
20
|
}
|
|
@@ -33,12 +28,8 @@ const handleHarvardKey = () => {
|
|
|
33
28
|
Cypress.Commands.add(
|
|
34
29
|
'handleHarvardKey',
|
|
35
30
|
(
|
|
36
|
-
|
|
37
|
-
url: string,
|
|
38
|
-
name: string,
|
|
39
|
-
},
|
|
31
|
+
name: string,
|
|
40
32
|
) => {
|
|
41
|
-
const { url, name } = opts;
|
|
42
33
|
cy.log('Handling HarvardKey authentication');
|
|
43
34
|
|
|
44
35
|
const userInfo = Cypress.env(name);
|
|
@@ -50,8 +41,6 @@ const handleHarvardKey = () => {
|
|
|
50
41
|
const { username } = userInfo;
|
|
51
42
|
const { password } = userInfo;
|
|
52
43
|
|
|
53
|
-
cy.visit(url);
|
|
54
|
-
|
|
55
44
|
// Get the Harvard login URL using originWithKaixa with auto-initialized functions
|
|
56
45
|
cy.origin('https://apps.cirrusidentity.com', () => {
|
|
57
46
|
Cypress.require('dceky');
|
|
@@ -30,9 +30,10 @@ const navigateToHref = () => {
|
|
|
30
30
|
) => {
|
|
31
31
|
cy.waitForElementVisible(item);
|
|
32
32
|
|
|
33
|
-
// get
|
|
34
|
-
const
|
|
35
|
-
|
|
33
|
+
// get origin (protocol + '//' + host) from current URL
|
|
34
|
+
const origin = cy.url().then((url: string) => {
|
|
35
|
+
const { protocol, host } = new URL(url);
|
|
36
|
+
return `${protocol}//${host}`;
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
return cy
|
|
@@ -41,7 +42,7 @@ const navigateToHref = () => {
|
|
|
41
42
|
.then((href: string) => {
|
|
42
43
|
// If the href is a relative URL, prepend the hostname
|
|
43
44
|
if (href.startsWith('/')) {
|
|
44
|
-
return
|
|
45
|
+
return origin + href;
|
|
45
46
|
}
|
|
46
47
|
return href;
|
|
47
48
|
});
|
|
@@ -10,9 +10,7 @@ declare global {
|
|
|
10
10
|
/**
|
|
11
11
|
* Run a script on the page
|
|
12
12
|
* @author Yuen Ler Chow
|
|
13
|
-
* @param
|
|
14
|
-
* If multiple script arguments are included, each argument will be considered a
|
|
15
|
-
* new line of the script.
|
|
13
|
+
* @param script the script to run
|
|
16
14
|
* @return Cypress chainable containing the return value from executing the script
|
|
17
15
|
*/
|
|
18
16
|
runScript(scriptLines: string): Chainable<any>;
|
|
@@ -28,12 +26,11 @@ const runScript = () => {
|
|
|
28
26
|
Cypress.Commands.add(
|
|
29
27
|
'runScript',
|
|
30
28
|
(
|
|
31
|
-
|
|
29
|
+
script: string,
|
|
32
30
|
) => {
|
|
33
31
|
cy.log('Running script');
|
|
34
|
-
const fullScript = scriptLines;
|
|
35
32
|
return cy.window().then((win) => {
|
|
36
|
-
const result = win.eval(
|
|
33
|
+
const result = win.eval(script);
|
|
37
34
|
return cy.wrap(result);
|
|
38
35
|
});
|
|
39
36
|
},
|
package/src/commands/typeInto.ts
CHANGED
|
@@ -47,10 +47,13 @@ const typeInto = () => {
|
|
|
47
47
|
const {
|
|
48
48
|
item, text, pressEnter, append,
|
|
49
49
|
} = opts;
|
|
50
|
-
cy.log(`Type "${text}" into ${item}`);
|
|
51
|
-
|
|
52
50
|
// Check if the text contains an enter key press
|
|
53
51
|
const enterAtEndOfText = text.charAt(text.length - 1) === '\n';
|
|
52
|
+
const willPressEnter = pressEnter || enterAtEndOfText;
|
|
53
|
+
|
|
54
|
+
const action = append ? 'Append' : 'Type';
|
|
55
|
+
const enterSuffix = willPressEnter ? ' and then press enter' : '';
|
|
56
|
+
cy.log(`${action} "${text}" into ${item}${enterSuffix}`);
|
|
54
57
|
|
|
55
58
|
// Type the text without a trailing enter if there was one
|
|
56
59
|
const textWithoutTrailingEnter = (
|
|
@@ -71,7 +74,7 @@ const typeInto = () => {
|
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
// Press enter if explicitly requested or if text ended with newline
|
|
74
|
-
if (
|
|
77
|
+
if (willPressEnter) {
|
|
75
78
|
cy.get(item).type('{enter}');
|
|
76
79
|
}
|
|
77
80
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// Import helpers
|
|
2
2
|
import init from './init';
|
|
3
3
|
import genConfiguration from './genConfiguration';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
// Automatically initialize upon importing the library
|
|
6
|
+
init();
|
|
5
7
|
|
|
6
8
|
// Export key functions
|
|
7
9
|
export {
|
|
8
10
|
genConfiguration,
|
|
9
|
-
genCommandPaths,
|
|
10
11
|
init,
|
|
11
12
|
};
|
package/src/init.ts
CHANGED
|
@@ -1,83 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// // const commandPaths: string[] = CypressRequire('cypress/commands/.dceky-paths.js');
|
|
40
|
-
|
|
41
|
-
// // cy.log('commandPaths', commandPaths);
|
|
42
|
-
|
|
43
|
-
// // commandPaths.forEach((file) => {
|
|
44
|
-
// // try {
|
|
45
|
-
// // CypressRequire(`cypress/commands/${file}`);
|
|
46
|
-
// // } catch (error) {
|
|
47
|
-
// // // eslint-disable-next-line no-console
|
|
48
|
-
// // console.error(`Error loading command from ${file}:`, error);
|
|
49
|
-
// // }
|
|
50
|
-
// // });
|
|
51
|
-
// CypressRequire('../commands/playVideo.ts').default();
|
|
52
|
-
// } catch (error) {
|
|
53
|
-
// // eslint-disable-next-line no-console
|
|
54
|
-
// console.warn(
|
|
55
|
-
// `Could not load consumer commands. Make sure to call genCommandPaths() in your cypress.config.js: ${error}`,
|
|
56
|
-
// );
|
|
57
|
-
// }
|
|
58
|
-
// };
|
|
59
|
-
|
|
60
|
-
// export default init;
|
|
61
|
-
|
|
62
|
-
const init = (CypressRequire: <T = any>(id: string) => T, c: any) => {
|
|
63
|
-
c.log('dceky init called!');
|
|
64
|
-
try {
|
|
65
|
-
// const pwd = (process.env.PWD || process.env.CWD);
|
|
66
|
-
const pwd = __dirname;
|
|
67
|
-
c.log('pwd:', pwd);
|
|
68
|
-
const playVideoPath = path.join(pwd, './../../../cypress/commands/playVideo.ts');
|
|
69
|
-
c.log('playVideoPath:', playVideoPath);
|
|
70
|
-
c.log('About to require playVideo...');
|
|
71
|
-
const playVideoModule = CypressRequire(playVideoPath);
|
|
72
|
-
c.log('playVideo module:', playVideoModule);
|
|
73
|
-
playVideoModule.default();
|
|
74
|
-
c.log('playVideo.default() called successfully');
|
|
75
|
-
} catch (error) {
|
|
76
|
-
c.log('Error in dceky init:', error.message);
|
|
77
|
-
c.log(
|
|
78
|
-
`Could not load consumer commands. Make sure to call genCommandPaths() in your cypress.config.js: ${error}`,
|
|
79
|
-
);
|
|
80
|
-
}
|
|
1
|
+
// Import all commands
|
|
2
|
+
import assertDoesNotHaveClass from './commands/assertDoesNotHaveClass';
|
|
3
|
+
import assertHasClass from './commands/assertHasClass';
|
|
4
|
+
import assertNumElements from './commands/assertNumElements';
|
|
5
|
+
import extractDataFromClass from './commands/extractDataFromClass';
|
|
6
|
+
import extractDataFromClassByContents from './commands/extractDataFromClassByContents';
|
|
7
|
+
import getJSON from './commands/getJSON';
|
|
8
|
+
import getNumElements from './commands/getNumElements';
|
|
9
|
+
import handleHarvardKey from './commands/handleHarvardKey';
|
|
10
|
+
import launchAs from './commands/launchAs';
|
|
11
|
+
import launchLTIUsingToken from './commands/launchLTIUsingToken';
|
|
12
|
+
import navigateToHref from './commands/navigateToHref';
|
|
13
|
+
import runScript from './commands/runScript';
|
|
14
|
+
import typeInto from './commands/typeInto';
|
|
15
|
+
import visitCanvasGETEndpoint from './commands/visitCanvasGETEndpoint';
|
|
16
|
+
import waitForElementVisible from './commands/waitForElementVisible';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Initialize custom commands
|
|
20
|
+
* @author Gabe Abrams
|
|
21
|
+
*/
|
|
22
|
+
const init = () => {
|
|
23
|
+
// Execute each command adder
|
|
24
|
+
assertDoesNotHaveClass();
|
|
25
|
+
assertHasClass();
|
|
26
|
+
assertNumElements();
|
|
27
|
+
getNumElements();
|
|
28
|
+
handleHarvardKey();
|
|
29
|
+
launchAs();
|
|
30
|
+
launchLTIUsingToken();
|
|
31
|
+
navigateToHref();
|
|
32
|
+
runScript();
|
|
33
|
+
typeInto();
|
|
34
|
+
visitCanvasGETEndpoint();
|
|
35
|
+
waitForElementVisible();
|
|
36
|
+
extractDataFromClass();
|
|
37
|
+
extractDataFromClassByContents();
|
|
38
|
+
getJSON();
|
|
81
39
|
};
|
|
82
40
|
|
|
83
41
|
export default init;
|
package/lib/genCommandPaths.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate an index.ts file that imports and runs all command files in cypress/commands
|
|
3
|
-
* This should be called from cypress.config.js (Node.js context)
|
|
4
|
-
* @returns The path to the generated file
|
|
5
|
-
* @author Yuen Ler Chow
|
|
6
|
-
*/
|
|
7
|
-
declare const genCommandPaths: () => string;
|
|
8
|
-
export default genCommandPaths;
|
package/lib/genCommandPaths.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
var fs = __importStar(require("fs"));
|
|
37
|
-
var path = __importStar(require("path"));
|
|
38
|
-
/**
|
|
39
|
-
* Generate an index.ts file that imports and runs all command files in cypress/commands
|
|
40
|
-
* This should be called from cypress.config.js (Node.js context)
|
|
41
|
-
* @returns The path to the generated file
|
|
42
|
-
* @author Yuen Ler Chow
|
|
43
|
-
*/
|
|
44
|
-
var genCommandPaths = function () {
|
|
45
|
-
var root = process.cwd();
|
|
46
|
-
var cypressCommandsDir = path.resolve(root, 'cypress/commands');
|
|
47
|
-
var outputFile = path.resolve(cypressCommandsDir, 'index.ts');
|
|
48
|
-
// Check if the directory exists
|
|
49
|
-
if (!fs.existsSync(cypressCommandsDir)) {
|
|
50
|
-
// eslint-disable-next-line no-console
|
|
51
|
-
console.warn("Cypress commands directory not found at: ".concat(cypressCommandsDir));
|
|
52
|
-
// Create an empty file so init doesn't fail
|
|
53
|
-
fs.writeFileSync(outputFile, '// Auto-generated by dceky - do not edit manually\n');
|
|
54
|
-
return outputFile;
|
|
55
|
-
}
|
|
56
|
-
// Get all files in the directory
|
|
57
|
-
var files = fs.readdirSync(cypressCommandsDir);
|
|
58
|
-
var commandFiles = [];
|
|
59
|
-
// Filter out non-JS/TS files and process each file
|
|
60
|
-
files.forEach(function (file) {
|
|
61
|
-
// Skip non-JS/TS files (like .d.ts, .map, etc.)
|
|
62
|
-
if (!file.endsWith('.js') && !file.endsWith('.ts')) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
// Skip index files
|
|
66
|
-
if (file === 'index.js' || file === 'index.ts') {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
var filePath = path.join(cypressCommandsDir, file);
|
|
70
|
-
// Check if it's a file (not a directory)
|
|
71
|
-
var stats = fs.statSync(filePath);
|
|
72
|
-
if (!stats.isFile()) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
// Store the file name
|
|
76
|
-
commandFiles.push(file);
|
|
77
|
-
});
|
|
78
|
-
// Generate require statements and function calls
|
|
79
|
-
var requires = [];
|
|
80
|
-
var calls = [];
|
|
81
|
-
commandFiles.forEach(function (file) {
|
|
82
|
-
var requirePath = "./".concat(file);
|
|
83
|
-
// Create a safe variable name (replace non-alphanumeric with underscore)
|
|
84
|
-
var importName = file.replace(/\.(js|ts)$/, '');
|
|
85
|
-
var varName = importName.replace(/[^a-zA-Z0-9]/g, '_');
|
|
86
|
-
requires.push("const ".concat(varName, " = require('").concat(requirePath, "');"));
|
|
87
|
-
calls.push("".concat(varName, ".default();"));
|
|
88
|
-
});
|
|
89
|
-
var content = "// Auto-generated by dceky - do not edit manually\n".concat(requires.join('\n'), "\n\n").concat(calls.join('\n'), "\n");
|
|
90
|
-
fs.writeFileSync(outputFile, content);
|
|
91
|
-
// eslint-disable-next-line no-console
|
|
92
|
-
console.log("Generated command index file: ".concat(outputFile, " (").concat(commandFiles.length, " commands)"));
|
|
93
|
-
return outputFile;
|
|
94
|
-
};
|
|
95
|
-
exports.default = genCommandPaths;
|
|
96
|
-
//# sourceMappingURL=genCommandPaths.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"genCommandPaths.js","sourceRoot":"","sources":["../src/genCommandPaths.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAE7B;;;;;GAKG;AACH,IAAM,eAAe,GAAG;IACtB,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IAClE,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;IAEhE,gCAAgC;IAChC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACvC,sCAAsC;QACtC,OAAO,CAAC,IAAI,CAAC,mDAA4C,kBAAkB,CAAE,CAAC,CAAC;QAC/E,4CAA4C;QAC5C,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,qDAAqD,CAAC,CAAC;QACpF,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,iCAAiC;IACjC,IAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IACjD,IAAM,YAAY,GAAa,EAAE,CAAC;IAElC,mDAAmD;IACnD,KAAK,CAAC,OAAO,CAAC,UAAC,IAAI;QACjB,gDAAgD;QAChD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACnD,OAAO;QACT,CAAC;QAED,mBAAmB;QACnB,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;YAC/C,OAAO;QACT,CAAC;QAED,IAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QAErD,yCAAyC;QACzC,IAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QAED,sBAAsB;QACtB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,iDAAiD;IACjD,IAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,YAAY,CAAC,OAAO,CAAC,UAAC,IAAI;QACxB,IAAM,WAAW,GAAG,YAAK,IAAI,CAAE,CAAC;QAChC,yEAAyE;QACzE,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAClD,IAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;QAEzD,QAAQ,CAAC,IAAI,CAAC,gBAAS,OAAO,yBAAe,WAAW,QAAK,CAAC,CAAC;QAC/D,KAAK,CAAC,IAAI,CAAC,UAAG,OAAO,gBAAa,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,IAAM,OAAO,GAAG,6DAChB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,iBAEnB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OACjB,CAAC;IAEA,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAEtC,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,wCAAiC,UAAU,eAAK,YAAY,CAAC,MAAM,eAAY,CAAC,CAAC;IAE7F,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
package/src/genCommandPaths.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Generate an index.ts file that imports and runs all command files in cypress/commands
|
|
6
|
-
* This should be called from cypress.config.js (Node.js context)
|
|
7
|
-
* @returns The path to the generated file
|
|
8
|
-
* @author Yuen Ler Chow
|
|
9
|
-
*/
|
|
10
|
-
const genCommandPaths = (): string => {
|
|
11
|
-
const root = process.cwd();
|
|
12
|
-
const cypressCommandsDir = path.resolve(root, 'cypress/commands');
|
|
13
|
-
const outputFile = path.resolve(cypressCommandsDir, 'index.ts');
|
|
14
|
-
|
|
15
|
-
// Check if the directory exists
|
|
16
|
-
if (!fs.existsSync(cypressCommandsDir)) {
|
|
17
|
-
// eslint-disable-next-line no-console
|
|
18
|
-
console.warn(`Cypress commands directory not found at: ${cypressCommandsDir}`);
|
|
19
|
-
// Create an empty file so init doesn't fail
|
|
20
|
-
fs.writeFileSync(outputFile, '// Auto-generated by dceky - do not edit manually\n');
|
|
21
|
-
return outputFile;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Get all files in the directory
|
|
25
|
-
const files = fs.readdirSync(cypressCommandsDir);
|
|
26
|
-
const commandFiles: string[] = [];
|
|
27
|
-
|
|
28
|
-
// Filter out non-JS/TS files and process each file
|
|
29
|
-
files.forEach((file) => {
|
|
30
|
-
// Skip non-JS/TS files (like .d.ts, .map, etc.)
|
|
31
|
-
if (!file.endsWith('.js') && !file.endsWith('.ts')) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Skip index files
|
|
36
|
-
if (file === 'index.js' || file === 'index.ts') {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const filePath = path.join(cypressCommandsDir, file);
|
|
41
|
-
|
|
42
|
-
// Check if it's a file (not a directory)
|
|
43
|
-
const stats = fs.statSync(filePath);
|
|
44
|
-
if (!stats.isFile()) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Store the file name
|
|
49
|
-
commandFiles.push(file);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Generate require statements and function calls
|
|
53
|
-
const requires: string[] = [];
|
|
54
|
-
const calls: string[] = [];
|
|
55
|
-
|
|
56
|
-
commandFiles.forEach((file) => {
|
|
57
|
-
const requirePath = `./${file}`;
|
|
58
|
-
// Create a safe variable name (replace non-alphanumeric with underscore)
|
|
59
|
-
const importName = file.replace(/\.(js|ts)$/, '');
|
|
60
|
-
const varName = importName.replace(/[^a-zA-Z0-9]/g, '_');
|
|
61
|
-
|
|
62
|
-
requires.push(`const ${varName} = require('${requirePath}');`);
|
|
63
|
-
calls.push(`${varName}.default();`);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const content = `// Auto-generated by dceky - do not edit manually
|
|
67
|
-
${requires.join('\n')}
|
|
68
|
-
|
|
69
|
-
${calls.join('\n')}
|
|
70
|
-
`;
|
|
71
|
-
|
|
72
|
-
fs.writeFileSync(outputFile, content);
|
|
73
|
-
|
|
74
|
-
// eslint-disable-next-line no-console
|
|
75
|
-
console.log(`Generated command index file: ${outputFile} (${commandFiles.length} commands)`);
|
|
76
|
-
|
|
77
|
-
return outputFile;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export default genCommandPaths;
|