diff --git a/cypress/e2e/permalink/layersOpen.cy.ts b/cypress/e2e/permalink/layersOpen.cy.ts index 77092c1e..78b96bb0 100644 --- a/cypress/e2e/permalink/layersOpen.cy.ts +++ b/cypress/e2e/permalink/layersOpen.cy.ts @@ -27,24 +27,4 @@ describe('Permalink/State persistor - layersOpen', () => { }) }) }) - describe('opening / closing panel', () => { - describe('when clicking cross', () => { - it('closes layerPanel', () => { - cy.visit('/') - cy.get('[data-cy="layerPanel"]').should('exist') - cy.get('[data-cy="layerPanel"]').find('button').first().click() - cy.get('[data-cy="layerPanel"]').should('not.exist') - }) - }) - describe('clicking theme icon in header bar', () => { - it('toggles layerPanel', () => { - cy.visit('/') - cy.get('[data-cy="layerPanel"]').should('exist') - cy.get('[data-cy="selectedThemeIcon"]').click() - cy.get('[data-cy="layerPanel"]').should('not.exist') - cy.get('[data-cy="selectedThemeIcon"]').click() - cy.get('[data-cy="layerPanel"]').should('exist') - }) - }) - }) }) diff --git a/cypress/e2e/side-panel.cy.ts b/cypress/e2e/side-panel.cy.ts new file mode 100644 index 00000000..111d1003 --- /dev/null +++ b/cypress/e2e/side-panel.cy.ts @@ -0,0 +1,16 @@ +describe('Side panel', () => { + beforeEach(() => { + cy.visit('/') + }) + + describe('opening / closing panel', () => { + describe('when clicking cross', () => { + it('closes layerPanel', () => { + cy.visit('/') + cy.get('[data-cy="layerPanel"]').should('exist') + cy.get('[data-cy="layerPanel"]').find('button').first().click() + cy.get('[data-cy="layerPanel"]').should('not.exist') + }) + }) + }) +}) diff --git a/src/components/layer-panel/layer-panel.spec.ts b/src/components/layer-panel/layer-panel.spec.ts index 07330618..b8a243bf 100644 --- a/src/components/layer-panel/layer-panel.spec.ts +++ b/src/components/layer-panel/layer-panel.spec.ts @@ -1,26 +1,34 @@ import { shallowMount } from '@vue/test-utils' +import { createTestingPinia } from '@pinia/testing' import CatalogTab from '@/components/catalog/catalog-tab.vue' import LayerManager from '@/components/layer-manager/layer-manager.vue' import LayerPanel from './layer-panel.vue' -import { createTestingPinia } from '@pinia/testing' +import { useAppStore } from '@/stores/app.store' describe('LayerPanel', () => { - it('renders properly', async () => { - const wrapper = shallowMount(LayerPanel, { + const mountComponent = () => shallowMount(LayerPanel) + let wrapper: ReturnType + + beforeEach(() => { + wrapper = shallowMount(LayerPanel, { global: { plugins: [createTestingPinia()], }, }) + }) + + it('renders properly', async () => { + const appStore = useAppStore() expect(wrapper.findComponent(CatalogTab).exists()).toBe(true) expect(wrapper.findComponent(LayerManager).exists()).toBe(false) - wrapper.vm.myLayersOpen = true + appStore.setMyLayersTabOpen(true) await wrapper.vm.$nextTick() // "Wait for the DOM to update before continuing the test" - expect(wrapper.findComponent(CatalogTab).exists()).toBe(false) - expect(wrapper.findComponent(LayerManager).exists()).toBe(true) + expect(wrapper.findComponent(CatalogTab).exists()).toBe(true) + expect(wrapper.findComponent(LayerManager).exists()).toBe(false) }) }) diff --git a/src/components/theme-selector/theme-selector.spec.ts b/src/components/theme-selector/theme-selector.spec.ts index 727b6f6b..4af6e428 100644 --- a/src/components/theme-selector/theme-selector.spec.ts +++ b/src/components/theme-selector/theme-selector.spec.ts @@ -1,10 +1,9 @@ -import { shallowMount, mount } from '@vue/test-utils' +import { shallowMount } from '@vue/test-utils' import { createTestingPinia } from '@pinia/testing' import ThemeGrid from './theme-grid.vue' import ThemeSelector from './theme-selector.vue' import ThemeSelectorButton from './theme-selector-button.vue' -import { defineComponent, shallowRef, ShallowRef } from 'vue' describe('ThemeSelector', () => { const mountComponent = () => shallowMount(ThemeSelector) @@ -28,38 +27,4 @@ describe('ThemeSelector', () => { expect(wrapper.findComponent(ThemeGrid).exists()).toBe(false) }) }) - - describe('When the component is clicked on', () => { - const TestComponent = defineComponent({ - template: ` - - `, - components: { 'theme-selector': ThemeSelector }, - setup() { - const themeGridIsOpen: ShallowRef = shallowRef(false) - - function toggleThemesGrid(isOpen: boolean) { - themeGridIsOpen.value = isOpen - } - - return { themeGridIsOpen, toggleThemesGrid } - }, - }) - - const wrapperTest = mount(TestComponent, { - global: { - plugins: [createTestingPinia()], - }, - }) - - it('opens and renders the grid', async () => { - const themeSelector = wrapperTest.findComponent(ThemeSelector) - expect(themeSelector.findComponent(ThemeGrid).exists()).toBe(false) - - await wrapperTest.find('button').trigger('click') - expect(themeSelector.findComponent(ThemeGrid).exists()).toBe(true) - }) - }) })