|
| 1 | +// @ts-check |
| 2 | +import { test, expect } from '@playwright/test'; |
| 3 | +import crypto from 'node:crypto'; |
| 4 | +import { login_steps, fill_field_condition, open_alert_page_and_filter } from './test-utils.js'; |
| 5 | + |
| 6 | +test('remove event definition should conflict rule', async ({ page }) => { |
| 7 | + await page.goto('/wizard/AlertRules'); |
| 8 | + |
| 9 | + await login_steps(page); |
| 10 | + |
| 11 | + // Fill Title |
| 12 | + const title = `CONF-${crypto.randomUUID()}`; |
| 13 | + await page.getByRole('link', { name: 'Create' }).click(); |
| 14 | + await page.getByRole('button', { name: 'OR' }).click(); |
| 15 | + await page.locator('#title').fill(title); |
| 16 | + |
| 17 | + // Add 1st Field Condition |
| 18 | + await fill_field_condition(page, 'message', 'matches exactly', 'abc'); |
| 19 | + |
| 20 | + // Fill 1st Search Query |
| 21 | + const searchQuery = 'a?c'; |
| 22 | + await page.locator('#search_query').first().fill(searchQuery); |
| 23 | + await page.waitForTimeout(200); |
| 24 | + |
| 25 | + // Add 2nd Field Condition |
| 26 | + await fill_field_condition(page, 'message', 'matches exactly', 'abc', 1); |
| 27 | + |
| 28 | + // Fill 2nd Search Query |
| 29 | + const searchQuery2 = 'b?d'; |
| 30 | + await page.locator('#search_query').nth(1).fill(searchQuery2); |
| 31 | + await page.waitForTimeout(200); |
| 32 | + |
| 33 | + // Save |
| 34 | + await page.getByRole('button', { name: 'Save' }).click(); |
| 35 | + |
| 36 | + // Delete EventDefinition |
| 37 | + await page.goto('/alerts/definitions'); |
| 38 | + await page.getByPlaceholder('Search for event definitions').fill(title); |
| 39 | + await page.waitForTimeout(500); |
| 40 | + await page.getByLabel("More actions").first().click(); |
| 41 | + await page.getByRole('menuitem', { name: 'Delete' }).click(); |
| 42 | + await page.getByLabel('Confirm').click(); |
| 43 | + await page.waitForTimeout(200); |
| 44 | + |
| 45 | + // Check if rule is corrupted |
| 46 | + await open_alert_page_and_filter(page, title); |
| 47 | + |
| 48 | + await expect(page.getByText('Corrupted')).toBeVisible(); |
| 49 | +}); |
0 commit comments