oncall-engine/grafana-plugin/e2e-tests/insights/insights.test.ts
Dominik Broj 344cd0efde
Add missing labels permissions, fix tilt ci from ops-devenv, fix expensive e2e tests (#4842)
# What this PR does

- add missing labels-related permissions for external service account
used by new oncall init process
- fix expensive e2e tests in new oncall init process
- unify Grafana versions between standard and expensive e2e tests
- fix running tilt through ops-devenv in new oncall init process
- avoid duplicated standard e2e tests on workflows that run daily and on
merges to main

## Which issue(s) this PR closes

Related to https://github.com/grafana/oncall-private/issues/2656

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.

---------

Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
2024-08-19 18:17:10 +00:00

84 lines
3.7 KiB
TypeScript

import { test, expect } from '../fixtures';
import { resolveFiringAlert } from '../utils/alertGroup';
import { isGrafanaVersionLowerThan } from '../utils/constants';
import { createEscalationChain, EscalationStep } from '../utils/escalationChain';
import { clickButton, generateRandomValue } from '../utils/forms';
import { createIntegrationAndSendDemoAlert } from '../utils/integrations';
import { goToGrafanaPage, goToOnCallPage } from '../utils/navigation';
import { createOnCallSchedule } from '../utils/schedule';
/**
* Insights is dependent on Scenes which were only added in Grafana 10.0.0
* https://grafana.com/docs/grafana/latest/whatsnew/whats-new-in-v10-0/#scenes
* TODO: remove the process.env.CURRENT_GRAFANA_VERSION portion
* and use the currentGrafanaVersion fixture once this bugged is patched in playwright
* https://github.com/microsoft/playwright/issues/29608
*/
test.skip(() => isGrafanaVersionLowerThan('10.0.0'), 'Insights is only available in Grafana 10.0.0 and above');
/**
* skipping as these tests are currently flaky
* see this Slack conversation for more details:
* https://raintank-corp.slack.com/archives/C04JCU51NF8/p1712069772861909
*/
test.describe.skip('Insights', () => {
test.beforeAll(async ({ adminRolePage: { page } }) => {
const DATASOURCE_NAME = 'OnCall Prometheus';
const DATASOURCE_URL = 'http://oncall-dev-prometheus-server.default.svc.cluster.local';
await goToGrafanaPage(page, '/connections/datasources');
await page.waitForLoadState('networkidle');
// setup data source if it's not already connected
const isDataSourceAlreadyConnected = await page.getByText(DATASOURCE_NAME).isVisible();
if (!isDataSourceAlreadyConnected) {
await page.getByRole('link', { name: 'Add data source' }).click();
await clickButton({ page, buttonText: 'Prometheus' });
await page.getByRole('textbox', { name: 'Data source settings page name input field' }).fill(DATASOURCE_NAME);
await page.getByPlaceholder('http://localhost:9090').fill(DATASOURCE_URL);
await clickButton({ page, buttonText: 'Save & test' });
}
});
test('Viewer can see all the panels in OnCall insights', async ({ viewerRolePage: { page } }) => {
await goToOnCallPage(page, 'insights');
[
'New alert groups',
'Mean time to respond \\(MTTR\\) average',
'Alert groups by Integration',
'Mean time to respond \\(MTTR\\) by Integration',
'Alert groups by Team',
'Mean time to respond \\(MTTR\\) by Team',
'New alert groups notifications',
].forEach(async (panelTitle) => {
await expect(page.getByRole('heading', { name: new RegExp(`^${panelTitle}$`) }).first()).toBeVisible();
});
});
test('There is no panel that misses data', async ({ adminRolePage: { page, userName } }) => {
test.setTimeout(90_000);
// send alert and resolve to get some values in insights
const escalationChainName = generateRandomValue();
const integrationName = generateRandomValue();
const onCallScheduleName = generateRandomValue();
await createOnCallSchedule(page, onCallScheduleName, userName);
await createEscalationChain(
page,
escalationChainName,
EscalationStep.NotifyUsersFromOnCallSchedule,
onCallScheduleName
);
await createIntegrationAndSendDemoAlert(page, integrationName, escalationChainName);
await resolveFiringAlert(page);
// wait for Prometheus to scrape the data
await page.waitForTimeout(5000);
// check that we have data in insights panels
await goToOnCallPage(page, 'insights');
await page.getByText('Last 24 hours').click();
await page.getByText('Last 1 hour').click();
await page.waitForTimeout(3000);
await expect(page.getByText('No data')).toBeHidden();
});
});