2023-12-15 09:58:25 +01:00
|
|
|
import { Page, expect } from '@playwright/test';
|
2023-11-17 11:07:12 +01:00
|
|
|
|
2023-11-10 11:54:22 -05:00
|
|
|
import { clickButton, generateRandomValue, selectDropdownValue } from './forms';
|
2023-03-10 06:45:15 +01:00
|
|
|
import { goToOnCallPage } from './navigation';
|
first UI integration test - phone verification + receive SMS alert flow (#900)
**What this PR does**:
Adds our first UI integration test using
[Playwright](https://playwright.dev/) and runs the test on CI. Right now
the test:
- logs into Grafana
- configures the plugin (if it isn't already)
- creates an OnCall schedule, where the current user will be OnCall
- creates an escalation chain to notify based on the newly created
OnCall schedule
- creates a webhook integration, attached to the created escalation
chain
- sends a demo alert for the new integration
- goes to the alert groups page and validates that the escalation step
to alert the OnCall user actually happened
Currently the Playwright tests are run against the 3 default headless
browsers, chromium, Firefox, and webkit. The CI job that runs these
tests is run as a matrix against 3 tagged versions of `grafana`; `main`,
`latest`, and `9.2.6`.
Secondly, it adds most of the logic for a second test which:
- logs into Grafana
- configures the plugin (if it isn't already)
- goes to the user's settings, verifies their phone number (using a tool
called [MailSlurp](https://www.mailslurp.com/))
- configures the current user's default escalation policy to send alerts
via SMS
- creates an escalation policy and configures it to send alerts to our
current user
- creates an integration and assigns the created escalation policy
- triggers a test alert + verifies that we receive the SMS alert text
(again, using MailSlurp)
**Which issue(s) this PR fixes**:
Closes #873
**Checklist**
- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-03-06 17:28:52 +01:00
|
|
|
|
2023-03-21 09:25:54 +01:00
|
|
|
export const openCreateIntegrationModal = async (page: Page): Promise<void> => {
|
first UI integration test - phone verification + receive SMS alert flow (#900)
**What this PR does**:
Adds our first UI integration test using
[Playwright](https://playwright.dev/) and runs the test on CI. Right now
the test:
- logs into Grafana
- configures the plugin (if it isn't already)
- creates an OnCall schedule, where the current user will be OnCall
- creates an escalation chain to notify based on the newly created
OnCall schedule
- creates a webhook integration, attached to the created escalation
chain
- sends a demo alert for the new integration
- goes to the alert groups page and validates that the escalation step
to alert the OnCall user actually happened
Currently the Playwright tests are run against the 3 default headless
browsers, chromium, Firefox, and webkit. The CI job that runs these
tests is run as a matrix against 3 tagged versions of `grafana`; `main`,
`latest`, and `9.2.6`.
Secondly, it adds most of the logic for a second test which:
- logs into Grafana
- configures the plugin (if it isn't already)
- goes to the user's settings, verifies their phone number (using a tool
called [MailSlurp](https://www.mailslurp.com/))
- configures the current user's default escalation policy to send alerts
via SMS
- creates an escalation policy and configures it to send alerts to our
current user
- creates an integration and assigns the created escalation policy
- triggers a test alert + verifies that we receive the SMS alert text
(again, using MailSlurp)
**Which issue(s) this PR fixes**:
Closes #873
**Checklist**
- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-03-06 17:28:52 +01:00
|
|
|
// open the create integration modal
|
2023-11-10 11:54:22 -05:00
|
|
|
await page.getByRole('button', { name: 'New integration' }).click();
|
first UI integration test - phone verification + receive SMS alert flow (#900)
**What this PR does**:
Adds our first UI integration test using
[Playwright](https://playwright.dev/) and runs the test on CI. Right now
the test:
- logs into Grafana
- configures the plugin (if it isn't already)
- creates an OnCall schedule, where the current user will be OnCall
- creates an escalation chain to notify based on the newly created
OnCall schedule
- creates a webhook integration, attached to the created escalation
chain
- sends a demo alert for the new integration
- goes to the alert groups page and validates that the escalation step
to alert the OnCall user actually happened
Currently the Playwright tests are run against the 3 default headless
browsers, chromium, Firefox, and webkit. The CI job that runs these
tests is run as a matrix against 3 tagged versions of `grafana`; `main`,
`latest`, and `9.2.6`.
Secondly, it adds most of the logic for a second test which:
- logs into Grafana
- configures the plugin (if it isn't already)
- goes to the user's settings, verifies their phone number (using a tool
called [MailSlurp](https://www.mailslurp.com/))
- configures the current user's default escalation policy to send alerts
via SMS
- creates an escalation policy and configures it to send alerts to our
current user
- creates an integration and assigns the created escalation policy
- triggers a test alert + verifies that we receive the SMS alert text
(again, using MailSlurp)
**Which issue(s) this PR fixes**:
Closes #873
**Checklist**
- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-03-06 17:28:52 +01:00
|
|
|
|
2023-03-21 09:25:54 +01:00
|
|
|
// wait for it to pop up
|
2023-11-10 11:54:22 -05:00
|
|
|
await page.getByTestId('create-integration-modal').waitFor();
|
2023-03-21 09:25:54 +01:00
|
|
|
};
|
|
|
|
|
|
2023-11-10 11:54:22 -05:00
|
|
|
export const createIntegration = async ({
|
|
|
|
|
page,
|
|
|
|
|
integrationName = `integration-${generateRandomValue()}`,
|
|
|
|
|
integrationSearchText = 'Webhook',
|
|
|
|
|
shouldGoToIntegrationsPage = true,
|
|
|
|
|
}: {
|
|
|
|
|
page: Page;
|
|
|
|
|
integrationName?: string;
|
|
|
|
|
integrationSearchText?: string;
|
|
|
|
|
shouldGoToIntegrationsPage?: boolean;
|
|
|
|
|
}): Promise<void> => {
|
|
|
|
|
if (shouldGoToIntegrationsPage) {
|
|
|
|
|
// go to the integrations page
|
|
|
|
|
await goToOnCallPage(page, 'integrations');
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 09:25:54 +01:00
|
|
|
await openCreateIntegrationModal(page);
|
|
|
|
|
|
2023-11-10 11:54:22 -05:00
|
|
|
// create an integration
|
|
|
|
|
await page
|
|
|
|
|
.getByTestId('create-integration-modal')
|
|
|
|
|
.getByTestId('integration-display-name')
|
|
|
|
|
.filter({ hasText: integrationSearchText })
|
|
|
|
|
.first()
|
|
|
|
|
.click();
|
first UI integration test - phone verification + receive SMS alert flow (#900)
**What this PR does**:
Adds our first UI integration test using
[Playwright](https://playwright.dev/) and runs the test on CI. Right now
the test:
- logs into Grafana
- configures the plugin (if it isn't already)
- creates an OnCall schedule, where the current user will be OnCall
- creates an escalation chain to notify based on the newly created
OnCall schedule
- creates a webhook integration, attached to the created escalation
chain
- sends a demo alert for the new integration
- goes to the alert groups page and validates that the escalation step
to alert the OnCall user actually happened
Currently the Playwright tests are run against the 3 default headless
browsers, chromium, Firefox, and webkit. The CI job that runs these
tests is run as a matrix against 3 tagged versions of `grafana`; `main`,
`latest`, and `9.2.6`.
Secondly, it adds most of the logic for a second test which:
- logs into Grafana
- configures the plugin (if it isn't already)
- goes to the user's settings, verifies their phone number (using a tool
called [MailSlurp](https://www.mailslurp.com/))
- configures the current user's default escalation policy to send alerts
via SMS
- creates an escalation policy and configures it to send alerts to our
current user
- creates an integration and assigns the created escalation policy
- triggers a test alert + verifies that we receive the SMS alert text
(again, using MailSlurp)
**Which issue(s) this PR fixes**:
Closes #873
**Checklist**
- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-03-06 17:28:52 +01:00
|
|
|
|
2023-06-23 11:50:18 +03:00
|
|
|
// fill in the required inputs
|
2023-12-15 09:58:25 +01:00
|
|
|
await page.getByPlaceholder('Integration Name').fill(integrationName);
|
|
|
|
|
await page.getByPlaceholder('Integration Description').fill('Here goes your integration description');
|
|
|
|
|
await page.getByTestId('update-integration-button').focus();
|
|
|
|
|
await page.getByTestId('update-integration-button').click();
|
first UI integration test - phone verification + receive SMS alert flow (#900)
**What this PR does**:
Adds our first UI integration test using
[Playwright](https://playwright.dev/) and runs the test on CI. Right now
the test:
- logs into Grafana
- configures the plugin (if it isn't already)
- creates an OnCall schedule, where the current user will be OnCall
- creates an escalation chain to notify based on the newly created
OnCall schedule
- creates a webhook integration, attached to the created escalation
chain
- sends a demo alert for the new integration
- goes to the alert groups page and validates that the escalation step
to alert the OnCall user actually happened
Currently the Playwright tests are run against the 3 default headless
browsers, chromium, Firefox, and webkit. The CI job that runs these
tests is run as a matrix against 3 tagged versions of `grafana`; `main`,
`latest`, and `9.2.6`.
Secondly, it adds most of the logic for a second test which:
- logs into Grafana
- configures the plugin (if it isn't already)
- goes to the user's settings, verifies their phone number (using a tool
called [MailSlurp](https://www.mailslurp.com/))
- configures the current user's default escalation policy to send alerts
via SMS
- creates an escalation policy and configures it to send alerts to our
current user
- creates an integration and assigns the created escalation policy
- triggers a test alert + verifies that we receive the SMS alert text
(again, using MailSlurp)
**Which issue(s) this PR fixes**:
Closes #873
**Checklist**
- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-03-06 17:28:52 +01:00
|
|
|
|
2023-12-15 09:58:25 +01:00
|
|
|
await goToOnCallPage(page, 'integrations');
|
|
|
|
|
await searchIntegrationAndAssertItsPresence({ page, integrationName });
|
|
|
|
|
|
|
|
|
|
await page.getByRole('link', { name: integrationName }).click();
|
2023-07-12 22:41:44 +02:00
|
|
|
};
|
first UI integration test - phone verification + receive SMS alert flow (#900)
**What this PR does**:
Adds our first UI integration test using
[Playwright](https://playwright.dev/) and runs the test on CI. Right now
the test:
- logs into Grafana
- configures the plugin (if it isn't already)
- creates an OnCall schedule, where the current user will be OnCall
- creates an escalation chain to notify based on the newly created
OnCall schedule
- creates a webhook integration, attached to the created escalation
chain
- sends a demo alert for the new integration
- goes to the alert groups page and validates that the escalation step
to alert the OnCall user actually happened
Currently the Playwright tests are run against the 3 default headless
browsers, chromium, Firefox, and webkit. The CI job that runs these
tests is run as a matrix against 3 tagged versions of `grafana`; `main`,
`latest`, and `9.2.6`.
Secondly, it adds most of the logic for a second test which:
- logs into Grafana
- configures the plugin (if it isn't already)
- goes to the user's settings, verifies their phone number (using a tool
called [MailSlurp](https://www.mailslurp.com/))
- configures the current user's default escalation policy to send alerts
via SMS
- creates an escalation policy and configures it to send alerts to our
current user
- creates an integration and assigns the created escalation policy
- triggers a test alert + verifies that we receive the SMS alert text
(again, using MailSlurp)
**Which issue(s) this PR fixes**:
Closes #873
**Checklist**
- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-03-06 17:28:52 +01:00
|
|
|
|
2023-07-12 22:41:44 +02:00
|
|
|
export const assignEscalationChainToIntegration = async (page: Page, escalationChainName: string): Promise<void> => {
|
2023-12-15 09:58:25 +01:00
|
|
|
const notSelected = page.getByTestId('integration-escalation-chain-not-selected');
|
|
|
|
|
if (await notSelected.isHidden()) {
|
|
|
|
|
await clickButton({ page, buttonText: 'Add route' });
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
}
|
|
|
|
|
await notSelected.last().click();
|
first UI integration test - phone verification + receive SMS alert flow (#900)
**What this PR does**:
Adds our first UI integration test using
[Playwright](https://playwright.dev/) and runs the test on CI. Right now
the test:
- logs into Grafana
- configures the plugin (if it isn't already)
- creates an OnCall schedule, where the current user will be OnCall
- creates an escalation chain to notify based on the newly created
OnCall schedule
- creates a webhook integration, attached to the created escalation
chain
- sends a demo alert for the new integration
- goes to the alert groups page and validates that the escalation step
to alert the OnCall user actually happened
Currently the Playwright tests are run against the 3 default headless
browsers, chromium, Firefox, and webkit. The CI job that runs these
tests is run as a matrix against 3 tagged versions of `grafana`; `main`,
`latest`, and `9.2.6`.
Secondly, it adds most of the logic for a second test which:
- logs into Grafana
- configures the plugin (if it isn't already)
- goes to the user's settings, verifies their phone number (using a tool
called [MailSlurp](https://www.mailslurp.com/))
- configures the current user's default escalation policy to send alerts
via SMS
- creates an escalation policy and configures it to send alerts to our
current user
- creates an integration and assigns the created escalation policy
- triggers a test alert + verifies that we receive the SMS alert text
(again, using MailSlurp)
**Which issue(s) this PR fixes**:
Closes #873
**Checklist**
- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-03-06 17:28:52 +01:00
|
|
|
|
2023-07-12 22:41:44 +02:00
|
|
|
// assign the escalation chain to the integration
|
|
|
|
|
await selectDropdownValue({
|
|
|
|
|
page,
|
|
|
|
|
selectType: 'grafanaSelect',
|
|
|
|
|
placeholderText: 'Select Escalation Chain',
|
|
|
|
|
value: escalationChainName,
|
2023-12-15 09:58:25 +01:00
|
|
|
startingLocator: page.getByTestId('escalation-chain-select').last(),
|
2023-07-12 22:41:44 +02:00
|
|
|
});
|
|
|
|
|
};
|
first UI integration test - phone verification + receive SMS alert flow (#900)
**What this PR does**:
Adds our first UI integration test using
[Playwright](https://playwright.dev/) and runs the test on CI. Right now
the test:
- logs into Grafana
- configures the plugin (if it isn't already)
- creates an OnCall schedule, where the current user will be OnCall
- creates an escalation chain to notify based on the newly created
OnCall schedule
- creates a webhook integration, attached to the created escalation
chain
- sends a demo alert for the new integration
- goes to the alert groups page and validates that the escalation step
to alert the OnCall user actually happened
Currently the Playwright tests are run against the 3 default headless
browsers, chromium, Firefox, and webkit. The CI job that runs these
tests is run as a matrix against 3 tagged versions of `grafana`; `main`,
`latest`, and `9.2.6`.
Secondly, it adds most of the logic for a second test which:
- logs into Grafana
- configures the plugin (if it isn't already)
- goes to the user's settings, verifies their phone number (using a tool
called [MailSlurp](https://www.mailslurp.com/))
- configures the current user's default escalation policy to send alerts
via SMS
- creates an escalation policy and configures it to send alerts to our
current user
- creates an integration and assigns the created escalation policy
- triggers a test alert + verifies that we receive the SMS alert text
(again, using MailSlurp)
**Which issue(s) this PR fixes**:
Closes #873
**Checklist**
- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-03-06 17:28:52 +01:00
|
|
|
|
2023-07-12 22:41:44 +02:00
|
|
|
export const sendDemoAlert = async (page: Page): Promise<void> => {
|
2023-11-17 11:07:12 +01:00
|
|
|
await clickButton({ page, buttonText: 'Send demo alert' });
|
|
|
|
|
await clickButton({ page, buttonText: 'Send Alert' });
|
2023-07-12 22:41:44 +02:00
|
|
|
await page.getByTestId('demo-alert-sent-notification').waitFor({ state: 'visible' });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createIntegrationAndSendDemoAlert = async (
|
|
|
|
|
page: Page,
|
|
|
|
|
integrationName: string,
|
|
|
|
|
escalationChainName: string
|
|
|
|
|
): Promise<void> => {
|
2023-11-10 11:54:22 -05:00
|
|
|
await createIntegration({ page, integrationName });
|
2023-07-12 22:41:44 +02:00
|
|
|
await assignEscalationChainToIntegration(page, escalationChainName);
|
|
|
|
|
await sendDemoAlert(page);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const filterIntegrationsTableAndGoToDetailPage = async (page: Page, integrationName: string): Promise<void> => {
|
|
|
|
|
// filter the integrations page by the integration in question, then go to its detail page
|
|
|
|
|
await selectDropdownValue({
|
|
|
|
|
page,
|
|
|
|
|
selectType: 'grafanaSelect',
|
|
|
|
|
placeholderText: 'Search or filter results...',
|
|
|
|
|
value: integrationName,
|
|
|
|
|
pressEnterInsteadOfSelectingOption: true,
|
|
|
|
|
});
|
|
|
|
|
|
2023-11-17 11:07:12 +01:00
|
|
|
await page.getByTestId('integrations-table').getByText(`${integrationName}`).click();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const searchIntegrationAndAssertItsPresence = async ({
|
|
|
|
|
page,
|
|
|
|
|
integrationName,
|
|
|
|
|
visibleExpected = true,
|
|
|
|
|
}: {
|
|
|
|
|
page: Page;
|
|
|
|
|
integrationName: string;
|
|
|
|
|
visibleExpected?: boolean;
|
|
|
|
|
}) => {
|
|
|
|
|
await page
|
|
|
|
|
.locator('div')
|
|
|
|
|
.filter({ hasText: /^Search or filter results\.\.\.$/ })
|
|
|
|
|
.nth(1)
|
|
|
|
|
.click();
|
2023-12-15 09:58:25 +01:00
|
|
|
const integrationsTable = page.getByTestId('integrations-table');
|
2023-11-17 11:07:12 +01:00
|
|
|
await page.keyboard.insertText(integrationName);
|
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
|
await page.waitForTimeout(2000);
|
|
|
|
|
const nbOfResults = await integrationsTable.getByText(integrationName).count();
|
|
|
|
|
if (visibleExpected) {
|
|
|
|
|
expect(nbOfResults).toBeGreaterThanOrEqual(1);
|
|
|
|
|
} else {
|
|
|
|
|
expect(nbOfResults).toBe(0);
|
|
|
|
|
}
|
first UI integration test - phone verification + receive SMS alert flow (#900)
**What this PR does**:
Adds our first UI integration test using
[Playwright](https://playwright.dev/) and runs the test on CI. Right now
the test:
- logs into Grafana
- configures the plugin (if it isn't already)
- creates an OnCall schedule, where the current user will be OnCall
- creates an escalation chain to notify based on the newly created
OnCall schedule
- creates a webhook integration, attached to the created escalation
chain
- sends a demo alert for the new integration
- goes to the alert groups page and validates that the escalation step
to alert the OnCall user actually happened
Currently the Playwright tests are run against the 3 default headless
browsers, chromium, Firefox, and webkit. The CI job that runs these
tests is run as a matrix against 3 tagged versions of `grafana`; `main`,
`latest`, and `9.2.6`.
Secondly, it adds most of the logic for a second test which:
- logs into Grafana
- configures the plugin (if it isn't already)
- goes to the user's settings, verifies their phone number (using a tool
called [MailSlurp](https://www.mailslurp.com/))
- configures the current user's default escalation policy to send alerts
via SMS
- creates an escalation policy and configures it to send alerts to our
current user
- creates an integration and assigns the created escalation policy
- triggers a test alert + verifies that we receive the SMS alert text
(again, using MailSlurp)
**Which issue(s) this PR fixes**:
Closes #873
**Checklist**
- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-03-06 17:28:52 +01:00
|
|
|
};
|