Skip to content

Refactor vuex snapshots #721

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 14 commits into from
Aug 1, 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
Original file line number Diff line number Diff line change
Expand Up @@ -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('<eventchild1>')
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)
})
})
76 changes: 43 additions & 33 deletions cypress/integration/vuex.tab.js → cypress/integration/vuex-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ 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('.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: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', () => {
Expand All @@ -28,28 +31,30 @@ 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('.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:"INCREMENT"')
expect(el.text()).to.include('count:2')
Expand All @@ -60,42 +65,45 @@ 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('.recording-vuex-state').should('not.be.visible')
cy.get('.loading-vuex-state').should('not.be.visible')
cy.get('.recording-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')
})
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 }) => {
get('#counter p').contains('1')
})

// 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 => {
Expand All @@ -104,8 +112,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 }) => {
Expand All @@ -114,10 +122,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 => {
Expand All @@ -129,10 +137,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 => {
Expand All @@ -153,7 +161,9 @@ 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('.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')
})
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@
"circular-json-es6": "^2.0.1",
"lodash.debounce": "^4.0.8",
"lodash.groupby": "^4.6.0",
"lru-cache": "^4.1.3",
"uglifyjs-webpack-plugin": "^1.1.4",
"vue": "^2.5.13",
"vue-router": "^3.0.1",
"vue-virtual-scroller": "^0.12.0",
"vuex": "^3.0.1"
},
"devDependencies": {
Expand Down
12 changes: 12 additions & 0 deletions shells/dev/target/Counter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<button class="increment" @click="increment">+1</button>
<button class="decrement" @click="decrement">-1</button>

<br>

<button @click="doLotMutations">Do a lot of mutations</button>

<p>Your counter is {{ $store.getters.isPositive ? 'positive' : 'negative' }}</p>
</div>
</template>
Expand All @@ -30,6 +34,14 @@ export default {
},
decrement () {
this.$store.commit('DECREMENT', 2)
},
doLotMutations () {
for (let i = 0; i < 10000; i++) {
this.increment()
}
for (let i = 0; i < 10000; i++) {
this.decrement()
}
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion shells/dev/target/EventChild.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
<div>
<button class="btn-emit-event" @click="emitEvent">Emit</button>
<button class="btn-emit-event1" @click="emitEvent1">Emit</button>
<button class="btn-emit-event2" @click="emitEvent2">Emit</button>
<button class="btn-emit-event2" @click="emitEvent2">Emit</button>

<br>

<button @click="emitManyEvents">Emit a lot of events</button>
</div>
</template>

Expand Down Expand Up @@ -35,6 +39,12 @@ export default {
}
}
this.$emit('event-2', complexData)
},

emitManyEvents () {
for (let i = 0; i < 10000; i++) {
this.$emit('event', i)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion shells/dev/target/Events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default {
},
methods: {
log (data) {
console.log('Event fired from child component with data', data)
// console.log('Event fired from child component with data', data)
}
}
}
Expand Down
Loading