Skip to content
Snippets Groups Projects
Commit ceedec7f authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-6949 handle api change' (#54) from OZG-6939-process-antwort-id into master

parents c61fa090 e1a6b62f
No related branches found
No related tags found
No related merge requests found
......@@ -27,12 +27,12 @@ import {
SEND_FAILED,
sendMessage
} from "./rueckfragenAPI";
import { Command, CommandReference, Message, Rueckfrage, RueckfrageHeader } from "../types";
import { Antwort, Command, CommandReference, Rueckfrage, RueckfrageHeader } from "../types";
import axios from "axios";
jest.mock("axios");
describe("Topic API tests", () => {
describe("Rueckfrage API tests", () => {
afterEach(() => {
jest.clearAllMocks(); // reset call counts
});
......@@ -130,7 +130,8 @@ describe("Topic API tests", () => {
...rueckfrage,
antworten: [
{
id: "1",
id: "2",
rueckfrageId: "1",
postfachId: "sjkdfhlksdfsdf",
nachrichtEventId: "1",
message: "test message",
......@@ -191,9 +192,10 @@ describe("Topic API tests", () => {
status: "FINISHED",
createdAt: 1
};
const newMessage: Message = {
const newMessage: Antwort = {
attachments: [],
id: "1",
rueckfrageId: "1",
postfachId: "sjkdfhlksdfsdf",
nachrichtEventId: "1",
message: "New message"
......
......@@ -20,7 +20,7 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import axios from "axios";
import { Command, CommandReference, Message, Rueckfrage, RueckfrageHeader } from "../types";
import { Antwort, Command, CommandReference, Rueckfrage, RueckfrageHeader } from "../types";
export const SEND_FAILED = "send failed";
export const STATUS_CHECK_FAILED = "sending status check failed";
......@@ -58,7 +58,7 @@ export async function getRueckfrageOfPostfach(link: string): Promise<Rueckfrage>
}
}
export async function sendMessage(newMessage: Message): Promise<Message> {
export async function sendMessage(newMessage: Antwort): Promise<Antwort> {
try {
const response = await axios.put(`/api/antwort`, newMessage, { timeout: SEND_TIMEOUT_IN_MS });
await checkSendStatus(response.data);
......
......@@ -43,6 +43,10 @@ interface Nachricht extends Message {
trustLevel: TrustLevel;
}
export interface Antwort extends Message {
rueckfrageId: string;
}
interface NachrichtHeader extends BaseMessage {
title: string;
vorgangId: string;
......@@ -61,7 +65,7 @@ interface BaseRueckfrage {
export interface Rueckfrage extends BaseRueckfrage {
nachricht: Nachricht;
antworten: Message[];
antworten: Antwort[];
}
interface RueckfrageLink {
......
......@@ -21,7 +21,7 @@
*/
import * as api from "../../api/rueckfragen/rueckfragenAPI";
import { Message, Rueckfrage, RueckfrageHeader } from "../../api/types";
import { Antwort, Rueckfrage, RueckfrageHeader } from "../../api/types";
import { store } from "../../store";
import {
clearSelectedRueckfrage,
......@@ -167,8 +167,9 @@ describe("rueckfragen reducer tests", () => {
});
describe("sendMessageThunk tests", () => {
const newMessage: Message = {
const newMessage: Antwort = {
id: "2",
rueckfrageId: "2",
postfachId: "sjkdfhlksdfsdf",
nachrichtEventId: "1",
message: "Test",
......@@ -188,6 +189,7 @@ describe("rueckfragen reducer tests", () => {
it("should call sendMessage from api", () => {
const mockMessage = {
id: "3",
rueckfrageId: "3",
attachments: [],
date: 12345,
message: "",
......
......@@ -20,7 +20,7 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import { Message, Rueckfrage, RueckfrageHeader } from "../../api/types";
import { Antwort, Rueckfrage, RueckfrageHeader } from "../../api/types";
import {
getRueckfrageHeadersOfPostfach,
getRueckfrageOfPostfach,
......@@ -87,7 +87,7 @@ const rueckfragenSlice = createSlice({
}
});
function updateRueckfrage(selectedRueckfrage: Rueckfrage, newMessage: Message): Rueckfrage {
function updateRueckfrage(selectedRueckfrage: Rueckfrage, newMessage: Antwort): Rueckfrage {
return {
...selectedRueckfrage,
antworten: [...selectedRueckfrage.antworten, newMessage]
......@@ -109,7 +109,7 @@ export const fetchRueckfragenThunk = createAsyncThunk(
interface SendMessagePayload {
id: string;
newMessage: Message;
newMessage: Antwort;
}
export const sendMessageThunk = createAsyncThunk(
......
......@@ -66,7 +66,8 @@ describe("is rueckfrage marked new tests", () => {
},
antworten: [
{
id: "1",
id: "2",
rueckfrageId: "1",
postfachId: "sjkdfhlksdfsdf",
nachrichtEventId: "1",
message: "test message",
......
......@@ -35,7 +35,7 @@ import {
resetRueckfrageHeaderStatus,
sendMessageThunk
} from "../../features/rueckfragen/rueckfrageSlice";
import { Message } from "../../api/types";
import { Antwort } from "../../api/types";
import { LoadingPage } from "../../components/Core/Loading Page/LoadingPage";
import { ErrorPage } from "../../components/Core/Error Page/ErrorPage";
import { formatTimestampToDate, formatTimestampToDateAndTime } from "../../lib/date";
......@@ -143,8 +143,9 @@ export function DetailPage() {
return; // the message should not be empty or contain only whitespaces
}
const newMessage: Message = {
const newMessage: Antwort = {
id: selectedRueckfrage!.nachricht.id,
rueckfrageId: selectedRueckfrage!.nachricht.id,
postfachId: selectedRueckfrage!.nachricht.postfachId,
nachrichtEventId: selectedRueckfrage!.nachricht.nachrichtEventId,
message,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment