add some tests

This commit is contained in:
Andreani Jean
2023-09-04 11:14:10 +02:00
parent 40f3560d94
commit 6f6e16c2c7
16 changed files with 124 additions and 2 deletions

3
cypress.env.json Normal file
View File

@@ -0,0 +1,3 @@
{
"api_url": "http://localhost:5000/"
}

25
cypress/e2e/about.cy.ts Normal file
View File

@@ -0,0 +1,25 @@
describe('In the about page', () => {
it('go to the login page', () => {
cy.visit('partager-des-photos')
cy.fixture('about').then((aboutData: aboutInterface) => {
cy.contains(aboutData.textButtonAbout).click()
})
})
it('go to the login page', () => {
cy.visit('partager-des-photos')
cy.fixture('about').then((aboutData: aboutInterface) => {
cy.contains(aboutData.textButtonAbout).click()
})
})
it('go to the cli page', () => {
cy.visit('partager-des-photos')
cy.fixture('about').then((aboutData: aboutInterface) => {
cy.contains(aboutData.textButtonCli).click()
})
})
})
interface aboutInterface {
textButtonAbout: string
textButtonCli: string
}
export {}

21
cypress/e2e/home.cy.ts Normal file
View File

@@ -0,0 +1,21 @@
describe('In the home page', () => {
it('click on the link in the header to go to the About page', () => {
cy.visit('/')
cy.fixture('home').then((homeData) => {
cy.contains(homeData.textLinkAbout).click()
cy.url().should('include', '/partager-des-photos')
})
})
it('click on the link in the header to go to the Login page', () => {
cy.visit('/')
cy.fixture('home').then((homeData) => {
cy.contains(homeData.textLinkLogin).click()
cy.url().should(
'include',
'/realms/geovisio/protocol/openid-connect/auth'
)
})
})
})
export {}

View File

@@ -1,6 +1,26 @@
describe('In the login page', () => {
it('type in the form to login', () => {
cy.visit('/')
cy.visit(`${Cypress.env('api_url')}api/auth/login`)
cy.get('#username').type('Elysee')
cy.get('#password').type('my password')
cy.fixture('upload').then((uploadData) => {
cy.contains(uploadData.textLinkLogin).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@testss.com')
cy.get('#username').type('Elysee124')
cy.get('#password').type('my password1')
cy.get('#password-confirm').type('my password1')
cy.get('form').submit()
cy.visit('/')
})
})
})

View File

@@ -0,0 +1,9 @@
{
"compilerOptions": {
"types": ["reflect-metadata", "jest", "cypress"],
"module": "commonjs",
"target": "es5",
"sourceMap": true
},
"exclude": ["node_modules"]
}

23
cypress/e2e/upload.cy.ts Normal file
View File

@@ -0,0 +1,23 @@
describe('In the login page', () => {
it('type in the form to login', () => {
cy.visit(`${Cypress.env('api_url')}api/auth/login`)
cy.fixture('upload').then((uploadData) => {
cy.get('#username').type('elysee')
cy.get('#password').type('my password')
cy.contains(uploadData.textLinkLogin).click()
cy.visit('/')
cy.contains(uploadData.textLinkUpload).click()
})
cy.get('.input-file').selectFile(
[
'cypress/fixtures/images/image1.JPG',
'cypress/fixtures/images/image2.JPG',
'cypress/fixtures/images/image3.JPG'
],
{ force: true }
)
cy.get('button[type=submit]').click()
})
})
export {}

View File

@@ -0,0 +1,4 @@
{
"textButtonAbout": "Créer un compte",
"textButtonCli": "Accéder à l'outil"
}

View File

@@ -0,0 +1,7 @@
{
"addressToSearch": "97 boulevard Voltaire 75011 paris",
"textAddressToSelect": "Boulevard Voltaire, Quartier de la Folie-Méricourt, Paris 11e Arrondissement, Paris, Île-de-France, France métropolitaine, 75011, France",
"textLinkAbout": "À propos",
"textLinkUpload": "Contribuer",
"textLinkLogin": "Connexion"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 KiB

View File

@@ -0,0 +1,3 @@
{
"textLinkRegister": "Register"
}

View File

@@ -0,0 +1,5 @@
{
"textLinkLogin": "Sign In",
"textLinkUpload": "Contribuer",
"textButtonUpload": "Déposez des photos dans la zone ou"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

View File

@@ -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",
@@ -58,6 +59,7 @@
"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",

View File

@@ -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