cypress-plugin-grep-boxes 1.1.2 → 1.1.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 (2) hide show
  1. package/index.js +41 -13
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -24,6 +24,7 @@ export const greppedTestToggle = () => {
24
24
  #grepTestToggleControls label {
25
25
  background-color: transparent;
26
26
  padding-top: 5px;
27
+ padding-right: 2px;
27
28
  }
28
29
  #grepTestToggleControls #grepTestToggleTooltip {
29
30
  visibility: hidden;
@@ -34,13 +35,16 @@ export const greppedTestToggle = () => {
34
35
  padding: 5px;
35
36
  border-radius: 3px;
36
37
  position: absolute;
37
- z-index: 1;
38
- top: 27px;
39
- left: 0px;
38
+ z-index: 99999;
39
+ top: 33px;
40
+ right: -2px;
40
41
  height: 28px;
42
+ overflow: visible;
41
43
  }
42
44
  #grepTestToggleControls:hover #grepTestToggleTooltip {
43
45
  visibility: visible;
46
+ z-index: 99999;
47
+ overflow: visible;
44
48
  }
45
49
  #grepTestToggleButton #grepTestToggleLabel {
46
50
  cursor: pointer;
@@ -49,15 +53,20 @@ export const greppedTestToggle = () => {
49
53
  content: " ";
50
54
  position: absolute;
51
55
  bottom: 100%; /* At the top of the tooltip */
52
- right: 85%;
56
+ left: 89%;
57
+ z-index: 99999;
53
58
  margin-left: -5px;
54
59
  border-width: 5px;
55
60
  border-style: solid;
61
+ overflow: visible;
56
62
  border-color: transparent transparent #f3f4fa transparent;
57
63
  }
58
64
  .reporter:has(#grepTestToggle:checked) .command.command-name-request:has(.command-is-event) {
59
65
  display:none
60
66
  }
67
+ .spec-container {
68
+ overflow: visible !important
69
+ }
61
70
  `;
62
71
  const turnOngrepTestToggleIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#afb3c7" class="bi bi-collection-play-fill" viewBox="0 0 16 16">
63
72
  <path d="M2.5 3.5a.5.5 0 0 1 0-1h11a.5.5 0 0 1 0 1zm2-2a.5.5 0 0 1 0-1h7a.5.5 0 0 1 0 1zM0 13a1.5 1.5 0 0 0 1.5 1.5h13A1.5 1.5 0 0 0 16 13V6a1.5 1.5 0 0 0-1.5-1.5h-13A1.5 1.5 0 0 0 0 6zm6.258-6.437a.5.5 0 0 1 .507.013l4 2.5a.5.5 0 0 1 0 .848l-4 2.5A.5.5 0 0 1 6 12V7a.5.5 0 0 1 .258-.437"/>
@@ -73,17 +82,27 @@ export const greppedTestToggle = () => {
73
82
 
74
83
  // append styles
75
84
  if (!hasStyles) {
76
- const reporterEl = window.top?.document.querySelector('#unified-reporter');
85
+ let reporterEl;
77
86
  const reporterStyleEl = document.createElement('style');
87
+ if (Cypress.version >= '15.0.0') {
88
+ reporterEl = window.top?.document.querySelector('.runnable-header');
89
+ } else {
90
+ reporterEl = window.top?.document.querySelector('#unified-reporter');
91
+ }
78
92
  reporterStyleEl.setAttribute('id', 'grepTestToggleStyle');
79
93
  reporterStyleEl.innerHTML = defaultStyles;
80
94
  reporterEl?.appendChild(reporterStyleEl);
81
95
  }
82
96
 
83
97
  if (!hasToggleButton) {
84
- const header = window.top?.document.querySelector(
85
- '#unified-reporter header'
86
- );
98
+ let header;
99
+ if (Cypress.version >= '15.0.0') {
100
+ // TODO: Cypress v15 GUI provides option for Cypress Studio which pushes the grep toggle button around the UI
101
+ // For simplicity, moving the toggle button to the spec container above the stop button
102
+ header = window.top?.document.querySelector('.runnable-header');
103
+ } else {
104
+ header = window.top?.document.querySelector('#unified-reporter header');
105
+ }
87
106
  const headerToggleDiv = document.createElement('div');
88
107
  const headerToggleSpan = document.createElement('span');
89
108
  const headerToggleTooltip = document.createElement('span');
@@ -98,7 +117,6 @@ export const greppedTestToggle = () => {
98
117
  headerToggleLabel.setAttribute('id', 'grepTestToggleLabel');
99
118
  headerToggleLabel.innerHTML = turnOffgrepTestToggleIcon;
100
119
 
101
- headerToggleDiv.setAttribute('class', 'controls');
102
120
  headerToggleDiv.setAttribute('id', 'grepTestToggleControls');
103
121
  headerToggleTooltip.setAttribute('id', 'grepTestToggleTooltip');
104
122
  headerToggleTooltip.innerText = turnOffgrepTestToggleDescription;
@@ -108,6 +126,7 @@ export const greppedTestToggle = () => {
108
126
  );
109
127
  headerToggleButton.setAttribute('id', 'grepTestToggleButton');
110
128
 
129
+ headerToggleDiv.setAttribute('class', 'controls');
111
130
  header?.appendChild(headerToggleDiv);
112
131
  headerToggleDiv?.appendChild(headerToggleSpan);
113
132
  headerToggleDiv?.appendChild(headerToggleTooltip);
@@ -152,6 +171,7 @@ export const greppedTestToggle = () => {
152
171
  1
153
172
  );
154
173
  }
174
+
155
175
  // if a non-checked test's title includes a checked test's title, invert grep for unchecked title
156
176
  uncheckedTests.forEach((u) => {
157
177
  if (u.includes(t)) {
@@ -188,6 +208,7 @@ export const addGrepButtons = () => {
188
208
 
189
209
  const defaultStyles = `
190
210
  .grep-tests-btn {
211
+ pointer-events: auto;
191
212
  background: none;
192
213
  color: inherit;
193
214
  padding: 0 20px;
@@ -207,9 +228,16 @@ export const addGrepButtons = () => {
207
228
  runnablesStyleEl.innerHTML = defaultStyles;
208
229
  runnablesEl?.appendChild(runnablesStyleEl);
209
230
  }
210
- const testsAndSuites = window.top?.document.querySelectorAll(
211
- '.test.runnable, .suite.runnable'
212
- );
231
+ let testsAndSuites;
232
+ if (Cypress.version >= '15.0.0') {
233
+ // TODO: Cypress v15 implemented a new suite naming convention that utilizes " > " separator between nested suites
234
+ // For now, only allowing tests to be selected for simplicity
235
+ testsAndSuites = window.top?.document.querySelectorAll('.test.runnable');
236
+ } else {
237
+ testsAndSuites = window.top?.document.querySelectorAll(
238
+ '.test.runnable, .suite.runnable'
239
+ );
240
+ }
213
241
  [...testsAndSuites].forEach((t) => {
214
242
  const header = t.querySelector('.collapsible-header');
215
243
  const title = header.querySelector('.runnable-title');
@@ -259,7 +287,7 @@ export const addGrepButtons = () => {
259
287
 
260
288
  // To prevent a checkbox from expanding a runnable, click the collapsible
261
289
  grepTestsBtn?.addEventListener('change', (e) => {
262
- if (e.target.checked) {
290
+ if (e.target.checked || e.target.unchecked) {
263
291
  header.click();
264
292
  }
265
293
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress-plugin-grep-boxes",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Cypress plugin that allows user to run specific tests in open mode.",
5
5
  "main": "./index.js",
6
6
  "keywords": [
@@ -9,8 +9,8 @@
9
9
  "cypress-plugin"
10
10
  ],
11
11
  "devDependencies": {
12
- "@bahmutov/cy-grep": "^2.0.22",
13
- "cypress": "^14.3.0"
12
+ "@bahmutov/cy-grep": "^2.0.37",
13
+ "cypress": "^15.4.0"
14
14
  },
15
15
  "publishConfig": {
16
16
  "registry": "https://registry.npmjs.org/"