From 52aecd14d42330802056d699f92ba6558d255568 Mon Sep 17 00:00:00 2001 From: pavel Hamawand Date: Tue, 19 Mar 2024 03:14:14 +0100 Subject: [PATCH 1/7] minor fix --- frontend/src/Pages/YourProjectsPage.tsx | 26 +++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/frontend/src/Pages/YourProjectsPage.tsx b/frontend/src/Pages/YourProjectsPage.tsx index 973baa3..5de772f 100644 --- a/frontend/src/Pages/YourProjectsPage.tsx +++ b/frontend/src/Pages/YourProjectsPage.tsx @@ -1,6 +1,5 @@ -import { useState, createContext, useEffect } from "react"; +import { useState, createContext } from "react"; import { Project } from "../Types/goTypes"; -import { api } from "../API/API"; import { Link } from "react-router-dom"; import BasicWindow from "../Components/BasicWindow"; @@ -28,10 +27,25 @@ function UserProjectPage(): JSX.Element { // Mock data const projects: Project[] = [ - { id: "1", name: "Project Test App" }, - { id: "2", name: "Project 2" }, - { id: "3", name: "Project 3" }, - // Add more mock projects as needed + { + id: 1, + name: "Project Test App", + description: "Description 1", + owner: "Owner 1", + }, + { + id: 2, + name: "Project 2", + description: "Description 2", + owner: "Owner 2", + }, + { + id: 3, + name: "Project 3", + description: "Description 3", + owner: "Owner 3", + }, + // Add more mock projects as neededects as needed ]; const handleProjectClick = (projectName: string): void => { From 4df8d3f8581c2eed3cda217b1c43f707f3962a95 Mon Sep 17 00:00:00 2001 From: pavel Hamawand Date: Tue, 19 Mar 2024 03:22:54 +0100 Subject: [PATCH 2/7] new component --- frontend/src/Components/ChangeUsername.tsx | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 frontend/src/Components/ChangeUsername.tsx diff --git a/frontend/src/Components/ChangeUsername.tsx b/frontend/src/Components/ChangeUsername.tsx new file mode 100644 index 0000000..e69de29 From 8b7ad8911b07956cf4a5ce659026ac283b4acb39 Mon Sep 17 00:00:00 2001 From: pavel Hamawand Date: Tue, 19 Mar 2024 03:39:05 +0100 Subject: [PATCH 3/7] implementing ChangeUser --- frontend/src/Components/ChangeUsername.tsx | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/frontend/src/Components/ChangeUsername.tsx b/frontend/src/Components/ChangeUsername.tsx index e69de29..71d5e57 100644 --- a/frontend/src/Components/ChangeUsername.tsx +++ b/frontend/src/Components/ChangeUsername.tsx @@ -0,0 +1,38 @@ +import React, { useState } from "react"; +import { api } from "../API/API"; +import InputField from "./InputField"; +import BackButton from "./BackButton"; +import Button from "./Button"; + + +function ChangeUsername(): JSX.Element { + const [newUsername, setNewUsername] = useState(""); + + const handleChange = (e: React.ChangeEvent): void => { + setNewUsername(e.target.value); + }; + + const handleSubmit = async (): Promise => { + try { + // Call the API function to update the username + await api.updateUsername(newUsername); + // Optionally, add a success message or redirect the user + } catch (error) { + console.error("Error updating username:", error); + // Optionally, handle the error + } + }; + + return ( +
+ +
+ ); +} + +export default ChangeUsername; From cbb62438c8790fb7fa478804b99112adb9113100 Mon Sep 17 00:00:00 2001 From: pavel Hamawand Date: Tue, 19 Mar 2024 03:40:17 +0100 Subject: [PATCH 4/7] implementing AdminChangeUsername --- frontend/src/Pages/AdminPages/AdminChangeUsername.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/Pages/AdminPages/AdminChangeUsername.tsx b/frontend/src/Pages/AdminPages/AdminChangeUsername.tsx index 7eb2e2e..b130fae 100644 --- a/frontend/src/Pages/AdminPages/AdminChangeUsername.tsx +++ b/frontend/src/Pages/AdminPages/AdminChangeUsername.tsx @@ -1,9 +1,14 @@ import BackButton from "../../Components/BackButton"; import BasicWindow from "../../Components/BasicWindow"; import Button from "../../Components/Button"; +import ChangeUsername from "../../Components/ChangeUsername"; function AdminChangeUsername(): JSX.Element { - const content = <>; + const content = ( + <> + + + ); const buttons = ( <> From 88c53ae4b67f2bb2fc2105e5c8a5b20e617f4b5b Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Tue, 19 Mar 2024 20:21:38 +0100 Subject: [PATCH 5/7] Golds automatic documentation generator --- backend/Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/Makefile b/backend/Makefile index 65a2f3c..331f8d5 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -130,4 +130,12 @@ install-just: .PHONY: types types: - tygo generate \ No newline at end of file + tygo generate + +.PHONY: install-golds +install-golds: + go install go101.org/golds@latest + +.PHONY: golds +golds: + golds -port 6060 -nouses -plainsrc -wdpkgs-listing=promoted ./... From 00f72df65f33af749f6476607b471e3ec6766931 Mon Sep 17 00:00:00 2001 From: Johanna Date: Wed, 20 Mar 2024 14:06:15 +0100 Subject: [PATCH 6/7] Added comments --- backend/internal/config/config_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backend/internal/config/config_test.go b/backend/internal/config/config_test.go index cb02a31..e8ddce8 100644 --- a/backend/internal/config/config_test.go +++ b/backend/internal/config/config_test.go @@ -5,8 +5,12 @@ import ( "testing" ) +// TestNewConfig tests the creation of a new configuration object func TestNewConfig(t *testing.T) { + // Arrange c := NewConfig() + + // Act & Assert if c.Port != 8080 { t.Errorf("Expected port to be 8080, got %d", c.Port) } @@ -24,9 +28,15 @@ func TestNewConfig(t *testing.T) { } } +// TestWriteConfig tests the function to write the configuration to a file func TestWriteConfig(t *testing.T) { + // Arrange c := NewConfig() + + //Act err := c.WriteConfigToFile("test.toml") + + // Assert if err != nil { t.Errorf("Expected no error, got %s", err) } @@ -35,14 +45,23 @@ func TestWriteConfig(t *testing.T) { _ = os.Remove("test.toml") } +// TestReadConfig tests the function to read the configuration from a file func TestReadConfig(t *testing.T) { + // Arrange c := NewConfig() + + // Act err := c.WriteConfigToFile("test.toml") + + // Assert if err != nil { t.Errorf("Expected no error, got %s", err) } + // Act c2, err := ReadConfigFromFile("test.toml") + + // Assert if err != nil { t.Errorf("Expected no error, got %s", err) } From 67680e2616fba65e825a6f46346adbc1f24a28ae Mon Sep 17 00:00:00 2001 From: Johanna Date: Wed, 20 Mar 2024 16:13:53 +0100 Subject: [PATCH 7/7] Added comments to db_test.go test functions --- backend/internal/database/db_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/backend/internal/database/db_test.go b/backend/internal/database/db_test.go index a7f3878..351f54d 100644 --- a/backend/internal/database/db_test.go +++ b/backend/internal/database/db_test.go @@ -7,6 +7,7 @@ import ( // Tests are not guaranteed to be sequential +// setupState initializes a database instance with necessary setup for testing func setupState() (Database, error) { db := DbConnect(":memory:") err := db.Migrate() @@ -16,11 +17,13 @@ func setupState() (Database, error) { return db, nil } +// TestDbConnect tests the connection to the database func TestDbConnect(t *testing.T) { db := DbConnect(":memory:") _ = db } +// TestDbAddUser tests the AddUser function of the database func TestDbAddUser(t *testing.T) { db, err := setupState() if err != nil { @@ -32,6 +35,7 @@ func TestDbAddUser(t *testing.T) { } } +// TestDbGetUserId tests the GetUserID function of the database func TestDbGetUserId(t *testing.T) { db, err := setupState() if err != nil { @@ -52,6 +56,7 @@ func TestDbGetUserId(t *testing.T) { } } +// TestDbAddProject tests the AddProject function of the database func TestDbAddProject(t *testing.T) { db, err := setupState() if err != nil { @@ -64,6 +69,7 @@ func TestDbAddProject(t *testing.T) { } } +// TestDbRemoveUser tests the RemoveUser function of the database func TestDbRemoveUser(t *testing.T) { db, err := setupState() if err != nil { @@ -76,6 +82,7 @@ func TestDbRemoveUser(t *testing.T) { } } +// TestPromoteToAdmin tests the PromoteToAdmin function of the database func TestPromoteToAdmin(t *testing.T) { db, err := setupState() if err != nil { @@ -93,6 +100,7 @@ func TestPromoteToAdmin(t *testing.T) { } } +// TestAddWeeklyReport tests the AddWeeklyReport function of the database func TestAddWeeklyReport(t *testing.T) { db, err := setupState() if err != nil { @@ -115,6 +123,7 @@ func TestAddWeeklyReport(t *testing.T) { } } +// TestAddUserToProject tests the AddUseToProject function of the database func TestAddUserToProject(t *testing.T) { db, err := setupState() if err != nil { @@ -142,6 +151,7 @@ func TestAddUserToProject(t *testing.T) { } } +// TestChangeUserRole tests the ChangeUserRole function of the database func TestChangeUserRole(t *testing.T) { db, err := setupState() if err != nil { @@ -186,6 +196,7 @@ func TestChangeUserRole(t *testing.T) { } +// TestGetAllUsersProject tests the GetAllUsersProject function of the database func TestGetAllUsersProject(t *testing.T) { db, err := setupState() if err != nil { @@ -252,6 +263,7 @@ func TestGetAllUsersProject(t *testing.T) { } } +// TestGetAllUsersApplication tests the GetAllUsersApplicsation function of the database func TestGetAllUsersApplication(t *testing.T) { db, err := setupState() if err != nil { @@ -298,6 +310,7 @@ func TestGetAllUsersApplication(t *testing.T) { } } +// TestGetProjectsForUser tests the GetProjectsForUser function of the database func TestGetProjectsForUser(t *testing.T) { db, err := setupState() if err != nil { @@ -338,6 +351,7 @@ func TestGetProjectsForUser(t *testing.T) { } } +// TestAddProject tests AddProject function of the database func TestAddProject(t *testing.T) { db, err := setupState() if err != nil { @@ -373,6 +387,7 @@ func TestAddProject(t *testing.T) { } } +// TestGetWeeklyReport tests GetWeeklyReport function of the database func TestGetWeeklyReport(t *testing.T) { db, err := setupState() if err != nil { @@ -412,6 +427,7 @@ func TestGetWeeklyReport(t *testing.T) { // Check other fields similarly } +// TestSignWeeklyReport tests SignWeeklyReport function of the database func TestSignWeeklyReport(t *testing.T) { db, err := setupState() if err != nil { @@ -484,6 +500,7 @@ func TestSignWeeklyReport(t *testing.T) { } } +// TestSignWeeklyReportByAnotherProjectManager tests the scenario where a project manager attempts to sign a weekly report for a user who is not assigned to their project func TestSignWeeklyReportByAnotherProjectManager(t *testing.T) { db, err := setupState() if err != nil { @@ -537,6 +554,7 @@ func TestSignWeeklyReportByAnotherProjectManager(t *testing.T) { } } +// TestGetProject tests GetProject function of the database func TestGetProject(t *testing.T) { db, err := setupState() if err != nil {