Skip to content

Commit 181720d

Browse files
authored
[Chore] Update tabs test to fix cypress errors (#3852)
Update tabs test to fix cypress errors
1 parent b7107bd commit 181720d

File tree

1 file changed

+47
-49
lines changed

1 file changed

+47
-49
lines changed

cypress/e2e/settings/tabs.spec.js

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,26 @@ describe("Tabs actions", () => {
2727
cy.visit("/code/file/views/11-e55790-f19nwx");
2828
});
2929
// Active tab should always be visible
30-
cy.get('[data-cy="UnpinnedTab"]').should("exist");
30+
cy.getBySelector("UnpinnedTab").should("exist");
3131
// Click the pin button on the active tab
3232
cy.get('[data-testid="PushPinOutlinedIcon"]').should("exist");
3333
cy.get('[data-testid="PushPinOutlinedIcon"]').click();
3434
// Active tab should show pinned state
3535
cy.get('[data-testid="PushPinIcon"]');
36-
cy.get('[data-cy="PinnedTab-0"]').find('[data-testid="PushPinIcon"]');
36+
cy.getBySelector("PinnedTab-0").find('[data-testid="PushPinIcon"]');
3737
});
3838

3939
it("Unpins tabs", () => {
4040
// Unpin the tab
41-
cy.get('[data-cy="PinnedTab-0"]')
41+
cy.getBySelector("PinnedTab-0")
4242
.find('[data-testid="PushPinIcon"]')
4343
.parent()
4444
.click();
4545
// Ensure it is unpinned
46-
cy.get('[data-cy="UnpinnedTab"]')
46+
cy.getBySelector("UnpinnedTab")
4747
.find('[data-testid="PushPinIcon"]')
4848
.should("not.exist");
49-
cy.get('[data-cy="UnpinnedTab"]')
49+
cy.getBySelector("UnpinnedTab")
5050
.find('[data-testid="PushPinOutlinedIcon"]')
5151
.should("exist");
5252
});
@@ -59,19 +59,19 @@ describe("Tabs actions", () => {
5959
// Pin the tab
6060
cy.get('[data-testid="PushPinOutlinedIcon"]').parent().click();
6161
// Ensure that it is pinned
62-
cy.get('[data-cy="PinnedTab-0"]')
62+
cy.getBySelector("PinnedTab-0")
6363
.find('[data-testid="PushPinIcon"]')
6464
.should("exist");
65-
cy.get('[data-cy="PinnedTab-0"]')
65+
cy.getBySelector("PinnedTab-0")
6666
.find('[data-testid="PushPinOutlinedIcon"]')
6767
.should("not.exist");
6868
// Navigate to second page
6969
cy.visit("/content");
7070
// Ensure active tab is unpinnned
71-
cy.get('[data-cy="UnpinnedTab"]')
71+
cy.getBySelector("UnpinnedTab")
7272
.find('[data-testid="PushPinIcon"]')
7373
.should("not.exist");
74-
cy.get('[data-cy="UnpinnedTab"]')
74+
cy.getBySelector("UnpinnedTab")
7575
.find('[data-testid="PushPinOutlinedIcon"]')
7676
.should("exist");
7777
// Ensure the original tab is still pinned
@@ -89,26 +89,26 @@ describe("Tabs actions", () => {
8989
cy.waitOn("/v1/web/views/11-e55790-f19nwx", () => {
9090
cy.visit("/code/file/views/11-e55790-f19nwx");
9191
});
92-
cy.get('[data-cy="PinnedTab-0"]')
92+
cy.getBySelector("PinnedTab-0")
9393
.find('[data-testid="PushPinIcon"]')
9494
.should("exist");
95-
cy.get('[data-cy="PinnedTab-0"]')
95+
cy.getBySelector("PinnedTab-0")
9696
.find('[data-testid="PushPinOutlinedIcon"]')
9797
.should("not.exist");
9898

9999
// Pin tab #2 and ensure it is pinned
100100
cy.waitOn("/launchpad", () => {
101101
cy.visit("/launchpad");
102102
});
103-
cy.get('[data-cy="UnpinnedTab"]').should("exist");
103+
cy.getBySelector("UnpinnedTab").should("exist");
104104
// Verify that the 1st pinned tab still exists
105-
cy.get('[data-cy="PinnedTab-0"]').should("exist");
105+
cy.getBySelector("PinnedTab-0").should("exist");
106106
cy.get('[data-testid="PushPinOutlinedIcon"]')
107107
.should("exist")
108108
.parent()
109109
.trigger("mouseover")
110110
.click();
111-
cy.get('[data-cy="PinnedTab-1"]')
111+
cy.getBySelector("PinnedTab-1")
112112
.find('[data-testid="PushPinIcon"]')
113113
.should("exist");
114114

@@ -118,16 +118,16 @@ describe("Tabs actions", () => {
118118
cy.waitOn("/redirects", () => {
119119
cy.visit("/redirects");
120120
});
121-
cy.get('[data-cy="UnpinnedTab"]').should("exist");
121+
cy.getBySelector("UnpinnedTab").should("exist");
122122
// Verify that the other tabs still exist
123-
cy.get('[data-cy="PinnedTab-0"]').should("exist");
124-
cy.get('[data-cy="PinnedTab-1"]').should("exist");
123+
cy.getBySelector("PinnedTab-0").should("exist");
124+
cy.getBySelector("PinnedTab-1").should("exist");
125125
cy.get('[data-testid="PushPinOutlinedIcon"]')
126126
.should("exist")
127127
.parent()
128128
.trigger("mouseover")
129129
.click();
130-
cy.get('[data-cy="PinnedTab-2"]')
130+
cy.getBySelector("PinnedTab-2")
131131
.find('[data-testid="PushPinIcon"]')
132132
.should("exist");
133133

@@ -137,16 +137,16 @@ describe("Tabs actions", () => {
137137
cy.waitOn("/leads", () => {
138138
cy.visit("/leads");
139139
});
140-
cy.get('[data-cy="UnpinnedTab"]').should("exist");
140+
cy.getBySelector("UnpinnedTab").should("exist");
141141
// Verify that the other tabs still exist
142-
cy.get('[data-cy="PinnedTab-0"]').should("exist");
143-
cy.get('[data-cy="PinnedTab-1"]').should("exist");
142+
cy.getBySelector("PinnedTab-0").should("exist");
143+
cy.getBySelector("PinnedTab-1").should("exist");
144144
cy.get('[data-testid="PushPinOutlinedIcon"]')
145145
.should("exist")
146146
.parent()
147147
.trigger("mouseover")
148148
.click();
149-
cy.get('[data-cy="PinnedTab-2"]')
149+
cy.getBySelector("PinnedTab-2")
150150
.find('[data-testid="PushPinIcon"]')
151151
.should("exist");
152152

@@ -156,72 +156,70 @@ describe("Tabs actions", () => {
156156
cy.waitOn("/media", () => {
157157
cy.visit("/media");
158158
});
159-
cy.get('[data-cy="UnpinnedTab"]').should("exist");
159+
cy.getBySelector("UnpinnedTab").should("exist");
160160
// Verify that the other tabs still exist, we only have 4 pinned tabs at this point since the other 1 will go to the dropdown menu
161-
cy.get('[data-cy="PinnedTab-0"]').should("exist");
162-
cy.get('[data-cy="PinnedTab-1"]').should("exist");
161+
cy.getBySelector("PinnedTab-0").should("exist");
162+
cy.getBySelector("PinnedTab-1").should("exist");
163163
cy.get('[data-testid="PushPinOutlinedIcon"]')
164164
.should("exist")
165165
.parent()
166166
.trigger("mouseover")
167167
.click();
168-
cy.get('[data-cy="PinnedTab-2"]')
168+
cy.getBySelector("PinnedTab-2")
169169
.find('[data-testid="PushPinIcon"]')
170170
.should("exist");
171171

172172
cy.wait(1000); // Makes sure that the pinned tabs have been properly saved to indexdb before navigating to a new url
173173

174174
// Ensure dropdown menu exists
175-
cy.get('[data-cy="TabsDropdownButton"').should("exist");
176-
cy.get('[data-cy="TabsDropdownButton"').click();
177-
cy.get('[data-cy="TabsDropdownMenu"').should("exist");
175+
cy.getBySelector("TabsDropdownButton").should("exist");
176+
cy.getBySelector("TabsDropdownButton").click();
177+
cy.getBySelector("TabsDropdownMenu").should("exist");
178178

179179
// Search pins
180-
cy.get('[data-cy="TabsDropdownMenu"')
180+
cy.getBySelector("TabsDropdownMenu")
181181
.find("input[type=text]")
182182
.type("custom");
183183

184184
// Force click outside the dropdown menu to close it
185-
cy.get('[data-cy="PinnedTab-0"').click({ force: true });
185+
cy.getBySelector("PinnedTab-0").click({ force: true });
186186

187187
// Resize the viewport and assert that the dropdown is gone
188188
cy.viewport(3440, 720);
189-
cy.get('[data-cy="TabsDropdownButton"').should("not.exist");
189+
cy.getBySelector("TabsDropdownButton").should("not.exist");
190190
});
191191

192192
it("should put a selected tab from the dropdown menu as the first tab item", () => {
193193
// Verify that all pinned topbar tabs are loaded
194-
cy.get('[data-cy="PinnedTab-0"]').should("exist");
195-
cy.get('[data-cy="PinnedTab-1"]').should("exist");
196-
cy.get('[data-cy="PinnedTab-2"]').should("exist");
197-
cy.get('[data-cy="PinnedTab-3"]').should("exist");
194+
cy.getBySelector("PinnedTab-0").should("exist");
195+
cy.getBySelector("PinnedTab-1").should("exist");
196+
cy.getBySelector("PinnedTab-2").should("exist");
197+
cy.getBySelector("PinnedTab-3").should("exist");
198198

199199
cy.viewport(1280, 720);
200+
cy.reload();
200201

201202
// Open dropdown menu
202-
cy.get('[data-cy="TabsDropdownButton"').should("exist").click();
203+
cy.getBySelector("TabsDropdownButton").should("exist").click();
203204

204205
// Search for a pinned tab
205-
cy.get('[data-cy="TabsDropdownMenu"')
206+
cy.getBySelector("TabsDropdownMenu")
206207
.find("input[type=text]")
207208
.type("bevs.csv");
208209

209210
// Click the pinned tab
210-
cy.get('[data-cy="TabsDropdownMenu"').find("a").should("exist").click();
211+
cy.getBySelector("TabsDropdownMenu").find("a").should("exist").click();
211212

212213
// Ensure that the tab was moved
213-
cy.get('[data-cy="PinnedTab-0"]').should(
214-
"have.text",
215-
"customtype/bevs.csv"
216-
);
214+
cy.getBySelector("PinnedTab-0").should("have.text", "customtype/bevs.csv");
217215
});
218216

219217
it("should put an active tab to the left when screen is resized to prevent putting it to the dropdown menu", () => {
220218
// Verify that all pinned tabs are loaded
221-
cy.get('[data-cy="PinnedTab-0"]').should("exist");
222-
cy.get('[data-cy="PinnedTab-1"]').should("exist");
223-
cy.get('[data-cy="PinnedTab-2"]').should("exist");
224-
cy.get('[data-cy="PinnedTab-3"]').should("exist");
219+
cy.getBySelector("PinnedTab-0").should("exist");
220+
cy.getBySelector("PinnedTab-1").should("exist");
221+
cy.getBySelector("PinnedTab-2").should("exist");
222+
cy.getBySelector("PinnedTab-3").should("exist");
225223

226224
cy.waitOn("/launchpad", () => {
227225
cy.visit("/launchpad");
@@ -233,9 +231,9 @@ describe("Tabs actions", () => {
233231

234232
cy.viewport(1280, 720);
235233

236-
cy.get('[data-cy="TabsDropdownButton"').should("exist");
234+
cy.getBySelector("TabsDropdownButton").should("exist");
237235

238236
// Ensure that the tab was moved to the first pinned location
239-
cy.get('[data-cy="PinnedTab-0"]').should("have.text", "Launchpad");
237+
cy.getBySelector("PinnedTab-0").should("have.text", "Launchpad");
240238
});
241239
});

0 commit comments

Comments
 (0)