From d22e3615508b8bd60f3c44673fe54057b37893c2 Mon Sep 17 00:00:00 2001 From: Stuart Clark Date: Thu, 29 Sep 2022 10:05:33 +1000 Subject: [PATCH] chore(#81): update nuxt config and tests --- .github/workflows/test-preview.yml | 2 +- nuxt/cypress/e2e/homepage.cy.js | 14 ++++++++++++++ nuxt/nuxt.config.js | 2 +- nuxt/package.json | 4 +++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-preview.yml b/.github/workflows/test-preview.yml index 643e93a..e80ab32 100644 --- a/.github/workflows/test-preview.yml +++ b/.github/workflows/test-preview.yml @@ -61,7 +61,7 @@ jobs: run: cd nuxt && npm run test:unit - name: Generate dist ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป - run: cd nuxt && NUXT_TELEMETRY_DISABLED=1 npm run generate + run: cd nuxt && NUXT_TARGET=static NUXT_TELEMETRY_DISABLED=1 npm run generate - name: Run end-to-end tests ๐Ÿงช run: cd nuxt && npm run test:e2e diff --git a/nuxt/cypress/e2e/homepage.cy.js b/nuxt/cypress/e2e/homepage.cy.js index 5cf4cb1..4e54c56 100644 --- a/nuxt/cypress/e2e/homepage.cy.js +++ b/nuxt/cypress/e2e/homepage.cy.js @@ -3,4 +3,18 @@ it('Homepage', () => { // Given I visit the homepage. cy.visit('/') + + // Expect primary menu. + cy.get('div[blocks][name="primary_menu"]').should('exist') + .find('li').should('have.length', 1) + .first().should('contain.text', 'Home') + + // Expect secondary menu. + cy.get('div[blocks][name="secondary_menu"]').should('exist') + .find('li').should('have.length', 1) + .first().should('contain.text', 'Log in') + + // Expect empty frontpage in content block. + cy.get('div[blocks][name="content"]').should('exist') + .should('contain.text', 'No front page content has been created yet.') }) diff --git a/nuxt/nuxt.config.js b/nuxt/nuxt.config.js index 36d912a..0cceeba 100644 --- a/nuxt/nuxt.config.js +++ b/nuxt/nuxt.config.js @@ -2,7 +2,7 @@ require('dotenv').config({ path: '../.env' }) const baseUrl = process.env.BASE_URL || '' export default { - target: 'static', + target: process.env.NUXT_TARGET, // Global page headers: https://go.nuxtjs.dev/config-head head: { diff --git a/nuxt/package.json b/nuxt/package.json index 8cf00d8..0dd5e71 100644 --- a/nuxt/package.json +++ b/nuxt/package.json @@ -10,10 +10,12 @@ "lint:fix": "prettier --write --list-different . && npm run lint:js -- --fix && npm run lint:style -- --fix", "lint:js": "eslint --ext .js,.vue --ignore-path ../.gitignore .", "lint:style": "stylelint **/*.{vue,css} --ignore-path ../.gitignore", - "serve": "npm run generate && nuxt start", + "serve": "npm run build && npm start", "start": "nuxt start", "test": "npm run test:unit && npm run test:e2e", "test:e2e": "start-server-and-test serve http://localhost:3000 'npx cypress run'", + "test:e2e:dev": "start-server-and-test dev http://localhost:3000 'npx cypress open'", + "test:e2e:open": "start-server-and-test serve http://localhost:3000 'npx cypress open'", "test:unit": "jest" }, "lint-staged": {