1+ /* biome-ignore lint/suspicious/noExplicitAny: This is a test mock file */
12import type { UseQueryResult } from "@tanstack/react-query" ;
23import { useMutation , useQuery , useQueryClient } from "@tanstack/react-query" ;
34import {
@@ -108,7 +109,11 @@ describe("PlayersClientPage", () => {
108109 ...players . find ( ( p ) => p . id === variables . playerId ) ,
109110 ...variables . payload ,
110111 }
111- : { id : "new-id" , display_name : "Nora" , active : true } ;
112+ : {
113+ id : "00000000-0000-4000-8000-000000000003" ,
114+ display_name : "Nora" ,
115+ active : true ,
116+ } ;
112117
113118 if ( options . onSuccess ) await options . onSuccess ( result , variables ) ;
114119 return result ;
@@ -169,20 +174,25 @@ describe("RoundsClientPage", () => {
169174 const invalidateQueries = vi . fn ( ) ;
170175 mockUseQueryClient . mockReturnValue ( { invalidateQueries } ) ;
171176
177+ const p1Id = "00000000-0000-4000-8000-000000000011" ;
178+ const p2Id = "00000000-0000-4000-8000-000000000012" ;
179+ const r1Id = "00000000-0000-4000-8000-000000000100" ;
180+ const f1Id = "00000000-0000-4000-8000-000000000200" ;
181+
172182 const testPlayers : Player [ ] = [
173- { id : "round-p1" , display_name : "Ada" , active : true } ,
174- { id : "round-p2" , display_name : "Nils" , active : true } ,
183+ { id : p1Id , display_name : "Ada" , active : true } ,
184+ { id : p2Id , display_name : "Nils" , active : true } ,
175185 ] ;
176186
177187 const testRound : Round = {
178- id : "round-r1" ,
188+ id : r1Id ,
179189 created_at : new Date ( ) . toISOString ( ) ,
180190 participants : testPlayers ,
181191 loser : testPlayers [ 0 ] ! ,
182192 } ;
183193
184194 const testFettmattis : Fettmattis = {
185- id : "round-f1" ,
195+ id : f1Id ,
186196 created_at : new Date ( ) . toISOString ( ) ,
187197 player : testPlayers [ 1 ] ! ,
188198 round_id : testRound . id ,
@@ -210,11 +220,15 @@ describe("RoundsClientPage", () => {
210220
211221 render ( < RoundsClientPage /> ) ;
212222
213- // Award Fettmattis first to avoid participant toggle interference if any
214- fireEvent . change ( screen . getByLabelText ( "Spiller" ) , {
215- target : { value : "round-p2" } ,
223+ // Award Fettmattis
224+ const playerSelect = screen . getByLabelText ( "Spiller" ) ;
225+ fireEvent . change ( playerSelect , {
226+ target : { value : p2Id } ,
227+ } ) ;
228+ const tildelButton = screen . getByRole ( "button" , {
229+ name : "Tildel Fettmattis" ,
216230 } ) ;
217- fireEvent . click ( screen . getByRole ( "button" , { name : "Tildel Fettmattis" } ) ) ;
231+ fireEvent . click ( tildelButton ) ;
218232
219233 await waitFor ( ( ) => {
220234 expect ( toast . success ) . toHaveBeenCalledWith (
@@ -224,17 +238,19 @@ describe("RoundsClientPage", () => {
224238 } ) ;
225239
226240 // Save round
227- // Toggling Ada and Nils (they are initially unselected in the form state, even if active in troppen)
228- const adaButton = screen . getByRole ( "button" , { name : / A d a / } ) ;
229- const nilsButton = screen . getByRole ( "button" , { name : / N i l s / } ) ;
230- fireEvent . click ( adaButton ) ;
231- fireEvent . click ( nilsButton ) ;
232-
233- fireEvent . change ( screen . getByLabelText ( "Taper" ) , {
234- target : { value : "round-p1" } ,
241+ const adaBtn = screen . getByRole ( "button" , { name : / A d a / } ) ;
242+ const nilsBtn = screen . getByRole ( "button" , { name : / N i l s / } ) ;
243+ fireEvent . click ( adaBtn ) ;
244+ fireEvent . click ( nilsBtn ) ;
245+
246+ // Select loser
247+ const loserSelect = screen . getByLabelText ( "Taper" ) ;
248+ fireEvent . change ( loserSelect , {
249+ target : { value : p1Id } ,
235250 } ) ;
236251
237- fireEvent . click ( screen . getByRole ( "button" , { name : "Lagre runde" } ) ) ;
252+ const saveRoundButton = screen . getByRole ( "button" , { name : "Lagre runde" } ) ;
253+ fireEvent . click ( saveRoundButton ) ;
238254
239255 await waitFor ( ( ) => {
240256 expect ( toast . success ) . toHaveBeenCalledWith (
0 commit comments