Skip to content

Commit fa185d8

Browse files
hootlexAkryum
authored andcommitted
test: vuex edit (vuejs#728)
* add vuex object elements to dev * vuex-edit tests
1 parent 9f0cf3f commit fa185d8

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

cypress/integration/components-tab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { suite } from '../utils/suite'
22

3-
const baseInstanceCount = 8
3+
const baseInstanceCount = 9
44

55
suite('components tab', () => {
66
it('should detect instances inside shadow DOM', () => {

cypress/integration/vuex-edit.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { suite } from '../utils/suite'
22

33
suite('vuex edit', () => {
4-
it('should edit state', () => {
4+
it('should edit state using the decrease button', () => {
55
cy.get('.vuex-tab').click()
66
// using the decrease button
77
cy.get('.data-field').eq(0)
@@ -12,7 +12,9 @@ suite('vuex edit', () => {
1212
cy.get('#target').iframe().then(({ get }) => {
1313
get('#counter p').contains('-2')
1414
})
15+
})
1516

17+
it('should edit state using the increase button', () => {
1618
// using the increase button
1719
cy.get('.data-field').eq(0).click()
1820
.find('.actions .vue-ui-button').eq(2)
@@ -22,7 +24,9 @@ suite('vuex edit', () => {
2224
cy.get('#target').iframe().then(({ get }) => {
2325
get('#counter p').contains('0')
2426
})
27+
})
2528

29+
it('should edit state using the edit input', () => {
2630
// using the edit input
2731
cy.get('.data-field').eq(0).click()
2832
.find('.actions .vue-ui-button').eq(0).click({ force: true })
@@ -33,7 +37,7 @@ suite('vuex edit', () => {
3337
get('#counter p').contains('12')
3438
})
3539

36-
// change count back to 1
40+
// change count back to 0
3741
cy.get('.data-field').eq(0).click()
3842
.find('.actions .vue-ui-button').eq(0).click({ force: true })
3943
cy.get('.edit-input').type('0')
@@ -43,4 +47,36 @@ suite('vuex edit', () => {
4347
get('#counter p').contains('0')
4448
})
4549
})
50+
51+
it('should edit state nested field', () => {
52+
// using the decrease button
53+
cy.get('.data-field > .children > .data-field').eq(2)
54+
.find('.actions .vue-ui-button').eq(1)
55+
.click({ force: true })
56+
.click({ force: true })
57+
58+
cy.get('#target').iframe().then(({ get }) => {
59+
get('#vuex-object pre').contains('-2')
60+
})
61+
62+
// using the increase button
63+
cy.get('.data-field > .children > .data-field').eq(2)
64+
.find('.actions .vue-ui-button').eq(2)
65+
.click({ force: true })
66+
.click({ force: true })
67+
68+
cy.get('#target').iframe().then(({ get }) => {
69+
get('#vuex-object pre').contains('0')
70+
})
71+
72+
// using the input
73+
cy.get('.data-field > .children > .data-field').eq(2)
74+
.find('.actions .vue-ui-button').eq(0).click({ force: true })
75+
cy.get('.edit-input').eq(1).type('12')
76+
cy.get('.edit-overlay > .actions > :nth-child(2) > .content > .vue-ui-icon').click()
77+
78+
cy.get('#target').iframe().then(({ get }) => {
79+
get('#vuex-object pre').contains('12')
80+
})
81+
})
4682
})

shells/dev/target/VuexObject.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div id="vuex-object">
3+
<h2>Vuex Object</h2>
4+
<pre>{{ object }}</pre>
5+
</div>
6+
</template>
7+
8+
<script>
9+
import {mapState} from 'vuex'
10+
export default {
11+
computed: {
12+
...mapState(['object'])
13+
},
14+
}
15+
</script>
16+
17+
<style scoped>
18+
19+
</style>

shells/dev/target/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import store from './store'
33
import Target from './Target.vue'
44
import Other from './Other.vue'
55
import Counter from './Counter.vue'
6+
import VuexObject from './VuexObject.vue'
67
import NativeTypes from './NativeTypes.vue'
78
import Events from './Events.vue'
89
import MyClass from './MyClass.js'
@@ -27,11 +28,12 @@ new Vue({
2728
render (h) {
2829
return h('div', null, [
2930
h(Counter),
30-
h(Target, { props: { msg: 'hi', ins: new MyClass() }}),
31+
h(Target, { props: { msg: 'hi', ins: new MyClass() } }),
3132
h(Other),
3233
h(Events, { key: 'foo' }),
3334
h(NativeTypes, { key: new Date() }),
34-
h(Router, { key: [] })
35+
h(Router, { key: [] }),
36+
h(VuexObject)
3537
])
3638
},
3739
data: {

shells/dev/target/store.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ export default new Vuex.Store({
99
date: new Date(),
1010
set: new Set(),
1111
map: new Map(),
12-
sym: Symbol('test')
12+
sym: Symbol('test'),
13+
object: {
14+
name: 'I am Object',
15+
number: 0,
16+
children: [
17+
{
18+
number: 0
19+
}
20+
]
21+
}
1322
},
1423
mutations: {
1524
INCREMENT: state => state.count++,

0 commit comments

Comments
 (0)