diff --git a/cypress/integration/events.tab.js b/cypress/integration/events-tab.js similarity index 81% rename from cypress/integration/events.tab.js rename to cypress/integration/events-tab.js index 92af80a01a..e731615fe0 100644 --- a/cypress/integration/events.tab.js +++ b/cypress/integration/events-tab.js @@ -25,11 +25,11 @@ suite('events tab', () => { it('should search events', () => { cy.get('.left .search input').clear().type('event') - cy.get('.history .entry').should('have.length', 3) + cy.get('.history .entry[data-active="true"]').should('have.length', 3) cy.get('.left .search input').clear().type('') - cy.get('.history .entry').should('have.length', 1) + cy.get('.history .entry[data-active="true"]').should('have.length', 1) cy.get('.left .search input').clear() cy.get('.button.reset').click() - cy.get('.history .entry').should('have.length', 0) + cy.get('.history .entry[data-active="true"]').should('have.length', 0) }) }) diff --git a/cypress/integration/vuex.tab.js b/cypress/integration/vuex-tab.js similarity index 66% rename from cypress/integration/vuex.tab.js rename to cypress/integration/vuex-tab.js index c97b914d53..776dc65070 100644 --- a/cypress/integration/vuex.tab.js +++ b/cypress/integration/vuex-tab.js @@ -11,11 +11,13 @@ suite('vuex tab', () => { }) cy.get('.vuex-tab').click() cy.get('.history .entry').should('have.length', 4) + cy.get('[data-id="load-vuex-state"]').click() + 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:nth-child(4)').should('have.class', 'inspected').should('have.class', 'active') + cy.get('.history .entry').eq(3).should('have.class', 'inspected').should('have.class', 'active') }) it('should filter state & getters', () => { @@ -28,28 +30,29 @@ suite('vuex tab', () => { it('should filter history', () => { cy.get('.left .search input').clear().type('inc') - cy.get('.history .entry').should('have.length', 3) - cy.get('.history .entry.inspected').should('have.length', 1) - cy.get('.history .entry.active').should('have.length', 0) + cy.get('.history .entry[data-active="true"]').should('have.length', 2) + cy.get('.history .entry[data-active="true"].inspected').should('have.length', 0) + 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').should('have.length', 2) - cy.get('.history .entry.inspected').should('have.length', 1) - cy.get('.history .entry.active').should('have.length', 0) + cy.get('.history .entry[data-active="true"]').should('have.length', 1) + cy.get('.history .entry[data-active="true"].inspected').should('have.length', 0) + 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').should('have.length', 4) - cy.get('.history .entry.inspected').should('have.length', 1) - cy.get('.history .entry.active').should('have.length', 1) + cy.get('.history .entry[data-active="true"]').should('have.length', 3) + cy.get('.history .entry[data-active="true"].inspected').should('have.length', 0) + cy.get('.history .entry[data-active="true"].active').should('have.length', 1) cy.get('.left .search input').clear() }) it('should inspect state', () => { - cy.get('.history .entry:nth-child(3) .mutation-type').click() - cy.get('.history .entry:nth-child(3)') + cy.get('.history .entry .mutation-type').eq(2).click() + cy.get('.history .entry').eq(2) .should('have.class', 'inspected') .should('not.have.class', 'active') + cy.get('.loading-vuex-state').should('not.be.visible') cy.get('.vuex-state-inspector').then(el => { expect(el.text()).to.include('type:"INCREMENT"') expect(el.text()).to.include('count:2') @@ -60,21 +63,22 @@ suite('vuex tab', () => { }) it('should time-travel', () => { - cy.get('.history .entry:nth-child(3) .entry-actions .action:nth-child(3)').click({ force: true }) - cy.get('.history .entry:nth-child(3)') + cy.get('.history .entry[data-index="2"] .entry-actions .action:nth-child(3)').click({ force: true }) + cy.get('.history .entry[data-index="2"]') .should('have.class', 'inspected') .should('have.class', 'active') cy.get('#target').iframe().then(({ get }) => { get('#counter p').contains('2') }) - cy.get('.history .entry:nth-child(2) .mutation-type').click({ force: true }) - cy.get('.history .entry:nth-child(2)') + cy.get('.history .entry[data-index="1"] .mutation-type').click({ force: true }) + cy.get('.history .entry[data-index="1"]') .should('have.class', 'inspected') .should('not.have.class', 'active') - cy.get('.history .entry:nth-child(3)') + cy.get('.history .entry[data-index="2"]') .should('not.have.class', 'inspected') .should('have.class', 'active') + cy.get('.loading-vuex-state').should('not.be.visible') cy.get('.vuex-state-inspector').then(el => { expect(el.text()).to.include('type:"INCREMENT"') expect(el.text()).to.include('count:1') @@ -82,11 +86,11 @@ suite('vuex tab', () => { cy.get('#target').iframe().then(({ get }) => { get('#counter p').contains('2') }) - cy.get('.history .entry:nth-child(2) .entry-actions .action:nth-child(3)').click({ force: true }) - cy.get('.history .entry:nth-child(2)') + cy.get('.history .entry[data-index="1"] .entry-actions .action:nth-child(3)').click({ force: true }) + cy.get('.history .entry[data-index="1"]') .should('have.class', 'inspected') .should('have.class', 'active') - cy.get('.history .entry:nth-child(3)') + cy.get('.history .entry[data-index="2"]') .should('not.have.class', 'inspected') .should('not.have.class', 'active') cy.get('#target').iframe().then(({ get }) => { @@ -94,8 +98,8 @@ suite('vuex tab', () => { }) // Base state - cy.get('.history .entry:nth-child(1) .mutation-type').click({ force: true }) - cy.get('.history .entry:nth-child(1)') + cy.get('.history .entry[data-index="0"] .mutation-type').click({ force: true }) + cy.get('.history .entry[data-index="0"]') .should('have.class', 'inspected') .should('not.have.class', 'active') cy.get('.vuex-state-inspector').then(el => { @@ -104,8 +108,8 @@ suite('vuex tab', () => { cy.get('#target').iframe().then(({ get }) => { get('#counter p').contains('1') }) - cy.get('.history .entry:nth-child(1) .entry-actions .action:nth-child(1)').click({ force: true }) - cy.get('.history .entry:nth-child(1)') + cy.get('.history .entry[data-index="0"] .entry-actions .action:nth-child(1)').click({ force: true }) + cy.get('.history .entry[data-index="0"]') .should('have.class', 'inspected') .should('have.class', 'active') cy.get('#target').iframe().then(({ get }) => { @@ -114,10 +118,10 @@ suite('vuex tab', () => { }) it('should revert', () => { - cy.get('.history .entry:nth-child(4) .mutation-type').click({ force: true }) - cy.get('.history .entry:nth-child(4) .action:nth-child(2)').click({ force: true }) - cy.get('.history .entry').should('have.length', 3) - cy.get('.history .entry:nth-child(3)') + cy.get('.history .entry[data-index="3"] .mutation-type').click({ force: true }) + cy.get('.history .entry[data-index="3"]').find('.action:nth-child(2)').click({ force: true }) + cy.get('.history .entry[data-active="true"]').should('have.length', 3) + cy.get('.history .entry[data-index="2"]') .should('have.class', 'inspected') .should('have.class', 'active') cy.get('.vuex-state-inspector').then(el => { @@ -129,10 +133,10 @@ suite('vuex tab', () => { }) it('should commit', () => { - cy.get('.history .entry:nth-child(3) .mutation-type').click({ force: true }) - cy.get('.history .entry:nth-child(3) .action:nth-child(1)').click({ force: true }) - cy.get('.history .entry').should('have.length', 1) - cy.get('.history .entry:nth-child(1)') + cy.get('.history .entry[data-index="2"] .mutation-type').click({ force: true }) + cy.get('.history .entry[data-index="2"] .action:nth-child(1)').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') .should('have.class', 'active') cy.get('.vuex-state-inspector').then(el => { @@ -153,7 +157,8 @@ suite('vuex tab', () => { .click({ force: true }) .click({ force: true }) }) - cy.get('.history .entry:nth-child(4)').click({ force: true }) + cy.get('.history .entry[data-index="3"]').click({ force: true }) + cy.get('.loading-vuex-state').should('not.be.visible') cy.get('.vuex-state-inspector').then(el => { expect(el.text()).to.include('isPositive:false') }) diff --git a/shells/dev/target/Counter.vue b/shells/dev/target/Counter.vue index ff0a205176..2b2105323e 100644 --- a/shells/dev/target/Counter.vue +++ b/shells/dev/target/Counter.vue @@ -6,7 +6,7 @@
- +

Your counter is {{ $store.getters.isPositive ? 'positive' : 'negative' }}

diff --git a/src/devtools/index.js b/src/devtools/index.js index 6054eb713e..81159d8f26 100644 --- a/src/devtools/index.js +++ b/src/devtools/index.js @@ -140,7 +140,10 @@ function initApp (shell) { bridge.on('vuex:inspected-state', ({ index, snapshot }) => { snapshotsCache.set(index, snapshot) - store.commit('vuex/UPDATE_INSPECTED_STATE', snapshot) + store.commit('vuex/RECEIVE_STATE', snapshot) + if (store.state.vuex.inspectedIndex === index) { + store.commit('vuex/UPDATE_INSPECTED_STATE', snapshot) + } if (VuexResolve.travel) { VuexResolve.travel(snapshot) diff --git a/src/devtools/views/events/EventsHistory.vue b/src/devtools/views/events/EventsHistory.vue index 650d751383..7064fd1735 100644 --- a/src/devtools/views/events/EventsHistory.vue +++ b/src/devtools/views/events/EventsHistory.vue @@ -53,10 +53,11 @@ > No events found
(Recording is paused)
-