Skip to content

Commit b5cf823

Browse files
author
Guillaume Chau
committed
test(e2e): more stable tests
1 parent 7bc64b5 commit b5cf823

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

cypress/integration/component-data-edit.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ suite('component data edit', () => {
44
it('should edit data using the decrease button', () => {
55
// select Instance
66
cy.get('.instance:nth-child(1) .instance:nth-child(2)').eq(0).click()
7-
cy.get('.data-field').eq(7).find('.actions .vue-ui-button').eq(1).click({ force: true }).click({ force: true })
8-
cy.get('.data-field').eq(7).should('contain', '-1', { timeout: 5000 })
7+
cy.get('.data-field').eq(7).find('.actions .vue-ui-button').eq(1).click({ force: true })
8+
cy.get('.component-state-inspector').within(() => {
9+
cy.get('.key').contains('0').parent().get('.value').contains('0')
10+
})
11+
cy.get('.data-field').eq(7).find('.actions .vue-ui-button').eq(1).click({ force: true })
12+
cy.get('.component-state-inspector').within(() => {
13+
cy.get('.key').contains('0').parent().contains('-1')
14+
})
915

1016
// expect DOM element to be updated
1117
cy.get('#target').iframe().then(({ get }) => {
@@ -16,10 +22,11 @@ suite('component data edit', () => {
1622
it('should edit data using the increase button', () => {
1723
cy.get('.instance:nth-child(1) .instance:nth-child(2)').eq(0).click()
1824
cy.get('.data-field').eq(7).find('.actions .vue-ui-button').eq(2).click({ force: true })
19-
cy.get('.data-field').eq(7).should('contain', '0', { timeout: 5000 })
25+
cy.get('.component-state-inspector').within(() => {
26+
cy.get('.key').contains('0').parent().get('.value').contains('0')
27+
})
2028

2129
// expect DOM element to be updated
22-
cy.wait(200)
2330
cy.get('#target').iframe().then(({ get }) => {
2431
get('#target div').eq(0).contains('0')
2532
})
@@ -32,10 +39,11 @@ suite('component data edit', () => {
3239
cy.get('.edit-input').type('12')
3340
cy.get('.edit-overlay > .actions > :nth-child(2) > .content > .vue-ui-icon').click()
3441

35-
cy.get('.data-field').eq(7).should('contain', '12', { timeout: 5000 })
42+
cy.get('.component-state-inspector').within(() => {
43+
cy.get('.key').contains('0').parent().get('.value').contains('12')
44+
})
3645

3746
// expect DOM element to be updated
38-
cy.wait(200)
3947
cy.get('#target').iframe().then(({ get }) => {
4048
get('#target div').eq(0).contains('12')
4149
})
@@ -49,10 +57,11 @@ suite('component data edit', () => {
4957
cy.get('.edit-overlay > .actions > :nth-child(2) > .content > .vue-ui-icon').click()
5058

5159
cy.get('.data-field').eq(6).find('.children .data-field').should('have.length', '3', { timeout: 5000 })
52-
cy.get('.data-field').eq(6).find('.children .data-field').eq(2).should('contain', 55, { timeout: 5000 })
60+
cy.get('.component-state-inspector').within(() => {
61+
cy.get('.key').contains('2').parent().get('.value').contains('55')
62+
})
5363

5464
// expect DOM element to be updated
55-
cy.wait(200)
5665
cy.get('#target').iframe().then(({ get }) => {
5766
get('#target div').eq(4).contains('55')
5867
})

cypress/integration/components-tab.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ suite('components tab', () => {
1010
})
1111

1212
it('should select instance', () => {
13-
cy.get('.instance .self').eq(0).click().then(el => {
14-
expect(el).to.have.class('selected')
15-
})
13+
cy.get('.instance .self').eq(0).click().should('have.class', 'selected')
1614
cy.get('.tree').should('be.visible')
1715
cy.get('.action-header .title').contains('Root')
1816
cy.get('.data-field').contains('$route')

cypress/integration/vuex-edit.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ suite('vuex edit', () => {
99
cy.get('.state .data-field').eq(0)
1010
.find('.actions .vue-ui-button').eq(1)
1111
.click({ force: true })
12+
13+
cy.get('.vuex-state-inspector').within(() => {
14+
cy.get('.key').contains('count').parent().contains('-1')
15+
})
16+
17+
cy.get('.state .data-field').eq(0)
18+
.find('.actions .vue-ui-button').eq(1)
1219
.click({ force: true })
1320

14-
cy.wait(200)
21+
cy.get('.vuex-state-inspector').within(() => {
22+
cy.get('.key').contains('count').parent().contains('-2')
23+
})
24+
1525
cy.get('#target').iframe().then(({ get }) => {
1626
get('#counter p').contains('-2')
1727
})
@@ -22,9 +32,19 @@ suite('vuex edit', () => {
2232
cy.get('.state .data-field').eq(0).click()
2333
.find('.actions .vue-ui-button').eq(2)
2434
.click({ force: true })
35+
36+
cy.get('.vuex-state-inspector').within(() => {
37+
cy.get('.key').contains('count').parent().contains('-1')
38+
})
39+
40+
cy.get('.state .data-field').eq(0).click()
41+
.find('.actions .vue-ui-button').eq(2)
2542
.click({ force: true })
2643

27-
cy.wait(200)
44+
cy.get('.vuex-state-inspector').within(() => {
45+
cy.get('.key').contains('count').parent().contains('0')
46+
})
47+
2848
cy.get('#target').iframe().then(({ get }) => {
2949
get('#counter p').contains('0')
3050
})

0 commit comments

Comments
 (0)