提交 8035e4cf 编写于 作者: S Sp1ker 提交者: Guillaume Chau

fix: payload on replaying mutation, closes #773 , closes #792, closes #802 (#829)

* test(e2e): test mutation payload

* Fix payload on replaying mutation

* test(e2e): fix expect
Co-authored-by: NGuillaume Chau <guillaume.b.chau@gmail.com>
上级 ada7f58b
......@@ -23,7 +23,7 @@ suite('vuex tab', () => {
it('should filter state & getters', () => {
cy.get('.right .search input').clear().type('cou')
cy.get('.data-field').should('have.length', 1)
cy.get('.data-field').should('have.length', 2)
cy.get('.right .search input').clear().type('no value')
cy.get('.data-field').should('have.length', 0)
cy.get('.right .search input').clear()
......@@ -59,6 +59,11 @@ suite('vuex tab', () => {
expect(el.text()).to.include('type:"INCREMENT"')
expect(el.text()).to.include('count:2')
})
cy.get('.data-field .key').contains('lastCountPayload').click()
cy.get('.vuex-state-inspector').then(el => {
expect(el.text()).to.include('a:1')
expect(el.text()).to.include('b:Object')
})
cy.get('#target').iframe().then(({ get }) => {
get('#counter p').contains('1')
})
......
......@@ -7,6 +7,7 @@ export default new Vuex.Store({
state: {
inited: 0,
count: 0,
lastCountPayload: null,
date: new Date(),
set: new Set(),
map: new Map(),
......@@ -23,8 +24,14 @@ export default new Vuex.Store({
},
mutations: {
TEST_INIT: state => state.inited++,
INCREMENT: state => state.count++,
DECREMENT: state => state.count--,
INCREMENT: (state, payload) => {
state.count++
state.lastCountPayload = payload
},
DECREMENT: (state, payload) => {
state.count--
state.lastCountPayload = payload
},
UPDATE_DATE: state => {
state.date = new Date()
},
......
......@@ -146,7 +146,7 @@ export function initVuexBackend (hook, bridge) {
// Replay mutations
for (let i = snapshot.index + 1; i <= index; i++) {
const mutation = mutations[i]
mutation.handlers.forEach(handler => handler(state, mutation.payload))
mutation.handlers.forEach(handler => handler(mutation.payload))
if (i !== index && i % SharedData.cacheVuexSnapshotsEvery === 0) {
takeSnapshot(i, state)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册