@@ -64,14 +64,13 @@ const MetricsDisabledWrapper = ({ children }: PropsWithChildren<{}>) => {
64
64
65
65
describe ( "Metrics" , ( ) => {
66
66
it ( "renders" , async ( ) => {
67
- expect . assertions ( 5 ) ;
67
+ expect . assertions ( 4 ) ;
68
68
69
69
render ( < Metrics /> , { wrapper : Wrapper } ) ;
70
- await screen . findByText ( / V i e w i n G r a f a n a / ) ;
71
- expect ( screen . getByText ( / 5 m i n u t e s / ) ) . toBeVisible ( ) ;
72
- expect ( screen . getByText ( / T a s k s a n d A c t o r s / ) ) . toBeVisible ( ) ;
73
- expect ( screen . getByText ( / R a y R e s o u r c e U s a g e / ) ) . toBeVisible ( ) ;
74
- expect ( screen . getByText ( / H a r d w a r e U t i l i z a t i o n / ) ) . toBeVisible ( ) ;
70
+ await screen . findByText ( / V i e w t a b i n G r a f a n a / ) ;
71
+ expect ( screen . getByText ( / C o r e / ) ) . toBeVisible ( ) ;
72
+ expect ( screen . getByText ( / R a y D a t a / ) ) . toBeVisible ( ) ;
73
+ expect ( document . querySelector ( "iframe" ) ) . toBeTruthy ( ) ;
75
74
expect (
76
75
screen . queryByText (
77
76
/ S e t u p P r o m e t h e u s a n d G r a f a n a f o r b e t t e r R a y D a s h b o a r d e x p e r i e n c e / ,
@@ -80,47 +79,45 @@ describe("Metrics", () => {
80
79
} ) ;
81
80
82
81
it ( "renders warning when grafana is not available" , async ( ) => {
83
- expect . assertions ( 5 ) ;
82
+ expect . assertions ( 3 ) ;
84
83
85
84
render ( < Metrics /> , { wrapper : MetricsDisabledWrapper } ) ;
86
85
await screen . findByText (
87
86
/ S e t u p P r o m e t h e u s a n d G r a f a n a f o r b e t t e r R a y D a s h b o a r d e x p e r i e n c e / ,
88
87
) ;
89
- expect ( screen . queryByText ( / V i e w i n G r a f a n a / ) ) . toBeNull ( ) ;
90
- expect ( screen . queryByText ( / 5 m i n u t e s / ) ) . toBeNull ( ) ;
91
- expect ( screen . queryByText ( / T a s k s a n d A c t o r s / ) ) . toBeNull ( ) ;
92
- expect ( screen . queryByText ( / R a y R e s o u r c e U s a g e / ) ) . toBeNull ( ) ;
93
- expect ( screen . queryByText ( / H a r d w a r e U t i l i z a t i o n / ) ) . toBeNull ( ) ;
88
+ expect ( screen . queryByText ( / V i e w t a b i n G r a f a n a / ) ) . toBeNull ( ) ;
89
+ expect ( screen . queryByText ( / C o r e / ) ) . toBeNull ( ) ;
90
+ expect ( document . querySelector ( "iframe" ) ) . toBeNull ( ) ;
94
91
} ) ;
95
92
96
93
it ( "validates iframe query parameters are correctly constructed" , async ( ) => {
97
94
expect . assertions ( 11 ) ;
98
95
99
96
render ( < Metrics /> , { wrapper : Wrapper } ) ;
100
- await screen . findByText ( / V i e w i n G r a f a n a / ) ;
97
+ await screen . findByText ( / V i e w t a b i n G r a f a n a / ) ;
101
98
102
- // Get all iframe elements
99
+ // Get iframe element (should be only one)
103
100
const iframes = document . querySelectorAll ( "iframe" ) ;
104
- expect ( iframes . length ) . toBeGreaterThan ( 0 ) ;
101
+ expect ( iframes . length ) . toBe ( 1 ) ;
105
102
106
- // Test the first iframe to validate query parameters
107
- const firstIframe = iframes [ 0 ] as HTMLIFrameElement ;
108
- const iframeSrc = firstIframe . src ;
103
+ // Test the iframe to validate query parameters
104
+ const iframe = iframes [ 0 ] as HTMLIFrameElement ;
105
+ const iframeSrc = iframe . src ;
109
106
const url = new URL ( iframeSrc ) ;
110
107
111
108
// Validate required iframe query parameters
112
109
expect ( url . searchParams . get ( "orgId" ) ) . toBe ( "1" ) ;
113
110
expect ( url . searchParams . get ( "theme" ) ) . toBe ( "light" ) ;
114
- expect ( url . searchParams . get ( "panelId " ) ) . toBeTruthy ( ) ;
111
+ expect ( url . searchParams . get ( "kiosk " ) ) . toBe ( "1" ) ;
115
112
expect ( url . searchParams . get ( "var-SessionName" ) ) . toBe ( "session-name" ) ;
116
113
expect ( url . searchParams . get ( "var-datasource" ) ) . toBe ( "Prometheus" ) ;
117
114
expect ( url . searchParams . get ( "refresh" ) ) . toBe ( "5s" ) ;
118
115
expect ( url . searchParams . get ( "from" ) ) . toBe ( "now-5m" ) ;
119
116
expect ( url . searchParams . get ( "to" ) ) . toBe ( "now" ) ;
120
117
121
- // Validate URL structure
122
- expect ( iframeSrc ) . toMatch ( / l o c a l h o s t : 3 0 0 0 \/ d - s o l o \/ r a y D e f a u l t D a s h b o a r d \? / ) ;
123
- expect ( iframeSrc ) . toContain ( "/d-solo /rayDefaultDashboard" ) ;
118
+ // Validate URL structure (full dashboard, not panel-only)
119
+ expect ( iframeSrc ) . toMatch ( / l o c a l h o s t : 3 0 0 0 \/ d \/ r a y D e f a u l t D a s h b o a r d \/ \? / ) ;
120
+ expect ( iframeSrc ) . toContain ( "/d/rayDefaultDashboard" ) ;
124
121
} ) ;
125
122
126
123
it ( "validates iframe query parameters with cluster filter" , async ( ) => {
@@ -156,12 +153,12 @@ describe("Metrics", () => {
156
153
expect . assertions ( 2 ) ;
157
154
158
155
render ( < Metrics /> , { wrapper : WrapperWithClusterFilter } ) ;
159
- await screen . findByText ( / V i e w i n G r a f a n a / ) ;
156
+ await screen . findByText ( / V i e w t a b i n G r a f a n a / ) ;
160
157
161
- // Get the first iframe and validate cluster filter parameter
158
+ // Get the iframe and validate cluster filter parameter
162
159
const iframes = document . querySelectorAll ( "iframe" ) ;
163
- const firstIframe = iframes [ 0 ] as HTMLIFrameElement ;
164
- const iframeSrc = firstIframe . src ;
160
+ const iframe = iframes [ 0 ] as HTMLIFrameElement ;
161
+ const iframeSrc = iframe . src ;
165
162
const url = new URL ( iframeSrc ) ;
166
163
167
164
expect ( url . searchParams . get ( "var-Cluster" ) ) . toBe ( "test-cluster" ) ;
0 commit comments