Skip to content

Remember initial mutations #723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/integration/components-tab.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { suite } from '../utils/suite'

const baseInstanceCount = 9
const baseInstanceCount = 10

suite('components tab', () => {
it('should detect instances inside shadow DOM', () => {
Expand Down
12 changes: 7 additions & 5 deletions cypress/integration/vuex-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { suite } from '../utils/suite'
suite('vuex edit', () => {
it('should edit state using the decrease button', () => {
cy.get('.vuex-tab').click()
cy.get('[data-id="load-vuex-state"]').click()

// using the decrease button
cy.get('.data-field').eq(0)
cy.get('.state .data-field').eq(0)
.find('.actions .vue-ui-button').eq(1)
.click({ force: true })
.click({ force: true })
Expand All @@ -17,7 +19,7 @@ suite('vuex edit', () => {

it('should edit state using the increase button', () => {
// using the increase button
cy.get('.data-field').eq(0).click()
cy.get('.state .data-field').eq(0).click()
.find('.actions .vue-ui-button').eq(2)
.click({ force: true })
.click({ force: true })
Expand All @@ -30,7 +32,7 @@ suite('vuex edit', () => {

it('should edit state using the edit input', () => {
// using the edit input
cy.get('.data-field').eq(0).click()
cy.get('.state .data-field').eq(0).click()
.find('.actions .vue-ui-button').eq(0).click({ force: true })
cy.get('.edit-input').type('12')
cy.get('.edit-overlay > .actions > :nth-child(2) > .content > .vue-ui-icon').click()
Expand All @@ -40,8 +42,8 @@ suite('vuex edit', () => {
get('#counter p').contains('12')
})

// change count back to 0
cy.get('.data-field').eq(0).click()
// change count back to 1
cy.get('.state .data-field').eq(0).click()
.find('.actions .vue-ui-button').eq(0).click({ force: true })
cy.get('.edit-input').type('0')
cy.get('.edit-overlay > .actions > :nth-child(2) > .content > .vue-ui-icon').click()
Expand Down
50 changes: 26 additions & 24 deletions cypress/integration/vuex-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ suite('vuex tab', () => {
get('#counter p').contains('1')
})
cy.get('.vuex-tab').click()
cy.get('.history .entry').should('have.length', 4)
cy.get('.history .entry').should('have.length', 5)
cy.get('[data-id="load-vuex-state"]').click()
cy.get('.recording-vuex-state').should('not.be.visible')
cy.get('.loading-vuex-state').should('not.be.visible')
cy.get('.vuex-state-inspector').then(el => {
expect(el.text()).to.include('type:"DECREMENT"')
expect(el.text()).to.include('count:1')
})
cy.get('.history .entry').eq(3).should('have.class', 'inspected').should('have.class', 'active')
cy.get('.history .entry').eq(4).should('have.class', 'inspected').should('have.class', 'active')
})

it('should filter state & getters', () => {
Expand All @@ -41,7 +41,7 @@ suite('vuex tab', () => {
cy.get('.history .entry[data-active="true"].active').should('have.length', 0)

cy.get('.left .search input').clear().type('/dec)/i')
cy.get('.history .entry[data-active="true"]').should('have.length', 3)
cy.get('.history .entry[data-active="true"]').should('have.length', 4)
cy.get('.history .entry[data-active="true"].inspected').should('have.length', 0)
cy.get('.history .entry[data-active="true"].active').should('have.length', 1)

Expand All @@ -65,19 +65,19 @@ suite('vuex tab', () => {
})

it('should time-travel', () => {
cy.get('.history .entry[data-index="2"] .entry-actions .action-time-travel').click({ force: true })
cy.get('.history .entry[data-index="2"]')
cy.get('.history .entry[data-index="3"] .entry-actions .action-time-travel').click({ force: true })
cy.get('.history .entry[data-index="3"]')
.should('have.class', 'inspected')
.should('have.class', 'active')
cy.get('#target').iframe().then(({ get }) => {
get('#counter p').contains('2')
})

cy.get('.history .entry[data-index="1"] .mutation-type').click({ force: true })
cy.get('.history .entry[data-index="1"]')
cy.get('.history .entry[data-index="2"] .mutation-type').click({ force: true })
cy.get('.history .entry[data-index="2"]')
.should('have.class', 'inspected')
.should('not.have.class', 'active')
cy.get('.history .entry[data-index="2"]')
cy.get('.history .entry[data-index="3"]')
.should('not.have.class', 'inspected')
.should('have.class', 'active')
cy.get('.recording-vuex-state').should('not.be.visible')
Expand All @@ -90,11 +90,11 @@ suite('vuex tab', () => {
cy.get('#target').iframe().then(({ get }) => {
get('#counter p').contains('2')
})
cy.get('.history .entry[data-index="1"] .entry-actions .action-time-travel').click({ force: true })
cy.get('.history .entry[data-index="1"]')
cy.get('.history .entry[data-index="2"] .entry-actions .action-time-travel').click({ force: true })
cy.get('.history .entry[data-index="2"]')
.should('have.class', 'inspected')
.should('have.class', 'active')
cy.get('.history .entry[data-index="2"]')
cy.get('.history .entry[data-index="3"]')
.should('not.have.class', 'inspected')
.should('not.have.class', 'active')
cy.get('#target').iframe().then(({ get }) => {
Expand All @@ -112,8 +112,8 @@ suite('vuex tab', () => {
cy.get('#target').iframe().then(({ get }) => {
get('#counter p').contains('1')
})
cy.get('.history .entry[data-index="0"] .entry-actions .action-time-travel').click({ force: true })
cy.get('.history .entry[data-index="0"]')
cy.get('.history .entry[data-index="1"] .entry-actions .action-time-travel').click({ force: true })
cy.get('.history .entry[data-index="1"]')
.should('have.class', 'inspected')
.should('have.class', 'active')
cy.get('#target').iframe().then(({ get }) => {
Expand All @@ -122,10 +122,10 @@ suite('vuex tab', () => {
})

it('should revert', () => {
cy.get('.history .entry[data-index="3"] .mutation-type').click({ force: true })
cy.get('.history .entry[data-index="3"]').find('.action-revert').click({ force: true })
cy.get('.history .entry[data-active="true"]').should('have.length', 3)
cy.get('.history .entry[data-index="2"]')
cy.get('.history .entry[data-index="4"] .mutation-type').click({ force: true })
cy.get('.history .entry[data-index="4"]').find('.action-revert').click({ force: true })
cy.get('.history .entry[data-active="true"]').should('have.length', 4)
cy.get('.history .entry[data-index="3"]')
.should('have.class', 'inspected')
.should('have.class', 'active')
cy.get('.vuex-state-inspector').then(el => {
Expand All @@ -137,8 +137,7 @@ suite('vuex tab', () => {
})

it('should commit', () => {
cy.get('.history .entry[data-index="2"] .mutation-type').click({ force: true })
cy.get('.history .entry[data-index="2"] .action-commit').click({ force: true })
cy.get('.history .entry[data-index="3"] .action-commit').click({ force: true })
cy.get('.history .entry[data-active="true"]').should('have.length', 1)
cy.get('.history .entry[data-index="0"]')
.should('have.class', 'inspected')
Expand All @@ -152,20 +151,23 @@ suite('vuex tab', () => {
})

it('should display getters', () => {
cy.get('.vuex-state-inspector').then(el => {
expect(el.text()).to.include('isPositive:true')
cy.get('.vuex-state-inspector').within(() => {
cy.get('.key').contains('count').parent().contains('2')
cy.get('.key').contains('isPositive').parent().contains('true')
})
cy.get('#target').iframe().then(({ get }) => {
get('.decrement')
.click({ force: true })
.click({ force: true })
.click({ force: true })
get('#counter p').contains('-1')
})
cy.get('.history .entry[data-index="3"]').click({ force: true })
cy.get('.recording-vuex-state').should('not.be.visible')
cy.get('.loading-vuex-state').should('not.be.visible')
cy.get('.vuex-state-inspector').then(el => {
expect(el.text()).to.include('isPositive:false')
cy.get('.vuex-state-inspector').within(() => {
cy.get('.key').contains('count').parent().contains('-1')
cy.get('.key').contains('isPositive').parent().contains('false')
})
})

Expand All @@ -178,7 +180,7 @@ suite('vuex tab', () => {
cy.get('#target').iframe().then(({ get }) => {
get('.increment').click({ force: true })
})
cy.get('.history .entry').should('have.length', 4)
cy.get('.history .entry').should('have.length', 5)
})

it('should copy vuex state', () => {
Expand Down
20 changes: 20 additions & 0 deletions shells/dev/target/Init.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div id="init">
<p>Inited: {{ inited }}</p>
</div>
</template>

<script>
import { mapState } from 'vuex'

export default {
computed: {
...mapState({
inited: state => state.inited
})
},
created() {
this.$store.commit('TEST_INIT')
}
}
</script>
4 changes: 3 additions & 1 deletion shells/dev/target/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Vue from 'vue'
import store from './store'
import Target from './Target.vue'
import Other from './Other.vue'
import Init from './Init.vue'
import Counter from './Counter.vue'
import VuexObject from './VuexObject.vue'
import NativeTypes from './NativeTypes.vue'
Expand Down Expand Up @@ -39,7 +40,8 @@ new Vue({
h(Events, { key: 'foo' }),
h(NativeTypes, { key: new Date() }),
h(Router, { key: [] }),
h(VuexObject)
h(VuexObject),
h(Init)
])
}
}).$mount('#app')
Expand Down
2 changes: 2 additions & 0 deletions shells/dev/target/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Vue.use(Vuex)

export default new Vuex.Store({
state: {
inited: 0,
count: 0,
date: new Date(),
set: new Set(),
Expand All @@ -21,6 +22,7 @@ export default new Vuex.Store({
}
},
mutations: {
TEST_INIT: state => state.inited++,
INCREMENT: state => state.count++,
DECREMENT: state => state.count--,
UPDATE_DATE: state => {
Expand Down
Loading