-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5486 from grafana/dev
v1.15.1
- Loading branch information
Showing
9 changed files
with
415 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { test, expect } from '../fixtures'; | ||
import grafanaApiClient from '../utils/clients/grafana'; | ||
import { clickButton, generateRandomValue } from '../utils/forms'; | ||
import { goToOnCallPage } from '../utils/navigation'; | ||
import { checkWebhookPresenceInTable } from '../utils/outgoingWebhooks'; | ||
|
||
const WEBHOOK_NAME = generateRandomValue(); | ||
const TRIGGER_TYPE = 'Personal Notification'; | ||
|
||
let webhookID: string; | ||
|
||
test.afterAll(async ({ request }) => { | ||
// Delete the created webhook | ||
if (webhookID) { | ||
await grafanaApiClient.makeRequest( | ||
request, | ||
`resources/webhooks/${webhookID}/`, | ||
'delete', | ||
) | ||
} | ||
}); | ||
|
||
test('Connects a personal notification webhook', async ({ adminRolePage: { page } }) => { | ||
// Create a new webhook | ||
await goToOnCallPage(page, 'outgoing_webhooks'); | ||
await page.getByRole('button', { name: 'New Outgoing Webhook' }).click(); | ||
|
||
// Choose Advanced webhook | ||
await page.getByTestId('create-outgoing-webhook-modal').locator('div').filter({ hasText: 'AdvancedAn advanced webhook' }).first().click(); | ||
|
||
// Give it a name | ||
await page.locator('input[name="name"]').fill(WEBHOOK_NAME); | ||
|
||
// Choose a trigger type | ||
await page.getByTestId('triggerType-selector').locator('div').nth(1).click(); | ||
await page.getByLabel('Select options menu').getByText(TRIGGER_TYPE).click(); | ||
|
||
// Set a URL | ||
await page.locator('#OutgoingWebhook div').locator('.monaco-editor').first().click(); | ||
await page.keyboard.insertText('https://example.com'); | ||
|
||
// Create and check it has been created | ||
const responsePromise = page.waitForResponse('**/resources/webhooks/'); | ||
await clickButton({ page, buttonText: 'Create' }); | ||
await checkWebhookPresenceInTable({ page, webhookName: WEBHOOK_NAME, expectedTriggerType: TRIGGER_TYPE }); | ||
|
||
// save the ID so we can delete the webhook after the tests have run | ||
const response = await responsePromise; | ||
const wh = await response.json(); | ||
webhookID = wh?.id; | ||
|
||
await goToOnCallPage(page, 'users/me'); | ||
await page.getByRole('tab', { name: 'Webhook connection' }).click(); | ||
|
||
// Select webhook | ||
await page.getByRole('dialog').locator('svg').nth(2).click(); | ||
await page.getByLabel('Select options menu').getByText(WEBHOOK_NAME).click(); | ||
|
||
// Add some context | ||
await page.getByRole('textbox').fill('{ "test": true }'); | ||
|
||
// Connect | ||
await page.getByRole('button', { name: 'Connect' }).click(); | ||
|
||
// Check connection on User Info tab | ||
await page.getByRole('tab', { name: 'User info' }).click(); | ||
expect(page.getByText(WEBHOOK_NAME)).toBeVisible(); | ||
|
||
// Disconnect | ||
await page.getByRole('tab', { name: 'Webhook connection' }).click(); | ||
await page.getByRole('button', { name: 'Disconnect' }).click(); | ||
await page.getByTestId('data-testid Confirm Modal Danger Button').click(); | ||
|
||
// Check connection is no longer shown | ||
await page.getByRole('tab', { name: 'User info' }).click(); | ||
expect(page.getByText(WEBHOOK_NAME)).not.toBeVisible(); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.