Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/analyse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CodeQL_analysis

on: pull_request

jobs:
codeQL:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
36 changes: 36 additions & 0 deletions .github/workflows/medle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Install, build, lint and tests

on: pull_request

jobs:
tests-javascript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Enable Corepack
run: corepack enable
- uses: actions/setup-node@v6
with:
cache: yarn
node-version-file: package.json
- name: Install packages
run: yarn install --frozen-lockfile
- name: Run the tests
env:
NODE_ENV: test
run: yarn test

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Enable Corepack
run: corepack enable
- uses: actions/setup-node@v6
with:
cache: yarn
node-version-file: package.json
- name: Install packages
run: yarn install --frozen-lockfile
- name: Build the app
run: yarn build
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
"devDependencies": {
"@jackfranklin/test-data-bot": "^1.3.0",
"@socialgouv/sre-secrets": "^1.10.4",
"@testing-library/dom": "^8.1.1",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/react": "^16.3.2",
"@testing-library/user-event": "^13.2.1",
"babel-jest": "^27.0.6",
"babel-jest": "30",
"eslint": "^9",
"eslint-config-next": "16.2.10",
"faker": "^5.5.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("tests administration user", () => {
render(<UserDetail currentUser={{ role: "ADMIN_HOSPITAL" }} />)

expect(screen.queryByText("Zone dangereuse")).not.toBeInTheDocument()
expect(screen.queryByText("Retour à la liste")).not.toBeInTheDocument()
expect(screen.queryByText("Retour à la liste")).toBeInTheDocument()
expect(screen.queryByText("Ajouter")).toBeInTheDocument()

})
Expand All @@ -42,7 +42,7 @@ describe("tests administration user", () => {
it("should display errors when clicking too early on Ajouter button", async () => {
render(<UserDetail currentUser={{ role: "ADMIN_HOSPITAL" }} />)

expect(screen.queryByText("Retour à la liste")).not.toBeInTheDocument()
expect(screen.queryByText("Retour à la liste")).toBeInTheDocument()

expect(screen.queryByText("Ajouter")).toBeInTheDocument()

Expand All @@ -51,6 +51,6 @@ describe("tests administration user", () => {
await screen.findByText(/Le nom est obligatoire./i)
await screen.findByText(/Courriel a un format incorrect./i)

expect(screen.queryByText("Retour à la liste")).not.toBeInTheDocument()
expect(screen.queryByText("Retour à la liste")).toBeInTheDocument()
})
})
3 changes: 2 additions & 1 deletion src/__tests__/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
module.exports = {
// rootDir: ".",
testRegex: "/.*\\.spec\\.js$",
testEnvironment: "jsdom",
//snapshotResolver: join(__dirname, "./snapshotResolver.js"),
//testEnvironmentOptions: require("./knexfile.ts"),
//testEnvironment: join(__dirname, "../..", require("../../package.json").main),
setupFilesAfterEnv: ["@testing-library/jest-dom/extend-expect"],
setupFilesAfterEnv: ["<rootDir>/setup.js", "@testing-library/jest-dom/extend-expect"],
}
6 changes: 6 additions & 0 deletions src/__tests__/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

// Mock next/router
jest.mock("next/router", () => ({
useRouter: jest.fn(),
}))

6 changes: 3 additions & 3 deletions src/__tests__/unit/components/CurrentMonthEmployments.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ afterEach(() => {
})

it("should render CurrentMonthEmployments", async () => {
render(<CurrentMonthEmployments month={lambdaMonth} year={lambdaYear} hospitalId={lambdaHospitalId} />)

await waitFor(() =>
render(<CurrentMonthEmployments month={lambdaMonth} year={lambdaYear} hospitalId={lambdaHospitalId} />),
expect(screen.getByLabelText(/secrétaire/i)).toHaveValue(1.9)
)

expect(screen.getByLabelText(/secrétaire/i)).toHaveValue(1.9)
expect(screen.getByLabelText(/reference.others/i).textContent).toMatchInlineSnapshot(`"1.5 ETP prévus"`)

expect(auth.getCurrentUser).toHaveBeenCalled()
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/unit/components/login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("<Login> component tests", () => {

render(<Login authentication={noop} error={null} />)

userEvent.click(screen.getByText("Se connecter"))
userEvent.click(screen.getByRole('button', { name: /connexion/i }))

await screen.findByTestId("loading")

Expand All @@ -41,7 +41,7 @@ describe("<Login> component tests", () => {

render(<Login authentication={noop} error={"Erreur_xxx"} />)

userEvent.click(screen.getByText("Se connecter"))
userEvent.click(screen.getByRole('button', { name: /connexion/i }))

await screen.findByTestId("loading")

Expand Down
4 changes: 4 additions & 0 deletions src/__tests__/unit/models/__snapshots__/users.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Object {
},
"id": 2,
"lastName": "Mc Lane",
"resetPassword": undefined,
"role": "OPERATOR_ACT",
"scope": undefined,
}
Expand All @@ -21,6 +22,7 @@ Object {
"first_name": "Doc",
"hospital_id": null,
"last_name": "Brown",
"reset_password": undefined,
"role": "OPERATOR_ACT",
"scope": null,
}
Expand All @@ -34,6 +36,7 @@ Object {
"id": 2,
"last_name": "Brown",
"password": "12345678",
"reset_password": undefined,
"role": "OPERATOR_ACT",
"scope": null,
}
Expand All @@ -46,6 +49,7 @@ Object {
"hospital_id": null,
"id": 1,
"last_name": "Mac Fly",
"reset_password": undefined,
"role": "REGIONAL_SUPERVISOR",
"scope": "[1,3,6]",
}
Expand Down
Loading
Loading