Skip to content

Commit 79742da

Browse files
committed
Fix tests for Cypress 12
State no longer persists between `it()`s
1 parent 7eae303 commit 79742da

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

tests/e2e/specs/drawer.cy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('Drawer component', () => {
2323
.should('be.visible')
2424
})
2525
it('it should have a width of 260', () => {
26+
cy.visit('/#/')
2627
cy.get('.v-navigation-drawer').invoke('innerWidth').should('be.eq', 260)
2728
})
2829
it('Is NOT displayed when mode is mobile', () => {

tests/e2e/specs/menu.cy.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ describe('CylcObject Menu component', () => {
1919
const collapsedWorkflowMenuLength = 6 // (5 mutations + "show more" btn)
2020
const expandedWorkflowMenuLength = 21
2121

22-
it('should not be displayed initially on load', () => {
22+
beforeEach(() => {
2323
cy.visit('/#/workspace/one')
24+
})
25+
26+
it('should not be displayed initially on load', () => {
2427
cy.get('.c-interactive:first') // wait for view to load
2528
.get('.c-mutation-menu:first')
2629
.should('not.exist')
@@ -38,24 +41,22 @@ describe('CylcObject Menu component', () => {
3841
.should('be.visible')
3942
})
4043

41-
it('expands when "show more" is clicked', () => {
42-
cy.get('#less-more-button')
44+
it('expands and collapses', () => {
45+
cy.get('#workflow-mutate-button.c-interactive')
46+
.click()
47+
.get('#less-more-button')
4348
.click()
4449
.get('.c-mutation-menu-list')
4550
.should('be.visible')
4651
.children()
4752
.should('have.length', expandedWorkflowMenuLength)
48-
})
49-
50-
it('closes when clicking outside of the menu', () => {
51-
// Click on hidden element to avoid clicking on anything unexpected
53+
// Should close when clicking outside of the menu
54+
// (click on hidden element to avoid clicking on anything unexpected)
5255
cy.get('noscript')
5356
.click({ force: true })
5457
.get('.c-mutation-menu-list:first')
5558
.should('not.be.visible')
56-
})
57-
58-
it('should be collapsed next time it is opened', () => {
59+
// Should be collapsed next time it is opened
5960
cy.get('#workflow-mutate-button')
6061
.click()
6162
.get('.c-mutation-menu-list')
@@ -66,8 +67,7 @@ describe('CylcObject Menu component', () => {
6667

6768
it('updates when clicking on a different Cylc object', () => {
6869
let firstID
69-
cy.visit('/#/workspace/one')
70-
.get('.node-data-cycle:first')
70+
cy.get('.node-data-cycle:first')
7171
.find('.c-interactive:first')
7272
.click()
7373
.get('.c-mutation-menu')
@@ -88,14 +88,15 @@ describe('CylcObject Menu component', () => {
8888
})
8989
})
9090

91-
it('should not close when clicking inside menu', () => {
91+
it('only closes when appropriate if clicking inside menu', () => {
92+
cy.get('#workflow-mutate-button.c-interactive')
93+
.click()
94+
// Should not close when clicking on non-interactive thing inside menu
9295
cy.get('.v-card__title')
9396
.click()
9497
.get('.c-mutation-menu')
9598
.should('be.visible')
96-
})
97-
98-
it('closes when clicking on task mutation', () => {
99+
// Should close when clicking on task mutation
99100
cy.get('.c-mutation-menu-list')
100101
.find('.c-mutation:not([aria-disabled]):first')
101102
.click()

tests/e2e/specs/workspace.cy.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616
*/
1717

1818
describe('Workspace view and component/widget', () => {
19+
beforeEach(() => {
20+
cy.visit('/#/workspace/one')
21+
})
22+
1923
afterEach(() => {
2024
cy
2125
.get('.v-alert')
2226
.should('not.exist')
2327
})
2428

2529
it('Should display the Lumino component in the Workspace view, with a Tree widget', () => {
26-
cy.visit('/#/workspace/one')
2730
cy.get('.lm-TabBar-tabLabel').should('have.length', 1)
2831

2932
// The skeleton loader should stop existing
@@ -40,22 +43,18 @@ describe('Workspace view and component/widget', () => {
4043
})
4144

4245
it('Should remove the default widget and leave no more widgets', () => {
43-
cy.visit('/#/workspace/one')
4446
cy.get('.lm-TabBar-tabCloseIcon').click()
4547
cy.get('.lm-TabBar-tabLabel').should('not.exist')
4648
})
4749

4850
it('Should be able to add two widgets of the same type', () => {
49-
cy.visit('/#/workspace/one')
5051
cy.get('.lm-TabBar-tabLabel').should('have.length', 1)
5152
cy.get('a.add-view').click()
5253
cy.get('#toolbar-add-Tree-view').click()
5354
cy.get('.lm-TabBar-tabLabel').should('have.length', 2)
5455
})
5556

5657
it('Should be able to add two widgets of different types', () => {
57-
cy.visit('/#/workspace/one')
58-
5958
// there should be one widget open by default (tree)
6059
cy.get('.lm-TabBar-tabLabel')
6160
// there should be a tab representing the widget
@@ -80,21 +79,21 @@ describe('Workspace view and component/widget', () => {
8079
})
8180

8281
it('Should remove widgets added successfully', () => {
83-
cy.visit('/#/workspace/one')
8482
cy.get('.lm-TabBar-tabLabel').should('have.length', 1)
8583
// add a tree view
8684
cy.get('a.add-view').click()
8785
cy.get('#toolbar-add-Tree-view').click()
8886
// ensure we have 2 widgets now
8987
cy.get('.lm-TabBar-tabLabel').should('have.length', 2)
9088
// close all widgets
91-
cy.get('.lm-TabBar-tabCloseIcon').click({ multiple: true })
89+
cy.get('.lm-TabBar-tabCloseIcon').each(($el) => {
90+
cy.wrap($el).click()
91+
})
9292
// ensure we have no widgets now
9393
cy.get('.lm-TabBar-tabLabel').should('not.exist')
9494
})
9595

9696
it('Should remove widgets when leaving the Workspace view', () => {
97-
cy.visit('/#/workspace/one')
9897
cy.get('.lm-TabBar-tabLabel').should('have.length', 1)
9998
// add a tree view
10099
cy.get('a.add-view').click()
@@ -107,7 +106,6 @@ describe('Workspace view and component/widget', () => {
107106
})
108107

109108
it('Should remove widgets when updating the Workspace view', () => {
110-
cy.visit('/#/workspace/one')
111109
cy.get('.lm-TabBar-tabLabel').should('have.length', 1)
112110
// add a tree view
113111
cy.get('a.add-view').click()

0 commit comments

Comments
 (0)