cypress-cli-select 1.0.0

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 (45) hide show
  1. package/.github/workflows/jest.yml +12 -0
  2. package/CONTRIBUTING.md +39 -0
  3. package/LICENSE.md +21 -0
  4. package/README.md +197 -0
  5. package/assets/choose-spec-pattern-demo.gif +0 -0
  6. package/assets/cypress-cli-select-animated.gif +0 -0
  7. package/assets/print-selected-demo.png +0 -0
  8. package/assets/run-help.gif +0 -0
  9. package/assets/run-spec-tag.gif +0 -0
  10. package/assets/run-spec-title.gif +0 -0
  11. package/cypress/e2e/1-getting-started/todo.cy.js +143 -0
  12. package/cypress/e2e/2-advanced-examples/actions.cy.js +321 -0
  13. package/cypress/e2e/2-advanced-examples/aliasing.cy.js +39 -0
  14. package/cypress/e2e/2-advanced-examples/assertions.cy.js +176 -0
  15. package/cypress/e2e/2-advanced-examples/connectors.cy.js +98 -0
  16. package/cypress/e2e/2-advanced-examples/cookies.cy.js +118 -0
  17. package/cypress/e2e/2-advanced-examples/cypress_api.cy.js +211 -0
  18. package/cypress/e2e/2-advanced-examples/location.cy.js +32 -0
  19. package/cypress/e2e/2-advanced-examples/misc.cy.js +90 -0
  20. package/cypress/e2e/2-advanced-examples/navigation.cy.js +55 -0
  21. package/cypress/e2e/2-advanced-examples/network_requests.cy.js +163 -0
  22. package/cypress/e2e/2-advanced-examples/querying.cy.js +114 -0
  23. package/cypress/e2e/2-advanced-examples/spies_stubs_clocks.cy.js +220 -0
  24. package/cypress/e2e/2-advanced-examples/storage.cy.js +117 -0
  25. package/cypress/e2e/2-advanced-examples/traversal.cy.js +126 -0
  26. package/cypress/e2e/2-advanced-examples/utilities.cy.js +109 -0
  27. package/cypress/e2e/2-advanced-examples/viewport.cy.js +58 -0
  28. package/cypress/e2e/2-advanced-examples/waiting.cy.js +30 -0
  29. package/cypress/e2e/2-advanced-examples/window.cy.js +22 -0
  30. package/cypress/support/commands.js +25 -0
  31. package/cypress/support/component-index.html +14 -0
  32. package/cypress/support/component.js +24 -0
  33. package/cypress/support/e2e.js +19 -0
  34. package/cypress.config.js +25 -0
  35. package/cypress.new.config.js +26 -0
  36. package/index.js +586 -0
  37. package/package.json +46 -0
  38. package/src/components/Clock.cy.js +13 -0
  39. package/src/components/Stepper.cy.js +13 -0
  40. package/src/sortable-list.js +82 -0
  41. package/tapes/run-help.tape +94 -0
  42. package/tapes/run-spec-tag.tape +163 -0
  43. package/tapes/run-spec-title.tape +191 -0
  44. package/tests/cli-component.spec.js +409 -0
  45. package/tests/cli-e2e.spec.js +439 -0
@@ -0,0 +1,82 @@
1
+ const {
2
+ createPrompt,
3
+ useState,
4
+ useKeypress,
5
+ usePrefix,
6
+ usePagination,
7
+ makeTheme,
8
+ isUpKey,
9
+ isDownKey,
10
+ isEnterKey,
11
+ } = require("@inquirer/core");
12
+ const pc = require("picocolors");
13
+
14
+ export const sortingList = createPrompt((config, done) => {
15
+ const { message, choices, pageSize = 10 } = config;
16
+ const theme = makeTheme({
17
+ icon: { cursor: pc.cyan(">") },
18
+ style: { highlight: pc.cyan },
19
+ });
20
+
21
+ const prefix = usePrefix({ theme });
22
+ const [status, setStatus] = useState("idle");
23
+
24
+ const [items, setItems] = useState(choices);
25
+ const [active, setActive] = useState(0);
26
+
27
+ if (items.length === 0) {
28
+ return `${prefix.idle} ${message}\n(No items to display)`;
29
+ }
30
+
31
+ useKeypress((key) => {
32
+ if (isEnterKey(key)) {
33
+ setStatus("done");
34
+ done(items);
35
+ } else if (isUpKey(key) || isDownKey(key)) {
36
+ const offset = isUpKey(key) ? -1 : 1;
37
+
38
+ if (key.shift) {
39
+ // Reorder the items with Shift + Arrow
40
+ const newIndex = active + offset;
41
+ if (newIndex >= 0 && newIndex < items.length) {
42
+ const newItems = [...items];
43
+ [newItems[active], newItems[newIndex]] = [
44
+ newItems[newIndex],
45
+ newItems[active],
46
+ ];
47
+ setItems(newItems);
48
+ setActive(newIndex); // Update active position
49
+ }
50
+ } else {
51
+ // Navigate the list
52
+ const newActive = active + offset;
53
+ if (newActive >= 0 && newActive < items.length) {
54
+ setActive(newActive);
55
+ }
56
+ }
57
+ }
58
+ });
59
+
60
+ const page = usePagination({
61
+ items,
62
+ active,
63
+ renderItem({ item, isActive }) {
64
+ const cursor = isActive ? theme.icon.cursor : " ";
65
+ const color = isActive ? theme.style.highlight : (text) => text;
66
+
67
+ return color(`${cursor} ${pc.bold(item)}`);
68
+ },
69
+ pageSize,
70
+ loop: false, // Disable loop
71
+ });
72
+
73
+ if (status === "done") {
74
+ return `${theme.prefix.idle} ${pc.bold(message)} ${pc.cyan(items).toString()}`;
75
+ }
76
+ const helpermessage = `(use arrow keys to navigate, shift+up/down to reorder, enter to confirm)`;
77
+ return `${theme.prefix.idle} ${pc.bold(message)}\n${page}\n${pc.dim(
78
+ helpermessage,
79
+ )}`;
80
+ });
81
+
82
+ module.exports = { sortingList };
@@ -0,0 +1,94 @@
1
+
2
+ # VHS documentation
3
+ #
4
+ # Output:
5
+ # Output <path>.gif Create a GIF output at the given <path>
6
+ # Output <path>.mp4 Create an MP4 output at the given <path>
7
+ # Output <path>.webm Create a WebM output at the given <path>
8
+ #
9
+ # Require:
10
+ # Require <string> Ensure a program is on the $PATH to proceed
11
+ #
12
+ # Settings:
13
+ # Set FontSize <number> Set the font size of the terminal
14
+ # Set FontFamily <string> Set the font family of the terminal
15
+ # Set Height <number> Set the height of the terminal
16
+ # Set Width <number> Set the width of the terminal
17
+ # Set LetterSpacing <float> Set the font letter spacing (tracking)
18
+ # Set LineHeight <float> Set the font line height
19
+ # Set LoopOffset <float>% Set the starting frame offset for the GIF loop
20
+ # Set Theme <json|string> Set the theme of the terminal
21
+ # Set Padding <number> Set the padding of the terminal
22
+ # Set Framerate <number> Set the framerate of the recording
23
+ # Set PlaybackSpeed <float> Set the playback speed of the recording
24
+ # Set MarginFill <file|#000000> Set the file or color the margin will be filled with.
25
+ # Set Margin <number> Set the size of the margin. Has no effect if MarginFill isn't set.
26
+ # Set BorderRadius <number> Set terminal border radius, in pixels.
27
+ # Set WindowBar <string> Set window bar type. (one of: Rings, RingsRight, Colorful, ColorfulRight)
28
+ # Set WindowBarSize <number> Set window bar size, in pixels. Default is 40.
29
+ # Set TypingSpeed <time> Set the typing speed of the terminal. Default is 50ms.
30
+ #
31
+ # Sleep:
32
+ # Sleep <time> Sleep for a set amount of <time> in seconds
33
+ #
34
+ # Type:
35
+ # Type[@<time>] "<characters>" Type <characters> into the terminal with a
36
+ # <time> delay between each character
37
+ #
38
+ # Keys:
39
+ # Escape[@<time>] [number] Press the Escape key
40
+ # Backspace[@<time>] [number] Press the Backspace key
41
+ # Delete[@<time>] [number] Press the Delete key
42
+ # Insert[@<time>] [number] Press the Insert key
43
+ # Down[@<time>] [number] Press the Down key
44
+ # Enter[@<time>] [number] Press the Enter key
45
+ # Space[@<time>] [number] Press the Space key
46
+ # Tab[@<time>] [number] Press the Tab key
47
+ # Left[@<time>] [number] Press the Left Arrow key
48
+ # Right[@<time>] [number] Press the Right Arrow key
49
+ # Up[@<time>] [number] Press the Up Arrow key
50
+ # Down[@<time>] [number] Press the Down Arrow key
51
+ # PageUp[@<time>] [number] Press the Page Up key
52
+ # PageDown[@<time>] [number] Press the Page Down key
53
+ # Ctrl+<key> Press the Control key + <key> (e.g. Ctrl+C)
54
+ #
55
+ # Display:
56
+ # Hide Hide the subsequent commands from the output
57
+ # Show Show the subsequent commands in the output
58
+
59
+ # Where should we write the GIF?
60
+ Output assets/run-help.gif
61
+
62
+ # Set fontsize and width/height
63
+ Set FontSize 20
64
+ Set Width 1600
65
+ Set Height 1000
66
+
67
+ # Set margin + color
68
+ Set Margin 50
69
+ Set MarginFill "#5f76d9"
70
+ Set BorderRadius 10
71
+
72
+ # Set window bar
73
+ Set WindowBar Colorful
74
+ Set WindowBarSize 60
75
+
76
+ # Set theme
77
+ Set Theme "nord"
78
+
79
+ # Type a command in the terminal.
80
+ Type@100ms "npx cypress-cli-select run --help"
81
+
82
+ # Hide the npx loader
83
+ Hide
84
+
85
+ # Run the command
86
+ Enter
87
+
88
+ # Await the help menu
89
+ Wait+Screen /Interactive cli prompts to select Cypress/
90
+
91
+ # Now restart recording
92
+ Show
93
+ Sleep 8s
94
+
@@ -0,0 +1,163 @@
1
+ # VHS documentation
2
+ #
3
+ # Output:
4
+ # Output <path>.gif Create a GIF output at the given <path>
5
+ # Output <path>.mp4 Create an MP4 output at the given <path>
6
+ # Output <path>.webm Create a WebM output at the given <path>
7
+ #
8
+ # Require:
9
+ # Require <string> Ensure a program is on the $PATH to proceed
10
+ #
11
+ # Settings:
12
+ # Set FontSize <number> Set the font size of the terminal
13
+ # Set FontFamily <string> Set the font family of the terminal
14
+ # Set Height <number> Set the height of the terminal
15
+ # Set Width <number> Set the width of the terminal
16
+ # Set LetterSpacing <float> Set the font letter spacing (tracking)
17
+ # Set LineHeight <float> Set the font line height
18
+ # Set LoopOffset <float>% Set the starting frame offset for the GIF loop
19
+ # Set Theme <json|string> Set the theme of the terminal
20
+ # Set Padding <number> Set the padding of the terminal
21
+ # Set Framerate <number> Set the framerate of the recording
22
+ # Set PlaybackSpeed <float> Set the playback speed of the recording
23
+ # Set MarginFill <file|#000000> Set the file or color the margin will be filled with.
24
+ # Set Margin <number> Set the size of the margin. Has no effect if MarginFill isn't set.
25
+ # Set BorderRadius <number> Set terminal border radius, in pixels.
26
+ # Set WindowBar <string> Set window bar type. (one of: Rings, RingsRight, Colorful, ColorfulRight)
27
+ # Set WindowBarSize <number> Set window bar size, in pixels. Default is 40.
28
+ # Set TypingSpeed <time> Set the typing speed of the terminal. Default is 50ms.
29
+ #
30
+ # Sleep:
31
+ # Sleep <time> Sleep for a set amount of <time> in seconds
32
+ #
33
+ # Type:
34
+ # Type[@<time>] "<characters>" Type <characters> into the terminal with a
35
+ # <time> delay between each character
36
+ #
37
+ # Keys:
38
+ # Escape[@<time>] [number] Press the Escape key
39
+ # Backspace[@<time>] [number] Press the Backspace key
40
+ # Delete[@<time>] [number] Press the Delete key
41
+ # Insert[@<time>] [number] Press the Insert key
42
+ # Down[@<time>] [number] Press the Down key
43
+ # Enter[@<time>] [number] Press the Enter key
44
+ # Space[@<time>] [number] Press the Space key
45
+ # Tab[@<time>] [number] Press the Tab key
46
+ # Left[@<time>] [number] Press the Left Arrow key
47
+ # Right[@<time>] [number] Press the Right Arrow key
48
+ # Up[@<time>] [number] Press the Up Arrow key
49
+ # Down[@<time>] [number] Press the Down Arrow key
50
+ # PageUp[@<time>] [number] Press the Page Up key
51
+ # PageDown[@<time>] [number] Press the Page Down key
52
+ # Ctrl+<key> Press the Control key + <key> (e.g. Ctrl+C)
53
+ #
54
+ # Display:
55
+ # Hide Hide the subsequent commands from the output
56
+ # Show Show the subsequent commands in the output
57
+
58
+ # Where should we write the GIF?
59
+ Output assets/run-spec-tag.gif
60
+
61
+ # Set fontsize and width/height
62
+ Set FontSize 20
63
+ Set Width 1600
64
+ Set Height 1000
65
+
66
+ # Set margin + color
67
+ Set Margin 50
68
+ Set MarginFill "#5f76d9"
69
+ Set BorderRadius 10
70
+
71
+ # Set window bar
72
+ Set WindowBar Colorful
73
+ Set WindowBarSize 60
74
+
75
+ # Set theme
76
+ Set Theme "nord"
77
+
78
+ Hide
79
+ # Type a command in the terminal.
80
+ Type@100ms "npx cypress-cli-select run"
81
+
82
+ # Run the command
83
+ Enter
84
+
85
+ # Await the cli title and first prompt
86
+ Wait+Screen /Cypress-cli-select/
87
+ Wait+Screen /Choose to filter by specs, specific test titles or tags/
88
+
89
+ # Now restart recording
90
+ Sleep 1s
91
+
92
+ # Ensure the first prompt choices are visible on screen
93
+ Wait+Screen /Specs/
94
+ Wait+Screen /Test titles or tags \(requires cy-grep\)/
95
+
96
+ # Select all options
97
+ Down
98
+ Sleep 1s
99
+ Tab
100
+
101
+ Sleep 1s
102
+
103
+ # Confirm
104
+ Enter
105
+
106
+ # Await the second prompt for titles or tags
107
+ Wait+Screen /Choose to filter by specific test titles or tags/
108
+ Wait+Screen /Test titles \(requires cy-grep\)/
109
+ Wait+Screen /Test tags \(requires cy-grep\)/
110
+
111
+ Show
112
+ Sleep 1s
113
+ Down
114
+ Sleep 1s
115
+
116
+ # Submit tags
117
+ Enter
118
+
119
+ # Await tag list
120
+ Wait+Screen /Select tags to run/
121
+ Wait+Screen /@smoke/
122
+ Wait+Screen /@p2/
123
+ Wait+Screen /@nightly/
124
+ Wait+Screen /@p3/
125
+ Wait+Screen /@sanity/
126
+ Wait+Screen /@p1/
127
+
128
+ Sleep 2s
129
+
130
+ # Type a search in the prompt
131
+ Type@200ms "sanity"
132
+
133
+ # Await the test list to show search result
134
+ Wait+Screen /@sanity/
135
+ Sleep 2s
136
+
137
+ # Select tag
138
+ Tab
139
+
140
+ Sleep 2s
141
+
142
+ # Remove selected tag
143
+ Backspace
144
+
145
+ Sleep 1s
146
+
147
+ # Type a new search in the prompt
148
+ Type@200ms "nightly"
149
+
150
+ # Await the tag list to show search result
151
+ Wait+Screen /@nightly/
152
+
153
+ # Select new tag
154
+ Tab
155
+
156
+ Sleep 2s
157
+
158
+ Hide
159
+ # Confirm
160
+ Enter
161
+
162
+ # Await the cypress run title to show
163
+ Wait+Screen /Running Cypress/
@@ -0,0 +1,191 @@
1
+ # VHS documentation
2
+ #
3
+ # Output:
4
+ # Output <path>.gif Create a GIF output at the given <path>
5
+ # Output <path>.mp4 Create an MP4 output at the given <path>
6
+ # Output <path>.webm Create a WebM output at the given <path>
7
+ #
8
+ # Require:
9
+ # Require <string> Ensure a program is on the $PATH to proceed
10
+ #
11
+ # Settings:
12
+ # Set FontSize <number> Set the font size of the terminal
13
+ # Set FontFamily <string> Set the font family of the terminal
14
+ # Set Height <number> Set the height of the terminal
15
+ # Set Width <number> Set the width of the terminal
16
+ # Set LetterSpacing <float> Set the font letter spacing (tracking)
17
+ # Set LineHeight <float> Set the font line height
18
+ # Set LoopOffset <float>% Set the starting frame offset for the GIF loop
19
+ # Set Theme <json|string> Set the theme of the terminal
20
+ # Set Padding <number> Set the padding of the terminal
21
+ # Set Framerate <number> Set the framerate of the recording
22
+ # Set PlaybackSpeed <float> Set the playback speed of the recording
23
+ # Set MarginFill <file|#000000> Set the file or color the margin will be filled with.
24
+ # Set Margin <number> Set the size of the margin. Has no effect if MarginFill isn't set.
25
+ # Set BorderRadius <number> Set terminal border radius, in pixels.
26
+ # Set WindowBar <string> Set window bar type. (one of: Rings, RingsRight, Colorful, ColorfulRight)
27
+ # Set WindowBarSize <number> Set window bar size, in pixels. Default is 40.
28
+ # Set TypingSpeed <time> Set the typing speed of the terminal. Default is 50ms.
29
+ #
30
+ # Sleep:
31
+ # Sleep <time> Sleep for a set amount of <time> in seconds
32
+ #
33
+ # Type:
34
+ # Type[@<time>] "<characters>" Type <characters> into the terminal with a
35
+ # <time> delay between each character
36
+ #
37
+ # Keys:
38
+ # Escape[@<time>] [number] Press the Escape key
39
+ # Backspace[@<time>] [number] Press the Backspace key
40
+ # Delete[@<time>] [number] Press the Delete key
41
+ # Insert[@<time>] [number] Press the Insert key
42
+ # Down[@<time>] [number] Press the Down key
43
+ # Enter[@<time>] [number] Press the Enter key
44
+ # Space[@<time>] [number] Press the Space key
45
+ # Tab[@<time>] [number] Press the Tab key
46
+ # Left[@<time>] [number] Press the Left Arrow key
47
+ # Right[@<time>] [number] Press the Right Arrow key
48
+ # Up[@<time>] [number] Press the Up Arrow key
49
+ # Down[@<time>] [number] Press the Down Arrow key
50
+ # PageUp[@<time>] [number] Press the Page Up key
51
+ # PageDown[@<time>] [number] Press the Page Down key
52
+ # Ctrl+<key> Press the Control key + <key> (e.g. Ctrl+C)
53
+ #
54
+ # Display:
55
+ # Hide Hide the subsequent commands from the output
56
+ # Show Show the subsequent commands in the output
57
+
58
+ # Where should we write the GIF?
59
+ Output assets/run-spec-title.gif
60
+
61
+ # Set fontsize and width/height
62
+ Set FontSize 20
63
+ Set Width 1600
64
+ Set Height 1000
65
+
66
+ # Set margin + color
67
+ Set Margin 50
68
+ Set MarginFill "#5f76d9"
69
+ Set BorderRadius 10
70
+
71
+ # Set window bar
72
+ Set WindowBar Colorful
73
+ Set WindowBarSize 60
74
+
75
+ # Set theme
76
+ Set Theme "nord"
77
+
78
+ # Type a command in the terminal.
79
+ Type@150ms "npx cypress-cli-select run"
80
+
81
+ # Hide the npx loader
82
+ Hide
83
+
84
+ # Run the command
85
+ Enter
86
+
87
+ # Await the cli title and first prompt
88
+ Wait+Screen /Cypress-cli-select/
89
+ Wait+Screen /Choose to filter by specs, specific test titles or tags/
90
+
91
+ # Now restart recording
92
+ Show
93
+ Sleep 1s
94
+
95
+ # Ensure the first prompt choices are visible on screen
96
+ Wait+Screen /Specs/
97
+ Wait+Screen /Test titles or tags \(requires cy-grep\)/
98
+
99
+ # Select all options
100
+ Ctrl+a
101
+
102
+ Sleep 2s
103
+
104
+ # Confirm
105
+ Enter
106
+
107
+ # Await the second prompt for titles or tags
108
+ Wait+Screen /Choose to filter by specific test titles or tags/
109
+ Wait+Screen /Test titles \(requires cy-grep\)/
110
+ Wait+Screen /Test tags \(requires cy-grep\)/
111
+
112
+ Sleep 2s
113
+
114
+ # Submit titles
115
+ Enter
116
+
117
+ # Await the spec list
118
+ Wait+Screen /Select specs to run/
119
+ Wait+Screen /todo\.cy\.js/
120
+ Wait+Screen /actions\.cy\.js/
121
+
122
+ Sleep 2s
123
+
124
+ # Type a search in the prompt
125
+ Type@100ms "misc"
126
+ # Await the spec list to show search result
127
+ Wait+Screen /misc\.cy\.js/
128
+
129
+ Sleep 2s
130
+
131
+ # Select spec by pressing tab
132
+ Tab
133
+
134
+ Sleep 2s
135
+
136
+ # Confirm spec
137
+ Enter
138
+
139
+ # Await test list
140
+ Wait+Screen /Select tests to run/
141
+ Wait+Screen /todo\.cy\.js > example to-do app > displays two todo items by default/
142
+ Wait+Screen /actions\.cy\.js > Actions > \.type\(\) - type into a DOM element/
143
+
144
+ Sleep 2s
145
+
146
+ # Type a search in the prompt
147
+ Type@200ms "navigation"
148
+
149
+ # Await the test list to show search result
150
+ Wait+Screen /navigation\.cy\.js > Navigation > cy\.reload\(\) - reload the page/
151
+ Sleep 2s
152
+
153
+ # Move down two
154
+ Down
155
+ Sleep 1s
156
+ Down
157
+ Sleep 1s
158
+
159
+ # Select title
160
+ Tab
161
+
162
+ Sleep 2s
163
+
164
+ # Remove selected title
165
+ Backspace
166
+
167
+ Sleep 1s
168
+
169
+ # Type a new search in the prompt
170
+ Type@200ms "window"
171
+
172
+ # Await the test list to show search result
173
+ Wait+Screen /window\.cy\.js > Window > cy\.title\(\) - get the title/
174
+
175
+ # Move down two
176
+ Down
177
+ Sleep 1s
178
+ Down
179
+ Sleep 1s
180
+
181
+ # Select new title
182
+ Tab
183
+
184
+ Sleep 2s
185
+
186
+ # Confirm
187
+ Enter
188
+
189
+ # Await the cypress run title to show
190
+ Wait+Screen /Running Cypress/
191
+