dceky 1.0.0-beta-auto-import.2 → 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.
Files changed (44) hide show
  1. package/lib/commands/assertNumElements.d.ts +0 -1
  2. package/lib/commands/assertNumElements.js.map +1 -1
  3. package/lib/commands/extractDataFromClass.d.ts +18 -0
  4. package/lib/commands/extractDataFromClass.js +25 -0
  5. package/lib/commands/extractDataFromClass.js.map +1 -0
  6. package/lib/commands/extractDataFromClassByContents.d.ts +19 -0
  7. package/lib/commands/extractDataFromClassByContents.js +26 -0
  8. package/lib/commands/extractDataFromClassByContents.js.map +1 -0
  9. package/lib/commands/getJSON.d.ts +16 -0
  10. package/lib/commands/getJSON.js +20 -0
  11. package/lib/commands/getJSON.js.map +1 -0
  12. package/lib/commands/getNumElements.d.ts +1 -1
  13. package/lib/commands/handleHarvardKey.d.ts +2 -7
  14. package/lib/commands/handleHarvardKey.js +1 -3
  15. package/lib/commands/handleHarvardKey.js.map +1 -1
  16. package/lib/commands/navigateToHref.js +5 -4
  17. package/lib/commands/navigateToHref.js.map +1 -1
  18. package/lib/commands/runScript.d.ts +1 -3
  19. package/lib/commands/runScript.js +2 -3
  20. package/lib/commands/runScript.js.map +1 -1
  21. package/lib/commands/typeInto.js +5 -2
  22. package/lib/commands/typeInto.js.map +1 -1
  23. package/lib/index.d.ts +1 -2
  24. package/lib/index.js +3 -3
  25. package/lib/index.js.map +1 -1
  26. package/lib/init.d.ts +5 -1
  27. package/lib/init.js +37 -71
  28. package/lib/init.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/commands/assertNumElements.ts +0 -1
  31. package/src/commands/extractDataFromClass.ts +52 -0
  32. package/src/commands/extractDataFromClassByContents.ts +55 -0
  33. package/src/commands/getJSON.ts +44 -0
  34. package/src/commands/getNumElements.ts +1 -1
  35. package/src/commands/handleHarvardKey.ts +3 -14
  36. package/src/commands/navigateToHref.ts +5 -4
  37. package/src/commands/runScript.ts +3 -6
  38. package/src/commands/typeInto.ts +6 -3
  39. package/src/index.ts +3 -2
  40. package/src/init.ts +38 -80
  41. package/lib/genCommandPaths.d.ts +0 -9
  42. package/lib/genCommandPaths.js +0 -86
  43. package/lib/genCommandPaths.js.map +0 -1
  44. package/src/genCommandPaths.ts +0 -65
@@ -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;;AA2BjC,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"}
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 opts object containing all arguments
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(opts: {
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 (opts) {
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;;AA2BjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,gBAAgB,GAAG;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,kBAAkB,EAClB,UACE,IAGC;QAEO,IAAA,GAAG,GAAW,IAAI,IAAf,EAAE,IAAI,GAAK,IAAI,KAAT,CAAU;QAC3B,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,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEd,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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AAC;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 hostname from current URL
11
- var hostname = cy.url().then(function (url) {
12
- return new URL(url).hostname;
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 hostname + href;
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,gBA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AAG,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 scriptLines the script to run in an anonymous function on the page.
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 (scriptLines) {
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(fullScript);
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;;AAsBjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,SAAS,GAAG;IAChB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,WAAW,EACX,UACE,WAAmB;QAEnB,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QACzB,IAAM,UAAU,GAAG,WAAW,CAAC;QAC/B,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,UAAC,GAAG;YAC1B,IAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACpC,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"}
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"}
@@ -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 (pressEnter || enterAtEndOfText) {
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,EAAE,CAAC,GAAG,CAAC,iBAAS,IAAI,qBAAU,IAAI,CAAE,CAAC,CAAC;QAEtC,gDAAgD;QAChD,IAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;QAE/D,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,wBA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C1D,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
@@ -1,4 +1,3 @@
1
1
  import init from './init';
2
2
  import genConfiguration from './genConfiguration';
3
- import genCommandPaths from './genCommandPaths';
4
- export { genConfiguration, genCommandPaths, init, };
3
+ export { genConfiguration, init, };
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.genCommandPaths = exports.genConfiguration = void 0;
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
- var genCommandPaths_1 = __importDefault(require("./genCommandPaths"));
13
- exports.genCommandPaths = genCommandPaths_1.default;
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;AAQxB,eARK,cAAI,CAQL;AAPN,wEAAkD;AAKhD,2BALK,0BAAgB,CAKL;AAJlB,sEAAgD;AAK9C,0BALK,yBAAe,CAKL"}
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
@@ -1,2 +1,6 @@
1
- declare const init: (CypressRequire: <T = any>(id: string) => T, c: any) => void;
1
+ /**
2
+ * Initialize custom commands
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const init: () => void;
2
6
  export default init;
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
- var path_1 = __importDefault(require("path"));
7
- // // Import all commands
8
- // import assertDoesNotHaveClass from './commands/assertDoesNotHaveClass';
9
- // import assertHasClass from './commands/assertHasClass';
10
- // import assertNumElements from './commands/assertNumElements';
11
- // import getNumElements from './commands/getNumElements';
12
- // import handleHarvardKey from './commands/handleHarvardKey';
13
- // import launchAs from './commands/launchAs';
14
- // import launchLTIUsingToken from './commands/launchLTIUsingToken';
15
- // import navigateToHref from './commands/navigateToHref';
16
- // import runScript from './commands/runScript';
17
- // import typeInto from './commands/typeInto';
18
- // import visitCanvasGETEndpoint from './commands/visitCanvasGETEndpoint';
19
- // import waitForElementVisible from './commands/waitForElementVisible';
20
- // /**
21
- // * Initialize custom commands
22
- // * @author Gabe Abrams
23
- // */
24
- // const init = (CypressRequire: <T = any>(id: string) => T) => {
25
- // // Execute each built-in command adder
26
- // assertDoesNotHaveClass();
27
- // assertHasClass();
28
- // assertNumElements();
29
- // getNumElements();
30
- // handleHarvardKey();
31
- // launchAs();
32
- // launchLTIUsingToken();
33
- // navigateToHref();
34
- // runScript();
35
- // typeInto();
36
- // visitCanvasGETEndpoint();
37
- // waitForElementVisible();
38
- // /* --------------- Run Cypress.Require on consumer's commands --------------- */
39
- // try {
40
- // // const commandPaths: string[] = CypressRequire('cypress/commands/.dceky-paths.js');
41
- // // cy.log('commandPaths', commandPaths);
42
- // // commandPaths.forEach((file) => {
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","sour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,CAAC;IACjC,IAAA,iBAAO,GAAE,CAAC;AACZ,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dceky",
3
- "version": "1.0.0-beta-auto-import.2",
3
+ "version": "1.0.0-beta-yuenler.3",
4
4
  "description": "Cypress toolkit for Harvard DCE",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -13,7 +13,6 @@ declare global {
13
13
  * @param opts object containing all arguments
14
14
  * @param opts.item a CSS selector corresponding to the item
15
15
  * @param opts.num the precise number of elements expected
16
- * @return Cypress chainable
17
16
  */
18
17
  assertNumElements(
19
18
  opts: {
@@ -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 opts object containing all arguments
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
- opts: {
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
- opts: {
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 hostname from current URL
34
- const hostname = cy.url().then((url: string) => {
35
- return new URL(url).hostname;
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 hostname + href;
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 scriptLines the script to run in an anonymous function on the page.
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
- scriptLines: string,
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(fullScript);
33
+ const result = win.eval(script);
37
34
  return cy.wrap(result);
38
35
  });
39
36
  },
@@ -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 (pressEnter || enterAtEndOfText) {
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
- import genCommandPaths from './genCommandPaths';
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
- import fs from 'fs';
2
- import path from 'path';
3
- // // Import all commands
4
- // import assertDoesNotHaveClass from './commands/assertDoesNotHaveClass';
5
- // import assertHasClass from './commands/assertHasClass';
6
- // import assertNumElements from './commands/assertNumElements';
7
- // import getNumElements from './commands/getNumElements';
8
- // import handleHarvardKey from './commands/handleHarvardKey';
9
- // import launchAs from './commands/launchAs';
10
- // import launchLTIUsingToken from './commands/launchLTIUsingToken';
11
- // import navigateToHref from './commands/navigateToHref';
12
- // import runScript from './commands/runScript';
13
- // import typeInto from './commands/typeInto';
14
- // import visitCanvasGETEndpoint from './commands/visitCanvasGETEndpoint';
15
- // import waitForElementVisible from './commands/waitForElementVisible';
16
-
17
- // /**
18
- // * Initialize custom commands
19
- // * @author Gabe Abrams
20
- // */
21
- // const init = (CypressRequire: <T = any>(id: string) => T) => {
22
- // // Execute each built-in command adder
23
- // assertDoesNotHaveClass();
24
- // assertHasClass();
25
- // assertNumElements();
26
- // getNumElements();
27
- // handleHarvardKey();
28
- // launchAs();
29
- // launchLTIUsingToken();
30
- // navigateToHref();
31
- // runScript();
32
- // typeInto();
33
- // visitCanvasGETEndpoint();
34
- // waitForElementVisible();
35
-
36
- // /* --------------- Run Cypress.Require on consumer's commands --------------- */
37
-
38
- // try {
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;
@@ -1,9 +0,0 @@
1
- /**
2
- * Generate a file containing paths to all command files in cypress/commands
3
- * This should be called from cypress.config.js (Node.js context)
4
- * @param projectRoot - The root directory of the Cypress project (optional, defaults to process.cwd())
5
- * @returns The path to the generated file
6
- * @author Gabe Abrams
7
- */
8
- declare const genCommandPaths: () => string;
9
- export default genCommandPaths;
@@ -1,86 +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 a file containing paths to all command files in cypress/commands
40
- * This should be called from cypress.config.js (Node.js context)
41
- * @param projectRoot - The root directory of the Cypress project (optional, defaults to process.cwd())
42
- * @returns The path to the generated file
43
- * @author Gabe Abrams
44
- */
45
- var genCommandPaths = function () {
46
- var root = process.cwd();
47
- var cypressCommandsDir = path.resolve(root, 'cypress', 'commands');
48
- var outputFile = path.resolve(cypressCommandsDir, '.dceky-paths.js');
49
- // Check if the directory exists
50
- if (!fs.existsSync(cypressCommandsDir)) {
51
- // eslint-disable-next-line no-console
52
- console.warn("Cypress commands directory not found at: ".concat(cypressCommandsDir));
53
- // Create an empty file so init doesn't fail
54
- fs.writeFileSync(outputFile, 'module.exports = [];\n');
55
- return outputFile;
56
- }
57
- // Get all files in the directory
58
- var files = fs.readdirSync(cypressCommandsDir);
59
- var commandPaths = [];
60
- // Filter out non-JS/TS files and process each file
61
- files.forEach(function (file) {
62
- // Skip non-JS files (like .d.ts, .map, etc.)
63
- if (!file.endsWith('.js') && !file.endsWith('.ts')) {
64
- return;
65
- }
66
- // Skip index files and the generated paths file
67
- if (file === 'index.js' || file === 'index.ts' || file === '.dceky-paths.js') {
68
- return;
69
- }
70
- var filePath = path.join(cypressCommandsDir, file);
71
- // Check if it's a file (not a directory)
72
- var stats = fs.statSync(filePath);
73
- if (!stats.isFile()) {
74
- return;
75
- }
76
- // Store the relative path from cypress/commands
77
- commandPaths.push(file);
78
- });
79
- var content = "// Auto-generated by dceky - do not edit manually\nmodule.exports = ".concat(JSON.stringify(commandPaths, null, 2), ";\n");
80
- fs.writeFileSync(outputFile, content);
81
- // eslint-disable-next-line no-console
82
- console.log("Generated command paths file: ".concat(outputFile, " (").concat(commandPaths.length, " commands)"));
83
- return outputFile;
84
- };
85
- exports.default = genCommandPaths;
86
- //# 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;;;;;;GAMG;AACH,IAAM,eAAe,GAAG;IACtB,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;IACrE,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC;IAEvE,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,wBAAwB,CAAC,CAAC;QACvD,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,6CAA6C;QAC7C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACnD,OAAO;QACT,CAAC;QAED,gDAAgD;QAChD,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC7E,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,gDAAgD;QAChD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,IAAM,OAAO,GAAG,8EACC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,QACvD,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"}
@@ -1,65 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
-
4
- /**
5
- * Generate a file containing paths to all command files in cypress/commands
6
- * This should be called from cypress.config.js (Node.js context)
7
- * @param projectRoot - The root directory of the Cypress project (optional, defaults to process.cwd())
8
- * @returns The path to the generated file
9
- * @author Gabe Abrams
10
- */
11
- const genCommandPaths = (): string => {
12
- const root = process.cwd();
13
- const cypressCommandsDir = path.resolve(root, 'cypress', 'commands');
14
- const outputFile = path.resolve(cypressCommandsDir, '.dceky-paths.js');
15
-
16
- // Check if the directory exists
17
- if (!fs.existsSync(cypressCommandsDir)) {
18
- // eslint-disable-next-line no-console
19
- console.warn(`Cypress commands directory not found at: ${cypressCommandsDir}`);
20
- // Create an empty file so init doesn't fail
21
- fs.writeFileSync(outputFile, 'module.exports = [];\n');
22
- return outputFile;
23
- }
24
-
25
- // Get all files in the directory
26
- const files = fs.readdirSync(cypressCommandsDir);
27
- const commandPaths: string[] = [];
28
-
29
- // Filter out non-JS/TS files and process each file
30
- files.forEach((file) => {
31
- // Skip non-JS files (like .d.ts, .map, etc.)
32
- if (!file.endsWith('.js') && !file.endsWith('.ts')) {
33
- return;
34
- }
35
-
36
- // Skip index files and the generated paths file
37
- if (file === 'index.js' || file === 'index.ts' || file === '.dceky-paths.js') {
38
- return;
39
- }
40
-
41
- const filePath = path.join(cypressCommandsDir, file);
42
-
43
- // Check if it's a file (not a directory)
44
- const stats = fs.statSync(filePath);
45
- if (!stats.isFile()) {
46
- return;
47
- }
48
-
49
- // Store the relative path from cypress/commands
50
- commandPaths.push(file);
51
- });
52
-
53
- const content = `// Auto-generated by dceky - do not edit manually
54
- module.exports = ${JSON.stringify(commandPaths, null, 2)};
55
- `;
56
-
57
- fs.writeFileSync(outputFile, content);
58
-
59
- // eslint-disable-next-line no-console
60
- console.log(`Generated command paths file: ${outputFile} (${commandPaths.length} commands)`);
61
-
62
- return outputFile;
63
- };
64
-
65
- export default genCommandPaths;