From 8100c23a3c73dea1ec19381ddb1f7f4a16510f96 Mon Sep 17 00:00:00 2001 From: Xavier Pillons Date: Fri, 8 Sep 2023 11:16:03 +0200 Subject: [PATCH] Add a test if grafana is installed --- tests/grafana_home.spec.ts | 70 ++++++++++++-------------------------- 1 file changed, 22 insertions(+), 48 deletions(-) diff --git a/tests/grafana_home.spec.ts b/tests/grafana_home.spec.ts index 529718e75..88c3572cf 100644 --- a/tests/grafana_home.spec.ts +++ b/tests/grafana_home.spec.ts @@ -1,58 +1,32 @@ import {test, expect} from '@playwright/test'; - -// test('Grafana', async ({browser}) => { -// // create context with HTTP credentials -// const context = await browser.newContext(); - -// // Open Grafana -// const page = await context.newPage(); -// await page.goto('/rnode/grafana/3000', { waitUntil: 'networkidle' }); - -// // Click [aria-label="Dashboards"] div -// //await page.click('[aria-label="Dashboards"] div'); -// // Click text=Browse >> [data-testid="dropdown-child-icon"] -// //await page.click('text=Browse >> [data-testid="dropdown-child-icon"]'); - -// await page.goto('/rnode/grafana/3000/dashboards', { waitUntil: 'networkidle' }); -// // Click text=dashboards| Go to folder -// await page.click('text=dashboards| Go to folder'); - -// // Click text=azhop - Infra Servers -// await Promise.all([ -// page.waitForNavigation({ waitUntil: 'networkidle' }), -// page.click('text=azhop - Infra Servers') -// ]); - -// await page.close() - -// // Close the browser -// await context.close(); -// }); - +import azhopConfig from './azhop.config'; test('Grafana', async ({ browser }) => { // create context with HTTP credentials const context = await browser.newContext(); - // Create a page - const page = await context.newPage(); - await page.goto('/', { waitUntil: 'networkidle' }); - - await page.getByRole('button', { name: 'Monitoring' }).click(); - const page1Promise = page.waitForEvent('popup'); - await page.getByRole('link', { name: 'Grafana Dashboard' }).click(); - const page1 = await page1Promise; - await page1.getByRole('button', { name: 'Toggle menu' }).click(); - await page1.getByTestId('navbarmenu').getByRole('link', { name: 'Dashboards' }).click(); - await page1.getByTestId('data-testid Folder header dashboards').getByText('dashboards').click(); - await page1.getByRole('link', { name: 'azhop - Infra Servers' }).click(); - await page1.waitForLoadState('networkidle'); - await page1.getByTestId('data-testid Dashboard template variables Variable Value DropDown value link text ondemand').click(); - await page1.getByRole('checkbox', { name: 'ccportal' }).click(); - - await page1.waitForLoadState('networkidle'); - await page1.close() + // if grafan is enabled then browse to the UI + if (azhopConfig.monitoring.grafana) { + // Create a page + const page = await context.newPage(); + await page.goto('/', { waitUntil: 'networkidle' }); + + await page.getByRole('button', { name: 'Monitoring' }).click(); + const page1Promise = page.waitForEvent('popup'); + await page.getByRole('link', { name: 'Grafana Dashboard' }).click(); + const page1 = await page1Promise; + await page1.getByRole('button', { name: 'Toggle menu' }).click(); + await page1.getByTestId('navbarmenu').getByRole('link', { name: 'Dashboards' }).click(); + await page1.getByTestId('data-testid Folder header dashboards').getByText('dashboards').click(); + await page1.getByRole('link', { name: 'azhop - Infra Servers' }).click(); + await page1.waitForLoadState('networkidle'); + await page1.getByTestId('data-testid Dashboard template variables Variable Value DropDown value link text ondemand').click(); + await page1.getByRole('checkbox', { name: 'ccportal' }).click(); + + await page1.waitForLoadState('networkidle'); + await page1.close() + } // Close the browser await context.close(); });