diff --git a/frontend/index.html b/frontend/index.html index d518aeec..a69db5dc 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,10 +4,10 @@ - Vite + React + UCSB Rec
- \ No newline at end of file + diff --git a/frontend/src/main/components/Nav/AppNavbar.jsx b/frontend/src/main/components/Nav/AppNavbar.jsx index 17824854..9ca3e785 100644 --- a/frontend/src/main/components/Nav/AppNavbar.jsx +++ b/frontend/src/main/components/Nav/AppNavbar.jsx @@ -25,7 +25,7 @@ export default function AppNavbar({ > - Example + UCSB Rec @@ -61,6 +61,22 @@ export default function AppNavbar({ )} + {hasRole(currentUser, "ROLE_ADMIN") && ( + <> + + Request Types + + + )} + {currentUser && currentUser.loggedIn ? ( + <> + + Recommendation Request + + + ) : ( + <> + )} {hasRole(currentUser, "ROLE_PROFESSOR") && ( <> diff --git a/frontend/src/tests/components/Nav/AppNavbar.test.jsx b/frontend/src/tests/components/Nav/AppNavbar.test.jsx index 8b4efff0..b642b050 100644 --- a/frontend/src/tests/components/Nav/AppNavbar.test.jsx +++ b/frontend/src/tests/components/Nav/AppNavbar.test.jsx @@ -42,6 +42,120 @@ describe("AppNavbar tests", () => { expect(adminMenu).toBeInTheDocument(); }); + test("renders the recommendation requests for logged in users", async () => { + const currentUser = currentUserFixtures.userOnly; + const systemInfo = systemInfoFixtures.showingBoth; + const doLogin = vi.fn(); + + render( + + + + + , + ); + + await screen.findByText("Recommendation Request"); + const pendingLink = screen.getByText("Recommendation Request"); + expect(pendingLink).toBeInTheDocument(); + }); + + test("does not render the recommendation requests for unlogged users", async () => { + const currentUser = null; + const systemInfo = systemInfoFixtures.showingBoth; + const doLogin = vi.fn(); + + render( + + + + + , + ); + + expect( + screen.queryByText("Recommendation Request"), + ).not.toBeInTheDocument(); + }); + + test("request types renders correctly for admin user", async () => { + const currentUser = currentUserFixtures.adminUser; + const doLogin = vi.fn(); + + render( + + + + + , + ); + + await screen.findByText("Request Types"); + const pendingLink = screen.getByText("Request Types"); + expect(pendingLink).toBeInTheDocument(); + }); + + test("request types does Not render for normal users", async () => { + const currentUser = currentUserFixtures.userOnly; + const systemInfo = systemInfoFixtures.showingBoth; + const doLogin = vi.fn(); + + render( + + + + + , + ); + + expect(screen.queryByText("Request Types")).not.toBeInTheDocument(); + }); + test("UCSB Rec renders correctly for regular logged in user", async () => { + const currentUser = currentUserFixtures.userOnly; + const doLogin = vi.fn(); + + render( + + + + + , + ); + + await screen.findByText("UCSB Rec"); + const pendingLink = screen.getByText("UCSB Rec"); + expect(pendingLink).toBeInTheDocument(); + }); + + test("UCSB Rec renders correctly for admin user", async () => { + const currentUser = currentUserFixtures.adminUser; + const doLogin = vi.fn(); + + render( + + + + + , + ); + + await screen.findByText("UCSB Rec"); + const pendingLink = screen.getByText("UCSB Rec"); + expect(pendingLink).toBeInTheDocument(); + }); + test("renders H2Console and Swagger links correctly", async () => { const currentUser = currentUserFixtures.adminUser; const systemInfo = systemInfoFixtures.showingBoth; diff --git a/src/main/resources/application-development.properties b/src/main/resources/application-development.properties index 3e3da24c..43073a74 100644 --- a/src/main/resources/application-development.properties +++ b/src/main/resources/application-development.properties @@ -1,6 +1,6 @@ logging.level.sql=DEBUG logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE -spring.datasource.url=jdbc:h2:file:./target/db-development +spring.datasource.url=jdbc:h2:file:./target/db-development;AUTO_SERVER=TRUE spring.datasource.username=sa spring.datasource.password=password spring.h2.console.settings.web-allow-others=true @@ -8,4 +8,4 @@ spring.h2.console.enabled=true app.showSwaggerUILink=true spring.jpa.database-platform=org.hibernate.dialect.H2Dialect -spring.datasource.initialization-mode=always \ No newline at end of file +spring.datasource.initialization-mode=always