@@ -9,24 +9,12 @@ const state = ref<Record<string, TestState>>({})
99
1010export function useTestState ( ) {
1111 return {
12- /**
13- * Get the current status of a test
14- */
1512 getStatus : ( id : string ) => state . value [ id ] ?. status ?? 'idle' ,
1613
17- /**
18- * Get the result of a test
19- */
2014 getResult : ( id : string ) => state . value [ id ] ?. result ,
2115
22- /**
23- * Get the error of a test
24- */
2516 getError : ( id : string ) => state . value [ id ] ?. error ,
2617
27- /**
28- * Set the status of a test
29- */
3018 setStatus : ( id : string , status : TestState [ 'status' ] ) => {
3119 if ( ! state . value [ id ] ) {
3220 state . value [ id ] = { status, timestamp : Date . now ( ) }
@@ -36,9 +24,6 @@ export function useTestState() {
3624 }
3725 } ,
3826
39- /**
40- * Set the result of a test
41- */
4227 setResult : ( id : string , result : any ) => {
4328 if ( ! state . value [ id ] ) {
4429 state . value [ id ] = { status : 'success' , result, timestamp : Date . now ( ) }
@@ -47,9 +32,6 @@ export function useTestState() {
4732 }
4833 } ,
4934
50- /**
51- * Set the error of a test
52- */
5335 setError : ( id : string , error : any ) => {
5436 if ( ! state . value [ id ] ) {
5537 state . value [ id ] = { status : 'error' , error, timestamp : Date . now ( ) }
@@ -58,33 +40,19 @@ export function useTestState() {
5840 }
5941 } ,
6042
61- /**
62- * Clear results for a test (keep status)
63- */
6443 clearResults : ( id : string ) => {
6544 if ( state . value [ id ] ) {
6645 state . value [ id ] . result = undefined
6746 state . value [ id ] . error = undefined
6847 }
6948 } ,
7049
71- /**
72- * Clear a test entirely
73- */
7450 clearTest : ( id : string ) => {
7551 delete state . value [ id ]
7652 } ,
7753
78- /**
79- * Reset all tests
80- */
8154 resetAll : ( ) => {
8255 state . value = { }
8356 } ,
84-
85- /**
86- * Get all test states (for debugging/history)
87- */
88- getAllStates : ( ) => computed ( ( ) => state . value ) ,
8957 }
9058}
0 commit comments