From 69faef313c8830527eb8142c4ce093449d80e8f9 Mon Sep 17 00:00:00 2001 From: matejnesuta Date: Thu, 23 May 2024 18:37:02 +0200 Subject: [PATCH 1/8] first overview page tests --- .../MessageCenter/MessageCenter.tsx | 6 +- .../src/pages/Kiali/Header/HelpKiali.tsx | 2 +- .../src/pages/Kiali/Header/KialiHeader.tsx | 2 + .../pages/Kiali/Header/NamespaceSelector.tsx | 1 + .../Overview/OverviewCard/OverviewCard.tsx | 2 +- plugins/kiali/tests/kialiPage.spec.ts | 80 +++++++++++++++++++ 6 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 plugins/kiali/tests/kialiPage.spec.ts diff --git a/plugins/kiali/src/components/MessageCenter/MessageCenter.tsx b/plugins/kiali/src/components/MessageCenter/MessageCenter.tsx index 3c3c09e5ba..c0ba443fa7 100644 --- a/plugins/kiali/src/components/MessageCenter/MessageCenter.tsx +++ b/plugins/kiali/src/components/MessageCenter/MessageCenter.tsx @@ -89,7 +89,11 @@ export const MessageCenter = (props: { color?: string }) => { */ return ( <> - { color="primary" icon={} label={homeCluster?.name} + data-test={'home-cluster'} /> @@ -35,6 +36,7 @@ export const KialiHeader = () => { flexDirection: 'row', justifyContent: 'space-between', }} + data-test={'user'} > User : diff --git a/plugins/kiali/src/pages/Kiali/Header/NamespaceSelector.tsx b/plugins/kiali/src/pages/Kiali/Header/NamespaceSelector.tsx index d7df38c588..d141584718 100644 --- a/plugins/kiali/src/pages/Kiali/Header/NamespaceSelector.tsx +++ b/plugins/kiali/src/pages/Kiali/Header/NamespaceSelector.tsx @@ -56,6 +56,7 @@ export const NamespaceSelector = (props: { page?: boolean }) => { onChange={handleChange} renderValue={selected => (selected as string[]).join(', ')} MenuProps={MenuProps} + data-test={'namespace-selector'} > {(kialiState.namespaces.items || []).map(ns => ( diff --git a/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx b/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx index e141afd26a..0963de75b7 100644 --- a/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx +++ b/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx @@ -111,7 +111,7 @@ export const OverviewCard = (props: OverviewCardProps) => { }; return ( - + {!props.entity && } {!props.entity && isMultiCluster && props.namespace.cluster && ( diff --git a/plugins/kiali/tests/kialiPage.spec.ts b/plugins/kiali/tests/kialiPage.spec.ts new file mode 100644 index 0000000000..b992be628d --- /dev/null +++ b/plugins/kiali/tests/kialiPage.spec.ts @@ -0,0 +1,80 @@ +import { expect, Page, test } from '@playwright/test'; + +import CONFIG from '../dev/__fixtures__/general/config.json'; +import NAMESPACES from '../dev/__fixtures__/general/namespaces.json'; +import { Common } from './kialiHelper'; + +function filterByIstioInjectionEnabled(jsonArray: any): any { + return jsonArray.filter( + json => + (json.labels && json.labels['istio-injection'] === 'enabled') || + (json.name && json.name === 'istio-system'), + ); +} +const visibleNamespaces = filterByIstioInjectionEnabled(NAMESPACES); + +test.describe('Kiali page', () => { + let page: Page; + let common: Common; + test.describe('overview', () => { + test.beforeEach(async ({ browser }) => { + const context = await browser.newContext(); + page = await context.newPage(); + common = new Common(page); + await common.loginAsGuest(); + }); + + test('Home cluster is visible', async () => { + await expect(page.locator('data-test=home-cluster')).toHaveText( + CONFIG.clusters.Kubernetes.name, + ); + }); + + test('Debug info can be opened', async () => { + await page.click('data-test=help-button'); + await page.click('text=View Debug Info'); + await expect( + page.locator('css=[aria-describedby="Debug information"]'), + ).toBeVisible(); + }); + + test('User is visible', async () => { + if (CONFIG.authStrategy === 'anonymous') { + await expect(page.locator('data-test=user')).toHaveText( + 'User : anonymous', + ); + } + // There could be an else branch with non-anonymous auth strategies, but there is not enough test data in the fixtures for this. + }); + + test('Check namespaces visible to Kiali', async () => { + await page.click('data-test=namespace-selector'); + for (const ns of visibleNamespaces) { + await expect(page.locator(`ul[role="listbox"]`)).toContainText(ns.name); + } + await expect(page.locator('ul[role="listbox"] > li')).toHaveCount( + visibleNamespaces.length, + ); + }); + + test('No namespaces are selected', async () => { + await page.click('data-test=namespace-selector'); + for (const ns of visibleNamespaces) { + await page.click(`ul[role="listbox"] > li:has-text("${ns.name}")`); + } + for (const ns of visibleNamespaces) { + await expect( + page.locator(`data-test=overview-card-${ns.name}`), + ).toHaveCount(0); + } + }); + + test('All namespaces are selected', async () => { + for (const ns of visibleNamespaces) { + await expect( + page.locator(`data-test=overview-card-${ns.name}`), + ).toHaveCount(1); + } + }); + }); +}); From 4776ee510fc7f797df18013ff10c13a8fcebf938 Mon Sep 17 00:00:00 2001 From: matejnesuta Date: Thu, 30 May 2024 18:02:03 +0200 Subject: [PATCH 2/8] tests mostly related to the header on the main page --- .../src/components/About/AboutUIModal.tsx | 13 ++- .../components/MessageCenter/AlertDrawer.tsx | 3 +- .../MessageCenter/AlertDrawerGroup.tsx | 17 ++- .../MessageCenter/AlertDrawerMessage.tsx | 12 ++- plugins/kiali/tests/kialiHelper.ts | 2 + plugins/kiali/tests/kialiPage.spec.ts | 100 +++++++++++++++++- 6 files changed, 132 insertions(+), 15 deletions(-) diff --git a/plugins/kiali/src/components/About/AboutUIModal.tsx b/plugins/kiali/src/components/About/AboutUIModal.tsx index 2fb50d2f76..05aa7c12bc 100644 --- a/plugins/kiali/src/components/About/AboutUIModal.tsx +++ b/plugins/kiali/src/components/About/AboutUIModal.tsx @@ -86,7 +86,12 @@ export const AboutUIModal = (props: AboutUIModalProps) => { {name} - + {additionalInfo} @@ -157,19 +162,19 @@ export const AboutUIModal = (props: AboutUIModalProps) => { Kiali - + {coreVersion || 'Unknown'} Kiali Container - + {containerVersion || 'Unknown'} Service Mesh - + {meshVersion || 'Unknown'} diff --git a/plugins/kiali/src/components/MessageCenter/AlertDrawer.tsx b/plugins/kiali/src/components/MessageCenter/AlertDrawer.tsx index 2b5d3b19fa..d8efb59754 100644 --- a/plugins/kiali/src/components/MessageCenter/AlertDrawer.tsx +++ b/plugins/kiali/src/components/MessageCenter/AlertDrawer.tsx @@ -61,7 +61,7 @@ const noNotificationsMessage = ( export const AlertDrawer = (props: AlertDrawerProps) => { return ( - + @@ -74,6 +74,7 @@ export const AlertDrawer = (props: AlertDrawerProps) => { } + data-test={'message-center-summary'} > {group.title} {getUnreadMessageLabel(group.messages)} diff --git a/plugins/kiali/src/components/MessageCenter/AlertDrawerGroup.tsx b/plugins/kiali/src/components/MessageCenter/AlertDrawerGroup.tsx index 839be0834f..04c1008851 100644 --- a/plugins/kiali/src/components/MessageCenter/AlertDrawerGroup.tsx +++ b/plugins/kiali/src/components/MessageCenter/AlertDrawerGroup.tsx @@ -59,7 +59,10 @@ export const AlertDrawerGroup = (props: AlertDrawerGroupProps) => { return ( - + {group.messages.length === 0 && noNotificationsMessage} {getMessages().map(message => ( @@ -67,10 +70,18 @@ export const AlertDrawerGroup = (props: AlertDrawerGroupProps) => { {group.showActions && group.messages.length > 0 && ( - - diff --git a/plugins/kiali/src/components/MessageCenter/AlertDrawerMessage.tsx b/plugins/kiali/src/components/MessageCenter/AlertDrawerMessage.tsx index 6861cbf894..3ae51c6ed3 100644 --- a/plugins/kiali/src/components/MessageCenter/AlertDrawerMessage.tsx +++ b/plugins/kiali/src/components/MessageCenter/AlertDrawerMessage.tsx @@ -46,7 +46,7 @@ export const AlertDrawerMessage = (props: AlertDrawerMessageProps) => { return ( - + {getIcon(props.message.type)}{' '} {props.message.seen ? ( props.message.content @@ -60,11 +60,17 @@ export const AlertDrawerMessage = (props: AlertDrawerMessageProps) => { onClick={() => toggleMessageDetail(props.message)} expandIcon={} > - + {props.message.showDetail ? 'Hide Detail' : 'Show Detail'} - +
                 {props.message.detail}
               
diff --git a/plugins/kiali/tests/kialiHelper.ts b/plugins/kiali/tests/kialiHelper.ts index 888eecc39f..cb747b2440 100644 --- a/plugins/kiali/tests/kialiHelper.ts +++ b/plugins/kiali/tests/kialiHelper.ts @@ -1,5 +1,7 @@ import { expect, type Locator, type Page } from '@playwright/test'; +export { kialiData } from '../dev/__fixtures__'; + export class Common { page: Page; diff --git a/plugins/kiali/tests/kialiPage.spec.ts b/plugins/kiali/tests/kialiPage.spec.ts index b992be628d..f0fe44ec97 100644 --- a/plugins/kiali/tests/kialiPage.spec.ts +++ b/plugins/kiali/tests/kialiPage.spec.ts @@ -1,8 +1,10 @@ import { expect, Page, test } from '@playwright/test'; -import CONFIG from '../dev/__fixtures__/general/config.json'; -import NAMESPACES from '../dev/__fixtures__/general/namespaces.json'; -import { Common } from './kialiHelper'; +import { Common, kialiData } from './kialiHelper'; + +const CONFIG = kialiData.config; +const NAMESPACES = kialiData.namespaces; +const STATUS = kialiData.status; function filterByIstioInjectionEnabled(jsonArray: any): any { return jsonArray.filter( @@ -17,12 +19,15 @@ test.describe('Kiali page', () => { let page: Page; let common: Common; test.describe('overview', () => { - test.beforeEach(async ({ browser }) => { + test.beforeAll(async ({ browser }) => { const context = await browser.newContext(); page = await context.newPage(); common = new Common(page); await common.loginAsGuest(); }); + test.beforeEach(async () => { + page.reload(); + }); test('Home cluster is visible', async () => { await expect(page.locator('data-test=home-cluster')).toHaveText( @@ -38,6 +43,93 @@ test.describe('Kiali page', () => { ).toBeVisible(); }); + test('About page can be opened', async () => { + await page.click('data-test=help-button'); + await page.click('text=About'); + await expect(page.locator('data-test=Kiali')).toContainText( + STATUS.status['Kiali version'], + ); + await expect(page.locator('data-test=Kiali')).toContainText( + STATUS.status['Kiali commit hash'], + ); + await expect(page.locator('data-test=Kiali container')).toContainText( + STATUS.status['Kiali container version'], + ); + await expect(page.locator('data-test=Service Mesh')).toContainText( + STATUS.status['Mesh name'], + ); + await expect(page.locator('data-test=Service Mesh')).toContainText( + STATUS.status['Mesh version'], + ); + + for (const external of STATUS.externalServices) { + let text; + if (external.version) { + text = external.version; + } else { + text = 'N/A'; + } + await expect(page.locator(`data-test=${external.name}`)).toContainText( + text, + ); + } + }); + + test('MessageCenter can be opened', async () => { + await page.click('data-test=message-center'); + await expect( + page.locator('data-test=message-center-modal'), + ).toBeVisible(); + await expect(page.locator('data-test=message-center-summary')).toHaveText( + 'Notifications 2 Unread Messages', + ); + await page.click('data-test=message-center-summary'); + await page.locator( + 'data-test=message-center-messages [data-test=drawer-message]', + ); + }); + + test('Detail of a message in MessageCenter can be opened', async () => { + await page.click('data-test=message-center'); + await page.click('data-test=message-center-summary'); + await page.click('data-test=show-message-detail'); + await expect(page.locator('data-test=message-detail').first()).toHaveText( + 'grafana URL is not set in Kiali configuration', + ); + }); + + test('Detail of a message in MessageCenter can be closed', async () => { + await page.click('data-test=message-center'); + await page.click('data-test=message-center-summary'); + await page.click('data-test=show-message-detail'); + await page.click('data-test=hide-message-detail'); + await expect( + page.locator('data-test=message-detail').first(), + ).toBeHidden(); + }); + + test('Messages can be marked as read', async () => { + await page.click('data-test=message-center'); + await page.click('data-test=message-center-summary'); + await page.click('data-test=mark-as-read'); + await expect(page.locator('data-test=message-center-summary')).toHaveText( + 'Notifications 0 Unread Messages', + ); + }); + + test('Messages can be cleared', async () => { + await page.click('data-test=message-center'); + await page.click('data-test=message-center-summary'); + await page.click('data-test=clear-all'); + await expect(page.locator('data-test=message-center-summary')).toHaveText( + 'Notifications 0 Unread Messages', + ); + await expect( + page.locator('data-test=message-center-messages'), + ).toHaveText('No Messages Available'); + await expect(page.locator('data-test=drawer-message')).toHaveCount(0); + }); + test('User is visible', async () => { if (CONFIG.authStrategy === 'anonymous') { await expect(page.locator('data-test=user')).toHaveText( From 0991bc1efbb5345c44c3aecd53e5cf85777356e9 Mon Sep 17 00:00:00 2001 From: matejnesuta Date: Mon, 3 Jun 2024 14:56:27 +0200 Subject: [PATCH 3/8] unfinished labels test --- .../Overview/OverviewCard/NamespaceLabels.tsx | 4 ++-- plugins/kiali/tests/kialiPage.spec.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/kiali/src/pages/Overview/OverviewCard/NamespaceLabels.tsx b/plugins/kiali/src/pages/Overview/OverviewCard/NamespaceLabels.tsx index aba4c70b89..6298d15257 100644 --- a/plugins/kiali/src/pages/Overview/OverviewCard/NamespaceLabels.tsx +++ b/plugins/kiali/src/pages/Overview/OverviewCard/NamespaceLabels.tsx @@ -13,7 +13,7 @@ export const NamespaceLabels = (props: NamespaceLabelsprops) => { ? `${Object.entries(props.labels).length}` : 'No'; const tooltipTitle = ( -
    +
      {Object.entries(props.labels || []).map(([key, value]) => (
    • {key}={value} @@ -27,7 +27,7 @@ export const NamespaceLabels = (props: NamespaceLabelsprops) => { {labelsLength} label{labelsLength !== '1' ? 's' : ''} - + diff --git a/plugins/kiali/tests/kialiPage.spec.ts b/plugins/kiali/tests/kialiPage.spec.ts index f0fe44ec97..32e64d45c9 100644 --- a/plugins/kiali/tests/kialiPage.spec.ts +++ b/plugins/kiali/tests/kialiPage.spec.ts @@ -168,5 +168,20 @@ test.describe('Kiali page', () => { ).toHaveCount(1); } }); + + test('Namespace card should have labels', async () => { + const ns = visibleNamespaces[0]; + const ns_card = await page.locator(`data-test=overview-card-${ns.name}`); + const icon = await ns_card.locator('data-test=labels-info-icon'); + icon.hover(); + for (const [key, value] of Object.entries(ns.labels)) { + await expect( + page.locator('data-test=namespace-labels > li'), + ).toHaveText(`${key}=${value}`); + } + await expect(page.locator('#labels_info')).toContainText( + `${Object.entries(ns.labels).length} labels`, + ); + }); }); }); From eb5f45ac98655b40c216747ff978881c5b375caf Mon Sep 17 00:00:00 2001 From: matejnesuta Date: Mon, 3 Jun 2024 18:25:04 +0200 Subject: [PATCH 4/8] finished label test --- plugins/kiali/tests/kialiPage.spec.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/kiali/tests/kialiPage.spec.ts b/plugins/kiali/tests/kialiPage.spec.ts index 32e64d45c9..891700fc6c 100644 --- a/plugins/kiali/tests/kialiPage.spec.ts +++ b/plugins/kiali/tests/kialiPage.spec.ts @@ -173,13 +173,18 @@ test.describe('Kiali page', () => { const ns = visibleNamespaces[0]; const ns_card = await page.locator(`data-test=overview-card-${ns.name}`); const icon = await ns_card.locator('data-test=labels-info-icon'); - icon.hover(); + await icon.hover(); + let list = await page.locator('data-test=namespace-labels'); + + // Wait for the list to appear + await page.waitForSelector('data-test=namespace-labels'); + for (const [key, value] of Object.entries(ns.labels)) { - await expect( - page.locator('data-test=namespace-labels > li'), - ).toHaveText(`${key}=${value}`); + await icon.hover({ force: true }).then(async () => { + await expect(list).toContainText(`${key}=${value}`); + }); } - await expect(page.locator('#labels_info')).toContainText( + await expect(ns_card.locator('#labels_info')).toContainText( `${Object.entries(ns.labels).length} labels`, ); }); From 69f7a21db8c01e79e3ec6c806de037df90f1d028 Mon Sep 17 00:00:00 2001 From: matejnesuta Date: Wed, 5 Jun 2024 17:02:10 +0200 Subject: [PATCH 5/8] added tests for validations --- .../general/istioValidations.json | 4 +- .../namespaces/travel-agency/health/app.json | 2 +- .../namespaces/travel-control/health/app.json | 2 +- .../Validations/ValidationSummary.tsx | 1 + .../Overview/OverviewCard/OverviewCard.tsx | 1 + .../src/pages/Overview/OverviewStatus.tsx | 6 +- plugins/kiali/tests/kialiPage.spec.ts | 111 ++++++++++++++++++ 7 files changed, 121 insertions(+), 6 deletions(-) diff --git a/plugins/kiali/dev/__fixtures__/general/istioValidations.json b/plugins/kiali/dev/__fixtures__/general/istioValidations.json index 2e03262db2..612b8f42d7 100644 --- a/plugins/kiali/dev/__fixtures__/general/istioValidations.json +++ b/plugins/kiali/dev/__fixtures__/general/istioValidations.json @@ -32,8 +32,8 @@ }, "travel-control": { "errors": 0, - "objectCount": 0, - "warnings": 0 + "objectCount": 1, + "warnings": 1 }, "travel-portal": { "errors": 0, diff --git a/plugins/kiali/dev/__fixtures__/namespaces/travel-agency/health/app.json b/plugins/kiali/dev/__fixtures__/namespaces/travel-agency/health/app.json index 84a00bf3c8..a73a7af661 100644 --- a/plugins/kiali/dev/__fixtures__/namespaces/travel-agency/health/app.json +++ b/plugins/kiali/dev/__fixtures__/namespaces/travel-agency/health/app.json @@ -50,7 +50,7 @@ "desiredReplicas": 1, "currentReplicas": 1, "availableReplicas": 1, - "syncedProxies": 1 + "syncedProxies": 0 } ], "requests": { diff --git a/plugins/kiali/dev/__fixtures__/namespaces/travel-control/health/app.json b/plugins/kiali/dev/__fixtures__/namespaces/travel-control/health/app.json index 2800f2b95a..79a6902cd0 100644 --- a/plugins/kiali/dev/__fixtures__/namespaces/travel-control/health/app.json +++ b/plugins/kiali/dev/__fixtures__/namespaces/travel-control/health/app.json @@ -4,7 +4,7 @@ { "name": "control", "desiredReplicas": 1, - "currentReplicas": 1, + "currentReplicas": 0, "availableReplicas": 1, "syncedProxies": 1 } diff --git a/plugins/kiali/src/components/Validations/ValidationSummary.tsx b/plugins/kiali/src/components/Validations/ValidationSummary.tsx index 573d43988c..80953a5cb8 100644 --- a/plugins/kiali/src/components/Validations/ValidationSummary.tsx +++ b/plugins/kiali/src/components/Validations/ValidationSummary.tsx @@ -128,6 +128,7 @@ export const ValidationSummary = (props: Props) => { return ( diff --git a/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx b/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx index 0963de75b7..5cf016eb0d 100644 --- a/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx +++ b/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx @@ -106,6 +106,7 @@ export const OverviewCard = (props: OverviewCardProps) => { errors={validations.errors} warnings={validations.warnings} objectCount={validations.objectCount} + data-test={'validation-summary'} /> ); }; diff --git a/plugins/kiali/src/pages/Overview/OverviewStatus.tsx b/plugins/kiali/src/pages/Overview/OverviewStatus.tsx index 30218ad873..c92d06253c 100644 --- a/plugins/kiali/src/pages/Overview/OverviewStatus.tsx +++ b/plugins/kiali/src/pages/Overview/OverviewStatus.tsx @@ -43,8 +43,10 @@ export class OverviewStatus extends React.Component { items.push(`and ${length - items.length} more...`); } const tooltipContent = ( -
      - {this.props.status.name} +
      + + {this.props.status.name} + {items.map((app, idx) => { return (
      { + const ns_card = await page.locator(`data-test=overview-card-${ns}`); + await page.click('[aria-label="Health for"]'); + await page.click(`[data-value=${type}]`); + + const icon = await ns_card.locator('data-test=overview-app-health'); + await icon.hover(); + let list = await page.locator('data-test=overview-status'); + + // Wait for the list to appear + await page.waitForSelector('data-test=overview-status'); + + let i = 0; + for (const object of Object.entries(objects)) { + if (i == 5) { + break; + } + await icon.hover({ force: true }).then(async () => { + await expect(list).toContainText(`${object[1].name}`); + }); + i++; + } + let expected = type == 'app' ? 'application' : type; + await expect( + ns_card.locator(`data-test=overview-type-${type}`), + ).toContainText(`${Object.entries(objects).length} ${expected}s`); +} function filterByIstioInjectionEnabled(jsonArray: any): any { return jsonArray.filter( @@ -188,5 +224,80 @@ test.describe('Kiali page', () => { `${Object.entries(ns.labels).length} labels`, ); }); + + test('Apps should be reported in the namespace card', async () => { + const ns = BOOKINFO_APPS.namespace.name; + await checkReportedItems('app', ns, BOOKINFO_APPS.applications, page); + }); + + test('Services should be reported in the namespace card', async () => { + const ns = BOOKINFO_SERVICES.namespace.name; + await checkReportedItems('service', ns, BOOKINFO_SERVICES.services, page); + }); + + test('Workloads should be reported in the namespace card', async () => { + const ns = BOOKINFO_WORKLOADS.namespace.name; + await checkReportedItems( + 'workload', + ns, + BOOKINFO_WORKLOADS.workloads, + page, + ); + }); + + test('Healthy apps should be reported in the namespace card', async () => { + const ns_card = await page.locator(`data-test=overview-card-bookinfo`); + const icon = await ns_card.locator('data-test=overview-app-health'); + await icon.hover(); + await page.waitForSelector('data-test=overview-status'); + await expect(ns_card.locator('data-test=Healthy-status')).toBeDefined(); + }); + + test('Degraded apps should be reported in the namespace card', async () => { + const ns_card = await page.locator( + `data-test=overview-card-travel-agency`, + ); + const icon = await ns_card + .locator('[aria-label="Overview status"]') + .first(); + await icon.hover(); + await page.waitForSelector('data-test=overview-status'); + await expect(ns_card.locator('data-test=Degraded-status')).toBeDefined(); + }); + + test('Failed apps should be reported in the namespace card', async () => { + const ns_card = await page.locator( + `data-test=overview-card-travel-control`, + ); + const icon = await ns_card.locator('[aria-label="Overview status"]'); + await icon.hover(); + await page.waitForSelector('data-test=overview-status'); + await expect(ns_card.locator('data-test=Failure-status')).toBeDefined(); + }); + + test('Istio config with success should be reported in the namespace card', async () => { + const ns_card = await page.locator( + `data-test=overview-card-travel-agency`, + ); + await expect( + ns_card.locator('data-test=validation-icon-correct'), + ).toBeVisible(); + }); + + test('Istio config with warning should be reported in the namespace card', async () => { + const ns_card = await page.locator( + `data-test=overview-card-travel-control`, + ); + await expect( + ns_card.locator('data-test=validation-icon-warning'), + ).toBeVisible(); + }); + + test('Istio config with error should be reported in the namespace card', async () => { + const ns_card = await page.locator(`data-test=overview-card-bookinfo`); + await expect( + ns_card.locator('data-test=validation-icon-error'), + ).toBeVisible(); + }); }); }); From 75a5c0e558a7d479c67397c72cae5feed93ff334 Mon Sep 17 00:00:00 2001 From: matejnesuta Date: Mon, 24 Jun 2024 12:39:45 +0200 Subject: [PATCH 6/8] addresed some changes after a rebase --- plugins/kiali/tests/kialiPage.spec.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/plugins/kiali/tests/kialiPage.spec.ts b/plugins/kiali/tests/kialiPage.spec.ts index bb3c83c145..0766a90d78 100644 --- a/plugins/kiali/tests/kialiPage.spec.ts +++ b/plugins/kiali/tests/kialiPage.spec.ts @@ -71,17 +71,8 @@ test.describe('Kiali page', () => { ); }); - test('Debug info can be opened', async () => { - await page.click('data-test=help-button'); - await page.click('text=View Debug Info'); - await expect( - page.locator('css=[aria-describedby="Debug information"]'), - ).toBeVisible(); - }); - test('About page can be opened', async () => { await page.click('data-test=help-button'); - await page.click('text=About'); await expect(page.locator('data-test=Kiali')).toContainText( STATUS.status['Kiali version'], ); From 95a0afc823553b967439c6ae9499a913d3d48642 Mon Sep 17 00:00:00 2001 From: matejnesuta Date: Mon, 24 Jun 2024 15:44:58 +0200 Subject: [PATCH 7/8] prettier fix --- plugins/kiali/src/pages/Kiali/Header/HelpKiali.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/kiali/src/pages/Kiali/Header/HelpKiali.tsx b/plugins/kiali/src/pages/Kiali/Header/HelpKiali.tsx index 794fad00c6..ed01c0ab5f 100644 --- a/plugins/kiali/src/pages/Kiali/Header/HelpKiali.tsx +++ b/plugins/kiali/src/pages/Kiali/Header/HelpKiali.tsx @@ -16,7 +16,11 @@ export const HelpKiali = (props: { color?: string }) => { return ( <> - Date: Tue, 25 Jun 2024 21:53:22 +0200 Subject: [PATCH 8/8] fixed linting issues --- plugins/kiali/src/components/About/AboutUIModal.tsx | 6 +++--- .../kiali/src/components/MessageCenter/AlertDrawer.tsx | 4 ++-- .../src/components/MessageCenter/AlertDrawerGroup.tsx | 6 +++--- .../src/components/MessageCenter/AlertDrawerMessage.tsx | 4 ++-- .../kiali/src/components/MessageCenter/MessageCenter.tsx | 2 +- plugins/kiali/src/pages/Kiali/Header/HelpKiali.tsx | 2 +- plugins/kiali/src/pages/Kiali/Header/KialiHeader.tsx | 4 ++-- .../kiali/src/pages/Kiali/Header/NamespaceSelector.tsx | 2 +- .../src/pages/Overview/OverviewCard/NamespaceLabels.tsx | 4 ++-- .../src/pages/Overview/OverviewCard/OverviewCard.tsx | 2 +- plugins/kiali/src/pages/Overview/OverviewStatus.tsx | 2 +- plugins/kiali/tests/kialiPage.spec.ts | 8 ++++---- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/plugins/kiali/src/components/About/AboutUIModal.tsx b/plugins/kiali/src/components/About/AboutUIModal.tsx index 05aa7c12bc..7b1c8e8ff8 100644 --- a/plugins/kiali/src/components/About/AboutUIModal.tsx +++ b/plugins/kiali/src/components/About/AboutUIModal.tsx @@ -162,19 +162,19 @@ export const AboutUIModal = (props: AboutUIModalProps) => { Kiali - + {coreVersion || 'Unknown'} Kiali Container - + {containerVersion || 'Unknown'} Service Mesh - + {meshVersion || 'Unknown'} diff --git a/plugins/kiali/src/components/MessageCenter/AlertDrawer.tsx b/plugins/kiali/src/components/MessageCenter/AlertDrawer.tsx index d8efb59754..2ce0118ecd 100644 --- a/plugins/kiali/src/components/MessageCenter/AlertDrawer.tsx +++ b/plugins/kiali/src/components/MessageCenter/AlertDrawer.tsx @@ -61,7 +61,7 @@ const noNotificationsMessage = ( export const AlertDrawer = (props: AlertDrawerProps) => { return ( - + @@ -74,7 +74,7 @@ export const AlertDrawer = (props: AlertDrawerProps) => { } - data-test={'message-center-summary'} + data-test="message-center-summary" > {group.title} {getUnreadMessageLabel(group.messages)} diff --git a/plugins/kiali/src/components/MessageCenter/AlertDrawerGroup.tsx b/plugins/kiali/src/components/MessageCenter/AlertDrawerGroup.tsx index 04c1008851..9a59f99384 100644 --- a/plugins/kiali/src/components/MessageCenter/AlertDrawerGroup.tsx +++ b/plugins/kiali/src/components/MessageCenter/AlertDrawerGroup.tsx @@ -61,7 +61,7 @@ export const AlertDrawerGroup = (props: AlertDrawerGroupProps) => { {group.messages.length === 0 && noNotificationsMessage} {getMessages().map(message => ( @@ -71,14 +71,14 @@ export const AlertDrawerGroup = (props: AlertDrawerGroupProps) => { {group.showActions && group.messages.length > 0 && ( diff --git a/plugins/kiali/src/pages/Kiali/Header/KialiHeader.tsx b/plugins/kiali/src/pages/Kiali/Header/KialiHeader.tsx index bf5f5e8db4..f5982caf5e 100644 --- a/plugins/kiali/src/pages/Kiali/Header/KialiHeader.tsx +++ b/plugins/kiali/src/pages/Kiali/Header/KialiHeader.tsx @@ -24,7 +24,7 @@ export const KialiHeader = () => { color="primary" icon={} label={homeCluster?.name} - data-test={'home-cluster'} + data-test="home-cluster" /> @@ -36,7 +36,7 @@ export const KialiHeader = () => { flexDirection: 'row', justifyContent: 'space-between', }} - data-test={'user'} + data-test="user" > User : diff --git a/plugins/kiali/src/pages/Kiali/Header/NamespaceSelector.tsx b/plugins/kiali/src/pages/Kiali/Header/NamespaceSelector.tsx index d141584718..57f0acee9d 100644 --- a/plugins/kiali/src/pages/Kiali/Header/NamespaceSelector.tsx +++ b/plugins/kiali/src/pages/Kiali/Header/NamespaceSelector.tsx @@ -56,7 +56,7 @@ export const NamespaceSelector = (props: { page?: boolean }) => { onChange={handleChange} renderValue={selected => (selected as string[]).join(', ')} MenuProps={MenuProps} - data-test={'namespace-selector'} + data-test="namespace-selector" > {(kialiState.namespaces.items || []).map(ns => ( diff --git a/plugins/kiali/src/pages/Overview/OverviewCard/NamespaceLabels.tsx b/plugins/kiali/src/pages/Overview/OverviewCard/NamespaceLabels.tsx index 6298d15257..b12094e302 100644 --- a/plugins/kiali/src/pages/Overview/OverviewCard/NamespaceLabels.tsx +++ b/plugins/kiali/src/pages/Overview/OverviewCard/NamespaceLabels.tsx @@ -13,7 +13,7 @@ export const NamespaceLabels = (props: NamespaceLabelsprops) => { ? `${Object.entries(props.labels).length}` : 'No'; const tooltipTitle = ( -
        +
          {Object.entries(props.labels || []).map(([key, value]) => (
        • {key}={value} @@ -27,7 +27,7 @@ export const NamespaceLabels = (props: NamespaceLabelsprops) => { {labelsLength} label{labelsLength !== '1' ? 's' : ''}
      - + diff --git a/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx b/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx index 5cf016eb0d..548aacf9a0 100644 --- a/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx +++ b/plugins/kiali/src/pages/Overview/OverviewCard/OverviewCard.tsx @@ -106,7 +106,7 @@ export const OverviewCard = (props: OverviewCardProps) => { errors={validations.errors} warnings={validations.warnings} objectCount={validations.objectCount} - data-test={'validation-summary'} + data-test="validation-summary" /> ); }; diff --git a/plugins/kiali/src/pages/Overview/OverviewStatus.tsx b/plugins/kiali/src/pages/Overview/OverviewStatus.tsx index c92d06253c..12f76d784d 100644 --- a/plugins/kiali/src/pages/Overview/OverviewStatus.tsx +++ b/plugins/kiali/src/pages/Overview/OverviewStatus.tsx @@ -43,7 +43,7 @@ export class OverviewStatus extends React.Component { items.push(`and ${length - items.length} more...`); } const tooltipContent = ( -
      +
      {this.props.status.name} diff --git a/plugins/kiali/tests/kialiPage.spec.ts b/plugins/kiali/tests/kialiPage.spec.ts index 0766a90d78..bb1931420f 100644 --- a/plugins/kiali/tests/kialiPage.spec.ts +++ b/plugins/kiali/tests/kialiPage.spec.ts @@ -21,14 +21,14 @@ async function checkReportedItems( const icon = await ns_card.locator('data-test=overview-app-health'); await icon.hover(); - let list = await page.locator('data-test=overview-status'); + const list = await page.locator('data-test=overview-status'); // Wait for the list to appear await page.waitForSelector('data-test=overview-status'); let i = 0; for (const object of Object.entries(objects)) { - if (i == 5) { + if (i === 5) { break; } await icon.hover({ force: true }).then(async () => { @@ -36,7 +36,7 @@ async function checkReportedItems( }); i++; } - let expected = type == 'app' ? 'application' : type; + const expected = type === 'app' ? 'application' : type; await expect( ns_card.locator(`data-test=overview-type-${type}`), ).toContainText(`${Object.entries(objects).length} ${expected}s`); @@ -201,7 +201,7 @@ test.describe('Kiali page', () => { const ns_card = await page.locator(`data-test=overview-card-${ns.name}`); const icon = await ns_card.locator('data-test=labels-info-icon'); await icon.hover(); - let list = await page.locator('data-test=namespace-labels'); + const list = await page.locator('data-test=namespace-labels'); // Wait for the list to appear await page.waitForSelector('data-test=namespace-labels');