Skip to content

Commit

Permalink
add apiv2 tests on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannbr committed Nov 8, 2024
1 parent 3b8fc89 commit 25a3dc7
Show file tree
Hide file tree
Showing 9 changed files with 8,463 additions and 4,080 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/run-tests-api-v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: API V2 - Run Tests

on:
workflow_dispatch:
workflow_call:
inputs:
branch_name:
required: true
type: string
pull_request:
branches:
- main
merge_group:
types:
- checks_requested

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch_name }}

- name: Node 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x

- uses: actions/cache@v4
id: cache-npm
with:
path: |
apiv2/node_modules
key: ${{ runner.os }}-nodemodules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-nodemodules-
- name: Install packages
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci

- name: Build lib
working-directory: packages/lib
run: npm run build

- name: Run tests
working-directory: apiv2
run: npm test
11 changes: 7 additions & 4 deletions apiv2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions apiv2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version": "0.0.1",
"description": "",
"author": "",
"engines": {
"node": "^18.20",
"npm": "^10.5"
},
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ describe("InviterReferentClasse", () => {
});

it("should call notificationGateway.sendEmail template INSCRIPTION", async () => {
// Arrange
const referentId = "referent-id";
const classeId = "classe-id";
const invitationType = InvitationType.INSCRIPTION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ClasseAdminCleGuard implements CanActivate {
const request = context.switchToHttp().getRequest<CustomRequest>();
request.classe = await this.classeGuardService.findClasse(request);

// TODO : handle request.user mapping
// TODO : request.user mapping
if (isSuperAdmin({ role: request.user.role, subRole: request.user.sousRole })) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { CanActivate, ExecutionContext, Injectable, Logger } from "@nestjs/common";
import { ClasseGuardService } from "./ClasseGuard.service";

// Attention aux query mutltiples via Mongoose si utilisation de plusieurs guards
// Solutions
// Cache de même cycle de vie qu'une requête
// attacher les données de la classe au contexte de la requête : OK
// Factory de guards

@Injectable()
export class ClasseRegionGuard implements CanActivate {
constructor(
Expand Down
1 change: 0 additions & 1 deletion apiv2/test/admin/iam/ReferentMongo.repository.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { REFERENT_MONGOOSE_ENTITY, ReferentDocument } from "src/admin/infra/iam/
import { setupAdminTest } from "../setUpAdminTest";
import { createReferent } from "./ReferentHelper";
import { ClsService } from "nestjs-cls";
import { id } from "date-fns/locale";

describe("ReferentGateway", () => {
let referentGateway: ReferentGateway;
Expand Down
Loading

0 comments on commit 25a3dc7

Please sign in to comment.