File size: 8,735 Bytes
4d70170 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
import { suite } from '../utils/suite'
suite('vuex tab', () => {
it('should display mutations history', () => {
cy.get('#target').iframe().then(({ get }) => {
get('.increment')
.click({ force: true })
.click({ force: true })
get('.decrement').click({ force: true })
get('#counter p').contains('1')
})
cy.get('.vuex-tab').click()
cy.get('.history .entry').should('have.length', 6)
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')
.should('contain', 'type:"DECREMENT"')
.should('contain', 'count:1')
cy.get('.history .entry').eq(5).should('have.class', 'inspected').should('have.class', 'active')
})
it('should filter state & getters', () => {
cy.get('.right .search input').clear().type('cou')
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()
})
it('should filter history', () => {
cy.get('.left .search input').clear().type('inc')
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[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[data-active="true"]').should('have.length', 5)
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 .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')
expect(el.text()).to.include('Error from getter')
})
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')
})
})
it('should time-travel', () => {
cy.get('.history .entry[data-index="4"] .entry-actions .action-time-travel').click({ force: true })
cy.get('.history .entry[data-index="4"]')
.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="3"] .mutation-type').click({ force: true })
cy.get('.history .entry[data-index="3"]')
.should('have.class', 'inspected')
.should('not.have.class', 'active')
cy.get('.history .entry[data-index="4"]')
.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[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('.history .entry[data-index="4"]')
.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[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) => {
expect(el.text()).to.include('count:0')
})
cy.get('#target').iframe().then(({ get }) => {
get('#counter p').contains('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('#target').iframe().then(({ get }) => {
get('#counter p').contains('0')
})
})
it('should revert', () => {
cy.get('.history .entry[data-index="5"] .mutation-type').click({ force: true })
cy.get('.history .entry[data-index="5"]').find('.action-revert').click({ force: true })
cy.get('.history .entry[data-active="true"]').should('have.length', 5)
cy.get('.history .entry[data-index="4"]')
.should('have.class', 'inspected')
.should('have.class', 'active')
cy.get('.vuex-state-inspector').then((el) => {
expect(el.text()).to.include('count:2')
})
cy.get('#target').iframe().then(({ get }) => {
get('#counter p').contains('2')
})
})
it('should commit', () => {
cy.get('.history .entry[data-index="4"] .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')
.should('have.class', 'active')
cy.get('.vuex-state-inspector').then((el) => {
expect(el.text()).to.include('count:2')
})
cy.get('#target').iframe().then(({ get }) => {
get('#counter p').contains('2')
})
})
it('should display getters', () => {
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').within(() => {
cy.get('.key').contains('count').parent().contains('-1')
cy.get('.key').contains('isPositive').parent().contains('false')
})
})
it('should toggle recording', () => {
cy.get('.toggle-recording')
.click()
.contains('Paused')
cy.get('.toggle-recording .svg-icon').should('not.have.class', 'enabled')
// should not record
cy.get('#target').iframe().then(({ get }) => {
get('.increment').click({ force: true })
})
cy.get('.history .entry[data-active="true"]').should('have.length', 4)
})
it('should copy vuex state', () => {
cy.get('.export').click()
cy.get('.export .message')
.contains('(Copied to clipboard!)')
.should('not.be.visible', { timeout: 5000 })
})
it('should import vuex state', () => {
cy.get('.import').click()
cy.get('.import-state').should('be.visible')
cy.get('.import-state textarea').clear().type('{{}invalid: json}')
cy.get('.message.invalid-json').should('be.visible')
cy.get('.import-state textarea').clear().type('{{}"count":42,"date":"[native Date Fri Dec 22 2017 10:12:04 GMT+0100 (CET)]","nested":{{}"foo":"meow"},"instant":{{}"hey":"hi"}}')
cy.wait(500)
cy.get('.message.invalid-json').should('not.be.visible')
cy.wait(500)
cy.get('.vuex-state-inspector').then((el) => {
expect(el.text()).to.include('count:42')
expect(el.text()).to.include(`date:${new Date('Fri Dec 22 2017 10:12:04 GMT+0100 (CET)')}`)
})
cy.get('.import').click()
cy.get('.import-state').should('not.be.visible')
})
})
|