Skip to content

Commit

Permalink
feat: teachers can create letters now
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMarc-RAJAONARIVELONA authored Nov 20, 2024
1 parent deafe34 commit 47fcd2a
Show file tree
Hide file tree
Showing 22 changed files with 375 additions and 170 deletions.
34 changes: 17 additions & 17 deletions cypress/e2e/download.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Manager.Work.Docs.Download", () => {
);
cy.intercept(
"POST",
`/students/${student1Mock.id}/work_files/raw?filename=new_document&work_study_status=WORKING*`,
`/users/${student1Mock.id}/work_files/raw?filename=new_document&work_study_status=WORKING*`,
newWorkerDoc
);

Expand Down Expand Up @@ -60,32 +60,32 @@ describe("Student.Transcript.Docs.Download", () => {
cy.intercept("GET", `/students/${student1Mock.id}`, student1Mock);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
`/users/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
transcriptsMock
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=OTHER*`,
`/users/${student1Mock.id}/files?file_type=OTHER*`,
otherDocsMocks
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${transcript1.id}`,
`/users/${student1Mock.id}/files/${transcript1.id}`,
transcript1
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${otherDoc1.id}`,
`/users/${student1Mock.id}/files/${otherDoc1.id}`,
otherDoc1
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/work_files?*`,
`/users/${student1Mock.id}/work_files?*`,
workDocsMocks
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/work_files/${workDoc1.id}`,
`/users/${student1Mock.id}/work_files/${workDoc1.id}`,
workDoc1
);

Expand All @@ -110,22 +110,22 @@ describe("Student.Work.Docs.Download", () => {
cy.intercept("GET", `/students/${student1Mock.id}`, student1Mock);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
`/users/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
transcriptsMock
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=OTHER*`,
`/users/${student1Mock.id}/files?file_type=OTHER*`,
otherDocsMocks
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${transcript1.id}`,
`/users/${student1Mock.id}/files/${transcript1.id}`,
transcript1
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${otherDoc1.id}`,
`/users/${student1Mock.id}/files/${otherDoc1.id}`,
otherDoc1
);
cy.intercept(
Expand Down Expand Up @@ -160,32 +160,32 @@ describe("Student.Other.Docs.Download", () => {
cy.intercept("GET", `/students/${student1Mock.id}`, student1Mock);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
`/users/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
transcriptsMock
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=OTHER*`,
`/users/${student1Mock.id}/files?file_type=OTHER*`,
otherDocsMocks
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${transcript1.id}`,
`/users/${student1Mock.id}/files/${transcript1.id}`,
transcript1
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${otherDoc1.id}`,
`/users/${student1Mock.id}/files/${otherDoc1.id}`,
otherDoc1
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/work_files?*`,
`/users/${student1Mock.id}/work_files?*`,
workDocsMocks
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/work_files/${workDoc1.id}`,
`/users/${student1Mock.id}/work_files/${workDoc1.id}`,
workDoc1
);

Expand Down
8 changes: 3 additions & 5 deletions cypress/e2e/letter.event.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ describe("Letter.event", () => {
`/events/${event1mock.id}/participants?page=1&page_size=10`,
eventParticipantsMock
).as("getEventParticipantPage1");
cy.intercept(
"POST",
`/students/${student1Mock.id}/letters?*`,
newLetter
).as("createLetter");
cy.intercept("POST", `/users/${student1Mock.id}/letters?*`, newLetter).as(
"createLetter"
);
cy.intercept("GET", `/events/${event1mock.id}`, event1mock);
});

Expand Down
64 changes: 35 additions & 29 deletions cypress/e2e/letters.cy.tsx → cypress/e2e/letters.users.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
import {
newLetter,
statsMocks,
student1LettersMocks,
teacher1LettersMocks,
} from "../fixtures/api_mocks/letters-mocks";
import {student1Mock, studentsMock} from "../fixtures/api_mocks/students-mocks";
import {teacher1Mock} from "../fixtures/api_mocks/teachers-mocks";

const ITEM_PER_LIST = 10;

describe("Student.Letters", () => {
const testLettersFunctionality = (
role: string,
id: string,
letterMocks: any
) => {
beforeEach(() => {
cy.login({role: "STUDENT"});
cy.intercept(
"GET",
`/students/${student1Mock.id}/letters?page=1&page_size=10`,
student1LettersMocks.slice(0, ITEM_PER_LIST)
).as("getStudent1LettersPage1");
cy.intercept(
"POST",
`/students/${student1Mock.id}/letters?*`,
newLetter
).as("createLetter");
cy.intercept("GET", `/students/${newLetter.id}`);
cy.intercept("GET", `letters/stats`, statsMocks).as("getStats");
cy.login({role});

const userId = id;
expect(userId).to.exist;

cy.intercept(
"GET",
`/students/${student1Mock.id}/letters?page=1&page_size=10&status=PENDING`,
student1LettersMocks
).as("getStudent1LettersPending");
`/users/${userId}/letters?page=1&page_size=10`,
letterMocks.slice(0, ITEM_PER_LIST)
).as("getusers1LettersPage1");
cy.intercept("POST", `/users/${userId}/letters?*`, newLetter).as(
"createLetter"
);
});

it("student can list his letters", () => {
it("can list letters", () => {
cy.getByTestid("letters-list-tab").click();
cy.wait("@getStudent1LettersPage1");
cy.wait("@getusers1LettersPage1");
cy.getByTestid("letter-list-wrapper")
.children()
.should("have.length", ITEM_PER_LIST);
});

it("student can create his letters", () => {
it("can create letters", () => {
cy.getByTestid("letters-list-tab").click();
cy.getByTestid("letter-create-button").click();
cy.get("#description").type(newLetter.description!);
Expand All @@ -50,6 +50,14 @@ describe("Student.Letters", () => {
expect(interception.response!.statusCode).to.eq(200);
});
});
};

describe("Student.Letters", () => {
testLettersFunctionality("STUDENT", student1Mock.id, student1LettersMocks);
});

describe("Teacher.Letters", () => {
testLettersFunctionality("TEACHER", teacher1Mock.id, teacher1LettersMocks);
});

describe("Manager.Letters.student", () => {
Expand Down Expand Up @@ -83,22 +91,20 @@ describe("Manager.Letters.student", () => {
it("manager can list student letter", () => {
cy.intercept(
"GET",
`/students/${student1Mock.id}/letters?page=1&page_size=10`,
`/users/${student1Mock.id}/letters?page=1&page_size=10`,
student1LettersMocks.slice(0, ITEM_PER_LIST)
).as("getStudent1LettersPage1");
).as("getusers1LettersPage1");
cy.getByTestid("letters-list-tab").click();
cy.wait("@getStudent1LettersPage1");
cy.wait("@getusers1LettersPage1");
cy.getByTestid("letter-list-wrapper")
.children()
.should("have.length", ITEM_PER_LIST);
});

it("manager can create letters for student", () => {
cy.intercept(
"POST",
`/students/${student1Mock.id}/letters?*`,
newLetter
).as("createLetter");
cy.intercept("POST", `/users/${student1Mock.id}/letters?*`, newLetter).as(
"createLetter"
);
cy.getByTestid("letters-list-tab").click();
cy.getByTestid("letter-create-button").click();
cy.get("#description").type(newLetter.description!);
Expand Down
32 changes: 16 additions & 16 deletions cypress/e2e/student.docs.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,32 @@ describe("Transcript.Docs", () => {
cy.intercept("GET", `/students/${student1Mock.id}`, student1Mock);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
`/users/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
transcriptsMock
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=OTHER*`,
`/users/${student1Mock.id}/files?file_type=OTHER*`,
otherDocsMocks
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${transcript1.id}`,
`/users/${student1Mock.id}/files/${transcript1.id}`,
transcript1
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${otherDoc1.id}`,
`/users/${student1Mock.id}/files/${otherDoc1.id}`,
otherDoc1
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/work_files?*`,
`/users/${student1Mock.id}/work_files?*`,
workDocsMocks
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/work_files/${workDoc1.id}`,
`/users/${student1Mock.id}/work_files/${workDoc1.id}`,
workDoc1
);

Expand All @@ -63,22 +63,22 @@ describe("Work.Docs", () => {
cy.intercept("GET", `/students/${student1Mock.id}`, student1Mock);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
`/users/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
transcriptsMock
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=OTHER*`,
`/users/${student1Mock.id}/files?file_type=OTHER*`,
otherDocsMocks
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${transcript1.id}`,
`/users/${student1Mock.id}/files/${transcript1.id}`,
transcript1
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${otherDoc1.id}`,
`/users/${student1Mock.id}/files/${otherDoc1.id}`,
otherDoc1
);
cy.intercept(
Expand Down Expand Up @@ -112,32 +112,32 @@ describe("Other.Docs", () => {
cy.intercept("GET", `/students/${student1Mock.id}`, student1Mock);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
`/users/${student1Mock.id}/files?file_type=TRANSCRIPT*`,
transcriptsMock
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files?file_type=OTHER*`,
`/users/${student1Mock.id}/files?file_type=OTHER*`,
otherDocsMocks
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${transcript1.id}`,
`/users/${student1Mock.id}/files/${transcript1.id}`,
transcript1
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/files/${otherDoc1.id}`,
`/users/${student1Mock.id}/files/${otherDoc1.id}`,
otherDoc1
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/work_files?*`,
`/users/${student1Mock.id}/work_files?*`,
workDocsMocks
);
cy.intercept(
"GET",
`/students/${student1Mock.id}/work_files/${workDoc1.id}`,
`/users/${student1Mock.id}/work_files/${workDoc1.id}`,
workDoc1
);

Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/student.fees.mpbs.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("Mobile payment by student", () => {
).should("exist");
});

it("can create a mpbs", () => {
it.only("can create a mpbs", () => {
const [fee1Mock, ...fees] = feesMock;

cy.intercept(
Expand All @@ -52,7 +52,7 @@ describe("Mobile payment by student", () => {
).click({force: true});

cy.get("#psp_id").click().type("MP240726.1541.D88425");
cy.get('[data-testid="SaveIcon"]').click();
cy.contains("Enregistrer").click();

cy.contains("Frais créés avec succès");

Expand Down
Loading

0 comments on commit 47fcd2a

Please sign in to comment.