diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5fad5b1..b22903d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,36 @@ -geovisio-publish: - stage: deploy +stages: + - 'Install' + - 'Test' + - 'Deploy' + +before_script: + ## chmod is unfortunately currently mandatory : https://github.com/nodejs/docker-node/issues/661 + - npm install -g yarn@1.22.19 && chmod +x /usr/local/lib/node_modules/yarn/bin/yarn.js + +install: + stage: Install + image: node:18.13.0 + script: + - yarn install + artifacts: + name: 'artifacts' + untracked: true + expire_in: 30 mins + paths: + - .yarn/ + - node_modules/ + +test: + stage: Test + image: node:18.13.0 + script: + - yarn test:unit + dependencies: + - install + coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/ + +deploy: + stage: Deploy image: node:18.13.0 cache: paths: diff --git a/src/components/__tests__/Header.spec.js b/src/components/__tests__/Header.spec.js index dca8c1b..0995591 100644 --- a/src/components/__tests__/Header.spec.js +++ b/src/components/__tests__/Header.spec.js @@ -1,6 +1,8 @@ -import { it, test, describe, expect } from 'vitest' +import { vi, it, test, describe, expect } from 'vitest' import { mount } from '@vue/test-utils' import Header from '../Header.vue' +vi.mock('vue-router') + describe('Template Snapshot test', () => { describe('When the user is not logged', () => { it('should render the component with his childs', () => { @@ -20,7 +22,11 @@ describe('Template Snapshot test', () => { }) }) describe('When the user is logged', () => { - it('should render the component with his childs', () => { + it('should render the component with his childs', async () => { + const VueRouter = await import('vue-router') + VueRouter.useRoute.mockReturnValueOnce({ + path: 'my-path' + }) Object.defineProperty(document, 'cookie', { value: 'user_id=abc123' }) @@ -34,6 +40,11 @@ describe('Template Snapshot test', () => { template: '' } } + }, + computed: { + logoutUrl() { + return 'test' + } } }) expect(wrapper.element).toMatchSnapshot() @@ -44,6 +55,10 @@ describe('Template Snapshot test', () => { describe('Methods', () => { describe('toggleMenu', () => { test('should change menuIsClosed value', async () => { + const VueRouter = await import('vue-router') + VueRouter.useRoute.mockReturnValueOnce({ + path: 'my-path' + }) const wrapper = mount(Header, { global: { mocks: { diff --git a/src/components/__tests__/__snapshots__/Header.spec.js.snap b/src/components/__tests__/__snapshots__/Header.spec.js.snap index 0e5524a..9be4ad2 100644 --- a/src/components/__tests__/__snapshots__/Header.spec.js.snap +++ b/src/components/__tests__/__snapshots__/Header.spec.js.snap @@ -5,6 +5,24 @@ exports[`Template Snapshot test > When the user is logged > should render the co class="header" data-v-a81738bd="" > +
+

+ general.header.title + + general.beta_version + +

+
`; @@ -89,6 +153,24 @@ exports[`Template Snapshot test > When the user is not logged > should render th class="header" data-v-a81738bd="" > +
+

+ general.header.title + + general.beta_version + +

+
`; diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 4697bfd..abe1705 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -98,7 +98,7 @@ onMounted(async () => { } @media (max-width: 500px) { .entry-page { - padding-top: 12rem; + padding-top: 11rem; } .entry-viewer { min-height: -webkit-fill-available;