Skip to content

Commit

Permalink
Merge pull request #1678 from Azure/fix/1624
Browse files Browse the repository at this point in the history
UI Tests : skip grafana if not installed
  • Loading branch information
xpillons authored Sep 8, 2023
2 parents 110de2e + 8100c23 commit f1101bf
Showing 1 changed file with 22 additions and 48 deletions.
70 changes: 22 additions & 48 deletions tests/grafana_home.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});

0 comments on commit f1101bf

Please sign in to comment.