Skip to content

Commit

Permalink
Merge pull request #449 from Onlineberatung/fix-last-message-type
Browse files Browse the repository at this point in the history
fix: missing lastMessageType response due to changed alias-message de…
  • Loading branch information
webatspeed authored Jul 27, 2022
2 parents 4201a7f + c819088 commit c452660
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
5 changes: 5 additions & 0 deletions api/userservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,8 @@ components:
$ref: '#/components/schemas/VideoCallMessageDTO'
messageType:
$ref: '#/components/schemas/MessageType'
content:
type: string

ForwardMessageDTO:
type: object
Expand Down Expand Up @@ -2143,6 +2145,9 @@ components:
MessageType:
type: string
enum:
- "APPOINTMENT_SET"
- "APPOINTMENT_CANCELLED"
- "APPOINTMENT_RESCHEDULED"
- "FURTHER_STEPS"
- "UPDATE_SESSION_DATA"
- "FORWARD"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,66 @@ void getSessionsForAuthenticatedUserShouldReturnSessionsLastMessageTypeE2eeActiv
.andExpect(jsonPath("sessions[1].chat", is(nullValue())));
}

@Test
@WithMockUser(authorities = AuthorityValue.USER_DEFAULT)
void getSessionsForAuthenticatedUserShouldReturnSessionsLastMessageTypeResetLastMessage()
throws Exception {
givenAValidUser(true);
givenAValidConsultant();
givenASessionInProgress();
givenAValidRocketChatSystemUser();
givenAValidRocketChatGetRoomsResponse(session.getGroupId(),
MessageType.REASSIGN_CONSULTANT_RESET_LAST_MESSAGE, null);
givenAnEmptyRocketChatGetSubscriptionsResponse();
user.getSessions().forEach(session ->
givenAValidRocketChatInfoUserResponse(session.getConsultant())
);

mockMvc.perform(
get("/users/sessions/askers")
.cookie(CSRF_COOKIE)
.header(CSRF_HEADER, CSRF_VALUE)
.header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN)
.accept(MediaType.APPLICATION_JSON)
)
.andExpect(status().isOk())
.andExpect(jsonPath("sessions", hasSize(2)))
.andExpect(jsonPath("sessions[*].session.lastMessageType",
containsInAnyOrder("REASSIGN_CONSULTANT_RESET_LAST_MESSAGE", "FURTHER_STEPS")))
.andExpect(jsonPath("sessions[0].chat", is(nullValue())))
.andExpect(jsonPath("sessions[1].chat", is(nullValue())));
}

@Test
@WithMockUser(authorities = AuthorityValue.USER_DEFAULT)
void getSessionsForAuthenticatedUserShouldReturnSessionsLastMessageTypeReassignConsultant()
throws Exception {
givenAValidUser(true);
givenAValidConsultant();
givenASessionInProgress();
givenAValidRocketChatSystemUser();
givenAValidRocketChatGetRoomsResponse(session.getGroupId(), MessageType.REASSIGN_CONSULTANT,
"a message");
givenAnEmptyRocketChatGetSubscriptionsResponse();
user.getSessions().forEach(session ->
givenAValidRocketChatInfoUserResponse(session.getConsultant())
);

mockMvc.perform(
get("/users/sessions/askers")
.cookie(CSRF_COOKIE)
.header(CSRF_HEADER, CSRF_VALUE)
.header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN)
.accept(MediaType.APPLICATION_JSON)
)
.andExpect(status().isOk())
.andExpect(jsonPath("sessions", hasSize(2)))
.andExpect(jsonPath("sessions[*].session.lastMessageType",
containsInAnyOrder("REASSIGN_CONSULTANT", "FURTHER_STEPS")))
.andExpect(jsonPath("sessions[0].chat", is(nullValue())))
.andExpect(jsonPath("sessions[1].chat", is(nullValue())));
}

@Test
@WithMockUser(authorities = {AuthorityValue.USER_DEFAULT})
void getSessionsForGroupOrFeedbackGroupIdsShouldFindSessionsByGroupOrFeedbackGroup()
Expand Down Expand Up @@ -599,7 +659,8 @@ void getSessionsForGroupOrFeedbackGroupIdsShouldContainConsultantOfUserSession()
.andExpect(status().isOk())
.andExpect(jsonPath("sessions[0].session.groupId", is("YWKxhFX5K2HPpsFbs")))
.andExpect(jsonPath("sessions[0].consultant.username", is("u25main")))
.andExpect(jsonPath("sessions[0].consultant.id", is("bad14912-cf9f-4c16-9d0e-fe8ede9b60dc")))
.andExpect(
jsonPath("sessions[0].consultant.id", is("bad14912-cf9f-4c16-9d0e-fe8ede9b60dc")))
.andExpect(jsonPath("sessions[0].consultant.firstName").doesNotExist())
.andExpect(jsonPath("sessions[0].consultant.lastName").doesNotExist())
.andExpect(jsonPath("sessions[0].agency", is(notNullValue())))
Expand Down Expand Up @@ -717,7 +778,8 @@ void getSessionForIdShouldFindSessionsBySessionId()
.andExpect(jsonPath("sessions[0].session.id", is(900)))
.andExpect(jsonPath("sessions[0].session.groupId", is("YWKxhFX5K2HPpsFbs")))
.andExpect(jsonPath("sessions[0].consultant.username", is("u25main")))
.andExpect(jsonPath("sessions[0].consultant.id", is("bad14912-cf9f-4c16-9d0e-fe8ede9b60dc")))
.andExpect(
jsonPath("sessions[0].consultant.id", is("bad14912-cf9f-4c16-9d0e-fe8ede9b60dc")))
.andExpect(jsonPath("sessions[0].consultant.firstName").doesNotExist())
.andExpect(jsonPath("sessions[0].consultant.lastName").doesNotExist())
.andExpect(jsonPath("sessions[0].agency", is(notNullValue())))
Expand Down

0 comments on commit c452660

Please sign in to comment.