Skip to content

Commit

Permalink
fix(backend): fix referrerId and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Jan 27, 2025
1 parent 1a9cbf4 commit 0f362f4
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,4 @@ export const AgendaControllerSecurityTests: AppTestHttpClientSecurityTestDef[] =
),
}),
},
{
label: `${CONTROLLER}.getAllUsersForAgenda`,
query: async (context: AppTestContext) => ({
response: await AppTestHttpClient.get("/agenda/users", {
context,
}),
expectedStatus: expectedResponseStatusBuilder.allowStructureOnly(
context.user,
{
roles: ["simple", "responsable", "admin"],
}
),
}),
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@ export const CUSTOM_DOC_ATTESTATION_POSTALE: StructureCustomDocTags = {
PROCURATION_DATE_FIN: "",
PROCURATION_DATE_NAISSANCE: "",
PROCURATIONS_NOMBRE: 0,
REFERENT: "",
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const CUSTOM_DOC_COURRIER_REFUS: StructureCustomDocTags = {
DATE_PREMIERE_DOM: "11 janvier 2018",
DATE_RADIATION: "",
PREMIERE_DOM_NOM_AGENT: "",

REFERENT: "",
ENTRETIEN_ACCOMPAGNEMENT: "NON",
ENTRETIEN_ACCOMPAGNEMENT_DETAIL: "",
ENTRETIEN_ORIENTATION: "OUI",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function setUsagerDefaultAttributes(usager: Partial<Usager>): void {
};
usager.typeDom = usager?.typeDom ?? "PREMIERE_DOM";
usager.pinnedNote = null;
usager.referrerId = null;

if (!usager.ayantsDroits) {
usager.ayantsDroits = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const FIRST_SHEET_USAGERS = [
TRANSFERT_NOM: "",
MON_DOMIFA_ACTIVATION: "NON",
SMS_ACTIVATION: "NON",
REFERENT: "",
},
{
AD_DATE_NAISSANCE_0: "20/12/1978",
Expand Down Expand Up @@ -74,5 +75,6 @@ export const FIRST_SHEET_USAGERS = [
TRANSFERT_NOM: "",
MON_DOMIFA_ACTIVATION: "NON",
SMS_ACTIVATION: "NON",
REFERENT: "",
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
expectedResponseStatusBuilder,
securityTestDataBuilder,
} from "../../_tests";
import { USER_STRUCTURE_ROLE_ALL } from "../../_common/model";

const CONTROLLER = "UserController";

Expand All @@ -24,7 +25,7 @@ export const UserControllerSecurityTests: AppTestHttpClientSecurityTestDef[] = [
expectedStatus: expectedResponseStatusBuilder.allowStructureOnly(
context.user,
{
roles: ["responsable", "admin"],
roles: USER_STRUCTURE_ROLE_ALL,
}
),
}),
Expand Down
14 changes: 12 additions & 2 deletions packages/backend/src/users/controllers/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,22 @@ export class UsersController {
@ApiBearerAuth()
@ApiOperation({ summary: "Liste des utilisateurs" })
@Get("")
public getUsers(
public async getUsers(
@CurrentUser() user: UserStructureAuthenticated
): Promise<UserStructureProfile[]> {
return userStructureRepository.getVerifiedUsersByStructureId(
const users = await userStructureRepository.getVerifiedUsersByStructureId(
user.structureId
);
if (user.role === "facteur" || user.role === "simple") {
return users.map((user) => {
return {
id: user.id,
nom: user.nom,
prenom: user.prenom,
};
}) as UserStructureProfile[];
}
return users;
}

@AllowUserStructureRoles(...USER_STRUCTURE_ROLE_ALL)
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/search/classes/Search.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class Search {
public searchString: string | null;
public sortKey: string;
public sortValue: SortValues;
public page: number;
public page = 1;

constructor(search?: any) {
this.searchString = search?.searchString ?? null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum UsagersFilterCriteriaEntretien {
COMING = "COMING",
OVERDUE = "OVERDUE",
}
1 change: 1 addition & 0 deletions packages/common/src/search/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
export * from "./CriteriaSearchField.enum";
export * from "./SortValues.type";
export * from "./Timings.type";
export * from "./UsagersFilterCriteriaEntretien.enum";
export * from "./UsagersFilterCriteriaStatut.enum";
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe("EtatCivilParentFormComponent", () => {
nom: "TEST",
prenom: "TEST PRENOM ",
sexe: "homme",
referrerId: null,
surnom: "Chips",
numeroDistribution: "TSA 1000",
telephone: {
Expand Down

0 comments on commit 0f362f4

Please sign in to comment.