dceky 1.0.0-beta-yuenler.1 → 1.0.0-beta-auto-import.1

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 (67) hide show
  1. package/.eslintrc.js +93 -0
  2. package/lib/commands/assertDoesNotHaveClass.d.ts +2 -1
  3. package/lib/commands/assertDoesNotHaveClass.js.map +1 -1
  4. package/lib/commands/assertHasClass.d.ts +2 -1
  5. package/lib/commands/assertHasClass.js.map +1 -1
  6. package/lib/commands/assertNumElements.d.ts +2 -1
  7. package/lib/commands/assertNumElements.js.map +1 -1
  8. package/lib/commands/clickWithRetry.d.ts +8 -4
  9. package/lib/commands/clickWithRetry.js +3 -3
  10. package/lib/commands/clickWithRetry.js.map +1 -1
  11. package/lib/commands/getNumElements.d.ts +4 -4
  12. package/lib/commands/getNumElements.js +1 -1
  13. package/lib/commands/getNumElements.js.map +1 -1
  14. package/lib/commands/handleHarvardKey.d.ts +9 -3
  15. package/lib/commands/handleHarvardKey.js +20 -24
  16. package/lib/commands/handleHarvardKey.js.map +1 -1
  17. package/lib/commands/handleHarvardKey2.d.ts +14 -0
  18. package/lib/commands/handleHarvardKey2.js +88 -0
  19. package/lib/commands/handleHarvardKey2.js.map +1 -0
  20. package/lib/commands/launchAs.d.ts +14 -12
  21. package/lib/commands/launchAs.js +24 -23
  22. package/lib/commands/launchAs.js.map +1 -1
  23. package/lib/commands/launchLTIUsingToken.d.ts +9 -4
  24. package/lib/commands/launchLTIUsingToken.js +25 -14
  25. package/lib/commands/launchLTIUsingToken.js.map +1 -1
  26. package/lib/commands/navigateToHref.d.ts +4 -9
  27. package/lib/commands/navigateToHref.js +10 -3
  28. package/lib/commands/navigateToHref.js.map +1 -1
  29. package/lib/commands/runScript.d.ts +3 -3
  30. package/lib/commands/runScript.js +2 -6
  31. package/lib/commands/runScript.js.map +1 -1
  32. package/lib/commands/typeInto.d.ts +5 -2
  33. package/lib/commands/typeInto.js +14 -4
  34. package/lib/commands/typeInto.js.map +1 -1
  35. package/lib/commands/visitCanvasGETEndpoint.d.ts +2 -2
  36. package/lib/commands/visitCanvasGETEndpoint.js +4 -4
  37. package/lib/commands/visitCanvasGETEndpoint.js.map +1 -1
  38. package/lib/commands/waitForElementVisible.d.ts +3 -2
  39. package/lib/commands/waitForElementVisible.js +1 -2
  40. package/lib/commands/waitForElementVisible.js.map +1 -1
  41. package/lib/genCommandPaths.d.ts +9 -0
  42. package/lib/genCommandPaths.js +86 -0
  43. package/lib/genCommandPaths.js.map +1 -0
  44. package/lib/index.d.ts +2 -1
  45. package/lib/index.js +3 -3
  46. package/lib/index.js.map +1 -1
  47. package/lib/init.d.ts +1 -5
  48. package/lib/init.js +71 -33
  49. package/lib/init.js.map +1 -1
  50. package/package.json +8 -2
  51. package/src/commands/assertDoesNotHaveClass.ts +20 -9
  52. package/src/commands/assertHasClass.ts +20 -9
  53. package/src/commands/assertNumElements.ts +20 -6
  54. package/src/commands/getNumElements.ts +17 -10
  55. package/src/commands/handleHarvardKey.ts +68 -53
  56. package/src/commands/launchAs.ts +79 -63
  57. package/src/commands/launchLTIUsingToken.ts +78 -47
  58. package/src/commands/navigateToHref.ts +28 -17
  59. package/src/commands/runScript.ts +16 -11
  60. package/src/commands/typeInto.ts +54 -26
  61. package/src/commands/visitCanvasGETEndpoint.ts +29 -16
  62. package/src/commands/waitForElementVisible.ts +19 -10
  63. package/src/genCommandPaths.ts +65 -0
  64. package/src/index.ts +2 -3
  65. package/src/init.ts +80 -34
  66. package/.eslintrc.json +0 -58
  67. package/src/commands/clickWithRetry.ts +0 -51
@@ -9,13 +9,11 @@ declare global {
9
9
  interface Chainable {
10
10
  /**
11
11
  * Navigate to href attribute of Harvard identity provider button
12
- * @param opts object containing all arguments
13
- * @param opts.item the CSS selector of interest
14
- * @param opts.domain the domain of the page
15
- * @returns The full URL constructed from the href
16
- * @example cy.navigateToHref({ item: '#login-button', domain: 'https://example.com' })
12
+ * @author Yuen Ler Chow
13
+ * @param item the CSS selector of interest
14
+ * @return Cypress chainable containing the full URL string (hostname + href attribute value)
17
15
  */
18
- navigateToHref(opts: { item: string; domain: string }): Chainable<string>;
16
+ navigateToHref(item: string): Chainable<string>;
19
17
  }
20
18
  }
21
19
  }
@@ -25,17 +23,30 @@ declare global {
25
23
  /*----------------------------------------*/
26
24
 
27
25
  const navigateToHref = () => {
28
- Cypress.Commands.add('navigateToHref', (opts: { item: string; domain: string }) => {
29
- const { item, domain } = opts;
30
-
31
- cy.waitForElementVisible(item);
32
- return cy
33
- .get(item)
34
- .invoke('attr', 'href')
35
- .then((href: any) => {
36
- return domain + href;
37
- });
38
- });
26
+ Cypress.Commands.add(
27
+ 'navigateToHref',
28
+ (
29
+ item: string,
30
+ ) => {
31
+ cy.waitForElementVisible(item);
32
+
33
+ // get hostname from current URL
34
+ const hostname = cy.url().then((url: string) => {
35
+ return new URL(url).hostname;
36
+ });
37
+
38
+ return cy
39
+ .get(item)
40
+ .invoke('attr', 'href')
41
+ .then((href: string) => {
42
+ // If the href is a relative URL, prepend the hostname
43
+ if (href.startsWith('/')) {
44
+ return hostname + href;
45
+ }
46
+ return href;
47
+ });
48
+ },
49
+ );
39
50
  };
40
51
 
41
52
  /*----------------------------------------*/
@@ -9,13 +9,13 @@ declare global {
9
9
  interface Chainable {
10
10
  /**
11
11
  * Run a script on the page
12
+ * @author Yuen Ler Chow
12
13
  * @param scriptLines the script to run in an anonymous function on the page.
13
14
  * If multiple script arguments are included, each argument will be considered a
14
15
  * new line of the script.
15
- * @returns return value of the script
16
- * @example cy.runScript('console.log("Hello");', 'return document.title;')
16
+ * @return Cypress chainable containing the return value from executing the script
17
17
  */
18
- runScript(...scriptLines: string[]): Chainable<any>;
18
+ runScript(scriptLines: string): Chainable<any>;
19
19
  }
20
20
  }
21
21
  }
@@ -25,14 +25,19 @@ declare global {
25
25
  /*----------------------------------------*/
26
26
 
27
27
  const runScript = () => {
28
- Cypress.Commands.add('runScript', (...scriptLines: string[]) => {
29
- cy.log('Running script');
30
- const fullScript = scriptLines.join('\n');
31
- return cy.window().then((win: any) => {
32
- const result = win.eval(fullScript);
33
- return cy.wrap(result);
34
- });
35
- });
28
+ Cypress.Commands.add(
29
+ 'runScript',
30
+ (
31
+ scriptLines: string,
32
+ ) => {
33
+ cy.log('Running script');
34
+ const fullScript = scriptLines;
35
+ return cy.window().then((win) => {
36
+ const result = win.eval(fullScript);
37
+ return cy.wrap(result);
38
+ });
39
+ },
40
+ );
36
41
  };
37
42
 
38
43
  /*----------------------------------------*/
@@ -9,17 +9,22 @@ declare global {
9
9
  interface Chainable {
10
10
  /**
11
11
  * Type text into an element. This function first removes the previous text in the element
12
+ * @author Yuen Ler Chow
12
13
  * @param opts object containing all arguments
13
14
  * @param opts.item the CSS selector of interest
14
15
  * @param opts.text the text to type
15
- * @param opts.pressEnter if true, after typing into the text field, simulate pressing enter
16
- * @example cy.typeInto({ item: '#username', text: 'john_doe', pressEnter: false })
16
+ * @param [opts.pressEnter] if true, after typing into the text field, simulate pressing enter
17
+ * @param [opts.append] if true, append the text to the end of the existing text in the element instead of replacing it
18
+ * @return Cypress chainable containing the input element that text was typed into
17
19
  */
18
- typeInto(opts: {
19
- item: string;
20
- text: string;
21
- pressEnter?: boolean;
22
- }): Chainable<Element>;
20
+ typeInto(
21
+ opts: {
22
+ item: string,
23
+ text: string,
24
+ pressEnter?: boolean,
25
+ append?: boolean,
26
+ },
27
+ ): Chainable<Element>;
23
28
  }
24
29
  }
25
30
  }
@@ -29,25 +34,48 @@ declare global {
29
34
  /*----------------------------------------*/
30
35
 
31
36
  const typeInto = () => {
32
- Cypress.Commands.add('typeInto', (opts: { item: string; text: string; pressEnter?: boolean }) => {
33
- const { item, text, pressEnter } = opts;
34
- cy.log(`Type "${text}" into ${item}`);
35
-
36
- // Check if the text contains an enter key press
37
- const enterAtEndOfText = text.charAt(text.length - 1) === '\n';
38
-
39
- // Type the text without a trailing enter if there was one
40
- const textWithoutTrailingEnter = enterAtEndOfText
41
- ? text.substring(0, text.length - 1)
42
- : text;
43
-
44
- cy.get(item).clear().type(textWithoutTrailingEnter);
45
-
46
- // Press enter if explicitly requested or if text ended with newline
47
- if (pressEnter || enterAtEndOfText) {
48
- cy.get(item).type('{enter}');
49
- }
50
- });
37
+ Cypress.Commands.add(
38
+ 'typeInto',
39
+ (
40
+ opts: {
41
+ item: string,
42
+ text: string,
43
+ pressEnter?: boolean,
44
+ append?: boolean,
45
+ },
46
+ ) => {
47
+ const {
48
+ item, text, pressEnter, append,
49
+ } = opts;
50
+ cy.log(`Type "${text}" into ${item}`);
51
+
52
+ // Check if the text contains an enter key press
53
+ const enterAtEndOfText = text.charAt(text.length - 1) === '\n';
54
+
55
+ // Type the text without a trailing enter if there was one
56
+ const textWithoutTrailingEnter = (
57
+ enterAtEndOfText
58
+ ? text.substring(0, text.length - 1)
59
+ : text
60
+ );
61
+
62
+ if (append) {
63
+ cy
64
+ .get(item)
65
+ .type(textWithoutTrailingEnter);
66
+ } else {
67
+ cy
68
+ .get(item)
69
+ .clear()
70
+ .type(textWithoutTrailingEnter);
71
+ }
72
+
73
+ // Press enter if explicitly requested or if text ended with newline
74
+ if (pressEnter || enterAtEndOfText) {
75
+ cy.get(item).type('{enter}');
76
+ }
77
+ },
78
+ );
51
79
  };
52
80
 
53
81
  /*----------------------------------------*/
@@ -9,13 +9,18 @@ declare global {
9
9
  interface Chainable {
10
10
  /**
11
11
  * Makes a GET request to Canvas API endpoint
12
+ * @author Yuen Ler Chow
12
13
  * @param opts object containing all arguments
13
14
  * @param opts.path The API path (e.g., '/courses', '/users/self')
14
15
  * @param opts.accessToken The Canvas access token
15
- * @returns The API response body
16
- * @example cy.visitCanvasGETEndpoint({ path: '/courses', accessToken: 'your_token' })
16
+ * @return Cypress chainable containing the Canvas API response body
17
17
  */
18
- visitCanvasGETEndpoint(opts: { path: string; accessToken: string }): Chainable<any>;
18
+ visitCanvasGETEndpoint(
19
+ opts: {
20
+ path: string,
21
+ accessToken: string,
22
+ }
23
+ ): Chainable<any>;
19
24
  }
20
25
  }
21
26
  }
@@ -25,20 +30,28 @@ declare global {
25
30
  /*----------------------------------------*/
26
31
 
27
32
  const visitCanvasGETEndpoint = () => {
28
- Cypress.Commands.add('visitCanvasGETEndpoint', (opts: { path: string; accessToken: string }) => {
29
- cy.log('Visiting Canvas GET endpoint');
30
- const { path, accessToken } = opts;
33
+ Cypress.Commands.add(
34
+ 'visitCanvasGETEndpoint',
35
+ (
36
+ opts: {
37
+ path: string,
38
+ accessToken: string,
39
+ },
40
+ ) => {
41
+ cy.log('Visiting Canvas GET endpoint');
42
+ const { path, accessToken } = opts;
31
43
 
32
- cy.log('Canvas API: ' + path);
33
- return cy.request({
34
- method: 'GET',
35
- url: 'https://canvas.harvard.edu/api/v1' + path,
36
- qs: {
37
- per_page: 200,
38
- access_token: accessToken
39
- }
40
- }).its('body');
41
- });
44
+ cy.log(`Canvas API: ${path}`);
45
+ return cy.request({
46
+ method: 'GET',
47
+ url: `https://canvas.harvard.edu/api/v1${path}`,
48
+ qs: {
49
+ per_page: 200,
50
+ access_token: accessToken,
51
+ },
52
+ }).its('body');
53
+ },
54
+ );
42
55
  };
43
56
 
44
57
  /*----------------------------------------*/
@@ -9,11 +9,15 @@ declare global {
9
9
  interface Chainable {
10
10
  /**
11
11
  * Wait for an element to be visible
12
+ * @author Yuen Ler Chow
12
13
  * @param item the CSS selector of interest
13
- * @param timeoutSec the number of seconds to wait before timing out (default: 10)
14
- * @example cy.waitForElementVisible('#submit-button', 15)
14
+ * @param [timeoutSec=10] the number of seconds to wait before timing out
15
+ * @return Cypress chainable containing the visible element
15
16
  */
16
- waitForElementVisible(item: string, timeoutSec?: number): Chainable<JQuery<HTMLElement>>;
17
+ waitForElementVisible(
18
+ item: string,
19
+ timeoutSec?: number,
20
+ ): Chainable<JQuery<HTMLElement>>;
17
21
  }
18
22
  }
19
23
  }
@@ -23,14 +27,19 @@ declare global {
23
27
  /*----------------------------------------*/
24
28
 
25
29
  const waitForElementVisible = () => {
26
- Cypress.Commands.add('waitForElementVisible', (item: string, timeoutSec?: number) => {
27
- cy.log('Waiting for element to be visible');
28
- timeoutSec = timeoutSec || 10;
30
+ Cypress.Commands.add(
31
+ 'waitForElementVisible',
32
+ (
33
+ item: string,
34
+ timeoutSec?: number,
35
+ ) => {
36
+ cy.log('Waiting for element to be visible');
29
37
 
30
- const timeoutMs = timeoutSec * 1000;
31
- cy.log(`Wait for ${item} to be visible`);
32
- return cy.get(item, { timeout: timeoutMs }).should('be.visible');
33
- });
38
+ const timeoutMs = (timeoutSec || 10) * 1000;
39
+ cy.log(`Wait for ${item} to be visible`);
40
+ return cy.get(item, { timeout: timeoutMs }).should('be.visible');
41
+ },
42
+ );
34
43
  };
35
44
 
36
45
  /*----------------------------------------*/
@@ -0,0 +1,65 @@
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;
package/src/index.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  // Import helpers
2
2
  import init from './init';
3
3
  import genConfiguration from './genConfiguration';
4
-
5
- // Automatically initialize upon importing the library
6
- init();
4
+ import genCommandPaths from './genCommandPaths';
7
5
 
8
6
  // Export key functions
9
7
  export {
10
8
  genConfiguration,
9
+ genCommandPaths,
11
10
  init,
12
11
  };
package/src/init.ts CHANGED
@@ -1,37 +1,83 @@
1
- // Import all commands
2
- import assertDoesNotHaveClass from './commands/assertDoesNotHaveClass';
3
- import assertHasClass from './commands/assertHasClass';
4
- import assertNumElements from './commands/assertNumElements';
5
- import clickWithRetry from './commands/clickWithRetry';
6
- import getNumElements from './commands/getNumElements';
7
- import handleHarvardKey from './commands/handleHarvardKey';
8
- import launchAs from './commands/launchAs';
9
- import launchLTIUsingToken from './commands/launchLTIUsingToken';
10
- import navigateToHref from './commands/navigateToHref';
11
- import runScript from './commands/runScript';
12
- import typeInto from './commands/typeInto';
13
- import visitCanvasGETEndpoint from './commands/visitCanvasGETEndpoint';
14
- import waitForElementVisible from './commands/waitForElementVisible';
15
-
16
- /**
17
- * Initialize custom commands
18
- * @author Gabe Abrams
19
- */
20
- const init = () => {
21
- // Execute each command adder
22
- assertDoesNotHaveClass();
23
- assertHasClass();
24
- assertNumElements();
25
- clickWithRetry();
26
- getNumElements();
27
- handleHarvardKey();
28
- launchAs();
29
- launchLTIUsingToken();
30
- navigateToHref();
31
- runScript();
32
- typeInto();
33
- visitCanvasGETEndpoint();
34
- waitForElementVisible();
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
+ }
35
81
  };
36
82
 
37
83
  export default init;
package/.eslintrc.json DELETED
@@ -1,58 +0,0 @@
1
- {
2
- "extends": "airbnb",
3
- "env": {
4
- "browser": true,
5
- "node": true
6
- },
7
- "rules": {
8
- "arrow-body-style": [
9
- "warn",
10
- "always"
11
- ],
12
- "arrow-parens": [ "warn", "always" ],
13
- "comma-dangle": [ "error", {
14
- "arrays": "always-multiline",
15
- "objects": "always-multiline",
16
- "imports": "always-multiline",
17
- "exports": "always-multiline",
18
- "functions": "never"
19
- }
20
- ],
21
- "consistent-return": "off",
22
- "id-length": "off",
23
- "max-len": [ "error",
24
- {
25
- "code": 80,
26
- "ignoreStrings": true,
27
- "ignoreTemplateLiterals": true,
28
- "ignoreUrls": true
29
- }
30
- ],
31
- "newline-per-chained-call": [
32
- "error",
33
- {
34
- "ignoreChainWithDepth": 2
35
- }
36
- ],
37
- "no-plusplus": [ "warn", { "allowForLoopAfterthoughts": true }],
38
- "prefer-template": "off",
39
- "prefer-destructuring": [ "error",
40
- {
41
- "VariableDeclarator": {
42
- "array": false,
43
- "object": true
44
- },
45
- "AssignmentExpression": {
46
- "array": false,
47
- "object": true
48
- }
49
- },
50
- {
51
- "enforceForRenamedProperties": false
52
- }
53
- ],
54
- "radix": "off",
55
- "no-underscore-dangle": "off",
56
- "max-params": [ "warn", { "max": 3 } ]
57
- }
58
- }
@@ -1,51 +0,0 @@
1
- /// <reference types="cypress" />
2
-
3
- /*----------------------------------------*/
4
- /* ---------------- Type ---------------- */
5
- /*----------------------------------------*/
6
-
7
- declare global {
8
- namespace Cypress {
9
- interface Chainable {
10
- /**
11
- * Click an element with visibility checking, scrolling, and timeout handling
12
- * @param item the CSS selector of interest
13
- * @param timeoutSec the number of seconds to wait before timing out (default: 10)
14
- * @param dontScrollTo if true, do not scroll to the element (default: false)
15
- * @example cy.clickWithRetry('.submit-button', 15, false)
16
- */
17
- clickWithRetry(item: string, timeoutSec?: number, dontScrollTo?: boolean): Chainable<JQuery<HTMLElement>>;
18
- }
19
- }
20
- }
21
-
22
- /*----------------------------------------*/
23
- /* --------------- Command -------------- */
24
- /*----------------------------------------*/
25
-
26
- const clickWithRetry = () => {
27
- Cypress.Commands.add('clickWithRetry', (item: string, timeoutSec?: number, dontScrollTo?: boolean) => {
28
- timeoutSec = timeoutSec || 10;
29
- dontScrollTo = dontScrollTo || false;
30
-
31
- cy.log(`Click ${item}`);
32
-
33
- // Wait for element to be visible first using our own function
34
- cy.waitForElementVisible(item, timeoutSec);
35
-
36
- // If scrolling is disabled, try to click directly
37
- if (dontScrollTo) {
38
- return cy.get(item).click();
39
- } else {
40
- // Scroll to element and then click using our own function
41
- cy.get(item).scrollIntoView();
42
- return cy.get(item).click();
43
- }
44
- });
45
- };
46
-
47
- /*----------------------------------------*/
48
- /* --------------- Export --------------- */
49
- /*----------------------------------------*/
50
-
51
- export default clickWithRetry;