oncall-engine/grafana-plugin/e2e-tests/integrations/heartbeat.test.ts
Maxim Mordasov 36f9851003
add a couple of tests for users screen (#2612)
# What this PR does

There are the following tests added:

 - admin is allowed to edit other profiles
 - editor is not allowed to edit other profiles

## Which issue(s) this PR fixes

https://github.com/grafana/oncall/issues/1586

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Rares Mardare <rares.mardare@grafana.com>
2023-08-02 15:42:48 +03:00

71 lines
2.4 KiB
TypeScript

import { test, Page, expect, Locator } from '../fixtures';
import { generateRandomValue, selectDropdownValue } from '../utils/forms';
import { createIntegration } from '../utils/integrations';
test.describe("updating an integration's heartbeat interval works", async () => {
test.slow();
const _openIntegrationSettingsPopup = async (page: Page): Promise<Locator> => {
const integrationSettingsPopupElement = page.getByTestId('integration-settings-context-menu');
await integrationSettingsPopupElement.click();
return integrationSettingsPopupElement;
};
const _openHeartbeatSettingsForm = async (page: Page) => {
const integrationSettingsPopupElement = await _openIntegrationSettingsPopup(page);
await integrationSettingsPopupElement.click();
await page.getByTestId('integration-heartbeat-settings').click();
};
test('change heartbeat interval', async ({ adminRolePage: { page } }) => {
const integrationName = generateRandomValue();
await createIntegration(page, integrationName);
await _openHeartbeatSettingsForm(page);
const heartbeatSettingsForm = page.getByTestId('heartbeat-settings-form');
const value = '30 minutes';
await selectDropdownValue({
page,
startingLocator: heartbeatSettingsForm,
selectType: 'grafanaSelect',
value,
optionExactMatch: false,
});
await heartbeatSettingsForm.getByTestId('update-heartbeat').click();
await _openHeartbeatSettingsForm(page);
const heartbeatIntervalValue = await heartbeatSettingsForm
.locator('div[class*="grafana-select-value-container"] > div[class*="-singleValue"]')
.textContent();
expect(heartbeatIntervalValue).toEqual(value);
});
test('send heartbeat', async ({ request, adminRolePage: { page } }) => {
const integrationName = generateRandomValue();
await createIntegration(page, integrationName);
await _openHeartbeatSettingsForm(page);
const heartbeatSettingsForm = page.getByTestId('heartbeat-settings-form');
const endpoint = await heartbeatSettingsForm
.getByTestId('input-wrapper')
.locator('input[class*="input-input"]')
.inputValue();
await request.get(endpoint);
await page.reload({ waitUntil: 'networkidle' });
// If heartbeat was never sent, there will be no badge
await page.getByTestId('heartbeat-badge').waitFor({ state: 'visible' });
});
});