forked from Ivasoft/geovisio-website
Tech add test e2e
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -90,6 +90,7 @@ sw.*
|
||||
*.swp
|
||||
|
||||
# Cypress generated screen and videos files
|
||||
cypress/downloads/*
|
||||
cypress/screenshot/
|
||||
cypress/videos/
|
||||
*.cy.ts.mp4
|
||||
@@ -8,9 +8,10 @@ variables:
|
||||
DOCKER_BUILDKIT: 1 # use buildkit for better performance
|
||||
DOCKER_DRIVER: overlay2 # better docker driver to avoid copying too many files on each run
|
||||
GITLAB_REGISTRY: registry.gitlab.com # We use docker.io for official images and gitlab's registry to store temporary images
|
||||
IMAGE_NAME: geovisio/api
|
||||
IMAGE_NAME: geovisio/website
|
||||
CI_IMAGE_CACHE: $GITLAB_REGISTRY/$IMAGE_NAME:build_cache
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DOCKER_TLS_CERTDIR: ''
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
|
||||
before_script:
|
||||
## chmod is unfortunately currently mandatory : https://github.com/nodejs/docker-node/issues/661
|
||||
@@ -22,28 +23,29 @@ cache:
|
||||
|
||||
install:
|
||||
stage: Install
|
||||
image: node:18.16.0
|
||||
image: node:18.16.1
|
||||
script:
|
||||
- yarn install
|
||||
- ls node_modules/.bin/cypress
|
||||
|
||||
test:unit:
|
||||
stage: Test
|
||||
image: node:18.16.0
|
||||
image: node:18.16.1
|
||||
script:
|
||||
- yarn test:unit
|
||||
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
|
||||
|
||||
test:e2e:
|
||||
stage: Test
|
||||
image: cypress/browsers:node-18.16.0-chrome-113.0.5672.92-1-ff-113.0-edge-113.0.1774.35-1
|
||||
image: node:18.16.1-alpine
|
||||
services:
|
||||
- docker:dind
|
||||
script:
|
||||
- yarn install
|
||||
- ./node_modules/.bin/cypress install
|
||||
- echo "VITE_API_URL=https://geovisio-proxy-dev.osc-fr1.scalingo.io/" > .env
|
||||
- echo "VITE_ENV=dev" >> .env
|
||||
- PORT=5173 yarn start &
|
||||
- yarn test:e2e
|
||||
- apk add --update --no-cache docker-cli docker-cli-compose git
|
||||
- PROJECT_DIR=$PWD docker compose -f cypress/docker-compose-geovisio.yml -f cypress/docker-compose-gitlab-override.yml run --rm e2e
|
||||
after_script:
|
||||
- PROJECT_DIR=$PWD docker compose -f cypress/docker-compose-geovisio.yml -f cypress/docker-compose-gitlab-override.yml logs web || true
|
||||
- PROJECT_DIR=$PWD docker compose -f cypress/docker-compose-geovisio.yml -f cypress/docker-compose-gitlab-override.yml down || true
|
||||
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
|
||||
artifacts:
|
||||
when: always
|
||||
@@ -54,7 +56,7 @@ test:e2e:
|
||||
|
||||
deploy:
|
||||
stage: Deploy
|
||||
image: node:18.16.0
|
||||
image: node:18.16.1
|
||||
cache:
|
||||
paths:
|
||||
- node_modules
|
||||
@@ -74,7 +76,7 @@ deploy:develop:
|
||||
stage: Deploy
|
||||
image: docker:latest
|
||||
services:
|
||||
- docker:dind
|
||||
- docker:dind
|
||||
before_script:
|
||||
# login to the gitlab docker registry to use the cache and to publish
|
||||
- echo $CI_DEPLOY_PASSWORD | docker login -u $CI_DEPLOY_USER --password-stdin $GITLAB_REGISTRY
|
||||
@@ -106,7 +108,7 @@ deploy:latest:
|
||||
stage: Deploy
|
||||
image: docker:latest
|
||||
services:
|
||||
- docker:dind
|
||||
- docker:dind
|
||||
before_script:
|
||||
# login to the gitlab docker registry to use the cache and to publish
|
||||
- echo $CI_DEPLOY_PASSWORD | docker login -u $CI_DEPLOY_USER --password-stdin $GITLAB_REGISTRY
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#- Build image
|
||||
#-
|
||||
|
||||
FROM node:18.16.0-alpine AS build
|
||||
FROM node:18.16.1-alpine AS build
|
||||
|
||||
WORKDIR /opt/geovisio
|
||||
|
||||
|
||||
@@ -12,6 +12,6 @@ export default defineConfig({
|
||||
setupNodeEvents(on, config) {
|
||||
// implement node event listeners here
|
||||
},
|
||||
baseUrl: 'http://localhost:5173'
|
||||
baseUrl: 'http://localhost:5173/'
|
||||
}
|
||||
})
|
||||
|
||||
3
cypress.env.json
Normal file
3
cypress.env.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"api_url": "http://localhost:5000/"
|
||||
}
|
||||
79
cypress/docker-compose-geovisio.yml
Normal file
79
cypress/docker-compose-geovisio.yml
Normal file
@@ -0,0 +1,79 @@
|
||||
services:
|
||||
api:
|
||||
image: geovisio/api:develop
|
||||
command: api
|
||||
restart: always
|
||||
ports:
|
||||
- 5000:5000
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
auth:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
DB_URL: postgres://gvs:gvspwd@db/geovisio
|
||||
PICTURE_PROCESS_THREADS_LIMIT: 2
|
||||
PICTURE_PROCESS_DERIVATES_STRATEGY: ON_DEMAND
|
||||
API_FORCE_AUTH_ON_UPLOAD: 'true'
|
||||
OAUTH_CLIENT_ID: geovisio
|
||||
OAUTH_CLIENT_SECRET: what_a_secret
|
||||
OAUTH_OIDC_URL: http://localhost:8183/realms/geovisio
|
||||
OAUTH_PROVIDER: oidc
|
||||
FLASK_SECRET_KEY: a_very_secret_key_never_to_be_used_in_production
|
||||
healthcheck:
|
||||
test: python -c "import requests; requests.get('http://localhost:5000/api').raise_for_status()"
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
extra_hosts:
|
||||
- 'localhost:host-gateway'
|
||||
|
||||
networks:
|
||||
db: {}
|
||||
geovisio:
|
||||
aliases:
|
||||
- api.localtest.me
|
||||
|
||||
db:
|
||||
image: postgis/postgis:13-3.2
|
||||
environment:
|
||||
- POSTGRES_USER=gvs
|
||||
- POSTGRES_PASSWORD=gvspwd
|
||||
- POSTGRES_DB=geovisio
|
||||
healthcheck:
|
||||
test: pg_isready -q -d $$POSTGRES_DB -U $$POSTGRES_USER
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
db: {}
|
||||
|
||||
auth:
|
||||
command: start-dev --import-realm
|
||||
environment:
|
||||
GEOVISIO_BASE_URL: http://localhost:5000
|
||||
GEOVISIO_CLIENT_SECRET: what_a_secret
|
||||
KEYCLOAK_ADMIN: admin
|
||||
KEYCLOAK_ADMIN_PASSWORD: password
|
||||
KEYCLOAK_FRONTEND_URL: http://localhost:5000/api/auth/login
|
||||
KC_HTTP_PORT: 8183
|
||||
ports:
|
||||
- '8183:8183'
|
||||
healthcheck:
|
||||
test: curl --fail http://localhost:8183/realms/geovisio
|
||||
timeout: 5s
|
||||
interval: 2s
|
||||
retries: 20
|
||||
start_period: 10s
|
||||
image: quay.io/keycloak/keycloak:20.0.1
|
||||
volumes:
|
||||
- ./keycloak-realm.json:/opt/keycloak/data/import/geovisio_realm.json
|
||||
|
||||
networks:
|
||||
geovisio:
|
||||
aliases:
|
||||
- keycloak.localtest.me
|
||||
|
||||
networks:
|
||||
db: {}
|
||||
geovisio: {}
|
||||
55
cypress/docker-compose-gitlab-override.yml
Normal file
55
cypress/docker-compose-gitlab-override.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
# Docker-compose used in gitlab-ci to run a container having access to all the other containers
|
||||
services:
|
||||
web:
|
||||
image: node:18.16.1-alpine
|
||||
volumes:
|
||||
- $PROJECT_DIR:/src
|
||||
working_dir: /src
|
||||
command: >
|
||||
sh -c "apk add --update --no-cache curl && yarn install && yarn start"
|
||||
environment:
|
||||
PORT: 5173
|
||||
VITE_API_URL: http://api.localtest.me:5000
|
||||
VITE_ENV: dev
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
auth:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- 5173:5173
|
||||
healthcheck:
|
||||
test: curl --fail http://0.0.0.0:5173
|
||||
timeout: 10s
|
||||
interval: 1s
|
||||
retries: 20
|
||||
start_period: 10s
|
||||
networks:
|
||||
geovisio:
|
||||
aliases:
|
||||
- front.localtest.me
|
||||
e2e:
|
||||
image: cypress/included:cypress-12.17.3-node-18.16.1-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1
|
||||
volumes:
|
||||
- $PROJECT_DIR:/src
|
||||
working_dir: /src
|
||||
environment:
|
||||
- CYPRESS_baseUrl=http://front.localtest.me:5173/
|
||||
- CYPRESS_api_url=http://api.localtest.me:5000/
|
||||
- LANG=fr
|
||||
command: sleep 2 && yarn add --dev cypress && ./node_modules/.bin/cypress install && yarn test:e2e
|
||||
depends_on:
|
||||
web:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
geovisio: {}
|
||||
|
||||
api:
|
||||
environment:
|
||||
OAUTH_OIDC_URL: http://keycloak.localtest.me:8183/realms/geovisio
|
||||
FLASK_SESSION_COOKIE_DOMAIN: localtest.me
|
||||
|
||||
auth:
|
||||
environment:
|
||||
GEOVISIO_BASE_URL: http://api.localtest.me:5000
|
||||
KEYCLOAK_FRONTEND_URL: http://api.localtest.me:5000/api/auth/login
|
||||
25
cypress/e2e/contribute.cy.ts
Normal file
25
cypress/e2e/contribute.cy.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
describe('In the contribute page', () => {
|
||||
it('go to the login page', () => {
|
||||
cy.visit('/pourquoi-contribuer')
|
||||
cy.get('.upload-text').scrollIntoView()
|
||||
cy.fixture('contribute').then((contributeData: contributeInterface) => {
|
||||
cy.contains(contributeData.textButtonContribute).click()
|
||||
})
|
||||
})
|
||||
it('go to the doc pages', () => {
|
||||
cy.visit('pourquoi-contribuer')
|
||||
cy.fixture('contribute').then((contributeData: contributeInterface) => {
|
||||
cy.get('.upload-text').scrollIntoView()
|
||||
cy.contains(contributeData.textButtonDocPython).click()
|
||||
cy.contains(contributeData.textButtonCli).click()
|
||||
cy.contains(contributeData.textButtonDocCli).click()
|
||||
cy.contains(contributeData.textButtonTiles).click()
|
||||
cy.contains(contributeData.textButtonDoc).click()
|
||||
})
|
||||
})
|
||||
})
|
||||
interface contributeInterface {
|
||||
textButtonContribute: string
|
||||
textButtonCli: string
|
||||
}
|
||||
export {}
|
||||
16
cypress/e2e/home.cy.ts
Normal file
16
cypress/e2e/home.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
describe('In the home page', () => {
|
||||
it('click on the link in the footer to go to Panoramax.fr', () => {
|
||||
cy.visit('/')
|
||||
cy.fixture('home').then((homeData) => {
|
||||
cy.contains(homeData.textLinkPanoramax).click()
|
||||
})
|
||||
})
|
||||
it('click on the link in the footer to go to Gitlab', () => {
|
||||
cy.visit('/')
|
||||
cy.fixture('home').then((homeData) => {
|
||||
cy.contains(homeData.textLinkGitlab).click()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
||||
@@ -1,7 +1,25 @@
|
||||
describe('In the login page', () => {
|
||||
it('type in the form to login', () => {
|
||||
cy.visit(`${Cypress.env('api_url')}api/auth/login`)
|
||||
cy.get('#username').type('Elysee')
|
||||
cy.get('#password').type('my password')
|
||||
cy.contains('Sign In').click()
|
||||
cy.visit('/')
|
||||
})
|
||||
it('go to the register form and create an account', () => {
|
||||
cy.visit(`${Cypress.env('api_url')}api/auth/login`)
|
||||
cy.fixture('login').then((loginData) => {
|
||||
cy.contains(loginData.textLinkRegister).click()
|
||||
cy.get('#firstName').type('Tom')
|
||||
cy.get('#lastName').type('Tom')
|
||||
cy.get('#email').type('test@test123.com')
|
||||
cy.get('#username').type('Elysee12445')
|
||||
cy.get('#password').type('my password1')
|
||||
cy.get('#password-confirm').type('my password1')
|
||||
cy.get('form').submit()
|
||||
cy.visit('/')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
||||
|
||||
9
cypress/e2e/tsconfig.json
Normal file
9
cypress/e2e/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"types": ["reflect-metadata", "jest", "cypress"],
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
8
cypress/fixtures/contribute.json
Normal file
8
cypress/fixtures/contribute.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"textButtonContribute": "Partager des images",
|
||||
"textButtonDocCli": "Voir la documentation",
|
||||
"textButtonDoc": "Retrouvez sa documentation ici",
|
||||
"textButtonDocPython": "de python (au moins la version 3.8)",
|
||||
"textButtonCli": "L'outil en ligne de commande",
|
||||
"textButtonTiles": "de tuiles vectorielles"
|
||||
}
|
||||
5
cypress/fixtures/home.json
Normal file
5
cypress/fixtures/home.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"textLinkContribute": "Pourquoi contribuer ?",
|
||||
"textLinkPanoramax": "Découvrir Panoramax",
|
||||
"textLinkGitlab": "Voir le code"
|
||||
}
|
||||
BIN
cypress/fixtures/images/image1.jpg
Normal file
BIN
cypress/fixtures/images/image1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
BIN
cypress/fixtures/images/image2.jpg
Normal file
BIN
cypress/fixtures/images/image2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
BIN
cypress/fixtures/images/image3.jpg
Normal file
BIN
cypress/fixtures/images/image3.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
4
cypress/fixtures/login.json
Normal file
4
cypress/fixtures/login.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"textLinkRegister": "Register",
|
||||
"textLinkLogin": "Sign In"
|
||||
}
|
||||
1987
cypress/keycloak-realm.json
Normal file
1987
cypress/keycloak-realm.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
"name": "geovisio-website",
|
||||
"version": "2.3.0",
|
||||
"engines": {
|
||||
"node": "18.16.0"
|
||||
"node": "18.16.1"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
@@ -42,6 +42,7 @@
|
||||
"devDependencies": {
|
||||
"@pinia/testing": "^0.1.2",
|
||||
"@rushstack/eslint-patch": "^1.1.4",
|
||||
"@types/jest": "^29.5.4",
|
||||
"@types/jsdom": "^20.0.1",
|
||||
"@types/node": "^18.11.18",
|
||||
"@typescript-eslint/eslint-plugin": "^5.46.0",
|
||||
@@ -52,12 +53,13 @@
|
||||
"@vue/eslint-config-typescript": "^11.0.0",
|
||||
"@vue/test-utils": "^2.2.4",
|
||||
"@vue/tsconfig": "^0.1.3",
|
||||
"cypress": "^12.12.0",
|
||||
"cypress": "^13.1.0",
|
||||
"eslint": "^8.29.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-import-resolver-typescript": "^3.5.5",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-vue": "^9.8.0",
|
||||
"jest": "^29.6.4",
|
||||
"jsdom": "^20.0.3",
|
||||
"less": "^4.2.0",
|
||||
"less-loader": "^11.1.3",
|
||||
|
||||
@@ -55,7 +55,7 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const titleImg = computed<string>(() =>
|
||||
props.disabled ? t('general.header.contribute_text') : ''
|
||||
props.disabled ? t('general.header.about_text') : ''
|
||||
)
|
||||
function triggerButton() {
|
||||
if (props.disabled) return
|
||||
|
||||
Reference in New Issue
Block a user