|
1 | 1 | import {expect, test} from '@playwright/test'; |
2 | 2 |
|
3 | 3 | import {backend} from '../../utils/constants'; |
| 4 | +import {NodePage} from '../nodes/NodePage'; |
4 | 5 | import {NodesPage} from '../nodes/NodesPage'; |
5 | 6 | import {ClusterNodesTable} from '../paginatedTable/paginatedTable'; |
6 | 7 |
|
@@ -193,3 +194,111 @@ test.describe('Test Nodes Paginated Table', async () => { |
193 | 194 | expect(hostValues.length).toBeGreaterThan(0); |
194 | 195 | }); |
195 | 196 | }); |
| 197 | + |
| 198 | +test.describe('Test Node Page Threads Tab', async () => { |
| 199 | + test('Threads tab is hidden when node has no thread data', async ({page}) => { |
| 200 | + // Mock the node API to return no thread data |
| 201 | + await page.route(`**/viewer/json/sysinfo?*`, async (route) => { |
| 202 | + await route.fulfill({ |
| 203 | + status: 200, |
| 204 | + contentType: 'application/json', |
| 205 | + body: JSON.stringify({ |
| 206 | + SystemStateInfo: [ |
| 207 | + { |
| 208 | + Host: 'localhost', |
| 209 | + NodeId: 1, |
| 210 | + SystemState: 'Green', |
| 211 | + Version: 'test-version', |
| 212 | + }, |
| 213 | + ], |
| 214 | + // No Threads property |
| 215 | + }), |
| 216 | + }); |
| 217 | + }); |
| 218 | + |
| 219 | + // Navigate directly to node page |
| 220 | + const nodePage = new NodePage(page, '1'); |
| 221 | + await nodePage.goto(); |
| 222 | + await nodePage.waitForNodePageLoad(); |
| 223 | + |
| 224 | + // Verify other tabs are still visible |
| 225 | + const tabNames = await nodePage.getAllTabNames(); |
| 226 | + expect(tabNames).toContain('Tablets'); |
| 227 | + expect(tabNames).not.toContain('Threads'); |
| 228 | + }); |
| 229 | + |
| 230 | + test('Threads tab is visible when node has thread data', async ({page}) => { |
| 231 | + // Mock the node API to return thread data |
| 232 | + await page.route(`**/viewer/json/sysinfo?*`, async (route) => { |
| 233 | + await route.fulfill({ |
| 234 | + status: 200, |
| 235 | + contentType: 'application/json', |
| 236 | + body: JSON.stringify({ |
| 237 | + SystemStateInfo: [ |
| 238 | + { |
| 239 | + Host: 'localhost', |
| 240 | + NodeId: 1, |
| 241 | + SystemState: 'Green', |
| 242 | + Version: 'test-version', |
| 243 | + Threads: [ |
| 244 | + { |
| 245 | + Name: 'TestPool', |
| 246 | + Threads: 4, |
| 247 | + }, |
| 248 | + ], |
| 249 | + }, |
| 250 | + ], |
| 251 | + }), |
| 252 | + }); |
| 253 | + }); |
| 254 | + |
| 255 | + // Navigate directly to node page |
| 256 | + const nodePage = new NodePage(page, '1'); |
| 257 | + await nodePage.goto(); |
| 258 | + await nodePage.waitForNodePageLoad(); |
| 259 | + |
| 260 | + // Verify threads tab is visible |
| 261 | + const isThreadsTabVisible = await nodePage.isThreadsTabVisible(); |
| 262 | + expect(isThreadsTabVisible).toBe(true); |
| 263 | + |
| 264 | + // Verify can click on threads tab |
| 265 | + await nodePage.clickThreadsTab(); |
| 266 | + await page.waitForURL(/\/node\/\d+\/threads/); |
| 267 | + |
| 268 | + // Verify other tabs are also visible |
| 269 | + const tabNames = await nodePage.getAllTabNames(); |
| 270 | + expect(tabNames).toContain('Tablets'); |
| 271 | + expect(tabNames).toContain('Threads'); |
| 272 | + }); |
| 273 | + |
| 274 | + test('Threads tab is hidden when node has empty thread array', async ({page}) => { |
| 275 | + // Mock the node API to return empty thread data |
| 276 | + await page.route(`**/viewer/json/sysinfo?*`, async (route) => { |
| 277 | + await route.fulfill({ |
| 278 | + status: 200, |
| 279 | + contentType: 'application/json', |
| 280 | + body: JSON.stringify({ |
| 281 | + SystemStateInfo: [ |
| 282 | + { |
| 283 | + Host: 'localhost', |
| 284 | + NodeId: 1, |
| 285 | + SystemState: 'Green', |
| 286 | + Version: 'test-version', |
| 287 | + }, |
| 288 | + ], |
| 289 | + Threads: [], // Empty array |
| 290 | + }), |
| 291 | + }); |
| 292 | + }); |
| 293 | + |
| 294 | + // Navigate directly to node page |
| 295 | + const nodePage = new NodePage(page, '1'); |
| 296 | + await nodePage.goto(); |
| 297 | + await nodePage.waitForNodePageLoad(); |
| 298 | + |
| 299 | + // Verify other tabs are still visible |
| 300 | + const tabNames = await nodePage.getAllTabNames(); |
| 301 | + expect(tabNames).toContain('Tablets'); |
| 302 | + expect(tabNames).not.toContain('Threads'); |
| 303 | + }); |
| 304 | +}); |
0 commit comments