Files
openobserve/tests/ui-testing/playwright-tests/utils/dashCreation.js
T
73b49ea686 test: dashboard filter testcases (#6284)
Co-authored-by: ktx-kirtan <124270523+ktx-kirtan@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: Kirtan Thakkar <kirtan@kiara.tech>
2025-03-17 15:13:49 +05:30

49 lines
1.7 KiB
JavaScript

import { expect } from "playwright/test";
import logData from "../../cypress/fixtures/log.json"
// fuction of Dashboard page and Apply query button
export const waitForDashboardPage = async function (page) {
const dashboardListApi = page.waitForResponse(
(response) =>
/\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200
);
await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**");
await page.waitForSelector(`text="Please wait while loading dashboards..."`, {
state: "hidden",
});
await dashboardListApi;
await page.waitForTimeout(500);
};
export const applyQueryButton = async function (page) {
const search = page.waitForResponse(logData.applyQuery);
await page.waitForTimeout(3000);
await page.locator("[data-test='logs-search-bar-refresh-btn']").click({
force: true,
});
await expect.poll(async () => (await search).status()).toBe(200);
};
export async function deleteDashboard(page, dashboardName) {
console.log(`Deleting dashboard with name: ${dashboardName}`);
// const dashboardRow = page.locator(`//tr[.//td[text()="${dashboardName}"]]`);
// await expect(dashboardRow).toBeVisible(); // Ensure the row is visible
const dashboardRow = page
.locator('//tr[.//td[text()="' + dashboardName + '"]]')
.nth(0);
const deleteButton = dashboardRow.locator('[data-test="dashboard-delete"]');
await deleteButton.click();
// Wait for the confirmation popup and confirm deletion
const confirmButton = page.locator('[data-test="confirm-button"]');
await expect(confirmButton).toBeVisible();
await confirmButton.click();
// Ensure the dashboard is removed
await expect(page.getByText("Dashboard deleted successfully")).toBeVisible();
}