Skip to content

Commit 2735a91

Browse files
authored
chore(sticker-catalogue,web-frontend): fix quarkus compose build issue and broken frontend in E2E tests (#214)
* chore: fix quarkus build issue * chore: better fix quarkus build issue with full quarkus upgrade * fix: broken UI breaking e2e tests * fix: change UI to show betterer info in sidebar
1 parent 28f01cc commit 2735a91

7 files changed

Lines changed: 55 additions & 44 deletions

File tree

sticker-catalogue/pom.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1919
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
2020
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
21-
<quarkus.platform.version>3.22.1</quarkus.platform.version>
21+
<quarkus.platform.version>3.31.3</quarkus.platform.version>
2222
<skipITs>true</skipITs>
2323
<surefire-plugin.version>3.5.2</surefire-plugin.version>
2424
<checkstyle.version>10.18.2</checkstyle.version>
@@ -115,12 +115,12 @@
115115
<dependency>
116116
<groupId>io.quarkiverse.loggingjson</groupId>
117117
<artifactId>quarkus-logging-json</artifactId>
118-
<version>3.2.0</version>
118+
<version>3.4.1</version>
119119
</dependency>
120120

121121
<dependency>
122122
<groupId>io.quarkus</groupId>
123-
<artifactId>quarkus-junit5</artifactId>
123+
<artifactId>quarkus-junit</artifactId>
124124
<scope>test</scope>
125125
</dependency>
126126
<dependency>
@@ -136,7 +136,7 @@
136136
</dependency>
137137
<dependency>
138138
<groupId>io.quarkus</groupId>
139-
<artifactId>quarkus-junit5-mockito</artifactId>
139+
<artifactId>quarkus-junit-mockito</artifactId>
140140
<scope>test</scope>
141141
</dependency>
142142

@@ -224,6 +224,7 @@
224224
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
225225
<maven.home>${maven.home}</maven.home>
226226
</systemPropertyVariables>
227+
<argLine>@{argLine}</argLine>
227228
</configuration>
228229
</plugin>
229230
<plugin>
@@ -243,6 +244,7 @@
243244
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
244245
<maven.home>${maven.home}</maven.home>
245246
</systemPropertyVariables>
247+
<argLine>@{argLine}</argLine>
246248
</configuration>
247249
</plugin>
248250
<!-- Spotless Plugin for Code Formatting -->

sticker-catalogue/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ quarkus.log.json.fields.mdc.flat-fields=true
1414
quarkus.datasource.db-kind=postgresql
1515

1616
# Hibernate ORM
17-
quarkus.hibernate-orm.database.generation=validate
17+
quarkus.hibernate-orm.schema-management.strategy=validate
1818
quarkus.hibernate-orm.log.sql=true
1919

2020
# Flyway

sticker-catalogue/src/test/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ quarkus.datasource.db-kind=postgresql
33
quarkus.datasource.devservices.enabled=true
44

55
# Test Hibernate ORM configuration
6-
quarkus.hibernate-orm.database.generation=drop-and-create
6+
quarkus.hibernate-orm.schema-management.strategy=drop-and-create
77
quarkus.hibernate-orm.log.sql=true
88

99
# Disable Flyway for tests

web-frontend/src/App.jsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { datadogRum } from '@datadog/browser-rum';
77
import "./App.css";
88

99
function App() {
10-
const { isAuthenticated, isLoading, user } = useAuth();
10+
const { isAuthenticated, user } = useAuth();
1111
const navigate = useNavigate();
1212

1313
if (isAuthenticated) {
@@ -18,18 +18,10 @@ function App() {
1818
}
1919

2020
useEffect(() => {
21-
if (!isLoading && isAuthenticated) {
21+
if (isAuthenticated) {
2222
navigate("/dashboard");
2323
}
24-
}, [isAuthenticated, isLoading, navigate]);
25-
26-
if (isLoading) {
27-
return (
28-
<div style={{ textAlign: "center", padding: "50px" }}>
29-
<h2>Loading...</h2>
30-
</div>
31-
);
32-
}
24+
}, [isAuthenticated, navigate]);
3325

3426
return (
3527
<div className="isolate flex flex-auto flex-col bg-[--root-bg]">

web-frontend/src/components/StickerDetail.jsx

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,20 @@ import LocalPrintshopOutlinedIcon from "@mui/icons-material/LocalPrintshopOutlin
44
import HeaderBar from "./HeaderBar";
55
import Sidebar from "./Sidebar";
66
import { API_BASE_URL } from "../config";
7-
import AuthService from "../services/AuthService";
87
import { useAuth } from "../context/AuthContext";
98
import { authFetch } from "../utils/authFetch";
109
import { getLastActiveEvent } from "../services/eventStorage";
1110

1211
function StickerDetail() {
1312
const { id } = useParams();
1413
const navigate = useNavigate();
15-
const { user, isLoading: authLoading } = useAuth();
14+
const { user } = useAuth();
1615
const [sticker, setSticker] = useState(null);
1716
const [loading, setLoading] = useState(true);
1817
const [error, setError] = useState(null);
1918
const [isOwned, setIsOwned] = useState(false);
2019

2120
useEffect(() => {
22-
const userId = user?.sub || user?.email;
23-
24-
// Validate userId before fetching
25-
if (!userId) {
26-
if (!authLoading) {
27-
setError('Unable to identify user. Please log in again.');
28-
setLoading(false);
29-
}
30-
return;
31-
}
32-
3321
const controller = new AbortController();
3422

3523
const fetchSticker = async () => {
@@ -47,20 +35,14 @@ function StickerDetail() {
4735
}
4836

4937
const data = await response.json();
50-
setSticker(data);
51-
52-
// Check if user owns this sticker
53-
const awardsResponse = await authFetch(
54-
`${API_BASE_URL}/api/awards/v1/assignments/${encodeURIComponent(userId)}`
55-
);
56-
if (awardsResponse.ok) {
57-
const awardsData = await awardsResponse.json();
58-
const assignments = awardsData.stickers || [];
59-
setIsOwned(assignments.some((a) => a.stickerId === id));
38+
if (!controller.signal.aborted) {
39+
setSticker(data);
6040
}
6141
} catch (err) {
6242
console.error("Error fetching sticker:", err);
63-
setError(err.message);
43+
if (!controller.signal.aborted) {
44+
setError(err.message);
45+
}
6446
} finally {
6547
if (!controller.signal.aborted) {
6648
setLoading(false);
@@ -69,8 +51,35 @@ function StickerDetail() {
6951
};
7052

7153
fetchSticker();
54+
return () => controller.abort();
7255
}, [id]);
7356

57+
// Check ownership when user context is available
58+
useEffect(() => {
59+
const userId = user?.sub || user?.email;
60+
if (!userId || !sticker) return;
61+
62+
const controller = new AbortController();
63+
64+
const checkOwnership = async () => {
65+
try {
66+
const awardsResponse = await authFetch(
67+
`${API_BASE_URL}/api/awards/v1/assignments/${encodeURIComponent(userId)}`
68+
);
69+
if (awardsResponse.ok && !controller.signal.aborted) {
70+
const awardsData = await awardsResponse.json();
71+
const assignments = awardsData.stickers || [];
72+
setIsOwned(assignments.some((a) => a.stickerId === id));
73+
}
74+
} catch (err) {
75+
console.error("Error checking ownership:", err);
76+
}
77+
};
78+
79+
checkOwnership();
80+
return () => controller.abort();
81+
}, [id, user, sticker]);
82+
7483
const formatDate = (dateString) => {
7584
if (!dateString) return "Unknown";
7685
return new Date(dateString).toLocaleDateString("en-US", {

web-frontend/src/components/UserInfo.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ function UserInfo() {
2828
<span className="block text-sm text-gray-600">
2929
{isLoading
3030
? "..."
31-
: user?.role?.length
32-
? user.role.join(", ")
33-
: "No roles assigned"}
31+
: user?.role?.includes("admin")
32+
? "Sticker Admin"
33+
: "Sticker Collector"}
3434
</span>
3535
</div>
3636
</div>

web-frontend/src/context/AuthContext.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ export const AuthProvider = ({ children }) => {
119119
clearLoginError
120120
}
121121

122+
if (isLoading) {
123+
return (
124+
<div style={{ textAlign: 'center', padding: '50px' }}>
125+
<h2>Loading...</h2>
126+
</div>
127+
)
128+
}
129+
122130
return (
123131
<AuthContext.Provider value={value}>
124132
{children}

0 commit comments

Comments
 (0)