From fe9ce450e3e8d9f5ccaf9de94252e7d7fc727e45 Mon Sep 17 00:00:00 2001 From: Elena Makarova Date: Wed, 13 Aug 2025 16:53:11 +0300 Subject: [PATCH 1/2] fix: broken tests for healthcheck --- .../tenant/diagnostics/tabs/info.test.ts | 98 ++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/tests/suites/tenant/diagnostics/tabs/info.test.ts b/tests/suites/tenant/diagnostics/tabs/info.test.ts index 98c060309c..f73cca7413 100644 --- a/tests/suites/tenant/diagnostics/tabs/info.test.ts +++ b/tests/suites/tenant/diagnostics/tabs/info.test.ts @@ -41,7 +41,101 @@ test.describe('Diagnostics Info tab', async () => { expect(utilization.memory.usage).toBeTruthy(); }); - test('Info tab shows healthcheck status', async ({page}) => { + test('Info tab shows healthcheck status when there are issues', async ({page}) => { + // Mock healthcheck API to return DEGRADED status with issues + await page.route(`**/viewer/json/healthcheck?*`, async (route) => { + await route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify({ + self_check_result: 'DEGRADED', + issue_log: [ + { + id: 'issue-1', + status: 'YELLOW', + message: 'Some degraded component', + location: { + database: { + name: tenantName, + }, + }, + }, + ], + }), + }); + }); + + const pageQueryParams = { + schema: tenantName, + database: tenantName, + tenantPage: 'diagnostics', + }; + const tenantPage = new TenantPage(page); + await tenantPage.goto(pageQueryParams); + + const diagnostics = new Diagnostics(page); + await diagnostics.clickTab(DiagnosticsTab.Info); + + // Healthcheck card should be visible when there are issues + const status = await diagnostics.getHealthcheckStatus(); + expect(status).toBeTruthy(); + + // Check for degraded status class + const isDegraded = await diagnostics.hasHealthcheckStatusClass( + 'ydb-healthcheck-preview__icon_degraded', + ); + expect(isDegraded).toBe(true); + }); + + test('Info tab hides healthcheck status when status is GOOD with no issues', async ({page}) => { + // Mock healthcheck API to return GOOD status with no issues + await page.route(`**/viewer/json/healthcheck?*`, async (route) => { + await route.fulfill({ + json: { + self_check_result: 'GOOD', + issue_log: [], + }, + }); + }); + + const pageQueryParams = { + schema: tenantName, + database: tenantName, + tenantPage: 'diagnostics', + }; + const tenantPage = new TenantPage(page); + await tenantPage.goto(pageQueryParams); + + const diagnostics = new Diagnostics(page); + await diagnostics.clickTab(DiagnosticsTab.Info); + + // Healthcheck card should not be visible when status is GOOD with no issues + const healthcheckCard = page.locator('.ydb-healthcheck-preview'); + await expect(healthcheckCard).toHaveCount(0); + }); + + test('Info tab shows healthcheck status when status is GOOD but has issues', async ({page}) => { + // Mock healthcheck API to return GOOD status but with issues (edge case) + await page.route(`**/viewer/json/healthcheck?*`, async (route) => { + await route.fulfill({ + json: { + self_check_result: 'GOOD', + issue_log: [ + { + id: 'issue-1', + status: 'GREEN', + message: 'Some informational issue', + location: { + database: { + name: tenantName, + }, + }, + }, + ], + }, + }); + }); + const pageQueryParams = { schema: tenantName, database: tenantName, @@ -53,9 +147,11 @@ test.describe('Diagnostics Info tab', async () => { const diagnostics = new Diagnostics(page); await diagnostics.clickTab(DiagnosticsTab.Info); + // Healthcheck card should be visible when there are issues, even if status is GOOD const status = await diagnostics.getHealthcheckStatus(); expect(status).toBeTruthy(); + // Check for good status class const isGood = await diagnostics.hasHealthcheckStatusClass( 'ydb-healthcheck-preview__icon_good', ); From 7c352baf03680f5fad45603df48f8ff18e8724ab Mon Sep 17 00:00:00 2001 From: Elena Makarova Date: Wed, 13 Aug 2025 18:26:16 +0300 Subject: [PATCH 2/2] fix: tests --- tests/suites/tenant/diagnostics/Diagnostics.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/suites/tenant/diagnostics/Diagnostics.ts b/tests/suites/tenant/diagnostics/Diagnostics.ts index 54538fdada..b45f8f2ad1 100644 --- a/tests/suites/tenant/diagnostics/Diagnostics.ts +++ b/tests/suites/tenant/diagnostics/Diagnostics.ts @@ -368,7 +368,6 @@ export class Diagnostics { await this.cpuCard.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT}); await this.storageCard.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT}); await this.memoryCard.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT}); - await this.healthcheckCard.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT}); return true; }