From 3564ba77138dc00e8c22430ecd0d5334632b21cc Mon Sep 17 00:00:00 2001 From: AlitaBernachot Date: Thu, 3 Aug 2023 15:52:14 +0200 Subject: [PATCH 1/3] fix(theme-selector): on click theme in header, should open side panel and show theme selection --- cypress/e2e/header-bar.cy.ts | 51 +++++++++++++++++++ src/components/catalog/catalog-tab.vue | 14 +++-- src/components/header/header-bar.vue | 21 ++++++-- src/components/layer-panel/layer-panel.vue | 32 +++++++----- src/components/theme-selector/theme-grid.vue | 2 +- .../theme-selector/theme-selector.vue | 18 +++---- src/stores/app.store.ts | 25 +++++++++ 7 files changed, 130 insertions(+), 33 deletions(-) create mode 100644 cypress/e2e/header-bar.cy.ts diff --git a/cypress/e2e/header-bar.cy.ts b/cypress/e2e/header-bar.cy.ts new file mode 100644 index 00000000..3a55e8bb --- /dev/null +++ b/cypress/e2e/header-bar.cy.ts @@ -0,0 +1,51 @@ +describe('Header bar', () => { + beforeEach(() => { + cy.clearLocalStorage() + cy.visit('/') + }) + + describe('When clicking on the theme button', () => { + describe('When side panel is already opened', () => { + describe('When side panel is on the "My Layers" tab', () => { + it('shows the catalog tab and opens the theme grid', () => { + cy.get('[data-cy="selectedThemeIcon"]').click() + cy.get('[data-cy="themeGrid"]').should('be.visible') + }) + }) + + describe('When side panel is already on the "Catalog" tab', () => { + beforeEach(() => { + cy.get('[data-cy="catalogButton"]').click() + cy.get('[data-cy="selectedThemeIcon"]').click() + }) + + it('shows the catalog tab and opens the theme grid', () => { + cy.get('[data-cy="themeGrid"]').should('be.visible') + }) + }) + + describe('When side panel is already on the "Catalog" tab and the grid is already opened', () => { + beforeEach(() => { + cy.get('[data-cy="catalogButton"]').click() + cy.get('[data-cy="themeSelectorButton"]').click() + cy.get('[data-cy="selectedThemeIcon"]').click() + }) + + it('closes the whole side panel', () => { + cy.get('[data-cy="layerPanel"]').should('not.exist') + }) + }) + }) + + describe('When side panel is NOT opened', () => { + beforeEach(() => { + window.localStorage.setItem('layersOpen', 'false') + }) + + it('shows the catalog tab and opens the theme grid', () => { + cy.get('[data-cy="selectedThemeIcon"]').click() + cy.get('[data-cy="themeGrid"]').should('be.visible') + }) + }) + }) +}) diff --git a/src/components/catalog/catalog-tab.vue b/src/components/catalog/catalog-tab.vue index 3c728e4c..2eb1f7ef 100644 --- a/src/components/catalog/catalog-tab.vue +++ b/src/components/catalog/catalog-tab.vue @@ -1,21 +1,19 @@ diff --git a/src/components/header/header-bar.vue b/src/components/header/header-bar.vue index a3ec53bf..8030e6c3 100644 --- a/src/components/header/header-bar.vue +++ b/src/components/header/header-bar.vue @@ -10,8 +10,8 @@ import { themeSelectorService } from '../theme-selector/theme-selector.service' const { t } = useTranslation() const appStore = useAppStore() -const { layersOpen } = storeToRefs(appStore) -const { setLayersOpen } = appStore +const { layersOpen, myLayersTabOpen, themeGridOpen } = storeToRefs(appStore) +const { setLayersOpen, setMyLayersTabOpen, setThemeGridOpen } = appStore const themeStore = useThemeStore() const { theme } = storeToRefs(themeStore) @@ -24,6 +24,21 @@ watch( }, { immediate: true } ) + +function onClick() { + if (!layersOpen.value) { + setLayersOpen(true) + myLayersTabOpen.value && setMyLayersTabOpen(false) + setThemeGridOpen(true) + } else if (layersOpen.value) { + if (themeGridOpen.value) { + setLayersOpen(false) + } else { + myLayersTabOpen.value && setMyLayersTabOpen(false) + setThemeGridOpen(true) + } + } +}