Quellcode durchsuchen

add multi env support and update CI

Olivier Massot vor 4 Jahren
Ursprung
Commit
6449cd82c9
6 geänderte Dateien mit 20 neuen und 16 gelöschten Zeilen
  1. 2 0
      .env.ci
  2. 2 0
      .env.local
  3. 5 6
      .gitlab-ci.yml
  4. 4 6
      nuxt.config.js
  5. 2 1
      package.json
  6. 5 3
      test/cypress/integration/structures/index.spec.js

+ 2 - 0
.env.ci

@@ -0,0 +1,2 @@
+SSR_API_BASE_URL = https://api.preprod.opentalent.fr
+CLIENT_API_BASE_URL = https://api.preprod.opentalent.fr

+ 2 - 0
.env.local

@@ -0,0 +1,2 @@
+SSR_API_BASE_URL = http://nginx
+CLIENT_API_BASE_URL = https://local.api.opentalent.fr

+ 5 - 6
.gitlab-ci.yml

@@ -1,6 +1,5 @@
 # @see https://docs.cypress.io/guides/continuous-integration/gitlab-ci
 # Consult the results on the Cypress dashboard: https://dashboard.cypress.io/
-
 stages:
   - build
   - test
@@ -24,16 +23,16 @@ install:
   stage: build
   script:
     - yarn install --dev
-    # check Cypress binary path and cached versions
     - npx cypress cache path
     - npx cypress cache list
+    - yarn build:ci
 
 chrome:
   image: cypress/browsers:node14.17.0-chrome88-ff89
   stage: test
   parallel: 5
   script:
-    - yarn dev & npx wait-on http://localhost:3004
+    - yarn ci & npx wait-on http://localhost:3004
     - yarn cypress:silent --record --parallel --browser chrome --group "Chrome"
 
 chrome-mobile:
@@ -41,7 +40,7 @@ chrome-mobile:
   stage: test
   parallel: 5
   script:
-    - yarn dev & npx wait-on http://localhost:3004
+    - yarn ci & npx wait-on http://localhost:3004
     - yarn cypress:silent --record --parallel --browser chrome --group "Chrome - Mobile" --config "viewportWidth=375,viewportHeight=667"
 
 firefox:
@@ -49,7 +48,7 @@ firefox:
   stage: test
   parallel: 5
   script:
-    - yarn dev & npx wait-on http://localhost:3004
+    - yarn ci & npx wait-on http://localhost:3004
     - yarn cypress:silent --record --parallel --browser firefox --group "Firefox"
 
 firefox-mobile:
@@ -57,5 +56,5 @@ firefox-mobile:
   stage: test
   parallel: 5
   script:
-    - yarn dev & npx wait-on http://localhost:3004
+    - yarn ci & npx wait-on http://localhost:3004
     - yarn cypress:silent --record --parallel --browser firefox --group "Firefox - Mobile" --config "viewportWidth=375,viewportHeight=667"

+ 4 - 6
nuxt.config.js

@@ -102,16 +102,14 @@ export default {
 
   // Env
   publicRuntimeConfig: {
-    baseURL: process.env.NODE_ENV === 'production' ? 'https://local.api.opentalent.fr' : 'https://local.api.opentalent.fr',
+    baseURL: process.env.CLIENT_API_BASE_URL,
     axios: {
       https: true,
-      browserBaseURL: process.env.NODE_ENV === 'production' ? 'https://local.api.opentalent.fr' : 'https://local.api.opentalent.fr'
+      browserBaseURL: process.env.CLIENT_API_BASE_URL
     }
   },
   privateRuntimeConfig: {
-    baseURL: process.env.NODE_ENV === 'production' ? 'https://local.api.opentalent.fr' : 'http://nginx',
-    axios: {
-      baseURL: process.env.NODE_ENV === 'production' ? 'https://local.api.opentalent.fr' : 'http://nginx'
-    }
+    baseURL: process.env.SSR_API_BASE_URL,
+    axios: { baseURL: process.env.SSR_API_BASE_URL }
   }
 }

+ 2 - 1
package.json

@@ -3,7 +3,8 @@
   "version": "0.2.0",
   "private": true,
   "scripts": {
-    "dev": "nuxt --hostname '0.0.0.0' --port 3004",
+    "dev": "nuxt --hostname '0.0.0.0' --port 3004 --dotenv .env.local",
+    "ci": "nuxt --hostname '0.0.0.0' --port 3004 --dotenv .env.ci",
     "build": "nuxt build",
     "start": "nuxt start",
     "generate": "nuxt generate",

+ 5 - 3
test/cypress/integration/structures/index.spec.js

@@ -68,15 +68,17 @@ describe('Test the /structures page', () => {
       .should('have.length', 8)
 
     // 8 pages are displayed in the pagination bar (max authorized)
-    cy.get('.v-pagination')
-      .find('button.v-pagination__item')
+    cy.get('.pagination')
+      .find('button')
+      .filter((_, elt) => { return /\d+/.match(elt.innerText) })
       .should('have.length.gte', 2)
 
     cy.getByLabel('input', 'Quoi ?').type('some long text that will hopefully match no result')
     cy.contains('Rechercher').click()
 
     cy.get('.v-pagination')
-      .find('button.v-pagination__item')
+      .find('button')
+      .filter((_, elt) => { return /\d+/.match(elt.innerText) })
       .should('have.length', 1)
   })