-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- skip test using eventBus emit, as it's not working yet - some inputs trigger a change in the base app, which doesn't exist in the test scope. - remove old spec
- Loading branch information
1 parent
ee4e60a
commit 9ccfe7a
Showing
2 changed files
with
113 additions
and
120 deletions.
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
src/fragments/forms/fields-container/components/form-fields/FormFields.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import FormFields from './FormFields.vue' | ||
import store from '@/store/store' | ||
import OrsMapFilters from '@/config/ors-map-filters' | ||
import OrsParamsParser from '@/support/map-data-services/ors-params-parser' | ||
import I18nBuilder from '@/i18n/i18n-builder' | ||
import constants from '@/resources/constants' | ||
import AppLoader from '@/app-loader' | ||
|
||
describe('<FormFields />', () => { | ||
const i18n = I18nBuilder.build() | ||
store.commit('mode', constants.modes.directions) | ||
OrsParamsParser.setFilters( | ||
{zoom: 10}, | ||
OrsMapFilters, | ||
constants.services.directions | ||
) | ||
|
||
it('renders and updates form fields', () => { | ||
// see: https://test-utils.vuejs.org/guide/ | ||
new AppLoader().fetchApiInitialData() | ||
cy.mount(FormFields, { | ||
propsData: { | ||
parameters: OrsMapFilters, | ||
parentIndex: 0 | ||
}, | ||
i18n: i18n, | ||
store: store | ||
}) | ||
cy.spy(FormFields.methods, 'fieldUpdated').as('fieldUpdatedSpy') | ||
cy.get('.form-fields') | ||
cy.get('.form-fields-autocomplete input').click() | ||
cy.get('.v-menu a').first().click() | ||
cy.get('@fieldUpdatedSpy').should('have.been.calledOnce') | ||
|
||
cy.get('.v-expansion-panel').first().click() | ||
cy.get('.multi-select input').first().click() | ||
cy.get('.multi-select').first().find('.v-menu a').eq(1).click() | ||
cy.get('@fieldUpdatedSpy').should('have.been.calledOnce') | ||
cy.get('.multi-select').first().find('.v-menu a').eq(0).click() | ||
cy.get('@fieldUpdatedSpy').should('have.been.calledOnce') | ||
}) | ||
|
||
it.skip('should react to filters changed externally', () => { | ||
new AppLoader().fetchApiInitialData() | ||
|
||
store.commit('mode', constants.modes.directions) | ||
const options = {zoom: 10} | ||
OrsParamsParser.setFilters(options, OrsMapFilters, constants.services.directions) | ||
const props = {parameters: OrsMapFilters, parentIndex: 0, level: 0} | ||
cy.mount(FormFields, {propsData: props, i18n: i18n, store: store}) | ||
cy.spy(FormFields, 'updated').as('updatedSpy') | ||
cy.get('.form-fields') | ||
// Todo: trigger eventBus emit | ||
// cy.window().its('Vue').its('eventBus').trigger('$emit','filtersChangedExternally') | ||
// cy.trigger('filtersChangedExternally') | ||
cy.get('@updatedSpy').should('have.been.called') | ||
}) | ||
|
||
it('should render form-fields with level 1', () => { | ||
new AppLoader().fetchApiInitialData() | ||
store.commit('mode', constants.modes.directions) | ||
let options = {zoom: 10} | ||
OrsParamsParser.setFilters(options, OrsMapFilters, constants.services.directions) | ||
const props = { parameters: OrsMapFilters, parentIndex: 0, level: 1 } | ||
cy.mount(FormFields, {propsData: props, i18n: i18n, store: store}) | ||
cy.get('.form-fields') | ||
}) | ||
|
||
it('should render form-fields with parent index', () => { | ||
new AppLoader().fetchApiInitialData() | ||
store.commit('mode', constants.modes.directions) | ||
let options = {zoom: 10} | ||
OrsParamsParser.setFilters(options, OrsMapFilters, constants.services.directions) | ||
const props = { parameters: OrsMapFilters[8], parentIndex: 8, level: 0 } | ||
|
||
cy.mount(FormFields, {propsData: props, i18n: i18n, store: store}) | ||
cy.get('.form-fields') | ||
}) | ||
|
||
it('should render form-fields in isochrones', () => { | ||
new AppLoader().fetchApiInitialData() | ||
store.commit('mode', constants.modes.isochrones) | ||
let options = {zoom: 10} | ||
OrsParamsParser.setFilters(options, OrsMapFilters, constants.services.directions) | ||
const props = { parameters: OrsMapFilters, parentIndex: 0, level: 0 } | ||
|
||
cy.mount(FormFields, {propsData: props, i18n: i18n, store: store}) | ||
cy.spy(FormFields, 'updated').as('updatedSpy') | ||
cy.get('.form-fields') | ||
cy.get('.v-slider input').first().as('slider') | ||
cy.get('@slider').invoke('val', '30').trigger('change') | ||
// TODO: this change triggers a change in the base app, which is not present in the test | ||
cy.get('@updatedSpy').should('have.been.called') | ||
|
||
cy.get('.form-fields-slider-text-input input[type="number"]').eq(1).as('sliderComboInput2') | ||
cy.get('@sliderComboInput2').focus() | ||
cy.get('@sliderComboInput2').invoke('val', 5).trigger('change') | ||
cy.get('@updatedSpy').should('have.been.called') | ||
}) | ||
|
||
it('should render form-fields in roundtrip', () => { | ||
new AppLoader().fetchApiInitialData() | ||
store.commit('mode', constants.modes.roundTrip) | ||
OrsParamsParser.setFilters({zoom: 10}, OrsMapFilters, constants.services.directions) | ||
const props = { parameters: OrsMapFilters, parentIndex: 0, level: 0 } | ||
|
||
cy.mount(FormFields, {propsData: props, i18n: i18n, store: store}) | ||
cy.spy(FormFields.methods, 'fieldUpdated').as('fieldUpdatedSpy') | ||
cy.get('.form-fields') | ||
cy.get('.generate-random').click() | ||
cy.get('@fieldUpdatedSpy').should('have.been.calledOnce') | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.