From bac6db568eca56050948a0a1a168996dbd096a75 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 08:18:36 -0600 Subject: [PATCH] prettier action fixes (#72) Co-authored-by: SydZero --- frontend/src/API/API_CreateMethods.tsx | 76 +- frontend/src/API/API_DeleteMethods.tsx | 12 +- frontend/src/API/API_GetMethods.tsx | 79 +- frontend/src/API/API_UpdateMethods.tsx | 27 +- frontend/src/pages/logIn.tsx | 2 +- frontend/test/API_CreateMethods.test.tsx | 82 +- frontend/test/API_DeleteMethods.test.tsx | 51 +- frontend/test/API_GetMethods.test.tsx | 953 +++++++++++++---------- frontend/test/API_UpdateMethods.test.tsx | 54 +- frontend/vitest.config.ts | 2 +- 10 files changed, 765 insertions(+), 573 deletions(-) diff --git a/frontend/src/API/API_CreateMethods.tsx b/frontend/src/API/API_CreateMethods.tsx index 75339d7b..79342e65 100644 --- a/frontend/src/API/API_CreateMethods.tsx +++ b/frontend/src/API/API_CreateMethods.tsx @@ -23,8 +23,11 @@ export async function createFamily(familyData: Family) { }); return response.data as Family; } catch (error: any) { - console.error(`Error creating family ${familyData.id}: ${error.message}`, error); - throw new Error('Failed to create family. Please try again later.'); + console.error( + `Error creating family ${familyData.id}: ${error.message}`, + error, + ); + throw new Error("Failed to create family. Please try again later."); } } @@ -37,8 +40,11 @@ export async function createMechanism(mechanismData: Mechanism) { }); return response.data as Mechanism; } catch (error: any) { - console.error(`Error creating mechanism ${mechanismData.id}: ${error.message}`, error); - throw new Error('Failed to create mechanism. Please try again later.'); + console.error( + `Error creating mechanism ${mechanismData.id}: ${error.message}`, + error, + ); + throw new Error("Failed to create mechanism. Please try again later."); } } @@ -52,8 +58,11 @@ export async function createReaction(reactionData: Reaction) { }); return response.data as Reaction; } catch (error: any) { - console.error(`Error creating reaction ${reactionData}: ${error.message}`, error); - throw new Error('Failed to create reaction. Please try again later.'); + console.error( + `Error creating reaction ${reactionData}: ${error.message}`, + error, + ); + throw new Error("Failed to create reaction. Please try again later."); } } @@ -66,8 +75,11 @@ export async function createSpecies(speciesData: Species) { }); return response.data as Species; } catch (error: any) { - console.error(`Error creating species ${speciesData}: ${error.message}`, error); - throw new Error('Failed to create species. Please try again later.'); + console.error( + `Error creating species ${speciesData}: ${error.message}`, + error, + ); + throw new Error("Failed to create species. Please try again later."); } } @@ -86,8 +98,13 @@ export async function addSpeciesToReaction( ); return response.data as ReactionSpecies; } catch (error: any) { - console.error(`Error adding species ${reactionSpeciesData.species_id} to reaction ${reactionSpeciesData.reaction_id}: ${error.message}`, error); - throw new Error('Failed to add species to reaction. Please try again later.'); + console.error( + `Error adding species ${reactionSpeciesData.species_id} to reaction ${reactionSpeciesData.reaction_id}: ${error.message}`, + error, + ); + throw new Error( + "Failed to add species to reaction. Please try again later.", + ); } } @@ -106,8 +123,13 @@ export async function addReactionToMechanism( ); return response.data as MechanismReaction; } catch (error: any) { - console.error(`Error add reaction ${mechanismReactionData.reaction_id} to mechanism ${mechanismReactionData.mechanism_id}: ${error.message}`, error); - throw new Error('Failed to add reaction to mechanism. Please try again later.'); + console.error( + `Error add reaction ${mechanismReactionData.reaction_id} to mechanism ${mechanismReactionData.mechanism_id}: ${error.message}`, + error, + ); + throw new Error( + "Failed to add reaction to mechanism. Please try again later.", + ); } } @@ -126,8 +148,13 @@ export async function addSpeciesToMechanism( ); return response.data as MechanismSpecies; } catch (error: any) { - console.error(`Error adding species ${mechanismSpeciesData.species_id} to mechanism ${mechanismSpeciesData.mechanism_id}: ${error.message}`, error); - throw new Error('Failed to add species to mechanism. Please try again later.'); + console.error( + `Error adding species ${mechanismSpeciesData.species_id} to mechanism ${mechanismSpeciesData.mechanism_id}: ${error.message}`, + error, + ); + throw new Error( + "Failed to add species to mechanism. Please try again later.", + ); } } @@ -140,8 +167,11 @@ export async function createUser(userData: User) { }); return response.data as User; } catch (error: any) { - console.error(`Error creating user ${userData.id}: ${error.message}`, error); - throw new Error('Failed to create user. Please try again later.'); + console.error( + `Error creating user ${userData.id}: ${error.message}`, + error, + ); + throw new Error("Failed to create user. Please try again later."); } } @@ -158,8 +188,11 @@ export async function addUserToMechanism(userMechanismData: UserMechanism) { ); return response.data as UserMechanism; } catch (error: any) { - console.error(`Error adding user ${userMechanismData.user_id} to mechanism: ${userMechanismData.mechanism_id} ${error.message}`, error); - throw new Error('Failed to add user to mechanism. Please try again later.'); + console.error( + `Error adding user ${userMechanismData.user_id} to mechanism: ${userMechanismData.mechanism_id} ${error.message}`, + error, + ); + throw new Error("Failed to add user to mechanism. Please try again later."); } } @@ -176,7 +209,10 @@ export async function createProperty(propertyData: Property) { ); return response.data as Property; } catch (error: any) { - console.error(`Error creating property ${propertyData.id}: ${error.message}`, error); - throw new Error('Failed to create property. Please try again later.'); + console.error( + `Error creating property ${propertyData.id}: ${error.message}`, + error, + ); + throw new Error("Failed to create property. Please try again later."); } } diff --git a/frontend/src/API/API_DeleteMethods.tsx b/frontend/src/API/API_DeleteMethods.tsx index 47f22273..37e9d62c 100644 --- a/frontend/src/API/API_DeleteMethods.tsx +++ b/frontend/src/API/API_DeleteMethods.tsx @@ -14,7 +14,7 @@ export async function deleteFamily(id: string) { return response.data; // Return response or a success indicator } catch (error: any) { console.error(`Error deleting family ${id}: ${error.message}`, error); - throw new Error('Failed to delete family. Please try again later.'); + throw new Error("Failed to delete family. Please try again later."); } } @@ -25,7 +25,7 @@ export async function deleteMechanism(id: string) { return response.data; } catch (error: any) { console.error(`Error deleting mechanism ${id}: ${error.message}`, error); - throw new Error('Failed to delete mechanism. Please try again later.'); + throw new Error("Failed to delete mechanism. Please try again later."); } } @@ -40,7 +40,7 @@ export async function deleteSpecies(id: string) { return response.data; } catch (error: any) { console.error(`Error deleting species ${id}: ${error.message}`, error); - throw new Error('Failed to delete species. Please try again later.'); + throw new Error("Failed to delete species. Please try again later."); } } @@ -55,7 +55,7 @@ export async function deleteReaction(id: string) { return response.data; } catch (error: any) { console.error(`Error deleting reaction ${id}: ${error.message}`, error); - throw new Error('Failed to delete reaction. Please try again later.'); + throw new Error("Failed to delete reaction. Please try again later."); } } @@ -70,7 +70,7 @@ export async function deleteUser(id: string) { return response.data; } catch (error: any) { console.error(`Error deleting user ${id}: ${error.message}`, error); - throw new Error('Failed to delete user. Please try again later.'); + throw new Error("Failed to delete user. Please try again later."); } } @@ -84,6 +84,6 @@ export async function deleteProperty(id: string) { return response.data; } catch (error: any) { console.error(`Error deleting property ${id}: ${error.message}`, error); - throw new Error('Failed to delete property. Please try again later.'); + throw new Error("Failed to delete property. Please try again later."); } } diff --git a/frontend/src/API/API_GetMethods.tsx b/frontend/src/API/API_GetMethods.tsx index 36a884bb..e9830f85 100644 --- a/frontend/src/API/API_GetMethods.tsx +++ b/frontend/src/API/API_GetMethods.tsx @@ -21,7 +21,7 @@ export async function getFamilies(): Promise { return response.data; } catch (error: any) { console.error(`Error fetching families: ${error.message}`, error); - return[] + return []; } } @@ -31,8 +31,8 @@ export async function getFamily(id: string): Promise { const response = await axios.get(`${BASE_URL}/families/${id}`); return response.data; } catch (error: any) { - console.error(`Error fetching family ${id}: ${error.message}`, error); - throw new Error('Failed to fetch family. Please try again later.'); + console.error(`Error fetching family ${id}: ${error.message}`, error); + throw new Error("Failed to fetch family. Please try again later."); } } @@ -57,7 +57,10 @@ export async function getMechanismsByFamilyId( ); return response.data; } catch (error: any) { - console.error(`Error fetching Mechanisms with family ${familyId}: ${error.message}`, error); + console.error( + `Error fetching Mechanisms with family ${familyId}: ${error.message}`, + error, + ); return []; } } @@ -69,7 +72,7 @@ export async function getMechanism(id: string): Promise { return response.data; } catch (error: any) { console.error(`Error fetching mechanism ${id}: ${error.message}`, error); - throw new Error('Failed to fetch mechanism. Please try again later.'); + throw new Error("Failed to fetch mechanism. Please try again later."); } } @@ -91,7 +94,7 @@ export async function getSpecies(id: string): Promise { return response.data; } catch (error: any) { console.error(`Error fetching species ${id}: ${error.message}`, error); - throw new Error('Failed to fetch species. Please try again later.'); + throw new Error("Failed to fetch species. Please try again later."); } } @@ -105,7 +108,10 @@ export async function getSpeciesByMechanismId( ); return response.data; } catch (error: any) { - console.error(`Error fetching species with mechanism ${mechanismId}: ${error.message}`, error); + console.error( + `Error fetching species with mechanism ${mechanismId}: ${error.message}`, + error, + ); return []; } } @@ -119,7 +125,10 @@ export async function getSpeciesByFamilyId( ); return response.data; } catch (error: any) { - console.error(`Error fetching species with family ${familyId}: ${error.message}`, error); + console.error( + `Error fetching species with family ${familyId}: ${error.message}`, + error, + ); return []; } } @@ -130,7 +139,10 @@ export async function getReactions(): Promise { const response = await axios.get(`${BASE_URL}/reactions`); return response.data; } catch (error: any) { - console.error(`Error fetching species with reactions: ${error.message}`, error); + console.error( + `Error fetching species with reactions: ${error.message}`, + error, + ); return []; } } @@ -142,7 +154,7 @@ export async function getReaction(id: string): Promise { return response.data; } catch (error: any) { console.error(`Error fetching reaction ${id}: ${error.message}`, error); - throw new Error('Failed to fetch reaction. Please try again later.'); + throw new Error("Failed to fetch reaction. Please try again later."); } } @@ -156,7 +168,10 @@ export async function getReactionsByMechanismId( ); return response.data; } catch (error: any) { - console.error(`Error fetching reactions from mechanism ${mechanismId}: ${error.message}`, error); + console.error( + `Error fetching reactions from mechanism ${mechanismId}: ${error.message}`, + error, + ); return []; } } @@ -170,7 +185,10 @@ export async function getReactionsByFamilyId( ); return response.data; } catch (error: any) { - console.error(`Error fetching reactions from family ${familyId}: ${error.message}`, error); + console.error( + `Error fetching reactions from family ${familyId}: ${error.message}`, + error, + ); return []; } } @@ -184,7 +202,10 @@ export async function getReactantsByReactionIdAsync( ); return response.data; } catch (error: any) { - console.error(`Error fetching reactants from reaction ${reactionId}: ${error.message}`, error); + console.error( + `Error fetching reactants from reaction ${reactionId}: ${error.message}`, + error, + ); return []; } } @@ -198,7 +219,10 @@ export async function getProductsByReactionIdAsync( ); return response.data; } catch (error: any) { - console.error(`Error fetching products from reaction ${reactionId}: ${error.message}`, error); + console.error( + `Error fetching products from reaction ${reactionId}: ${error.message}`, + error, + ); return []; } } @@ -221,8 +245,11 @@ export async function getUserByEmail(email: string): Promise { const response = await axios.get(`${BASE_URL}/users/email/${email}`); return response.data; } catch (error: any) { - console.error(`Error fetching user by email ${email}: ${error.message}`, error); - throw new Error('Failed to fetch user. Please try again later.'); + console.error( + `Error fetching user by email ${email}: ${error.message}`, + error, + ); + throw new Error("Failed to fetch user. Please try again later."); } } @@ -232,8 +259,8 @@ export async function getUserById(id: string): Promise { return response.data; } catch (error: any) { console.error(`Error fetching user ${id}: ${error.message}`, error); - throw new Error('Failed to fetch user. Please try again later.'); - } + throw new Error("Failed to fetch user. Please try again later."); + } } export async function getPropertyById(id: string): Promise { @@ -243,8 +270,11 @@ export async function getPropertyById(id: string): Promise { ); return response.data; } catch (error: any) { - console.error(`Error fetching user by property ${id}: ${error.message}`, error); - throw new Error('Failed to fetch property. Please try again later.'); + console.error( + `Error fetching user by property ${id}: ${error.message}`, + error, + ); + throw new Error("Failed to fetch property. Please try again later."); } } @@ -258,8 +288,13 @@ export async function getPropertyBySpeciesAndMechanism( ); return response.data; } catch (error: any) { - console.error(`Error fetching property by species ${species} and mechanism ${mechanism}: ${error.message}`, error); - throw new Error('Failed to fetch property by species and mechanism. Please try again later.'); + console.error( + `Error fetching property by species ${species} and mechanism ${mechanism}: ${error.message}`, + error, + ); + throw new Error( + "Failed to fetch property by species and mechanism. Please try again later.", + ); } } diff --git a/frontend/src/API/API_UpdateMethods.tsx b/frontend/src/API/API_UpdateMethods.tsx index 3aad2e0a..84da3b41 100644 --- a/frontend/src/API/API_UpdateMethods.tsx +++ b/frontend/src/API/API_UpdateMethods.tsx @@ -26,7 +26,7 @@ export async function updateFamily(family: Family) { return response.data as Family; } catch (error: any) { console.error(`Error updating family ${family}: ${error.message}`, error); - throw new Error('Failed to update family. Please try again later.'); + throw new Error("Failed to update family. Please try again later."); } } @@ -44,8 +44,11 @@ export async function updateMechanism(mechanism: Mechanism) { ); return response.data as Mechanism; } catch (error: any) { - console.error(`Error updating mechanism ${mechanism}: ${error.message}`, error); - throw new Error('Failed to update mechanism. Please try again later.'); + console.error( + `Error updating mechanism ${mechanism}: ${error.message}`, + error, + ); + throw new Error("Failed to update mechanism. Please try again later."); } } @@ -64,7 +67,7 @@ export async function updateSpecies(species: Species) { return response.data as Species; } catch (error: any) { console.error(`Error updating species ${species}: ${error.message}`, error); - throw new Error('Failed to update species. Please try again later.'); + throw new Error("Failed to update species. Please try again later."); } } @@ -82,8 +85,11 @@ export async function updateReaction(reaction: Reaction) { ); return response.data as Reaction; } catch (error: any) { - console.error(`Error updating reaction ${reaction}: ${error.message}`, error); - throw new Error('Failed to update reaction. Please try again later.'); + console.error( + `Error updating reaction ${reaction}: ${error.message}`, + error, + ); + throw new Error("Failed to update reaction. Please try again later."); } } @@ -97,7 +103,7 @@ export async function updateUser(id: string, user: User) { return response.data as User; } catch (error: any) { console.error(`Error updating user ${id}: ${error.message}`, error); - throw new Error('Failed to update user. Please try again later.'); + throw new Error("Failed to update user. Please try again later."); } } @@ -114,7 +120,10 @@ export async function updateProperty(property: Property) { ); return response.data as Property; } catch (error: any) { - console.error(`Error updating property ${property}: ${error.message}`, error); - throw new Error('Failed to update property. Please try again later.'); + console.error( + `Error updating property ${property}: ${error.message}`, + error, + ); + throw new Error("Failed to update property. Please try again later."); } } diff --git a/frontend/src/pages/logIn.tsx b/frontend/src/pages/logIn.tsx index 0921aefd..95dadc58 100644 --- a/frontend/src/pages/logIn.tsx +++ b/frontend/src/pages/logIn.tsx @@ -29,7 +29,7 @@ const LogIn = () => { const { setUser } = useAuth(); // Get setUser from AuthContext const [user, setLocalUser] = useState(null); const [profile, setProfile] = useState(null); - const navigate = useNavigate(); + const navigate = useNavigate(); const handleClick = () => navigate("/LoggedIn"); const login = useGoogleLogin({ diff --git a/frontend/test/API_CreateMethods.test.tsx b/frontend/test/API_CreateMethods.test.tsx index c1b5eb7e..e513ef8f 100644 --- a/frontend/test/API_CreateMethods.test.tsx +++ b/frontend/test/API_CreateMethods.test.tsx @@ -51,12 +51,12 @@ describe("API create functions tests", () => { const familyData = { id: "123", name: "Test Family" }; const errorMessage = "Request failed with status code 404"; - (axios.post as typeof axios.post & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.post as typeof axios.post & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(createFamily(familyData)).rejects.toThrow( - "Failed to create family. Please try again later." + "Failed to create family. Please try again later.", ); }); @@ -79,12 +79,12 @@ describe("API create functions tests", () => { const mechanismData = { id: "123", name: "Test Mechanism" }; const errorMessage = "Request failed with status code 404"; - (axios.post as typeof axios.post & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.post as typeof axios.post & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(createMechanism(mechanismData)).rejects.toThrow( - "Failed to create mechanism. Please try again later." + "Failed to create mechanism. Please try again later.", ); }); @@ -107,12 +107,12 @@ describe("API create functions tests", () => { const reactionData = { id: "123", type: "Test Reaction" }; const errorMessage = "Request failed with status code 404"; - (axios.post as typeof axios.post & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.post as typeof axios.post & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(createReaction(reactionData)).rejects.toThrow( - "Failed to create reaction. Please try again later." + "Failed to create reaction. Please try again later.", ); }); @@ -135,12 +135,12 @@ describe("API create functions tests", () => { const speciesData = { id: "123", name: "Test Species" }; const errorMessage = "Request failed with status code 404"; - (axios.post as typeof axios.post & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.post as typeof axios.post & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(createSpecies(speciesData)).rejects.toThrow( - "Failed to create species. Please try again later." + "Failed to create species. Please try again later.", ); }); @@ -163,12 +163,12 @@ describe("API create functions tests", () => { const reactionSpeciesData = { reactionId: "123", speciesId: "456" }; const errorMessage = "Request failed with status code 404"; - (axios.post as typeof axios.post & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.post as typeof axios.post & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(addSpeciesToReaction(reactionSpeciesData)).rejects.toThrow( - "Failed to add species to reaction. Please try again later." + "Failed to add species to reaction. Please try again later.", ); }); @@ -191,12 +191,12 @@ describe("API create functions tests", () => { const mechanismReactionData = { mechanismId: "123", reactionId: "456" }; const errorMessage = "Request failed with status code 404"; - (axios.post as typeof axios.post & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.post as typeof axios.post & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(addReactionToMechanism(mechanismReactionData)).rejects.toThrow( - "Failed to add reaction to mechanism. Please try again later." + "Failed to add reaction to mechanism. Please try again later.", ); }); @@ -219,12 +219,12 @@ describe("API create functions tests", () => { const mechanismSpeciesData = { mechanismId: "123", speciesId: "456" }; const errorMessage = "Request failed with status code 404"; - (axios.post as typeof axios.post & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.post as typeof axios.post & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(addSpeciesToMechanism(mechanismSpeciesData)).rejects.toThrow( - "Failed to add species to mechanism. Please try again later." + "Failed to add species to mechanism. Please try again later.", ); }); @@ -247,12 +247,12 @@ describe("API create functions tests", () => { const userData = { id: "123", name: "Test User" }; const errorMessage = "Request failed with status code 404"; - (axios.post as typeof axios.post & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.post as typeof axios.post & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(createUser(userData)).rejects.toThrow( - "Failed to create user. Please try again later." + "Failed to create user. Please try again later.", ); }); @@ -275,12 +275,12 @@ describe("API create functions tests", () => { const userMechanismData = { userId: "123", mechanismId: "456" }; const errorMessage = "Request failed with status code 404"; - (axios.post as typeof axios.post & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.post as typeof axios.post & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(addUserToMechanism(userMechanismData)).rejects.toThrow( - "Failed to add user to mechanism. Please try again later." + "Failed to add user to mechanism. Please try again later.", ); }); @@ -312,12 +312,12 @@ describe("API create functions tests", () => { }; const errorMessage = "Request failed with status code 404"; - (axios.post as typeof axios.post & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.post as typeof axios.post & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(createProperty(propertyData)).rejects.toThrow( - "Failed to create property. Please try again later." + "Failed to create property. Please try again later.", ); }); -}); \ No newline at end of file +}); diff --git a/frontend/test/API_DeleteMethods.test.tsx b/frontend/test/API_DeleteMethods.test.tsx index e2b79127..dc3d776e 100644 --- a/frontend/test/API_DeleteMethods.test.tsx +++ b/frontend/test/API_DeleteMethods.test.tsx @@ -48,13 +48,13 @@ describe("API delete functions tests", () => { const id = "12345"; const errorMessage = "Request failed with status code 404"; - (axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(deleteFamily(id)).rejects.toThrow( - "Failed to delete family. Please try again later." - ); + "Failed to delete family. Please try again later.", + ); expect(axios.delete).toHaveBeenCalledWith(`${BASE_URL}/families/${id}`, { headers: { @@ -81,12 +81,12 @@ describe("API delete functions tests", () => { const id = "12345"; const errorMessage = "Request failed with status code 404"; - (axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(deleteMechanism(id)).rejects.toThrow( - "Failed to delete mechanism. Please try again later." + "Failed to delete mechanism. Please try again later.", ); }); @@ -111,12 +111,12 @@ describe("API delete functions tests", () => { const id = "12345"; const errorMessage = "Request failed with status code 404"; - (axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(deleteSpecies(id)).rejects.toThrow( - "Failed to delete species. Please try again later." + "Failed to delete species. Please try again later.", ); expect(axios.delete).toHaveBeenCalledWith(`${BASE_URL}/species/${id}`, { @@ -147,12 +147,12 @@ describe("API delete functions tests", () => { const id = "12345"; const errorMessage = "Request failed with status code 404"; - (axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(deleteReaction(id)).rejects.toThrow( - "Failed to delete reaction. Please try again later." + "Failed to delete reaction. Please try again later.", ); expect(axios.delete).toHaveBeenCalledWith(`${BASE_URL}/reactions/${id}`, { @@ -162,7 +162,6 @@ describe("API delete functions tests", () => { }); }); - it("should successfully delete a user", async () => { const mockedDelete = vi .spyOn(axios, "delete") @@ -184,12 +183,12 @@ describe("API delete functions tests", () => { const id = "12345"; const errorMessage = "Request failed with status code 404"; - (axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(deleteUser(id)).rejects.toThrow( - "Failed to delete user. Please try again later." + "Failed to delete user. Please try again later.", ); expect(axios.delete).toHaveBeenCalledWith(`${BASE_URL}/users/${id}`, { @@ -220,12 +219,12 @@ describe("API delete functions tests", () => { const id = "12345"; const errorMessage = "Request failed with status code 404"; - (axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.delete as typeof axios.delete & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(deleteProperty(id)).rejects.toThrow( - "Failed to delete property. Please try again later." + "Failed to delete property. Please try again later.", ); expect(axios.delete).toHaveBeenCalledWith(`${BASE_URL}/properties/${id}`, { diff --git a/frontend/test/API_GetMethods.test.tsx b/frontend/test/API_GetMethods.test.tsx index c6f4d0be..34783af4 100644 --- a/frontend/test/API_GetMethods.test.tsx +++ b/frontend/test/API_GetMethods.test.tsx @@ -1,602 +1,711 @@ -import { describe, expect, it, vi } from 'vitest'; -import type { Mock } from 'vitest'; -import axios, { AxiosHeaders, AxiosResponse } from 'axios'; +import { describe, expect, it, vi } from "vitest"; +import type { Mock } from "vitest"; +import axios, { AxiosHeaders, AxiosResponse } from "axios"; import { - downloadOAJSON, - downloadOAYAML, - downloadOAMusicbox, - getFamilies, - getFamily, - getReactions, - getReaction, - getReactionsByMechanismId, - getAllSpecies, - getSpecies, - getSpeciesByMechanismId, - getMechanisms, - getMechanism, - getMechanismsByFamilyId, - getSpeciesByFamilyId, - getReactionsByFamilyId, - getReactantsByReactionIdAsync, - getProductsByReactionIdAsync, - getPropertyBySpeciesAndMechanism, - getUsers, - getUserByEmail, - getUserById, - getPropertyById, - getSpeciesPropertiesByMechanismIDAsync -} from '../src/API/API_GetMethods'; -import { Mechanism } from '../src/API/API_Interfaces'; + downloadOAJSON, + downloadOAYAML, + downloadOAMusicbox, + getFamilies, + getFamily, + getReactions, + getReaction, + getReactionsByMechanismId, + getAllSpecies, + getSpecies, + getSpeciesByMechanismId, + getMechanisms, + getMechanism, + getMechanismsByFamilyId, + getSpeciesByFamilyId, + getReactionsByFamilyId, + getReactantsByReactionIdAsync, + getProductsByReactionIdAsync, + getPropertyBySpeciesAndMechanism, + getUsers, + getUserByEmail, + getUserById, + getPropertyById, + getSpeciesPropertiesByMechanismIDAsync, +} from "../src/API/API_GetMethods"; +import { Mechanism } from "../src/API/API_Interfaces"; // Mock axios using vitest's built-in mock function -vi.mock('axios'); - -describe('API get functions tests', () => { - const mockResponseData = { success: true }; - - function createMockResponse() { - return { - data: mockResponseData, - status: 200, - statusText: 'OK', - headers: {}, - config: { - headers: new AxiosHeaders({ 'Content-Type': 'text/plain' }), - }, - } as AxiosResponse; - } - -// Tests for getFamilies -it('should successfully get all families', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; +vi.mock("axios"); + +describe("API get functions tests", () => { + const mockResponseData = { success: true }; + + function createMockResponse() { + return { + data: mockResponseData, + status: 200, + statusText: "OK", + headers: {}, + config: { + headers: new AxiosHeaders({ "Content-Type": "text/plain" }), + }, + } as AxiosResponse; + } + + // Tests for getFamilies + it("should successfully get all families", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; const result = await getFamilies(); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/families`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/families`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getFamilies', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getFamilies", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); const result = await getFamilies(); expect(result).toEqual([]); -}); - + }); + + it("should throw an error if the getFamilies() API call fails", async () => { + const mockError = { + response: { status: 500, statusText: "Internal Server Error" }, + }; + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); -it('should throw an error if the getFamilies() API call fails', async () => { - const mockError = { response: { status: 500, statusText: 'Internal Server Error' } }; - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); - const result = await getFamilies(); - expect(result).toEqual([]); -}); - + expect(result).toEqual([]); + }); -// Tests for getFamily -it('should successfully get a family with valid uuid', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + // Tests for getFamily + it("should successfully get a family with valid uuid", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const uuid = 'valid-uuid'; + const uuid = "valid-uuid"; const result = await getFamily(uuid); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/families/${uuid}`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/families/${uuid}`, + ); expect(result).toEqual(mockResponseData); -}); + }); + it("should throw an error if the getFamily() API call fails", async () => { + const mockError = { + response: { status: 500, statusText: "Internal Server Error" }, + }; + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); -it('should throw an error if the getFamily() API call fails', async () => { - const mockError = { response: { status: 500, statusText: 'Internal Server Error' } }; - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); - - const uuid = 'valid-uuid'; - await expect(getFamily(uuid)).rejects.toThrow('Failed to fetch family. Please try again later.'); -}); + const uuid = "valid-uuid"; + await expect(getFamily(uuid)).rejects.toThrow( + "Failed to fetch family. Please try again later.", + ); + }); - // Tests for getTagMechanisms -it('should successfully get all tag mechanisms', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + // Tests for getTagMechanisms + it("should successfully get all tag mechanisms", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; const result = await getMechanisms(); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/mechanism`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/mechanism`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getMechanisms', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getMechanisms", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); const result = await getMechanisms(); expect(result).toEqual([]); -}); + }); -// Tests for getTagMechanismsFromFamily -it('should successfully get tag mechanisms from family with valid family_uuid', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + // Tests for getTagMechanismsFromFamily + it("should successfully get tag mechanisms from family with valid family_uuid", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const family_uuid = 'valid-uuid'; + const family_uuid = "valid-uuid"; const result = await getMechanismsByFamilyId(family_uuid); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/mechanism/family/${family_uuid}`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/mechanism/family/${family_uuid}`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getMechanismsByFamilyID', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getMechanismsByFamilyID", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); - const family_uuid = 'valid-uuid'; + const family_uuid = "valid-uuid"; const result = await getMechanismsByFamilyId(family_uuid); expect(result).toEqual([]); -}); + }); -// Tests for getTagMechanism -it('should successfully get a tag mechanism with valid uuid', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + // Tests for getTagMechanism + it("should successfully get a tag mechanism with valid uuid", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const uuid = 'valid-uuid'; + const uuid = "valid-uuid"; const result = await getMechanism(uuid); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/mechanism/${uuid}`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/mechanism/${uuid}`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should throw an error if the getMechanism() API call fails', async () => { - const mockError = { response: { status: 500, statusText: 'Internal Server Error' } }; - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); - - const uuid = 'valid-uuid'; - await expect(getMechanism(uuid)).rejects.toThrow('Failed to fetch mechanism. Please try again later.'); -}); + it("should throw an error if the getMechanism() API call fails", async () => { + const mockError = { + response: { status: 500, statusText: "Internal Server Error" }, + }; + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); + const uuid = "valid-uuid"; + await expect(getMechanism(uuid)).rejects.toThrow( + "Failed to fetch mechanism. Please try again later.", + ); + }); - // Tests for getAllSpecies - it('should successfully get all species', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + // Tests for getAllSpecies + it("should successfully get all species", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; const result = await getAllSpecies(); expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/species`); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getSpecies', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getSpecies", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); const result = await getAllSpecies(); expect(result).toEqual([]); -}); + }); -// Tests for getSpecies -it('should successfully get a species with valid uuid', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + // Tests for getSpecies + it("should successfully get a species with valid uuid", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const uuid = 'valid-uuid'; + const uuid = "valid-uuid"; const result = await getSpecies(uuid); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/species/${uuid}`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/species/${uuid}`, + ); expect(result).toEqual(mockResponseData); -}); - -it('should throw an error if the API call fails for getSpeciesById', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + }); - const uuid = 'valid-uuid'; - await expect(getSpecies(uuid)).rejects.toThrow('Failed to fetch species. Please try again later.'); -}); + it("should throw an error if the API call fails for getSpeciesById", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); + const uuid = "valid-uuid"; + await expect(getSpecies(uuid)).rejects.toThrow( + "Failed to fetch species. Please try again later.", + ); + }); - it('should successfully get species with valid familyId', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + it("should successfully get species with valid familyId", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const familyId = 'valid-family-id'; + const familyId = "valid-family-id"; const result = await getSpeciesByFamilyId(familyId); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/species/family/${familyId}`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/species/family/${familyId}`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getSpeciesByFamilyId', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getSpeciesByFamilyId", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); - const family_uuid = 'valid-uuid'; + const family_uuid = "valid-uuid"; const result = await getSpeciesByFamilyId(family_uuid); expect(result).toEqual([]); -}); + }); -it('should successfully get species from mechanismId', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + it("should successfully get species from mechanismId", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const mechanismId = 'valid-mechanism-id'; + const mechanismId = "valid-mechanism-id"; const result = await getSpeciesByMechanismId(mechanismId); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/mechanismspecies/mechanism/${mechanismId}`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/mechanismspecies/mechanism/${mechanismId}`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getSpeciesByMechanismID', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getSpeciesByMechanismID", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); - const mechanism_uuid = 'valid-uuid'; + const mechanism_uuid = "valid-uuid"; const result = await getSpeciesByMechanismId(mechanism_uuid); expect(result).toEqual([]); -}); + }); -// Tests for getReactionsFromTagMechanism -it('should successfully get reactions from tag mechanism with valid tag_mechanism_uuid', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + // Tests for getReactionsFromTagMechanism + it("should successfully get reactions from tag mechanism with valid tag_mechanism_uuid", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const tag_mechanism_uuid = 'valid-uuid'; + const tag_mechanism_uuid = "valid-uuid"; const result = await getReactionsByMechanismId(tag_mechanism_uuid); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/reactions/mechanism/${tag_mechanism_uuid}`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/reactions/mechanism/${tag_mechanism_uuid}`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getReactionsByMechanismId', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getReactionsByMechanismId", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); - const mechanism_uuid = 'valid-uuid'; + const mechanism_uuid = "valid-uuid"; const result = await getReactionsByMechanismId(mechanism_uuid); expect(result).toEqual([]); -}); - + }); -it('should successfully get reactions from family with valid familyId', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + it("should successfully get reactions from family with valid familyId", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const familyId = 'valid-family-id'; + const familyId = "valid-family-id"; const result = await getReactionsByFamilyId(familyId); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/reactions/family/${familyId}`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/reactions/family/${familyId}`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getReactionsByFamilyId', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getReactionsByFamilyId", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); - const family_uuid = 'valid-uuid'; + const family_uuid = "valid-uuid"; const result = await getReactionsByFamilyId(family_uuid); expect(result).toEqual([]); -}); + }); -// Tests for getReactions -it('should successfully get all reactions', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + // Tests for getReactions + it("should successfully get all reactions", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; const result = await getReactions(); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/reactions`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/reactions`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getReactions', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getReactions", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); const result = await getReactions(); expect(result).toEqual([]); -}); + }); -// Tests for getReaction -it('should successfully get a reaction with valid uuid', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + // Tests for getReaction + it("should successfully get a reaction with valid uuid", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const uuid = 'valid-uuid'; + const uuid = "valid-uuid"; const result = await getReaction(uuid); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/reactions/${uuid}`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/reactions/${uuid}`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should throw an error if the API call fails', async () => { - const mockError = { response: { status: 500, statusText: 'Internal Server Error' } }; - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); - - const uuid = 'valid-uuid'; - await expect(getReaction(uuid)).rejects.toThrow('Failed to fetch reaction. Please try again later.'); -}); + it("should throw an error if the API call fails", async () => { + const mockError = { + response: { status: 500, statusText: "Internal Server Error" }, + }; + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); -it('should successfully get reactants by reaction ID', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + const uuid = "valid-uuid"; + await expect(getReaction(uuid)).rejects.toThrow( + "Failed to fetch reaction. Please try again later.", + ); + }); + + it("should successfully get reactants by reaction ID", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const reactionId = 'valid-reaction-id'; + const reactionId = "valid-reaction-id"; const result = await getReactantsByReactionIdAsync(reactionId); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/reactionspecies/reaction/${reactionId}/reactants`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/reactionspecies/reaction/${reactionId}/reactants`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getReactantsByReactionId', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getReactantsByReactionId", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); - const valid_uuid = 'valid-uuid'; + const valid_uuid = "valid-uuid"; const result = await getReactantsByReactionIdAsync(valid_uuid); expect(result).toEqual([]); -}); + }); -it('should successfully get products by reaction ID', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + it("should successfully get products by reaction ID", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const reactionId = 'valid-reaction-id'; + const reactionId = "valid-reaction-id"; const result = await getProductsByReactionIdAsync(reactionId); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/reactionspecies/reaction/${reactionId}/products`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/reactionspecies/reaction/${reactionId}/products`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getProductsByReactionId', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getProductsByReactionId", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); - const valid_uuid = 'valid-uuid'; + const valid_uuid = "valid-uuid"; const result = await getProductsByReactionIdAsync(valid_uuid); expect(result).toEqual([]); -}); + }); -// Tests for getUsers -it('should successfully get all users', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + // Tests for getUsers + it("should successfully get all users", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; const result = await getUsers(); expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/users`); expect(result).toEqual(mockResponseData); -}); + }); -it('should return an empty list if the API call fails for getUsers', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should return an empty list if the API call fails for getUsers", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); const result = await getUsers(); expect(result).toEqual([]); -}); + }); -it('should successfully get user by email', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; - const email = 'valid-user-email'; + it("should successfully get user by email", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; + const email = "valid-user-email"; const result = await getUserByEmail(email); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/users/email/${email}`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/users/email/${email}`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should throw an error if the getUserByEmail call fails', async () => { - const mockError = { response: { status: 500, statusText: 'Internal Server Error' } }; - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); - - const email = 'valid-email'; - await expect(getUserByEmail(email)).rejects.toThrow('Failed to fetch user. Please try again later.'); -}); + it("should throw an error if the getUserByEmail call fails", async () => { + const mockError = { + response: { status: 500, statusText: "Internal Server Error" }, + }; + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); -it('should successfully get user by id', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; - const UserId = 'valid-user-id'; + const email = "valid-email"; + await expect(getUserByEmail(email)).rejects.toThrow( + "Failed to fetch user. Please try again later.", + ); + }); + + it("should successfully get user by id", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; + const UserId = "valid-user-id"; const result = await getUserById(UserId); - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/users/id/${UserId}`); + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/users/id/${UserId}`, + ); expect(result).toEqual(mockResponseData); -}); + }); -it('should throw an error if the getUserById call fails with 404', async () => { - const mockError = { response: 'Internal Server Error'}; - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); - - const uuid = 'valid-uuid'; - await expect(getUserById(uuid)).rejects.toThrow('Failed to fetch user. Please try again later.'); -}); + it("should throw an error if the getUserById call fails with 404", async () => { + const mockError = { response: "Internal Server Error" }; + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); + + const uuid = "valid-uuid"; + await expect(getUserById(uuid)).rejects.toThrow( + "Failed to fetch user. Please try again later.", + ); + }); -it('should successfully get a property by id', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + it("should successfully get a property by id", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; - const propertyId = 'valid-property-id'; + const propertyId = "valid-property-id"; const result = await getPropertyById(propertyId); expect(mockedGet).toHaveBeenCalledWith( - `http://localhost:8080/api/properties/id/${propertyId}` + `http://localhost:8080/api/properties/id/${propertyId}`, ); expect(result).toEqual(mockResponseData); }); -it('should handle error correctly for getPropertyById', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should handle error correctly for getPropertyById", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); - const propertyId = 'invalid-property-id'; - await expect(getPropertyById(propertyId)).rejects.toThrow('Failed to fetch property. Please try again later.'); + const propertyId = "invalid-property-id"; + await expect(getPropertyById(propertyId)).rejects.toThrow( + "Failed to fetch property. Please try again later.", + ); expect(axios.get).toHaveBeenCalledWith( - `http://localhost:8080/api/properties/id/${propertyId}` + `http://localhost:8080/api/properties/id/${propertyId}`, ); }); -it('should successfully get a property by species and mechanism', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; + it("should successfully get a property by species and mechanism", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; const species = "species"; const mechanism = "mechanism"; const result = await getPropertyBySpeciesAndMechanism(species, mechanism); expect(mockedGet).toHaveBeenCalledWith( - `http://localhost:8080/api/properties/id/${species}/${mechanism}` + `http://localhost:8080/api/properties/id/${species}/${mechanism}`, ); expect(result).toEqual(mockResponseData); }); -it('should handle error correctly for property by species and mechanism', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); + it("should handle error correctly for property by species and mechanism", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); const species = "species"; const mechanism = "mechanism"; - await expect(getPropertyBySpeciesAndMechanism(species, mechanism)).rejects.toThrow('Failed to fetch property by species and mechanism. Please try again later.'); + await expect( + getPropertyBySpeciesAndMechanism(species, mechanism), + ).rejects.toThrow( + "Failed to fetch property by species and mechanism. Please try again later.", + ); + + expect(axios.get).toHaveBeenCalledWith( + `http://localhost:8080/api/properties/id/${species}/${mechanism}`, + ); + }); + + // Tests for downloadOAJSON + it("should successfully get OAJSON with valid tag_mechanism_uuid", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; + + const tag_mechanism_uuid = "valid-uuid"; + const result = await downloadOAJSON(tag_mechanism_uuid); + + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/json`, + { + headers: { "Content-Type": "text/plain" }, + responseType: "text", + }, + ); + + expect(result).toBe(mockResponseData); + }); + + it("should return an empty string when tag_mechanism_uuid is not provided", async () => { + const mockedGet = vi.spyOn(axios, "get"); + + const result = await downloadOAJSON(); + + expect(result).toBe(""); + expect(mockedGet).not.toHaveBeenCalled(); + + mockedGet.mockRestore(); + }); + + it("should handle error correctly for downloadOAJSON", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); + + const tag_mechanism_uuid = "invalid-uuid"; + await expect(downloadOAJSON(tag_mechanism_uuid)).rejects.toThrow( + "Network error", + ); expect(axios.get).toHaveBeenCalledWith( - `http://localhost:8080/api/properties/id/${species}/${mechanism}` - ); - }); - - // Tests for downloadOAJSON - it('should successfully get OAJSON with valid tag_mechanism_uuid', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; - - const tag_mechanism_uuid = 'valid-uuid'; - const result = await downloadOAJSON(tag_mechanism_uuid); - - expect(mockedGet).toHaveBeenCalledWith( - `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/json`, - { - headers: { 'Content-Type': 'text/plain' }, - responseType: 'text', - } - ); - - expect(result).toBe(mockResponseData); - }); - - it('should return an empty string when tag_mechanism_uuid is not provided', async () => { - const mockedGet = vi.spyOn(axios, 'get'); - - const result = await downloadOAJSON(); - - expect(result).toBe(""); - expect(mockedGet).not.toHaveBeenCalled(); - - mockedGet.mockRestore(); - }); - - it('should handle error correctly for downloadOAJSON', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); - - const tag_mechanism_uuid = 'invalid-uuid'; - await expect(downloadOAJSON(tag_mechanism_uuid)).rejects.toThrow('Network error'); - - expect(axios.get).toHaveBeenCalledWith( - `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/json`, - { - headers: { 'Content-Type': 'text/plain' }, - responseType: 'text', - } - ); - }); - - // Tests for downloadOAYAML - it('should successfully get OAYAML with valid tag_mechanism_uuid', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; - - const tag_mechanism_uuid = 'valid-uuid'; - const result = await downloadOAYAML(tag_mechanism_uuid); - - expect(mockedGet).toHaveBeenCalledWith( - `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/yaml`, - { - headers: { 'Content-Type': 'text/plain' }, - responseType: 'text', - } - ); - - expect(result).toBe(mockResponseData); - }); - - it('should return an empty string when tag_mechanism_uuid is not provided for OAYAML', async () => { - const mockedGet = vi.spyOn(axios, 'get'); - - const result = await downloadOAYAML(); - - expect(result).toBe(""); - expect(mockedGet).not.toHaveBeenCalled(); - - mockedGet.mockRestore(); - }); - - it('should handle error correctly for downloadOAYAML', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); - - const tag_mechanism_uuid = 'invalid-uuid'; - await expect(downloadOAYAML(tag_mechanism_uuid)).rejects.toThrow('Network error'); - - expect(axios.get).toHaveBeenCalledWith( - `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/yaml`, - { - headers: { 'Content-Type': 'text/plain' }, - responseType: 'text', - } - ); - }); - - // Tests for downloadOAMusicbox - it('should successfully get OAMusicbox with valid tag_mechanism_uuid', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; - - const tag_mechanism_uuid = 'valid-uuid'; - const result = await downloadOAMusicbox(tag_mechanism_uuid); - - expect(mockedGet).toHaveBeenCalledWith( - `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/musicbox`, - { - responseType: "arraybuffer", - headers: { Accept: "application/zip" } - } - ); - - expect(result).toBe(mockResponseData); - }); - - it('should return an empty string when tag_mechanism_uuid is not provided for OAMusicbox', async () => { - const mockedGet = vi.spyOn(axios, 'get'); - - const result = await downloadOAMusicbox(); - - expect(result).toBe(""); - expect(mockedGet).not.toHaveBeenCalled(); - - mockedGet.mockRestore(); - }); - - it('should handle error correctly for downloadOAMusicbox', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); - - const tag_mechanism_uuid = 'invalid-uuid'; - await expect(downloadOAMusicbox(tag_mechanism_uuid)).rejects.toThrow('Network error'); - - expect(axios.get).toHaveBeenCalledWith( - `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/musicbox`, - { - responseType: "arraybuffer", - headers: { Accept: "application/zip" } - } - ); - }); - - // Tests for getSpeciesPropertiesByMechanismIDAsync - it('should successfully getSpeciesPropertiesByMechanismIDAsync', async () => { - const mockedGet = vi.spyOn(axios, 'get').mockResolvedValueOnce(createMockResponse()) as Mock; - const uuid = 'valid-uuid'; - const result = await getSpeciesPropertiesByMechanismIDAsync(uuid); - - expect(mockedGet).toHaveBeenCalledWith(`http://localhost:8080/api/initialconditionspecies/mechanism/${uuid}`); - expect(result).toEqual(mockResponseData); - }); - - it('should return an empty list if the API call fails for getSpeciesPropertiesByMechanismIDAsync', async () => { - const mockError = new Error('Network error'); - vi.spyOn(axios, 'get').mockRejectedValueOnce(mockError); - const uuid = 'valid-uuid'; - - const result = await getSpeciesPropertiesByMechanismIDAsync(uuid); - expect(result).toEqual([]); - }); - -}); \ No newline at end of file + `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/json`, + { + headers: { "Content-Type": "text/plain" }, + responseType: "text", + }, + ); + }); + + // Tests for downloadOAYAML + it("should successfully get OAYAML with valid tag_mechanism_uuid", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; + + const tag_mechanism_uuid = "valid-uuid"; + const result = await downloadOAYAML(tag_mechanism_uuid); + + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/yaml`, + { + headers: { "Content-Type": "text/plain" }, + responseType: "text", + }, + ); + + expect(result).toBe(mockResponseData); + }); + + it("should return an empty string when tag_mechanism_uuid is not provided for OAYAML", async () => { + const mockedGet = vi.spyOn(axios, "get"); + + const result = await downloadOAYAML(); + + expect(result).toBe(""); + expect(mockedGet).not.toHaveBeenCalled(); + + mockedGet.mockRestore(); + }); + + it("should handle error correctly for downloadOAYAML", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); + + const tag_mechanism_uuid = "invalid-uuid"; + await expect(downloadOAYAML(tag_mechanism_uuid)).rejects.toThrow( + "Network error", + ); + + expect(axios.get).toHaveBeenCalledWith( + `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/yaml`, + { + headers: { "Content-Type": "text/plain" }, + responseType: "text", + }, + ); + }); + + // Tests for downloadOAMusicbox + it("should successfully get OAMusicbox with valid tag_mechanism_uuid", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; + + const tag_mechanism_uuid = "valid-uuid"; + const result = await downloadOAMusicbox(tag_mechanism_uuid); + + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/musicbox`, + { + responseType: "arraybuffer", + headers: { Accept: "application/zip" }, + }, + ); + + expect(result).toBe(mockResponseData); + }); + + it("should return an empty string when tag_mechanism_uuid is not provided for OAMusicbox", async () => { + const mockedGet = vi.spyOn(axios, "get"); + + const result = await downloadOAMusicbox(); + + expect(result).toBe(""); + expect(mockedGet).not.toHaveBeenCalled(); + + mockedGet.mockRestore(); + }); + + it("should handle error correctly for downloadOAMusicbox", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); + + const tag_mechanism_uuid = "invalid-uuid"; + await expect(downloadOAMusicbox(tag_mechanism_uuid)).rejects.toThrow( + "Network error", + ); + + expect(axios.get).toHaveBeenCalledWith( + `http://localhost:8080/api/openatmos/mechanism/${tag_mechanism_uuid}/musicbox`, + { + responseType: "arraybuffer", + headers: { Accept: "application/zip" }, + }, + ); + }); + + // Tests for getSpeciesPropertiesByMechanismIDAsync + it("should successfully getSpeciesPropertiesByMechanismIDAsync", async () => { + const mockedGet = vi + .spyOn(axios, "get") + .mockResolvedValueOnce(createMockResponse()) as Mock; + const uuid = "valid-uuid"; + const result = await getSpeciesPropertiesByMechanismIDAsync(uuid); + + expect(mockedGet).toHaveBeenCalledWith( + `http://localhost:8080/api/initialconditionspecies/mechanism/${uuid}`, + ); + expect(result).toEqual(mockResponseData); + }); + + it("should return an empty list if the API call fails for getSpeciesPropertiesByMechanismIDAsync", async () => { + const mockError = new Error("Network error"); + vi.spyOn(axios, "get").mockRejectedValueOnce(mockError); + const uuid = "valid-uuid"; + + const result = await getSpeciesPropertiesByMechanismIDAsync(uuid); + expect(result).toEqual([]); + }); +}); diff --git a/frontend/test/API_UpdateMethods.test.tsx b/frontend/test/API_UpdateMethods.test.tsx index 3472c90d..6d84156c 100644 --- a/frontend/test/API_UpdateMethods.test.tsx +++ b/frontend/test/API_UpdateMethods.test.tsx @@ -56,15 +56,19 @@ describe("API update functions tests", () => { }); it("should handle error correctly for updateFamily", async () => { - const family = { id: "1", name: "Test Family", description: "Test description" }; + const family = { + id: "1", + name: "Test Family", + description: "Test description", + }; const errorMessage = "Request failed with status code 404"; - (axios.put as typeof axios.put & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.put as typeof axios.put & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(updateFamily(family)).rejects.toThrow( - "Failed to update family. Please try again later." + "Failed to update family. Please try again later.", ); }); @@ -91,12 +95,12 @@ describe("API update functions tests", () => { const mechanism: Mechanism = { id: "2", name: "Test Mechanism" }; const errorMessage = "Request failed with status code 404"; - (axios.put as typeof axios.put & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.put as typeof axios.put & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(updateMechanism(mechanism)).rejects.toThrow( - "Failed to update mechanism. Please try again later." + "Failed to update mechanism. Please try again later.", ); }); @@ -123,12 +127,12 @@ describe("API update functions tests", () => { const species: Species = { id: "3", name: "Test Species" }; const errorMessage = "Request failed with status code 404"; - (axios.put as typeof axios.put & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.put as typeof axios.put & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(updateSpecies(species)).rejects.toThrow( - "Failed to update species. Please try again later." + "Failed to update species. Please try again later.", ); }); @@ -155,12 +159,12 @@ describe("API update functions tests", () => { const reaction: Reaction = { id: "4", name: "Test Reaction" }; const errorMessage = "Request failed with status code 404"; - (axios.put as typeof axios.put & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.put as typeof axios.put & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(updateReaction(reaction)).rejects.toThrow( - "Failed to update reaction. Please try again later." + "Failed to update reaction. Please try again later.", ); }); @@ -195,12 +199,12 @@ describe("API update functions tests", () => { }; const errorMessage = "Request failed with status code 404"; - (axios.put as typeof axios.put & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.put as typeof axios.put & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(updateUser(user.id, user)).rejects.toThrow( - "Failed to update user. Please try again later." + "Failed to update user. Please try again later.", ); }); @@ -241,12 +245,12 @@ describe("API update functions tests", () => { }; const errorMessage = "Request failed with status code 404"; - (axios.put as typeof axios.put & { mockRejectedValueOnce: Function }).mockRejectedValueOnce( - new Error(errorMessage) - ); + ( + axios.put as typeof axios.put & { mockRejectedValueOnce: Function } + ).mockRejectedValueOnce(new Error(errorMessage)); // Assert the function throws the correct error await expect(updateProperty(property)).rejects.toThrow( - "Failed to update property. Please try again later." + "Failed to update property. Please try again later.", ); }); }); diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts index 7c08f253..68ebb5df 100644 --- a/frontend/vitest.config.ts +++ b/frontend/vitest.config.ts @@ -1,5 +1,5 @@ import { defineConfig } from "vitest/config"; -import react from '@vitejs/plugin-react'; +import react from "@vitejs/plugin-react"; export default defineConfig({ plugins: [react()],