test: clone alert (#4931)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced alert creation and cloning functionality with improved
validation checks.
- Added support for comprehensive search capabilities in the alert list.
- Introduced functionality to verify user interactions with search
history.

- **Bug Fixes**
	- Improved error handling and user feedback during alert cloning.
	- Enhanced validation for required fields in alert creation.

- **Tests**
- New test cases added for alert management and search history
functionalities.
- Updated existing tests to ensure better coverage and error handling,
including the addition of new scenarios for invalid inputs.

- **Chores**
- Cleaned up the test suite by removing unused code and improving
structure.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Sai Nikhil <nikhil@openobserve.ai>
This commit is contained in:
Neha P 2024-10-30 17:53:27 +05:30 committed by GitHub
parent 51e32f4b35
commit 5306ad899f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 45 additions and 36 deletions

View File

@ -169,27 +169,7 @@ test.describe("Alerts testcases", () => {
await expect(page.locator(".q-notification__message").getByText(/Please fill required fields/).first()).toBeVisible(); await expect(page.locator(".q-notification__message").getByText(/Please fill required fields/).first()).toBeVisible();
}); });
// test("should saved template successfully", async ({ page }) => {
// await page.waitForTimeout(2000);
// await page.locator('[data-test="alert-templates-tab"]').click({ force: true });
// await page.waitForTimeout(1000);
// await page.locator(
// '[data-test="alert-template-list-add-alert-btn"]').click({
// force: true });
// await page.waitForTimeout(100);
// await page.locator(
// '[data-test="add-template-name-input"]').fill("automationalert");
// const jsonString = '{"text": "{alert_name} is active"}';
// await page.click(".view-line")
// await page.keyboard.type(jsonString);
// await page.locator(
// '[data-test="add-template-submit-btn"]').click({ force: true });await expect(page.locator(
// ".q-notification__message").getByText(/Template Saved Successfully/).first()).toBeVisible();
// await page.waitForTimeout(1000);
// // await page.locator('[data-test="alert-template-list-automationalert-delete-template"]').click({ force: true });
// // await page.waitForTimeout(100);
// // await page.locator('[data-test="confirm-button"]').click();
// });
test("should display error when valid JSON not entered under template body", async ({ page }) => { test("should display error when valid JSON not entered under template body", async ({ page }) => {
@ -239,6 +219,4 @@ test.describe("Alerts testcases", () => {
".q-notification__message").getByText(/Please fill required fields/).first()).toBeVisible(); ".q-notification__message").getByText(/Please fill required fields/).first()).toBeVisible();
}) })
}); });

View File

@ -423,7 +423,7 @@ test.describe("Sanity testcases", () => {
await page.waitForTimeout(100); await page.waitForTimeout(100);
await page await page
.locator('[data-test="add-template-name-input"]') .locator('[data-test="add-template-name-input"]')
.fill("sanitytemplates"); .fill("sanitytemp1");
const jsonString = '{"text": "{alert_name} is active"}'; const jsonString = '{"text": "{alert_name} is active"}';
await page.click(".view-line"); await page.click(".view-line");
await page.keyboard.type(jsonString); await page.keyboard.type(jsonString);
@ -434,6 +434,7 @@ test.describe("Sanity testcases", () => {
await expect( await expect(
page page
.locator(".q-notification__message") .locator(".q-notification__message")
.getByText(/Template Saved Successfully/) .getByText(/Template Saved Successfully/)
.first() .first()
).toBeVisible(); ).toBeVisible();
@ -448,9 +449,9 @@ test.describe("Sanity testcases", () => {
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
await page await page
.locator('[data-test="add-destination-name-input"]') .locator('[data-test="add-destination-name-input"]')
.fill("sanitydestinations"); .fill("sanitydest1");
await page.locator('[data-test="add-destination-template-select"]').click(); await page.locator('[data-test="add-destination-template-select"]').click();
await page.getByText("sanitytemplate").click(); await page.getByText("sanitytemp1").click();
await page.locator('[data-test="add-destination-url-input"]').click(); await page.locator('[data-test="add-destination-url-input"]').click();
await page await page
.locator('[data-test="add-destination-url-input"]') .locator('[data-test="add-destination-url-input"]')
@ -469,7 +470,7 @@ test.describe("Sanity testcases", () => {
await page await page
.locator('[data-test="add-alert-name-input"]') .locator('[data-test="add-alert-name-input"]')
.getByLabel("Name *") .getByLabel("Name *")
.fill("sanityalerts"); .fill("sanityalert1");
await page await page
.locator('[data-test="add-alert-stream-type-select"]') .locator('[data-test="add-alert-stream-type-select"]')
.getByText("arrow_drop_down") .getByText("arrow_drop_down")
@ -491,17 +492,43 @@ test.describe("Sanity testcases", () => {
.click(); .click();
await page await page
.locator( .locator(
'[data-test="add-alert-destination-sanitydestinations-select-item"]' '[data-test="add-alert-destination-sanitydest1-select-item"]'
) )
.click(); .click();
await page.locator('[data-test="add-alert-submit-btn"]').click(); await page.locator('[data-test="add-alert-submit-btn"]').click();
// Clone the alert
await page.locator('[data-test="alert-clone"]').click(); // Ensure this selector is correct
await page.getByLabel('Alert Name').click();
await page.getByLabel('Alert Name').fill('test-clone');
await page.locator('[data-test="to-be-clone-alert-name"]').click()
await page.locator('[data-test="to-be-clone-alert-name"]').fill('test-clone');
await page.locator('[data-test="to-be-clone-stream-type"]').click();
await page.getByRole('option', { name: 'logs' }).locator('div').nth(2).click();
await page.locator('[data-test="to-be-clone-stream-name"]').click();
await page.locator('[data-test="to-be-clone-stream-name"]').fill('e2e_automate');
await page.waitForTimeout(2000);
await page.getByRole('option', { name: 'e2e_automate' }).click({force:true});
await page.waitForTimeout(2000);
await page.locator('[data-test="clone-alert-submit-btn"]').click();
await page.getByText('Alert Cloned Successfully').click();
// Delete the cloned alert
await page.getByRole('cell', { name: 'test-clone' }).click();
await page.locator('[data-test="alert-list-test-clone-delete-alert"]').click(); // Adjust the selector if necessary
await page.locator('[data-test="confirm-button"]').click();
// Delete the original alert
await page.locator('[data-test="alert-list-search-input"]').click(); await page.locator('[data-test="alert-list-search-input"]').click();
await page.locator('[data-test="alert-list-search-input"]').fill("sani"); await page.locator('[data-test="alert-list-search-input"]').fill("sani");
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
await page await page
.locator('[data-test="alert-list-sanityalerts-delete-alert"]') .locator('[data-test="alert-list-sanityalert1-delete-alert"]')
.click(); .click();
await page.locator('[data-test="confirm-button"]').click(); await page.locator('[data-test="confirm-button"]').click();
await page.waitForTimeout(2000);
await page.locator('[data-test="alert-destinations-tab"]').click(); await page.locator('[data-test="alert-destinations-tab"]').click();
await page.locator('[data-test="destination-list-search-input"]').click(); await page.locator('[data-test="destination-list-search-input"]').click();
await page await page
@ -510,7 +537,7 @@ test.describe("Sanity testcases", () => {
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
await page await page
.locator( .locator(
'[data-test="alert-destination-list-sanitydestinations-delete-destination"]' '[data-test="alert-destination-list-sanitydest1-delete-destination"]'
) )
.click(); .click();
await page.locator('[data-test="confirm-button"]').click(); await page.locator('[data-test="confirm-button"]').click();
@ -522,7 +549,7 @@ test.describe("Sanity testcases", () => {
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
await page await page
.locator( .locator(
'[data-test="alert-template-list-sanitytemplates-delete-template"]' '[data-test="alert-template-list-sanitytemp1-delete-template"]'
) )
.click(); .click();
await page.locator('[data-test="confirm-button"]').click(); await page.locator('[data-test="confirm-button"]').click();
@ -965,6 +992,8 @@ test.describe("Sanity testcases", () => {
// Use a more specific locator for 'e2e_automate' by targeting its unique container or parent element // Use a more specific locator for 'e2e_automate' by targeting its unique container or parent element
await page.locator('[data-test="logs-search-index-list"]').getByText('e2e_automate').click(); await page.locator('[data-test="logs-search-index-list"]').getByText('e2e_automate').click();
}); });
});
});

View File

@ -258,14 +258,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div> </div>
<q-card-section> <q-card-section>
<q-form @submit="submitForm"> <q-form @submit="submitForm">
<q-input v-model="toBeCloneAlertName" label="Alert Name" /> <q-input data-test="to-be-clone-alert-name" v-model="toBeCloneAlertName" label="Alert Name" />
<q-select <q-select
data-test="to-be-clone-stream-type"
v-model="toBeClonestreamType" v-model="toBeClonestreamType"
label="Stream Type" label="Stream Type"
:options="streamTypes" :options="streamTypes"
@update:model-value="updateStreams()" @update:model-value="updateStreams()"
/> />
<q-select <q-select
data-test="to-be-clone-stream-name"
v-model="toBeClonestreamName" v-model="toBeClonestreamName"
:loading="isFetchingStreams" :loading="isFetchingStreams"
:disable="!toBeClonestreamType" :disable="!toBeClonestreamType"
@ -280,7 +282,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/> />
<div class="flex justify-center q-mt-lg"> <div class="flex justify-center q-mt-lg">
<q-btn <q-btn
data-test="add-alert-cancel-btn" data-test="clone-alert-cancel-btn"
v-close-popup="true" v-close-popup="true"
class="q-mb-md text-bold" class="q-mb-md text-bold"
:label="t('alerts.cancel')" :label="t('alerts.cancel')"
@ -289,7 +291,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
no-caps no-caps
/> />
<q-btn <q-btn
data-test="add-alert-submit-btn" data-test="clone-alert-submit-btn"
:label="t('alerts.save')" :label="t('alerts.save')"
class="q-mb-md text-bold no-border q-ml-md" class="q-mb-md text-bold no-border q-ml-md"
color="secondary" color="secondary"