Skip to content

Commit

Permalink
Run prettier on all frontend code
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashbrnrd committed Jun 10, 2024
1 parent 4eb864f commit a83d580
Show file tree
Hide file tree
Showing 84 changed files with 2,470 additions and 2,204 deletions.
46 changes: 22 additions & 24 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
require("@rushstack/eslint-patch/modern-module-resolution");

module.exports = {
root: true,
extends: [
'eslint:recommended',
"eslint:recommended",
// 'standard-with-typescript', // À décommenter quand le code sera typé
'standard',
'@vue/eslint-config-typescript',
'plugin:vue/vue3-recommended',
'./.eslintrc-auto-import.json',
"prettier"
],
plugins: [
'vue',
"standard",
"@vue/eslint-config-typescript",
"plugin:vue/vue3-recommended",
"./.eslintrc-auto-import.json",
"prettier",
],
plugins: ["vue"],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
parser: '@typescript-eslint/parser',
ecmaVersion: "latest",
sourceType: "module",
parser: "@typescript-eslint/parser",
tsconfigRootDir: __dirname,
project: ['./tsconfig.app.json'],
project: ["./tsconfig.app.json"],
},
env: {
'vue/setup-compiler-macros': true,
"vue/setup-compiler-macros": true,
browser: true,
es2021: true,
},
rules: {
'comma-dangle': [2, 'always-multiline'],
'@typescript-eslint/comma-dangle': [2, 'always-multiline'],
'vue/no-v-html': 0,
'no-irregular-whitespace': 0,
"comma-dangle": [2, "always-multiline"],
"@typescript-eslint/comma-dangle": [2, "always-multiline"],
"vue/no-v-html": 0,
"no-irregular-whitespace": 0,
},
overrides: [
{
files: ['**/__tests__/*.{j,t}s?(x)', '**/src/**/*.spec.{j,t}s?(x)'],
files: ["**/__tests__/*.{j,t}s?(x)", "**/src/**/*.spec.{j,t}s?(x)"],
env: {
jest: true,
},
},
{
files: ['src/utils/**/*.{j,t}s?(x)'],
files: ["src/utils/**/*.{j,t}s?(x)"],
rules: {
camelcase: 'off',
camelcase: "off",
},
},
{
files: ['**/src/**/*.e2e.js*', '**/src/**/*.cy.js'],
files: ["**/src/**/*.e2e.js*", "**/src/**/*.cy.js"],
globals: {
cy: true,
},
},
],
}
};
16 changes: 13 additions & 3 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Basegun Vue.js frontend

## Project setup

### Without Docker

```bash
# install requirements
npm install
Expand All @@ -12,37 +14,45 @@ npm run build
# Lints and fixes files
npm run lint
```

### With Docker

```bash
docker build --target dev -t basegun-front:dev .
```
If you are in a network blocked with proxy, remember to add arg `--build_arg https_proxy` where `https_proxy` is a variable already set in your env.


If you are in a network blocked with proxy, remember to add arg `--build_arg https_proxy` where `https_proxy` is a variable already set in your env.

## Run project

### Without Docker

```bash
npm run dev
```

Open localhost:3000

### With Docker

```bash
docker run --rm -p 3000:3000 -d basegun-front:dev
```

## Test project

Run end-to-end tests with cypress. You need first to have installed dependancies with `npm ci`.

First run website with Docker then

```bash
# run in headless mode (only in terminal)
npm --prefix frontend run test:e2e-run

# run with graphical interface
npm --prefix frontend run test:e2e-open
```
```

### Customize configuration

See [Configuration Reference](https://cli.vuejs.org/config/).
6 changes: 3 additions & 3 deletions frontend/cert/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
This folder is only useful if your network imposes you to use custom certs.

You can ignore it otherwise.
This folder is only useful if your network imposes you to use custom certs.

You can ignore it otherwise.
10 changes: 5 additions & 5 deletions frontend/cypress.config.cjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const { defineConfig } = require('cypress')
const { defineConfig } = require("cypress");

const frontendHost = process.env.FRONTEND_HOST || 'localhost'
const frontendPort = process.env.FRONTEND_PORT || '3000'
const frontendHost = process.env.FRONTEND_HOST || "localhost";
const frontendPort = process.env.FRONTEND_PORT || "3000";

module.exports = defineConfig({
e2e: {
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,ts}',
specPattern: "cypress/e2e/**/*.{cy,spec}.{js,ts}",
baseUrl: `http://${frontendHost}:${frontendPort}`,
// NEO - Crosscall X4 - Résolution : 18:9
// Iphone XR
viewportWidth: 414,
viewportHeight: 896,
video: false,
},
})
});
10 changes: 4 additions & 6 deletions frontend/cypress/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
module.exports = {
plugins: [
'cypress',
],
plugins: ["cypress"],
env: {
mocha: true,
'cypress/globals': true,
"cypress/globals": true,
},
rules: {
strict: 'off',
strict: "off",
},
}
};
98 changes: 52 additions & 46 deletions frontend/cypress/e2e/firearm-fiability.cy.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,57 @@
describe('Firearm Fiability', () => {
it('should identificate firearm with high fiability', () => {
cy.Identification()
describe("Firearm Fiability", () => {
it("should identificate firearm with high fiability", () => {
cy.Identification();

cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').as('upload')
cy.get('@fileInput').selectFile('./cypress/images/pistolet-semi-auto.jpg', { force: true })
cy.wait('@upload').then(({ response }) => {
expect(response.statusCode).to.eq(200)
})
cy.getByDataTestid('next-step').click()
cy.IdentificationPistoletSemiAuto()
cy.url().should('contain', '/guide-identification/resultat-final')
cy.getByDataTestid('arm-category').should('contain', 'Catégorie B')
cy.getByDataTestid('arm-category').should(() => {
expect(localStorage.getItem('confidenceLevel')).to.eq('"high"')
})
})
cy.getByDataTestid("select-file").as("fileInput");
cy.intercept("POST", "/api/upload").as("upload");
cy.get("@fileInput").selectFile("./cypress/images/pistolet-semi-auto.jpg", {
force: true,
});
cy.wait("@upload").then(({ response }) => {
expect(response.statusCode).to.eq(200);
});
cy.getByDataTestid("next-step").click();
cy.IdentificationPistoletSemiAuto();
cy.url().should("contain", "/guide-identification/resultat-final");
cy.getByDataTestid("arm-category").should("contain", "Catégorie B");
cy.getByDataTestid("arm-category").should(() => {
expect(localStorage.getItem("confidenceLevel")).to.eq('"high"');
});
});

it('should identificate firearm with medium fiability', () => {
cy.Identification()
it("should identificate firearm with medium fiability", () => {
cy.Identification();

cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').as('upload')
cy.get('@fileInput').selectFile('./cypress/images/arme-medium.png', { force: true })
cy.wait('@upload').then(({ response }) => {
expect(response.statusCode).to.eq(200)
})
cy.url().should('contain', '/guide-identification/resultat-typologie')
cy.contains('h3', 'Catégorie A, B ou D')
cy.get('h2').should(() => {
expect(localStorage.getItem('confidenceLevel')).to.eq('"medium"')
})
})
cy.getByDataTestid("select-file").as("fileInput");
cy.intercept("POST", "/api/upload").as("upload");
cy.get("@fileInput").selectFile("./cypress/images/arme-medium.png", {
force: true,
});
cy.wait("@upload").then(({ response }) => {
expect(response.statusCode).to.eq(200);
});
cy.url().should("contain", "/guide-identification/resultat-typologie");
cy.contains("h3", "Catégorie A, B ou D");
cy.get("h2").should(() => {
expect(localStorage.getItem("confidenceLevel")).to.eq('"medium"');
});
});

it('should identificate firearm with low fiability', () => {
cy.Identification()
it("should identificate firearm with low fiability", () => {
cy.Identification();

cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').as('upload')
cy.get('@fileInput').selectFile('./cypress/images/arme-low.png', { force: true })
cy.wait('@upload').then(({ response }) => {
expect(response.statusCode).to.eq(200)
})
cy.url().should('contain', '/guide-identification/resultat-typologie')
cy.contains('h2', 'Catégorie non déterminée')
cy.get('h2').should(() => {
expect(localStorage.getItem('confidenceLevel')).to.eq('"low"')
})
})
})
cy.getByDataTestid("select-file").as("fileInput");
cy.intercept("POST", "/api/upload").as("upload");
cy.get("@fileInput").selectFile("./cypress/images/arme-low.png", {
force: true,
});
cy.wait("@upload").then(({ response }) => {
expect(response.statusCode).to.eq(200);
});
cy.url().should("contain", "/guide-identification/resultat-typologie");
cy.contains("h2", "Catégorie non déterminée");
cy.get("h2").should(() => {
expect(localStorage.getItem("confidenceLevel")).to.eq('"low"');
});
});
});
64 changes: 34 additions & 30 deletions frontend/cypress/e2e/firearm-identification.cy.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
describe('Firearm Identification', () => {
it('should identificate real firearm', () => {
cy.Identification()
cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').as('upload')
cy.get('@fileInput').selectFile('./cypress/images/pistolet-semi-auto.jpg', { force: true })
cy.wait('@upload').then(({ response }) => {
expect(response.statusCode).to.eq(200)
})
cy.getByDataTestid('next-step').click()
cy.IdentificationPistoletSemiAuto()
cy.url().should('contain', '/guide-identification/resultat-final')
cy.getByDataTestid('arm-category').should('contain', 'Catégorie B')
cy.getByDataTestid('return-to-home-end').click()
cy.url().should('contain', '/accueil')
})
describe("Firearm Identification", () => {
it("should identificate real firearm", () => {
cy.Identification();
cy.getByDataTestid("select-file").as("fileInput");
cy.intercept("POST", "/api/upload").as("upload");
cy.get("@fileInput").selectFile("./cypress/images/pistolet-semi-auto.jpg", {
force: true,
});
cy.wait("@upload").then(({ response }) => {
expect(response.statusCode).to.eq(200);
});
cy.getByDataTestid("next-step").click();
cy.IdentificationPistoletSemiAuto();
cy.url().should("contain", "/guide-identification/resultat-final");
cy.getByDataTestid("arm-category").should("contain", "Catégorie B");
cy.getByDataTestid("return-to-home-end").click();
cy.url().should("contain", "/accueil");
});

it('should identificate dummy firearm', () => {
cy.Identification()
cy.getByDataTestid('select-file').as('fileInput')
cy.intercept('POST', '/api/upload').as('upload')
cy.get('@fileInput').selectFile('./cypress/images/pistolet-semi-auto.jpg', { force: true })
cy.wait('@upload').then(({ response }) => {
expect(response.statusCode).to.eq(200)
})
cy.getByDataTestid('next-step').click()
cy.IdentificationDummyPistolet()
cy.getByDataTestid('return-to-home-end').click()
cy.url().should('contain', '/accueil')
})
})
it("should identificate dummy firearm", () => {
cy.Identification();
cy.getByDataTestid("select-file").as("fileInput");
cy.intercept("POST", "/api/upload").as("upload");
cy.get("@fileInput").selectFile("./cypress/images/pistolet-semi-auto.jpg", {
force: true,
});
cy.wait("@upload").then(({ response }) => {
expect(response.statusCode).to.eq(200);
});
cy.getByDataTestid("next-step").click();
cy.IdentificationDummyPistolet();
cy.getByDataTestid("return-to-home-end").click();
cy.url().should("contain", "/accueil");
});
});
Loading

0 comments on commit a83d580

Please sign in to comment.