diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 7a9915e78e..fd0552bbf4 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -115,6 +115,7 @@ jobs: "changeOrg.spec.js", "serviceAccount.spec.js", "enrichment.spec.js", + "sanity2.spec.js" # "remotepipeline.spec.js", ] diff --git a/tests/api-testing/tests/test_fuzzy.py b/tests/api-testing/tests/test_fuzzy.py index f2066a5eb5..99af09a569 100644 --- a/tests/api-testing/tests/test_fuzzy.py +++ b/tests/api-testing/tests/test_fuzzy.py @@ -1,9 +1,9 @@ import json import requests import pytest +import time from datetime import datetime, timezone, timedelta - def get_dynamic_timestamps(): """Generate dynamic timestamps for the query.""" now = datetime.now(timezone.utc) @@ -11,16 +11,20 @@ def get_dynamic_timestamps(): one_min_ago = int((now - timedelta(minutes=1)).timestamp() * 1000000) return one_min_ago, end_time - -def post_query(session, base_url, org_id, query): - """Helper function to post SQL query and return the response.""" +def post_query(session, base_url, org_id, query, retries=3, delay=2): + """Helper function to post SQL query with retries and return the response.""" url = f"{base_url}api/{org_id}/_search?type=logs" - response = session.post(url, json={"query": query}) - assert ( - response.status_code == 200 - ), f"Expected 200 but got {response.status_code}. Response: {response.content}" - return response.json() - + for attempt in range(retries): + response = session.post(url, json={"query": query}) + if response.status_code == 200: + response_data = response.json() + if "hits" in response_data and len(response_data["hits"]) > 0: + return response_data + print(f"Attempt {attempt+1}: No logs found, retrying...") + else: + print(f"Attempt {attempt+1}: Received status {response.status_code}, Response: {response.content}") + time.sleep(delay) + return response.json() # Return last response even if unsuccessful @pytest.mark.parametrize( "sql_query", @@ -32,7 +36,7 @@ def post_query(session, base_url, org_id, query): ], ) def test_e2e_fuzzy(create_session, base_url, sql_query): - """Running E2E tests for various SQL queries.""" + """Running E2E tests for various SQL queries with retries.""" session = create_session org_id = "org_pytest_data" one_min_ago, end_time = get_dynamic_timestamps() @@ -49,6 +53,5 @@ def test_e2e_fuzzy(create_session, base_url, sql_query): response_data = post_query(session, base_url, org_id, query) # Additional Assertions on the response data - assert "hits" in response_data, "Response does not contain 'hits'." - assert len(response_data["hits"]) > 0, "No logs found in the response." - \ No newline at end of file + assert "hits" in response_data, f"Response does not contain 'hits'. Full response: {json.dumps(response_data, indent=2)}" + assert len(response_data["hits"]) > 0, f"No logs found in the response. Full response: {json.dumps(response_data, indent=2)}" diff --git a/tests/ui-testing/pages/logsPage.js b/tests/ui-testing/pages/logsPage.js index 43dbeed8d7..df76b5dca2 100644 --- a/tests/ui-testing/pages/logsPage.js +++ b/tests/ui-testing/pages/logsPage.js @@ -438,4 +438,10 @@ export class LogsPage { await expect(this.page.locator('[data-test="logs-search-result-logs-table"]')).toBeVisible(); } + async selectStreamAndStreamTypeForLogs(stream) { + await this.page.locator('[data-test="log-search-index-list-select-stream"]').click(); + await this.page.locator('[data-test="log-search-index-list-select-stream"]').fill(stream); + await this.page.waitForSelector(`[data-test="log-search-index-list-stream-toggle-${stream}"] div`, { state: "visible" }); + await this.page.locator(`[data-test="log-search-index-list-stream-toggle-${stream}"] div`).first().click(); +} } diff --git a/tests/ui-testing/playwright-tests/alerts.spec.js b/tests/ui-testing/playwright-tests/alerts.spec.js index dbc2e2f25e..42a84b1ad6 100644 --- a/tests/ui-testing/playwright-tests/alerts.spec.js +++ b/tests/ui-testing/playwright-tests/alerts.spec.js @@ -2,6 +2,7 @@ import { test, expect } from "./baseFixtures"; import logData from "../../ui-testing/cypress/fixtures/log.json"; import logsdata from "../../test-data/logs_data.json"; const uniqueText = `${new Date().valueOf()}` +import { LogsPage } from '../pages/logsPage.js'; @@ -20,7 +21,9 @@ const functionName = `automate${alphaUuid}`; async function login(page) { await page.goto(process.env["ZO_BASE_URL"]); await page.waitForTimeout(1000); - // await page.getByText('Login as internal user').click(); + if (await page.getByText('Login as internal user').isVisible()) { + await page.getByText('Login as internal user').click(); +} await page .locator('[data-cy="login-user-id"]') .fill(process.env["ZO_ROOT_USER_EMAIL"]); @@ -40,6 +43,7 @@ const selectStreamAndStreamTypeForLogs = async (page, stream) => { "div.q-item").getByText(`${stream}`).first().click({ force: true }); }; test.describe("Alerts testcases", () => { + let logsPage; // let logData; function removeUTFCharacters(text) { // console.log(text, "tex"); @@ -67,6 +71,7 @@ test.describe("Alerts testcases", () => { // }); test.beforeEach(async ({ page }) => { await login(page); + logsPage = new LogsPage(page); await page.waitForTimeout(5000) // ("ingests logs via API", () => { diff --git a/tests/ui-testing/playwright-tests/enrichment.spec.js b/tests/ui-testing/playwright-tests/enrichment.spec.js index 0dc0cad810..5a2b96b78f 100644 --- a/tests/ui-testing/playwright-tests/enrichment.spec.js +++ b/tests/ui-testing/playwright-tests/enrichment.spec.js @@ -3,6 +3,7 @@ import logData from "../../ui-testing/cypress/fixtures/log.json"; // import { log } from "console"; import logsdata from "../../test-data/logs_data.json"; import PipelinePage from "../pages/pipelinePage"; +import { LogsPage } from '../pages/logsPage.js'; // import { pipeline } from "stream"; // import fs from "fs"; import { v4 as uuidv4 } from "uuid"; @@ -14,7 +15,9 @@ const randomFunctionName = `Pipeline${Math.floor(Math.random() * 1000)}`; async function login(page) { await page.goto(process.env["ZO_BASE_URL"]); - // await page.getByText('Login as internal user').click(); + if (await page.getByText('Login as internal user').isVisible()) { + await page.getByText('Login as internal user').click(); +} await page.waitForTimeout(1000); await page .locator('[data-cy="login-user-id"]') @@ -70,6 +73,7 @@ const selectStreamAndStreamTypeForLogs = async (page, stream) => { test.describe("Enrichment data testcases", () => { + let logsPage; // let logData; function removeUTFCharacters(text) { // console.log(text, "tex"); @@ -91,6 +95,7 @@ test.describe("Enrichment data testcases", () => { test.beforeEach(async ({ page }) => { await login(page); + logsPage = new LogsPage(page); await page.waitForTimeout(5000); @@ -111,7 +116,7 @@ test.describe("Enrichment data testcases", () => { `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}` ); const allsearch = page.waitForResponse("**/api/default/_search**"); - await selectStreamAndStreamTypeForLogs(page, logData.Stream); + await logsPage.selectStreamAndStreamTypeForLogs("e2e_automate"); await applyQueryButton(page); }); diff --git a/tests/ui-testing/playwright-tests/logspage.spec.js b/tests/ui-testing/playwright-tests/logspage.spec.js index f7e012f8a6..46463f8844 100644 --- a/tests/ui-testing/playwright-tests/logspage.spec.js +++ b/tests/ui-testing/playwright-tests/logspage.spec.js @@ -1,12 +1,16 @@ import { test, expect } from "./baseFixtures"; import logData from "../../ui-testing/cypress/fixtures/log.json"; import logsdata from "../../test-data/logs_data.json"; +import { LogsPage } from '../pages/logsPage.js'; test.describe.configure({ mode: "parallel" }); async function login(page) { await page.goto(process.env["ZO_BASE_URL"]); -// await page.getByText('Login as internal user').click(); + if (await page.getByText('Login as internal user').isVisible()) { + await page.getByText('Login as internal user').click(); +} + console.log("ZO_BASE_URL", process.env["ZO_BASE_URL"]); await page.waitForTimeout(1000); await page @@ -49,18 +53,8 @@ async function ingestion(page) { console.log(response); } -const selectStreamAndStreamTypeForLogs = async (page, stream) => { - await page.waitForTimeout(4000); - await page - .locator('[data-test="log-search-index-list-select-stream"]') - .click({ force: true }); - await page - .locator("div.q-item") - .getByText(`${stream}`) - .first() - .click({ force: true }); -}; test.describe("Logs UI testcases", () => { + let logsPage; // let logData; function removeUTFCharacters(text) { // console.log(text, "tex"); @@ -88,6 +82,7 @@ test.describe("Logs UI testcases", () => { // }); test.beforeEach(async ({ page }) => { await login(page); + logsPage = new LogsPage(page); await page.waitForTimeout(1000) await ingestion(page); await page.waitForTimeout(2000) @@ -96,7 +91,7 @@ test.describe("Logs UI testcases", () => { `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}` ); const allsearch = page.waitForResponse("**/api/default/_search**"); - await selectStreamAndStreamTypeForLogs(page, logData.Stream); + await logsPage.selectStreamAndStreamTypeForLogs("e2e_automate"); await applyQueryButton(page); // const streams = page.waitForResponse("**/api/default/streams**"); }); diff --git a/tests/ui-testing/playwright-tests/logsqueries.spec.js b/tests/ui-testing/playwright-tests/logsqueries.spec.js index a765f7f0e7..3770dd4b89 100644 --- a/tests/ui-testing/playwright-tests/logsqueries.spec.js +++ b/tests/ui-testing/playwright-tests/logsqueries.spec.js @@ -8,7 +8,10 @@ test.describe.configure({ mode: 'parallel' }); async function login(page) { await page.goto(process.env["ZO_BASE_URL"]); await page.waitForTimeout(4000); - // await page.getByText('Login as internal user').click(); + await page.goto(process.env["ZO_BASE_URL"]); + if (await page.getByText('Login as internal user').isVisible()) { + await page.getByText('Login as internal user').click(); +} await page .locator('[data-cy="login-user-id"]') .fill(process.env["ZO_ROOT_USER_EMAIL"]); @@ -48,13 +51,6 @@ async function ingestion(page) { }); console.log(response); } - -const selectStreamAndStreamTypeForLogs = async (page, stream) => { - await page.waitForTimeout( - 4000); await page.locator( - '[data-test="log-search-index-list-select-stream"]').click({ force: true }); await page.locator( - "div.q-item").getByText(`${stream}`).first().click({ force: true }); -}; test.describe("Logs Queries testcases", () => { let logsPage; // let logData; @@ -78,6 +74,7 @@ test.describe("Logs Queries testcases", () => { test.beforeEach(async ({ page }) => { await login(page); + logsPage = new LogsPage(page); await page.waitForTimeout(1000) await ingestion(page); await page.waitForTimeout(2000) @@ -87,7 +84,7 @@ test.describe("Logs Queries testcases", () => { `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}` ); const allsearch = page.waitForResponse("**/api/default/_search**"); - await selectStreamAndStreamTypeForLogs(page, logData.Stream); + await logsPage.selectStreamAndStreamTypeForLogs("e2e_automate"); await applyQueryButton(page); // const streams = page.waitForResponse("**/api/default/streams**"); }); @@ -126,15 +123,16 @@ test.describe("Logs Queries testcases", () => { }); - - - - test.skip("should redirect to logs after clicking on stream explorer via stream page", async ({ page }) => { + test("should redirect to logs after clicking on stream explorer via stream page", async ({ page }) => { + // Generate a random saved view name + const randomSavedViewName = `streamslog${Math.random().toString(36).substring(2, 10)}`; + + // Interactions with the page await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); await page.locator('[data-test="logs-search-saved-views-btn"]').getByLabel('Expand').click(); await page.locator('button').filter({ hasText: 'savesaved_search' }).click(); await page.locator('[data-test="add-alert-name-input"]').click(); - await page.locator('[data-test="add-alert-name-input"]').fill('streamslognave'); + await page.locator('[data-test="add-alert-name-input"]').fill(randomSavedViewName); // Use the random name await page.locator('[data-test="saved-view-dialog-save-btn"]').click({ force: true }); await page.waitForTimeout(5000); await page.locator('[data-test="menu-link-\\/streams-item"]').click({ force: true }); @@ -142,26 +140,23 @@ test.describe("Logs Queries testcases", () => { await page.getByPlaceholder('Search Stream').fill('e2e'); await page.getByRole('button', { name: 'Explore' }).first().click({ force: true }); await page.waitForTimeout(5000); - await page.waitForSelector('[data-test="logs-search-saved-views-btn"]') + await page.waitForSelector('[data-test="logs-search-saved-views-btn"]'); await page.locator('[data-test="logs-search-saved-views-btn"]').getByLabel('Expand').click(); await page.locator('[data-test="log-search-saved-view-field-search-input"]').click({ force: true }); - await page.locator('[data-test="log-search-saved-view-field-search-input"]').fill('streamslognave'); + await page.locator('[data-test="log-search-saved-view-field-search-input"]').fill(randomSavedViewName); // Use the random name here await page.waitForTimeout(3000); - await page.waitForSelector(':text("streamslognav")'); - await page.click(':text("streamslognave")'); + await page.waitForSelector(`:text("${randomSavedViewName}")`); + await page.click(`:text("${randomSavedViewName}")`); await page.locator('[data-test="logs-search-saved-views-btn"]').getByLabel('Expand').click(); await page.locator('[data-test="log-search-saved-view-field-search-input"]').click(); - await page.getByTitle('streamslognave').click(); - await page.getByText('delete').click(); - await page.locator('[data-test="confirm-button"]').click(); - + await page.getByTitle(randomSavedViewName).click(); // Use the random name here + + // Dynamic delete button selector using the random saved view name + const deleteButtonSelector = `[data-test="logs-search-bar-delete-${randomSavedViewName}-saved-view-btn"]`; + await page.locator(deleteButtonSelector).click(); // Click delete + await page.locator('[data-test="confirm-button"]').click(); // Confirm deletion }); - - - - - test("should reset the editor on clicking reset filter button", async ({ page }) => { await page.locator('[data-test="date-time-btn"]').click({ force: true }); await page.locator('[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block').click({ force: true }); diff --git a/tests/ui-testing/playwright-tests/logsquickmode.spec.js b/tests/ui-testing/playwright-tests/logsquickmode.spec.js index 8c24f171c8..cf63e393f0 100644 --- a/tests/ui-testing/playwright-tests/logsquickmode.spec.js +++ b/tests/ui-testing/playwright-tests/logsquickmode.spec.js @@ -1,12 +1,16 @@ import { test, expect } from "./baseFixtures"; import logData from "../../ui-testing/cypress/fixtures/log.json"; import logsdata from "../../test-data/logs_data.json"; +import { LogsPage } from '../pages/logsPage.js'; test.describe.configure({ mode: 'parallel' }); async function login(page) { await page.goto(process.env["ZO_BASE_URL"]); - // await page.getByText('Login as internal user').click(); + if (await page.getByText('Login as internal user').isVisible()) { + await page.getByText('Login as internal user').click(); +} + console.log("ZO_BASE_URL", process.env["ZO_BASE_URL"]); await page.waitForTimeout(1000); await page @@ -57,6 +61,7 @@ const selectStreamAndStreamTypeForLogs = async (page, stream) => { }; test.describe("Logs Quickmode testcases", () => { + let logsPage; // let logData; function removeUTFCharacters(text) { // console.log(text, "tex"); @@ -78,6 +83,7 @@ test.describe("Logs Quickmode testcases", () => { test.beforeEach(async ({ page }) => { await login(page); + logsPage = new LogsPage(page); await page.waitForTimeout(1000) await ingestion(page); await page.waitForTimeout(2000) @@ -86,7 +92,8 @@ test.describe("Logs Quickmode testcases", () => { `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}` ); const allsearch = page.waitForResponse("**/api/default/_search**"); - await selectStreamAndStreamTypeForLogs(page, logData.Stream); + await logsPage.selectStreamAndStreamTypeForLogs("e2e_automate"); + await applyQueryButton(page); await page.waitForSelector('[data-test="logs-search-bar-quick-mode-toggle-btn"]'); // Get the toggle button element diff --git a/tests/ui-testing/playwright-tests/multiselect-stream.spec.js b/tests/ui-testing/playwright-tests/multiselect-stream.spec.js index 2d500905d7..1f2d93cd79 100644 --- a/tests/ui-testing/playwright-tests/multiselect-stream.spec.js +++ b/tests/ui-testing/playwright-tests/multiselect-stream.spec.js @@ -1,13 +1,9 @@ import { test, expect } from "./baseFixtures"; import logData from "../../ui-testing/cypress/fixtures/log.json"; -import logsdata from "../../test-data/logs_data.json"; import { LogsPage } from '../pages/logsPage.js'; -import { toZonedTime } from "date-fns-tz"; -import { log } from "console"; test.describe.configure({ mode: "parallel" }); -const folderName = `Folder ${Date.now()}`; -const dashboardName = `AutomatedDashboard${Date.now()}`; + async function login(page) { await page.goto(process.env["ZO_BASE_URL"]); @@ -23,17 +19,17 @@ async function login(page) { await page.locator('[data-cy="login-sign-in"]').click(); } -const selectStreamAndStreamTypeForLogs = async (page, stream) => { - await page.waitForTimeout(4000); - await page - .locator('[data-test="log-search-index-list-select-stream"]') - .click({ force: true }); - await page - .locator("div.q-item") - .getByText(`${stream}`) - .first() - .click({ force: true }); -}; +// const selectStreamAndStreamTypeForLogs = async (page, stream) => { +// await page.waitForTimeout(4000); +// await page +// .locator('[data-test="log-search-index-list-select-stream"]') +// .click({ force: true }); +// await page +// .locator("div.q-item") +// .getByText(`${stream}`) +// .first() +// .click({ force: true }); +// }; const getHeaders = () => { const basicAuthCredentials = Buffer.from( @@ -109,7 +105,7 @@ test.describe("Stream multiselect testcases", () => { `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}` ); const allsearch = page.waitForResponse("**/api/default/_search**"); - await selectStreamAndStreamTypeForLogs(page, logData.Stream); + await logsPage.selectStreamAndStreamTypeForLogs("e2e_automate"); await applyQueryButton(page); await logsPage.clickQuickModeToggle(); diff --git a/tests/ui-testing/playwright-tests/pipelines.spec.js b/tests/ui-testing/playwright-tests/pipelines.spec.js index c3f4f9ff6c..f8b110add5 100644 --- a/tests/ui-testing/playwright-tests/pipelines.spec.js +++ b/tests/ui-testing/playwright-tests/pipelines.spec.js @@ -3,9 +3,8 @@ import logData from "../../ui-testing/cypress/fixtures/log.json"; // import { log } from "console"; import logsdata from "../../test-data/logs_data.json"; import PipelinePage from "../pages/pipelinePage"; -// import { pipeline } from "stream"; -// import fs from "fs"; -import { v4 as uuidv4 } from "uuid"; +import { LogsPage } from '../pages/logsPage.js'; + test.describe.configure({ mode: "parallel" }); @@ -14,7 +13,9 @@ const randomFunctionName = `Pipeline${Math.floor(Math.random() * 1000)}`; async function login(page) { await page.goto(process.env["ZO_BASE_URL"]); - // await page.getByText('Login as internal user').click(); + if (await page.getByText('Login as internal user').isVisible()) { + await page.getByText('Login as internal user').click(); +} await page.waitForTimeout(1000); await page .locator('[data-cy="login-user-id"]') @@ -55,17 +56,7 @@ async function ingestion(page) { console.log(response); } -const selectStreamAndStreamTypeForLogs = async (page, stream) => { - await page.waitForTimeout(4000); - await page - .locator('[data-test="log-search-index-list-select-stream"]') - .click({ force: true }); - await page - .locator("div.q-item") - .getByText(`${stream}`) - .first() - .click({ force: true }); -}; + async function exploreStreamAndNavigateToPipeline(page, streamName) { // Navigate to the streams menu await page.locator('[data-test="menu-link-\\/streams-item"]').click(); @@ -127,6 +118,7 @@ async function deletePipeline(page, randomPipelineName) { await page.locator('[data-test="confirm-button"]').click(); } test.describe("Pipeline testcases", () => { + let logsPage; // let logData; function removeUTFCharacters(text) { // console.log(text, "tex"); @@ -148,6 +140,7 @@ test.describe("Pipeline testcases", () => { test.beforeEach(async ({ page }) => { await login(page); + logsPage = new LogsPage(page); await page.waitForTimeout(5000); @@ -168,7 +161,7 @@ test.describe("Pipeline testcases", () => { `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}` ); const allsearch = page.waitForResponse("**/api/default/_search**"); - await selectStreamAndStreamTypeForLogs(page, logData.Stream); + await logsPage.selectStreamAndStreamTypeForLogs("e2e_automate"); await applyQueryButton(page); }); diff --git a/tests/ui-testing/playwright-tests/sanity.spec.js b/tests/ui-testing/playwright-tests/sanity.spec.js index a753f0ee06..4eb1387893 100644 --- a/tests/ui-testing/playwright-tests/sanity.spec.js +++ b/tests/ui-testing/playwright-tests/sanity.spec.js @@ -2,12 +2,14 @@ import { test, expect } from './baseFixtures'; import logData from "../../ui-testing/cypress/fixtures/log.json"; import logsdata from "../../test-data/logs_data.json"; import { toZonedTime } from "date-fns-tz"; +import { LogsPage } from '../pages/logsPage.js'; test.describe.configure({ mode: "parallel" }); const folderName = `Folder ${Date.now()}`; const dashboardName = `AutomatedDashboard${Date.now()}`; async function login(page) { + await page.goto(process.env["ZO_BASE_URL"]); if (await page.getByText('Login as internal user').isVisible()) { await page.getByText('Login as internal user').click(); @@ -15,8 +17,6 @@ async function login(page) { console.log("ZO_BASE_URL", process.env["ZO_BASE_URL"]); await page.waitForTimeout(1000); - // await page.getByText('Login as internal user').click(); // Commented out as it is not required - await page .locator('[data-cy="login-user-id"]') .fill(process.env["ZO_ROOT_USER_EMAIL"]); @@ -57,19 +57,9 @@ async function ingestion(page) { console.log(response); } -const selectStreamAndStreamTypeForLogs = async (page, stream) => { - await page.waitForTimeout(4000); - await page - .locator('[data-test="log-search-index-list-select-stream"]') - .click({ force: true }); - await page - .locator("div.q-item") - .getByText(`${stream}`) - .first() - .click({ force: true }); -}; test.describe("Sanity testcases", () => { + let logsPage; // let logData; function removeUTFCharacters(text) { // console.log(text, "tex"); @@ -86,11 +76,11 @@ test.describe("Sanity testcases", () => { }); // get the data from the search variable await expect.poll(async () => (await search).status()).toBe(200); - // await search.hits.FIXME_should("be.an", "array"); } test.beforeEach(async ({ page }) => { await login(page); + logsPage = new LogsPage(page); await page.waitForTimeout(1000) await ingestion(page); await page.waitForTimeout(2000) @@ -99,7 +89,7 @@ test.describe("Sanity testcases", () => { `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}` ); const allsearch = page.waitForResponse("**/api/default/_search**"); - await selectStreamAndStreamTypeForLogs(page, logData.Stream); + await logsPage.selectStreamAndStreamTypeForLogs("e2e_automate"); await applyQueryButton(page); // const streams = page.waitForResponse("**/api/default/streams**"); }); @@ -323,60 +313,6 @@ test.describe("Sanity testcases", () => { await page.getByText("Function deleted").click(); }); - test.skip("should create and delete dashboard", async ({ page }) => { - await page.locator('[data-test="menu-link-\\/dashboards-item"]').click(); - await page.waitForTimeout(5000); - await page.locator('[data-test="dashboard-add"]').click(); - await page.waitForTimeout(5000); - await page.locator('[data-test="add-dashboard-name"]').click(); - - await page.locator('[data-test="add-dashboard-name"]').fill("sanitytest"); - await page.locator('[data-test="dashboard-add-submit"]').click(); - await page.waitForTimeout(2000); - await page - .locator('[data-test="dashboard-if-no-panel-add-panel-btn"]') - .click(); - await page.waitForTimeout(3000); - await page.locator('[data-test="index-dropdown-stream"]').click(); - await page.locator('[data-test="index-dropdown-stream"]').fill("e2e"); - await page - .getByRole("option", { name: "e2e_automate" }) - .locator("div") - .nth(2) - .click(); - await page.waitForTimeout(3000); - await page - .locator( - '[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubectl_kubernetes_io_default_container"] [data-test="dashboard-add-y-data"]' - ) - .click(); - await page.locator('[data-test="dashboard-apply"]').click(); - await page.locator('[data-test="date-time-btn"]').click(); - await page.locator('[data-test="date-time-relative-5-d-btn"]').click(); - await page.locator('[data-test="dashboard-apply"]').click(); - await page.locator('[data-test="chart-renderer"] canvas').last().click({ - position: { - x: 753, - y: 200, - }, - }); - await page.locator('[data-test="dashboard-panel-save"]').click(); - await page.locator('[data-test="dashboard-panel-name"]').click(); - await page.locator('[data-test="dashboard-panel-name"]').fill("sanitydash"); - await page.waitForTimeout(2000); - await page.locator('[data-test="dashboard-panel-save"]').click(); - await page.waitForTimeout(2000); - await page - .locator('[data-test="dashboard-edit-panel-sanitydash-dropdown"]') - .click(); - await page.locator('[data-test="dashboard-delete-panel"]').click(); - await page.locator('[data-test="confirm-button"]').click(); - await page - .locator("#q-notify div") - .filter({ hasText: "check_circlePanel deleted" }) - .nth(3) - .click(); - }); const randomFolderName = `Folder${Math.floor(Math.random() * 1000)}`; test("should create delete folder", async ({ page }) => { @@ -580,413 +516,413 @@ test.describe("Sanity testcases", () => { .click(); }); - test("should change settings successfully", async ({ page }) => { - await page.waitForTimeout(2000); - await page.locator('[data-test="menu-link-settings-item"]').click(); - await page.waitForTimeout(2000); - await page.getByText("General SettingsScrape").click(); - await page.getByRole("tab", { name: "General Settings" }).click(); - await page.getByLabel("Scrape Interval (In Seconds) *").fill("16"); - await page.locator('[data-test="dashboard-add-submit"]').click(); - await page.getByText("Organization settings updated").click(); - }); + // test("should change settings successfully", async ({ page }) => { + // await page.waitForTimeout(2000); + // await page.locator('[data-test="menu-link-settings-item"]').click(); + // await page.waitForTimeout(2000); + // await page.getByText("General SettingsScrape").click(); + // await page.getByRole("tab", { name: "General Settings" }).click(); + // await page.getByLabel("Scrape Interval (In Seconds) *").fill("16"); + // await page.locator('[data-test="dashboard-add-submit"]').click(); + // await page.getByText("Organization settings updated").click(); + // }); - test("should display results on click refresh stats", async ({ page }) => { - await page.locator('[data-test="menu-link-\\/streams-item"]').click(); - await page.locator('[data-test="log-stream-refresh-stats-btn"]').click(); - page.reload(); - await page.getByRole("cell", { name: "01", exact: true }).click(); - }); + // test("should display results on click refresh stats", async ({ page }) => { + // await page.locator('[data-test="menu-link-\\/streams-item"]').click(); + // await page.locator('[data-test="log-stream-refresh-stats-btn"]').click(); + // page.reload(); + // await page.getByRole("cell", { name: "01", exact: true }).click(); + // }); - test("should display pagination for schema", async ({ page }) => { - await page - .getByText("fast_rewind12345fast_forward100arrow_drop_down") - .click(); - await page.getByText("fast_rewind1/2fast_forward").click(); - await page - .locator('[data-test="logs-page-fields-list-pagination-nextpage-button"]') - .click(); - await page - .locator( - '[data-test="logs-page-fields-list-pagination-previouspage-button"]' - ) - .click(); - }); + // test("should display pagination for schema", async ({ page }) => { + // await page + // .getByText("fast_rewind12345fast_forward100arrow_drop_down") + // .click(); + // await page.getByText("fast_rewind1/2fast_forward").click(); + // await page + // .locator('[data-test="logs-page-fields-list-pagination-nextpage-button"]') + // .click(); + // await page + // .locator( + // '[data-test="logs-page-fields-list-pagination-previouspage-button"]' + // ) + // .click(); + // }); - test("should display pagination when histogram is off and clicking and closing the result", async ({ - page, - }) => { - await page - .locator('[data-test="logs-search-bar-show-histogram-toggle-btn"] div') - .nth(2) - .click(); - await page.locator('[data-test="log-table-column-0-source"]').click(); - await page.locator('[data-test="close-dialog"]').click(); - await page - .getByText("fast_rewind12345fast_forward100arrow_drop_down") - .click(); - }); + // test("should display pagination when histogram is off and clicking and closing the result", async ({ + // page, + // }) => { + // await page + // .locator('[data-test="logs-search-bar-show-histogram-toggle-btn"] div') + // .nth(2) + // .click(); + // await page.locator('[data-test="log-table-column-0-source"]').click(); + // await page.locator('[data-test="close-dialog"]').click(); + // await page + // .getByText("fast_rewind12345fast_forward100arrow_drop_down") + // .click(); + // }); - test("should display pagination when only SQL is on clicking and closing the result", async ({ - page, - }) => { - await page - .locator('[data-test="logs-search-bar-show-histogram-toggle-btn"] div') - .nth(2) - .click(); - await page.getByLabel("SQL Mode").locator("div").first().click(); - await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); - await page.locator('[data-test="log-table-column-1-_timestamp"]').click(); - await page.locator('[data-test="close-dialog"]').click(); - await page - .getByText("fast_rewind12345fast_forward100arrow_drop_down") - .click(); - }); + // test("should display pagination when only SQL is on clicking and closing the result", async ({ + // page, + // }) => { + // await page + // .locator('[data-test="logs-search-bar-show-histogram-toggle-btn"] div') + // .nth(2) + // .click(); + // await page.getByLabel("SQL Mode").locator("div").first().click(); + // await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + // await page.locator('[data-test="log-table-column-1-_timestamp"]').click(); + // await page.locator('[data-test="close-dialog"]').click(); + // await page + // .getByText("fast_rewind12345fast_forward100arrow_drop_down") + // .click(); + // }); - test(" should display histogram in sql mode", async ({ page }) => { - await page - .locator('[data-test="logs-search-result-bar-chart"] canvas') - .click({ - position: { - x: 182, - y: 66, - }, - }); - await page.getByLabel("SQL Mode").locator("div").nth(2).click(); - await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); - // await page.getByRole('heading', { name: 'Error while fetching' }).click(); + // test(" should display histogram in sql mode", async ({ page }) => { + // await page + // .locator('[data-test="logs-search-result-bar-chart"] canvas') + // .click({ + // position: { + // x: 182, + // y: 66, + // }, + // }); + // await page.getByLabel("SQL Mode").locator("div").nth(2).click(); + // await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + // // await page.getByRole('heading', { name: 'Error while fetching' }).click(); - await expect( - page.getByRole("heading", { name: "Error while fetching" }) - ).not.toBeVisible(); - await page - .locator('[data-test="logs-search-result-bar-chart"] canvas') - .click({ - position: { - x: 182, - y: 66, - }, - }); - }); + // await expect( + // page.getByRole("heading", { name: "Error while fetching" }) + // ).not.toBeVisible(); + // await page + // .locator('[data-test="logs-search-result-bar-chart"] canvas') + // .click({ + // position: { + // x: 182, + // y: 66, + // }, + // }); + // }); - test("should display results when SQL+histogram is on and then stream is selected", async ({ - page, - }) => { - await page.locator('[data-test="menu-link-\\/-item"]').click(); - await page.locator('[data-test="menu-link-\\/logs-item"]').click(); - await page - .locator( - "#fnEditor > .monaco-editor > .overflow-guard > .monaco-scrollable-element > .lines-content > .view-lines" - ) - .click(); - await page.getByLabel("SQL Mode").locator("div").nth(2).click(); - await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); - await page - .locator( - '[data-test="log-table-column-0-_timestamp"] [data-test="table-row-expand-menu"]' - ) - .click(); - }); + // test("should display results when SQL+histogram is on and then stream is selected", async ({ + // page, + // }) => { + // await page.locator('[data-test="menu-link-\\/-item"]').click(); + // await page.locator('[data-test="menu-link-\\/logs-item"]').click(); + // await page + // .locator( + // "#fnEditor > .monaco-editor > .overflow-guard > .monaco-scrollable-element > .lines-content > .view-lines" + // ) + // .click(); + // await page.getByLabel("SQL Mode").locator("div").nth(2).click(); + // await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + // await page + // .locator( + // '[data-test="log-table-column-0-_timestamp"] [data-test="table-row-expand-menu"]' + // ) + // .click(); + // }); - const getHeaders = () => { - const basicAuthCredentials = Buffer.from( - `${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}` - ).toString("base64"); + // const getHeaders = () => { + // const basicAuthCredentials = Buffer.from( + // `${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}` + // ).toString("base64"); - return { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }; - }; + // return { + // Authorization: `Basic ${basicAuthCredentials}`, + // "Content-Type": "application/json", + // }; + // }; - // Helper function to get ingestion URL - const getIngestionUrl = (orgId, streamName) => { - return `${process.env.INGESTION_URL}/api/${orgId}/${streamName}/_json`; - }; + // // Helper function to get ingestion URL + // const getIngestionUrl = (orgId, streamName) => { + // return `${process.env.INGESTION_URL}/api/${orgId}/${streamName}/_json`; + // }; - // Helper function to send POST request - const sendRequest = async (page, url, payload, headers) => { - return await page.evaluate( - async ({ url, headers, payload }) => { - const response = await fetch(url, { - method: "POST", - headers: headers, - body: JSON.stringify(payload), - }); - return await response.json(); - }, - { url, headers, payload } - ); - }; + // // Helper function to send POST request + // const sendRequest = async (page, url, payload, headers) => { + // return await page.evaluate( + // async ({ url, headers, payload }) => { + // const response = await fetch(url, { + // method: "POST", + // headers: headers, + // body: JSON.stringify(payload), + // }); + // return await response.json(); + // }, + // { url, headers, payload } + // ); + // }; - test.skip("should check JSON responses for successful:1 with timestamp 15 mins before", async ({ - page, - }) => { - const orgId = process.env["ORGNAME"]; - const streamName = "e2e_automate"; - const headers = getHeaders(); - const ingestionUrl = getIngestionUrl(orgId, streamName); + // test.skip("should check JSON responses for successful:1 with timestamp 15 mins before", async ({ + // page, + // }) => { + // const orgId = process.env["ORGNAME"]; + // const streamName = "e2e_automate"; + // const headers = getHeaders(); + // const ingestionUrl = getIngestionUrl(orgId, streamName); - // First payload - const payload1 = [ - { - level: "info", - job: "test", - log: "test message for openobserve", - e2e: "1", - }, - ]; + // // First payload + // const payload1 = [ + // { + // level: "info", + // job: "test", + // log: "test message for openobserve", + // e2e: "1", + // }, + // ]; - // Second payload with timestamp 15 minutes before - const timestamp = Date.now() - 15 * 60 * 1000; // 15 minutes before - const payload2 = [ - { - level: "info", - job: "test", - log: "test message for openobserve", - e2e: "1.1", - _timestamp: timestamp, - }, - ]; + // // Second payload with timestamp 15 minutes before + // const timestamp = Date.now() - 15 * 60 * 1000; // 15 minutes before + // const payload2 = [ + // { + // level: "info", + // job: "test", + // log: "test message for openobserve", + // e2e: "1.1", + // _timestamp: timestamp, + // }, + // ]; - // Sending first request - const response1 = await sendRequest(page, ingestionUrl, payload1, headers); - console.log(response1); + // // Sending first request + // const response1 = await sendRequest(page, ingestionUrl, payload1, headers); + // console.log(response1); - // Sending second request - const response2 = await sendRequest(page, ingestionUrl, payload2, headers); - console.log(response2); + // // Sending second request + // const response2 = await sendRequest(page, ingestionUrl, payload2, headers); + // console.log(response2); - // Assertions - expect(response1.status[0].successful).toBe(1); - expect(response2.status[0].successful).toBe(1); - }); + // // Assertions + // expect(response1.status[0].successful).toBe(1); + // expect(response2.status[0].successful).toBe(1); + // }); - test.skip("should display error if timestamp past the ingestion time limit", async ({ - page, - }) => { - const orgId = process.env["ORGNAME"]; - const streamName = "e2e_automate"; - const headers = getHeaders(); - const ingestionUrl = getIngestionUrl(orgId, streamName); + // test.skip("should display error if timestamp past the ingestion time limit", async ({ + // page, + // }) => { + // const orgId = process.env["ORGNAME"]; + // const streamName = "e2e_automate"; + // const headers = getHeaders(); + // const ingestionUrl = getIngestionUrl(orgId, streamName); - // First payload - const payload1 = [ - { - level: "info", - job: "test", - log: "test message for openobserve", - e2e: "1", - }, - ]; + // // First payload + // const payload1 = [ + // { + // level: "info", + // job: "test", + // log: "test message for openobserve", + // e2e: "1", + // }, + // ]; - // Second payload with timestamp 6 hours before - const timestamp = Date.now() - 6 * 60 * 60 * 1000; // 6 hours before - const payload2 = [ - { - level: "info", - job: "test", - log: "test message for openobserve", - e2e: "1.1", - _timestamp: timestamp, - }, - ]; + // // Second payload with timestamp 6 hours before + // const timestamp = Date.now() - 6 * 60 * 60 * 1000; // 6 hours before + // const payload2 = [ + // { + // level: "info", + // job: "test", + // log: "test message for openobserve", + // e2e: "1.1", + // _timestamp: timestamp, + // }, + // ]; - // Sending first request - const response1 = await sendRequest(page, ingestionUrl, payload1, headers); - console.log(response1); + // // Sending first request + // const response1 = await sendRequest(page, ingestionUrl, payload1, headers); + // console.log(response1); - // Sending second request - const response2 = await sendRequest(page, ingestionUrl, payload2, headers); - console.log(response2); + // // Sending second request + // const response2 = await sendRequest(page, ingestionUrl, payload2, headers); + // console.log(response2); - // Assertions - expect(response1.status[0].successful).toBe(1); - expect(response2.status[0].successful).toBe(0); - expect(response2.status[0].failed).toBe(1); - expect(response2.status[0].error).toBe( - "Too old data, only last 5 hours data can be ingested. Data discarded. You can adjust ingestion max time by setting the environment variable ZO_INGEST_ALLOWED_UPTO=" - ); - }); + // // Assertions + // expect(response1.status[0].successful).toBe(1); + // expect(response2.status[0].successful).toBe(0); + // expect(response2.status[0].failed).toBe(1); + // expect(response2.status[0].error).toBe( + // "Too old data, only last 5 hours data can be ingested. Data discarded. You can adjust ingestion max time by setting the environment variable ZO_INGEST_ALLOWED_UPTO=" + // ); + // }); - const formatDate = (date) => { - const year = String(date.getFullYear()); - const month = String(date.getMonth() + 1).padStart(2, "0"); - const day = String(date.getDate()).padStart(2, "0"); - const hours = String(date.getHours()).padStart(2, "0"); - const minutes = String(date.getMinutes()).padStart(2, "0"); - const seconds = String(date.getSeconds()).padStart(2, "0"); - return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; - }; - test.skip("should compare time displayed in table dashboards after changing timezone and then delete it ", async ({ page }) => { - const orgId = process.env["ORGNAME"]; - const streamName = "e2e_tabledashboard"; - const headers = getHeaders(); - const ingestionUrl = getIngestionUrl(orgId, streamName); - const timestamp = parseInt(Date.now() / 10000) * 10000 - 10 * 60 * 1000; // 10 minutes before - // First payload - const payload1 = [ - { - level: "info", - job: "test", - log: "test message for openobserve", - e2e: "1", - _timestamp: timestamp, - }, - ]; + // const formatDate = (date) => { + // const year = String(date.getFullYear()); + // const month = String(date.getMonth() + 1).padStart(2, "0"); + // const day = String(date.getDate()).padStart(2, "0"); + // const hours = String(date.getHours()).padStart(2, "0"); + // const minutes = String(date.getMinutes()).padStart(2, "0"); + // const seconds = String(date.getSeconds()).padStart(2, "0"); + // return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; + // }; + // test.skip("should compare time displayed in table dashboards after changing timezone and then delete it ", async ({ page }) => { + // const orgId = process.env["ORGNAME"]; + // const streamName = "e2e_tabledashboard"; + // const headers = getHeaders(); + // const ingestionUrl = getIngestionUrl(orgId, streamName); + // const timestamp = parseInt(Date.now() / 10000) * 10000 - 10 * 60 * 1000; // 10 minutes before + // // First payload + // const payload1 = [ + // { + // level: "info", + // job: "test", + // log: "test message for openobserve", + // e2e: "1", + // _timestamp: timestamp, + // }, + // ]; - // Sending first request - const response1 = await sendRequest(page, ingestionUrl, payload1, headers); - console.log(response1); + // // Sending first request + // const response1 = await sendRequest(page, ingestionUrl, payload1, headers); + // console.log(response1); - await page.locator('[data-test="menu-link-\\/dashboards-item"]').click(); - await page.waitForTimeout(5000); - await page.locator('[data-test="dashboard-add"]').click(); - await page.waitForTimeout(5000); - await page.locator('[data-test="add-dashboard-name"]').click(); + // await page.locator('[data-test="menu-link-\\/dashboards-item"]').click(); + // await page.waitForTimeout(5000); + // await page.locator('[data-test="dashboard-add"]').click(); + // await page.waitForTimeout(5000); + // await page.locator('[data-test="add-dashboard-name"]').click(); - await page.locator('[data-test="add-dashboard-name"]').fill(dashboardName); - await page.locator('[data-test="dashboard-add-submit"]').click(); - await page.waitForTimeout(2000); - await page - .locator('[data-test="dashboard-if-no-panel-add-panel-btn"]') - .click(); - await page.waitForTimeout(3000); - await page.locator('[data-test="selected-chart-table-item"] img').click(); - await page.locator('[data-test="index-dropdown-stream"]').click(); - await page - .locator('[data-test="index-dropdown-stream"]') - .fill("e2e_tabledashboard"); - await page.waitForTimeout(4000); - await page.getByRole("option", { name: "e2e_tabledashboard" }).click({ force: true }); - await page.waitForTimeout(6000); + // await page.locator('[data-test="add-dashboard-name"]').fill(dashboardName); + // await page.locator('[data-test="dashboard-add-submit"]').click(); + // await page.waitForTimeout(2000); + // await page + // .locator('[data-test="dashboard-if-no-panel-add-panel-btn"]') + // .click(); + // await page.waitForTimeout(3000); + // await page.locator('[data-test="selected-chart-table-item"] img').click(); + // await page.locator('[data-test="index-dropdown-stream"]').click(); + // await page + // .locator('[data-test="index-dropdown-stream"]') + // .fill("e2e_tabledashboard"); + // await page.waitForTimeout(4000); + // await page.getByRole("option", { name: "e2e_tabledashboard" }).click({ force: true }); + // await page.waitForTimeout(6000); - await page - .locator( - '[data-test="field-list-item-logs-e2e_tabledashboard-e2e"] [data-test="dashboard-add-y-data"]' - ) - .click(); - await page - .locator( - '[data-test="field-list-item-logs-e2e_tabledashboard-job"] [data-test="dashboard-add-y-data"]' - ) - .click(); - await page.locator('[data-test="dashboard-apply"]').click(); - await page.locator('[data-test="dashboard-panel-name"]').click(); - await page.locator('[data-test="dashboard-panel-name"]').fill("sanitydash"); - await page.waitForTimeout(2000); - await page.locator('[data-test="dashboard-panel-save"]').click(); - await page.waitForTimeout(2000); + // await page + // .locator( + // '[data-test="field-list-item-logs-e2e_tabledashboard-e2e"] [data-test="dashboard-add-y-data"]' + // ) + // .click(); + // await page + // .locator( + // '[data-test="field-list-item-logs-e2e_tabledashboard-job"] [data-test="dashboard-add-y-data"]' + // ) + // .click(); + // await page.locator('[data-test="dashboard-apply"]').click(); + // await page.locator('[data-test="dashboard-panel-name"]').click(); + // await page.locator('[data-test="dashboard-panel-name"]').fill("sanitydash"); + // await page.waitForTimeout(2000); + // await page.locator('[data-test="dashboard-panel-save"]').click(); + // await page.waitForTimeout(2000); - // // Change timezone to Asia/Calcutta - await page.locator('[data-test="date-time-btn"]').click(); - await page.locator('[data-test="datetime-timezone-select"]').click(); - await page - .locator('[data-test="datetime-timezone-select"]') - .fill("Asia/Calcutta"); - await page.getByText("Asia/Calcutta", { exact: true }).click(); - await page.waitForTimeout(200); + // // // Change timezone to Asia/Calcutta + // await page.locator('[data-test="date-time-btn"]').click(); + // await page.locator('[data-test="datetime-timezone-select"]').click(); + // await page + // .locator('[data-test="datetime-timezone-select"]') + // .fill("Asia/Calcutta"); + // await page.getByText("Asia/Calcutta", { exact: true }).click(); + // await page.waitForTimeout(200); - // NOTE: pass selected timezone - const calcuttaTime = toZonedTime(new Date(timestamp), "Asia/Calcutta"); - const displayedTimestampCalcutta = formatDate(calcuttaTime); - console.log(displayedTimestampCalcutta); - await page.waitForTimeout(2000); - // Verify the displayed time in Asia/Calcutta - const timeCellCalcutta = await page - .getByRole("cell", { name: displayedTimestampCalcutta }) - .textContent(); - expect(timeCellCalcutta).toBe(displayedTimestampCalcutta); - await page.waitForTimeout(1000); - // Change timezone to Europe/Zurich - await page.locator('[data-test="date-time-btn"]').click(); - await page.locator('[data-test="date-time-btn"]').click(); - await page.locator('[data-test="datetime-timezone-select"]').click(); - await page - .locator('[data-test="datetime-timezone-select"]') - .fill("Europe/Zurich"); - await page.getByText("Europe/Zurich", { exact: true }).click(); - await page.waitForTimeout(200); + // // NOTE: pass selected timezone + // const calcuttaTime = toZonedTime(new Date(timestamp), "Asia/Calcutta"); + // const displayedTimestampCalcutta = formatDate(calcuttaTime); + // console.log(displayedTimestampCalcutta); + // await page.waitForTimeout(2000); + // // Verify the displayed time in Asia/Calcutta + // const timeCellCalcutta = await page + // .getByRole("cell", { name: displayedTimestampCalcutta }) + // .textContent(); + // expect(timeCellCalcutta).toBe(displayedTimestampCalcutta); + // await page.waitForTimeout(1000); + // // Change timezone to Europe/Zurich + // await page.locator('[data-test="date-time-btn"]').click(); + // await page.locator('[data-test="date-time-btn"]').click(); + // await page.locator('[data-test="datetime-timezone-select"]').click(); + // await page + // .locator('[data-test="datetime-timezone-select"]') + // .fill("Europe/Zurich"); + // await page.getByText("Europe/Zurich", { exact: true }).click(); + // await page.waitForTimeout(200); - // Convert the timestamp to the required format in Europe/Zurich - const zurichTime = toZonedTime(new Date(timestamp), "Europe/Zurich"); - const displayedTimestampZurich = formatDate(zurichTime); - console.log(displayedTimestampZurich); + // // Convert the timestamp to the required format in Europe/Zurich + // const zurichTime = toZonedTime(new Date(timestamp), "Europe/Zurich"); + // const displayedTimestampZurich = formatDate(zurichTime); + // console.log(displayedTimestampZurich); - // Verify the displayed time in Europe/Zurich - const timeCellZurich = await page - .getByRole("cell", { name: displayedTimestampZurich }) - .textContent(); - expect(timeCellZurich).toBe(displayedTimestampZurich); - await page.waitForTimeout(2000); - await page - .locator('[data-test="dashboard-edit-panel-sanitydash-dropdown"]') - .click(); - await page.locator('[data-test="dashboard-delete-panel"]').click(); - await page.locator('[data-test="confirm-button"]').click(); - await page - .locator("#q-notify div") - .filter({ hasText: "check_circlePanel deleted" }) - .nth(3) - .click(); - await page.locator('[data-test="dashboard-back-btn"]'); - await page.locator('[data-test="dashboard-back-btn"]').click(); - await page - .getByRole("row", { name: dashboardName }) - .locator('[data-test="dashboard-delete"]') - .click(); - await page.locator('[data-test="confirm-button"]').click(); - }); - test.skip('should verify search history displayed and user navigates to logs', async ({ page, context }) => { - // Step 1: Click on the "Share Link" button - await page.getByLabel('SQL Mode').locator('div').nth(2).click(); - await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); - await page.getByRole('button', { name: 'Search History' }).click(); - await page.locator('[data-test="search-history-date-time"]').click(); - await page.locator('[data-test="date-time-relative-6-h-btn"]').click(); - await page.getByRole('button', { name: 'Get History' }).click(); - await page.waitForTimeout(6000); - await page.getByRole('cell', { name: 'Trace ID' }).click(); - // Locate the row using a known static value like the SQL query - // const row = page.locator('tr:has-text("select histogram")'); - // Locate the row using a known static value, ignoring case sensitivity - const row = page.locator('tr').filter({ hasText: /select histogram/i }); - // Click the button inside the located row - await row.locator('button.q-btn').nth(0).click(); - await page.getByRole('button', { name: 'Logs' }).click(); - await page.locator('[data-test="logs-search-index-list"]').getByText('e2e_automate').click() - await expect(page).toHaveURL(/stream_type=logs/) - }); + // // Verify the displayed time in Europe/Zurich + // const timeCellZurich = await page + // .getByRole("cell", { name: displayedTimestampZurich }) + // .textContent(); + // expect(timeCellZurich).toBe(displayedTimestampZurich); + // await page.waitForTimeout(2000); + // await page + // .locator('[data-test="dashboard-edit-panel-sanitydash-dropdown"]') + // .click(); + // await page.locator('[data-test="dashboard-delete-panel"]').click(); + // await page.locator('[data-test="confirm-button"]').click(); + // await page + // .locator("#q-notify div") + // .filter({ hasText: "check_circlePanel deleted" }) + // .nth(3) + // .click(); + // await page.locator('[data-test="dashboard-back-btn"]'); + // await page.locator('[data-test="dashboard-back-btn"]').click(); + // await page + // .getByRole("row", { name: dashboardName }) + // .locator('[data-test="dashboard-delete"]') + // .click(); + // await page.locator('[data-test="confirm-button"]').click(); + // }); + // test.skip('should verify search history displayed and user navigates to logs', async ({ page, context }) => { + // // Step 1: Click on the "Share Link" button + // await page.getByLabel('SQL Mode').locator('div').nth(2).click(); + // await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + // await page.getByRole('button', { name: 'Search History' }).click(); + // await page.locator('[data-test="search-history-date-time"]').click(); + // await page.locator('[data-test="date-time-relative-6-h-btn"]').click(); + // await page.getByRole('button', { name: 'Get History' }).click(); + // await page.waitForTimeout(6000); + // await page.getByRole('cell', { name: 'Trace ID' }).click(); + // // Locate the row using a known static value like the SQL query + // // const row = page.locator('tr:has-text("select histogram")'); + // // Locate the row using a known static value, ignoring case sensitivity + // const row = page.locator('tr').filter({ hasText: /select histogram/i }); + // // Click the button inside the located row + // await row.locator('button.q-btn').nth(0).click(); + // await page.getByRole('button', { name: 'Logs' }).click(); + // await page.locator('[data-test="logs-search-index-list"]').getByText('e2e_automate').click() + // await expect(page).toHaveURL(/stream_type=logs/) + // }); - test('should verify logs page displayed on click back button on search history page', async ({ page, context }) => { - // Step 1: Click on the "Share Link" button - await page.getByLabel('SQL Mode').locator('div').nth(2).click(); - await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); - await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); - await page.getByRole('button', { name: 'Search History' }).click(); - await page.locator('[data-test="search-history-date-time"]').click(); - await page.locator('[data-test="date-time-relative-6-h-btn"]').click(); - await page.locator('[data-test="search-history-alert-back-btn"]').click(); - await page.locator('[data-test="logs-search-index-list"] div').filter({ hasText: 'e2e_automate' }).nth(4).click(); - await page.waitForTimeout(2000); - await page.locator('[data-test="log-table-column-0-_timestamp"]').click(); - }); + // test('should verify logs page displayed on click back button on search history page', async ({ page, context }) => { + // // Step 1: Click on the "Share Link" button + // await page.getByLabel('SQL Mode').locator('div').nth(2).click(); + // await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + // await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + // await page.getByRole('button', { name: 'Search History' }).click(); + // await page.locator('[data-test="search-history-date-time"]').click(); + // await page.locator('[data-test="date-time-relative-6-h-btn"]').click(); + // await page.locator('[data-test="search-history-alert-back-btn"]').click(); + // await page.locator('[data-test="logs-search-index-list"] div').filter({ hasText: 'e2e_automate' }).nth(4).click(); + // await page.waitForTimeout(2000); + // await page.locator('[data-test="log-table-column-0-_timestamp"]').click(); + // }); - test('should verify user redirected to logs page when clicking stream explorer and on clicking get history, logs history displayed', async ({ page, context }) => { - // Step 1: Click on the "Share Link" button - await page.locator('[data-test="menu-link-\\/streams-item"]').click(); - await page.getByPlaceholder('Search Stream').click(); - await page.getByPlaceholder('Search Stream').fill('e2e_automate'); - await page.getByRole('button', { name: 'Explore' }).first().click(); - await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); - await page.getByRole('button', { name: 'Search History' }).click(); - await page.locator('[data-test="add-alert-title"]').click(); - await page.getByText('arrow_back_ios_new').click(); - await page.waitForTimeout(1000); + // test('should verify user redirected to logs page when clicking stream explorer and on clicking get history, logs history displayed', async ({ page, context }) => { + // // Step 1: Click on the "Share Link" button + // await page.locator('[data-test="menu-link-\\/streams-item"]').click(); + // await page.getByPlaceholder('Search Stream').click(); + // await page.getByPlaceholder('Search Stream').fill('e2e_automate'); + // await page.getByRole('button', { name: 'Explore' }).first().click(); + // await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + // await page.getByRole('button', { name: 'Search History' }).click(); + // await page.locator('[data-test="add-alert-title"]').click(); + // await page.getByText('arrow_back_ios_new').click(); + // await page.waitForTimeout(1000); - // 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(); + // // 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(); - }); + // }); }); diff --git a/tests/ui-testing/playwright-tests/sanity2.spec.js b/tests/ui-testing/playwright-tests/sanity2.spec.js new file mode 100644 index 0000000000..6c23284f45 --- /dev/null +++ b/tests/ui-testing/playwright-tests/sanity2.spec.js @@ -0,0 +1,507 @@ +import { test, expect } from './baseFixtures'; +import logData from "../cypress/fixtures/log.json"; +import logsdata from "../../test-data/logs_data.json"; +import { toZonedTime } from "date-fns-tz"; +import { LogsPage } from '../pages/logsPage.js'; + +test.describe.configure({ mode: "parallel" }); +const folderName = `Folder ${Date.now()}`; +const dashboardName = `AutomatedDashboard${Date.now()}`; + +async function login(page) { + + await page.goto(process.env["ZO_BASE_URL"]); + if (await page.getByText('Login as internal user').isVisible()) { + await page.getByText('Login as internal user').click(); +} + console.log("ZO_BASE_URL", process.env["ZO_BASE_URL"]); + await page.waitForTimeout(1000); + + await page + .locator('[data-cy="login-user-id"]') + .fill(process.env["ZO_ROOT_USER_EMAIL"]); + //Enter Password + await page + .locator('[data-cy="login-password"]') + .fill(process.env["ZO_ROOT_USER_PASSWORD"]); + await page.locator('[data-cy="login-sign-in"]').click(); + await page.waitForTimeout(4000); + await page.goto(process.env["ZO_BASE_URL"]); +} + +async function ingestion(page) { + const orgId = process.env["ORGNAME"]; + const streamName = "e2e_automate"; + const basicAuthCredentials = Buffer.from( + `${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}` + ).toString('base64'); + + const headers = { + "Authorization": `Basic ${basicAuthCredentials}`, + "Content-Type": "application/json", + }; + const response = await page.evaluate(async ({ url, headers, orgId, streamName, logsdata }) => { + const fetchResponse = await fetch(`${url}/api/${orgId}/${streamName}/_json`, { + method: 'POST', + headers: headers, + body: JSON.stringify(logsdata) + }); + return await fetchResponse.json(); + }, { + url: process.env.INGESTION_URL, + headers: headers, + orgId: orgId, + streamName: streamName, + logsdata: logsdata + }); + console.log(response); +} + + +test.describe("Sanity testcases", () => { + let logsPage; + // let logData; + function removeUTFCharacters(text) { + // console.log(text, "tex"); + // Remove UTF characters using regular expression + return text.replace(/[^\x00-\x7F]/g, " "); + } + async function applyQueryButton(page) { + // click on the run query button + // Type the value of a variable into an input field + const search = page.waitForResponse(logData.applyQuery); + await page.waitForTimeout(3000); + await page.locator("[data-test='logs-search-bar-refresh-btn']").click({ + force: true, + }); + // get the data from the search variable + await expect.poll(async () => (await search).status()).toBe(200); + } + + test.beforeEach(async ({ page }) => { + await login(page); + logsPage = new LogsPage(page); + await page.waitForTimeout(1000) + await ingestion(page); + await page.waitForTimeout(2000) + + await page.goto( + `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}` + ); + const allsearch = page.waitForResponse("**/api/default/_search**"); + await logsPage.selectStreamAndStreamTypeForLogs("e2e_automate"); + await applyQueryButton(page); + // const streams = page.waitForResponse("**/api/default/streams**"); + }); + + + test("should change settings successfully", async ({ page }) => { + await page.waitForTimeout(2000); + await page.locator('[data-test="menu-link-settings-item"]').click(); + await page.waitForTimeout(2000); + await page.getByText("General SettingsScrape").click(); + await page.getByRole("tab", { name: "General Settings" }).click(); + await page.getByLabel("Scrape Interval (In Seconds) *").fill("16"); + await page.locator('[data-test="dashboard-add-submit"]').click(); + await page.getByText("Organization settings updated").click(); + }); + + test("should display results on click refresh stats", async ({ page }) => { + await page.locator('[data-test="menu-link-\\/streams-item"]').click(); + await page.locator('[data-test="log-stream-refresh-stats-btn"]').click(); + page.reload(); + await page.getByRole("cell", { name: "01", exact: true }).click(); + }); + + test("should display pagination for schema", async ({ page }) => { + await page + .getByText("fast_rewind12345fast_forward100arrow_drop_down") + .click(); + await page.getByText("fast_rewind1/2fast_forward").click(); + await page + .locator('[data-test="logs-page-fields-list-pagination-nextpage-button"]') + .click(); + await page + .locator( + '[data-test="logs-page-fields-list-pagination-previouspage-button"]' + ) + .click(); + }); + + test("should display pagination when histogram is off and clicking and closing the result", async ({ + page, + }) => { + await page + .locator('[data-test="logs-search-bar-show-histogram-toggle-btn"] div') + .nth(2) + .click(); + await page.locator('[data-test="log-table-column-0-source"]').click(); + await page.locator('[data-test="close-dialog"]').click(); + await page + .getByText("fast_rewind12345fast_forward100arrow_drop_down") + .click(); + }); + + test("should display pagination when only SQL is on clicking and closing the result", async ({ + page, + }) => { + await page + .locator('[data-test="logs-search-bar-show-histogram-toggle-btn"] div') + .nth(2) + .click(); + await page.getByLabel("SQL Mode").locator("div").first().click(); + await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + await page.locator('[data-test="log-table-column-1-_timestamp"]').click(); + await page.locator('[data-test="close-dialog"]').click(); + await page + .getByText("fast_rewind12345fast_forward100arrow_drop_down") + .click(); + }); + + test(" should display histogram in sql mode", async ({ page }) => { + await page + .locator('[data-test="logs-search-result-bar-chart"] canvas') + .click({ + position: { + x: 182, + y: 66, + }, + }); + await page.getByLabel("SQL Mode").locator("div").nth(2).click(); + await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + // await page.getByRole('heading', { name: 'Error while fetching' }).click(); + + await expect( + page.getByRole("heading", { name: "Error while fetching" }) + ).not.toBeVisible(); + await page + .locator('[data-test="logs-search-result-bar-chart"] canvas') + .click({ + position: { + x: 182, + y: 66, + }, + }); + }); + + test("should display results when SQL+histogram is on and then stream is selected", async ({ + page, + }) => { + await page.locator('[data-test="menu-link-\\/-item"]').click(); + await page.locator('[data-test="menu-link-\\/logs-item"]').click(); + await page + .locator( + "#fnEditor > .monaco-editor > .overflow-guard > .monaco-scrollable-element > .lines-content > .view-lines" + ) + .click(); + await page.getByLabel("SQL Mode").locator("div").nth(2).click(); + await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + await page + .locator( + '[data-test="log-table-column-0-_timestamp"] [data-test="table-row-expand-menu"]' + ) + .click(); + }); + + const getHeaders = () => { + const basicAuthCredentials = Buffer.from( + `${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}` + ).toString("base64"); + + return { + Authorization: `Basic ${basicAuthCredentials}`, + "Content-Type": "application/json", + }; + }; + + // Helper function to get ingestion URL + const getIngestionUrl = (orgId, streamName) => { + return `${process.env.INGESTION_URL}/api/${orgId}/${streamName}/_json`; + }; + + // Helper function to send POST request + const sendRequest = async (page, url, payload, headers) => { + return await page.evaluate( + async ({ url, headers, payload }) => { + const response = await fetch(url, { + method: "POST", + headers: headers, + body: JSON.stringify(payload), + }); + return await response.json(); + }, + { url, headers, payload } + ); + }; + + test.skip("should check JSON responses for successful:1 with timestamp 15 mins before", async ({ + page, + }) => { + const orgId = process.env["ORGNAME"]; + const streamName = "e2e_automate"; + const headers = getHeaders(); + const ingestionUrl = getIngestionUrl(orgId, streamName); + + // First payload + const payload1 = [ + { + level: "info", + job: "test", + log: "test message for openobserve", + e2e: "1", + }, + ]; + + // Second payload with timestamp 15 minutes before + const timestamp = Date.now() - 15 * 60 * 1000; // 15 minutes before + const payload2 = [ + { + level: "info", + job: "test", + log: "test message for openobserve", + e2e: "1.1", + _timestamp: timestamp, + }, + ]; + + // Sending first request + const response1 = await sendRequest(page, ingestionUrl, payload1, headers); + console.log(response1); + + // Sending second request + const response2 = await sendRequest(page, ingestionUrl, payload2, headers); + console.log(response2); + + // Assertions + expect(response1.status[0].successful).toBe(1); + expect(response2.status[0].successful).toBe(1); + }); + +test.skip("should display error if timestamp past the ingestion time limit", async ({ + page, + }) => { + const orgId = process.env["ORGNAME"]; + const streamName = "e2e_automate"; + const headers = getHeaders(); + const ingestionUrl = getIngestionUrl(orgId, streamName); + + // First payload + const payload1 = [ + { + level: "info", + job: "test", + log: "test message for openobserve", + e2e: "1", + }, + ]; + + // Second payload with timestamp 6 hours before + const timestamp = Date.now() - 6 * 60 * 60 * 1000; // 6 hours before + const payload2 = [ + { + level: "info", + job: "test", + log: "test message for openobserve", + e2e: "1.1", + _timestamp: timestamp, + }, + ]; + + // Sending first request + const response1 = await sendRequest(page, ingestionUrl, payload1, headers); + console.log(response1); + + // Sending second request + const response2 = await sendRequest(page, ingestionUrl, payload2, headers); + console.log(response2); + + // Assertions + expect(response1.status[0].successful).toBe(1); + expect(response2.status[0].successful).toBe(0); + expect(response2.status[0].failed).toBe(1); + expect(response2.status[0].error).toBe( + "Too old data, only last 5 hours data can be ingested. Data discarded. You can adjust ingestion max time by setting the environment variable ZO_INGEST_ALLOWED_UPTO=" + ); + }); + + const formatDate = (date) => { + const year = String(date.getFullYear()); + const month = String(date.getMonth() + 1).padStart(2, "0"); + const day = String(date.getDate()).padStart(2, "0"); + const hours = String(date.getHours()).padStart(2, "0"); + const minutes = String(date.getMinutes()).padStart(2, "0"); + const seconds = String(date.getSeconds()).padStart(2, "0"); + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; + }; + test.skip("should compare time displayed in table dashboards after changing timezone and then delete it ", async ({ page }) => { + const orgId = process.env["ORGNAME"]; + const streamName = "e2e_tabledashboard"; + const headers = getHeaders(); + const ingestionUrl = getIngestionUrl(orgId, streamName); + const timestamp = parseInt(Date.now() / 10000) * 10000 - 10 * 60 * 1000; // 10 minutes before + // First payload + const payload1 = [ + { + level: "info", + job: "test", + log: "test message for openobserve", + e2e: "1", + _timestamp: timestamp, + }, + ]; + + // Sending first request + const response1 = await sendRequest(page, ingestionUrl, payload1, headers); + console.log(response1); + + await page.locator('[data-test="menu-link-\\/dashboards-item"]').click(); + await page.waitForTimeout(5000); + await page.locator('[data-test="dashboard-add"]').click(); + await page.waitForTimeout(5000); + await page.locator('[data-test="add-dashboard-name"]').click(); + + await page.locator('[data-test="add-dashboard-name"]').fill(dashboardName); + await page.locator('[data-test="dashboard-add-submit"]').click(); + await page.waitForTimeout(2000); + await page + .locator('[data-test="dashboard-if-no-panel-add-panel-btn"]') + .click(); + await page.waitForTimeout(3000); + await page.locator('[data-test="selected-chart-table-item"] img').click(); + await page.locator('[data-test="index-dropdown-stream"]').click(); + await page + .locator('[data-test="index-dropdown-stream"]') + .fill("e2e_tabledashboard"); + await page.waitForTimeout(4000); + await page.getByRole("option", { name: "e2e_tabledashboard" }).click({ force: true }); + await page.waitForTimeout(6000); + + await page + .locator( + '[data-test="field-list-item-logs-e2e_tabledashboard-e2e"] [data-test="dashboard-add-y-data"]' + ) + .click(); + await page + .locator( + '[data-test="field-list-item-logs-e2e_tabledashboard-job"] [data-test="dashboard-add-y-data"]' + ) + .click(); + await page.locator('[data-test="dashboard-apply"]').click(); + await page.locator('[data-test="dashboard-panel-name"]').click(); + await page.locator('[data-test="dashboard-panel-name"]').fill("sanitydash"); + await page.waitForTimeout(2000); + await page.locator('[data-test="dashboard-panel-save"]').click(); + await page.waitForTimeout(2000); + + // // Change timezone to Asia/Calcutta + await page.locator('[data-test="date-time-btn"]').click(); + await page.locator('[data-test="datetime-timezone-select"]').click(); + await page + .locator('[data-test="datetime-timezone-select"]') + .fill("Asia/Calcutta"); + await page.getByText("Asia/Calcutta", { exact: true }).click(); + await page.waitForTimeout(200); + + // NOTE: pass selected timezone + const calcuttaTime = toZonedTime(new Date(timestamp), "Asia/Calcutta"); + const displayedTimestampCalcutta = formatDate(calcuttaTime); + console.log(displayedTimestampCalcutta); + await page.waitForTimeout(2000); + // Verify the displayed time in Asia/Calcutta + const timeCellCalcutta = await page + .getByRole("cell", { name: displayedTimestampCalcutta }) + .textContent(); + expect(timeCellCalcutta).toBe(displayedTimestampCalcutta); + await page.waitForTimeout(1000); + // Change timezone to Europe/Zurich + await page.locator('[data-test="date-time-btn"]').click(); + await page.locator('[data-test="date-time-btn"]').click(); + await page.locator('[data-test="datetime-timezone-select"]').click(); + await page + .locator('[data-test="datetime-timezone-select"]') + .fill("Europe/Zurich"); + await page.getByText("Europe/Zurich", { exact: true }).click(); + await page.waitForTimeout(200); + + // Convert the timestamp to the required format in Europe/Zurich + const zurichTime = toZonedTime(new Date(timestamp), "Europe/Zurich"); + const displayedTimestampZurich = formatDate(zurichTime); + console.log(displayedTimestampZurich); + + // Verify the displayed time in Europe/Zurich + const timeCellZurich = await page + .getByRole("cell", { name: displayedTimestampZurich }) + .textContent(); + expect(timeCellZurich).toBe(displayedTimestampZurich); + await page.waitForTimeout(2000); + await page + .locator('[data-test="dashboard-edit-panel-sanitydash-dropdown"]') + .click(); + await page.locator('[data-test="dashboard-delete-panel"]').click(); + await page.locator('[data-test="confirm-button"]').click(); + await page + .locator("#q-notify div") + .filter({ hasText: "check_circlePanel deleted" }) + .nth(3) + .click(); + await page.locator('[data-test="dashboard-back-btn"]'); + await page.locator('[data-test="dashboard-back-btn"]').click(); + await page + .getByRole("row", { name: dashboardName }) + .locator('[data-test="dashboard-delete"]') + .click(); + await page.locator('[data-test="confirm-button"]').click(); + }); + test.skip('should verify search history displayed and user navigates to logs', async ({ page, context }) => { + // Step 1: Click on the "Share Link" button + await page.getByLabel('SQL Mode').locator('div').nth(2).click(); + await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + await page.getByRole('button', { name: 'Search History' }).click(); + await page.locator('[data-test="search-history-date-time"]').click(); + await page.locator('[data-test="date-time-relative-6-h-btn"]').click(); + await page.getByRole('button', { name: 'Get History' }).click(); + await page.waitForTimeout(6000); + await page.getByRole('cell', { name: 'Trace ID' }).click(); + // Locate the row using a known static value like the SQL query + // const row = page.locator('tr:has-text("select histogram")'); + // Locate the row using a known static value, ignoring case sensitivity + const row = page.locator('tr').filter({ hasText: /select histogram/i }); + // Click the button inside the located row + await row.locator('button.q-btn').nth(0).click(); + await page.getByRole('button', { name: 'Logs' }).click(); + await page.locator('[data-test="logs-search-index-list"]').getByText('e2e_automate').click() + await expect(page).toHaveURL(/stream_type=logs/) + }); + + test('should verify logs page displayed on click back button on search history page', async ({ page, context }) => { + // Step 1: Click on the "Share Link" button + await page.getByLabel('SQL Mode').locator('div').nth(2).click(); + await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + await page.getByRole('button', { name: 'Search History' }).click(); + await page.locator('[data-test="search-history-date-time"]').click(); + await page.locator('[data-test="date-time-relative-6-h-btn"]').click(); + await page.locator('[data-test="search-history-alert-back-btn"]').click(); + await page.locator('[data-test="logs-search-index-list"] div').filter({ hasText: 'e2e_automate' }).nth(4).click(); + await page.waitForTimeout(2000); + await page.locator('[data-test="log-table-column-0-_timestamp"]').click(); + }); + + test('should verify user redirected to logs page when clicking stream explorer and on clicking get history, logs history displayed', async ({ page, context }) => { + // Step 1: Click on the "Share Link" button + await page.locator('[data-test="menu-link-\\/streams-item"]').click(); + await page.getByPlaceholder('Search Stream').click(); + await page.getByPlaceholder('Search Stream').fill('e2e_automate'); + await page.getByRole('button', { name: 'Explore' }).first().click(); + await page.locator('[data-test="logs-search-bar-refresh-btn"]').click(); + await page.getByRole('button', { name: 'Search History' }).click(); + await page.locator('[data-test="add-alert-title"]').click(); + await page.getByText('arrow_back_ios_new').click(); + await page.waitForTimeout(1000); + + // 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(); + + }); + +}); diff --git a/tests/ui-testing/playwright-tests/schema.spec.js b/tests/ui-testing/playwright-tests/schema.spec.js index 0981aab2b2..b6ef6a6c8e 100644 --- a/tests/ui-testing/playwright-tests/schema.spec.js +++ b/tests/ui-testing/playwright-tests/schema.spec.js @@ -1,13 +1,16 @@ import { test, expect } from "./baseFixtures"; import logData from "../../ui-testing/cypress/fixtures/log.json"; import logsdata from "../../test-data/logs_data.json"; +import { LogsPage } from '../pages/logsPage.js'; test.describe.configure({ mode: 'parallel' }); const streamName = `stream${Date.now()}`; async function login(page) { await page.goto(process.env["ZO_BASE_URL"]); - // await page.getByText('Login as internal user').click(); + if (await page.getByText('Login as internal user').isVisible()) { + await page.getByText('Login as internal user').click(); +} await page.waitForTimeout(1000); await page .locator('[data-cy="login-user-id"]') @@ -48,14 +51,8 @@ async function ingestion(page) { console.log(response); } -const selectStreamAndStreamTypeForLogs = async (page, stream) => { - await page.waitForTimeout( - 4000); await page.locator( - '[data-test="log-search-index-list-select-stream"]').click({ force: true }); await page.locator( - "div.q-item").getByText(`${stream}`).first().click({ force: true }); -}; - test.describe("Schema testcases", () => { + let logsPage; // let logData; function removeUTFCharacters(text) { // console.log(text, "tex"); @@ -76,6 +73,7 @@ test.describe("Schema testcases", () => { test.beforeEach(async ({ page }) => { await login(page); + logsPage = new LogsPage(page); await page.waitForTimeout(1000) await ingestion(page); await page.waitForTimeout(2000) @@ -84,21 +82,11 @@ test.describe("Schema testcases", () => { `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}` ); const allsearch = page.waitForResponse("**/api/default/_search**"); - await selectStreamAndStreamTypeForLogs(page, logData.Stream); + await logsPage.selectStreamAndStreamTypeForLogs("e2e_automate"); await applyQueryButton(page); }); test('stream schema settings updated to be displayed under logs', async ({ page }) => { - // page.on('console', msg => console.log(msg.text())); - // page.on('response', async (resp) => { - // if (resp.url().includes('api/default/')) { - // console.log('url -> ', resp.url()); - // console.log('code -> ', resp.status()); - // console.log('payload -> ', resp.request().postData()); - // console.log('response -> ', await resp.text()); - // } - // }); - await page.locator('[data-test="menu-link-\\/streams-item"]').click(); await page.getByPlaceholder('Search Stream').click(); await page.getByPlaceholder('Search Stream').fill('e2e_automate'); diff --git a/tests/ui-testing/playwright-tests/unflattened.spec.js b/tests/ui-testing/playwright-tests/unflattened.spec.js index 061c168cf0..b9795ca447 100644 --- a/tests/ui-testing/playwright-tests/unflattened.spec.js +++ b/tests/ui-testing/playwright-tests/unflattened.spec.js @@ -2,13 +2,16 @@ import { test, expect } from "./baseFixtures"; import logData from "../../ui-testing/cypress/fixtures/log.json"; import logsdata from "../../test-data/logs_data.json"; import UnflattenedPage from "../pages/unflattened"; +import { LogsPage } from '../pages/logsPage.js'; test.describe.configure({ mode: "parallel" }); const streamName = `stream${Date.now()}`; async function login(page) { await page.goto(process.env["ZO_BASE_URL"]); -// await page.getByText("Login as internal user").click(); + if (await page.getByText('Login as internal user').isVisible()) { + await page.getByText('Login as internal user').click(); +} await page.waitForTimeout(1000); await page .locator('[data-cy="login-user-id"]') @@ -70,19 +73,8 @@ async function ingestion(page) { console.log(response); } -const selectStreamAndStreamTypeForLogs = async (page, stream) => { - await page.waitForTimeout(4000); - await page - .locator('[data-test="log-search-index-list-select-stream"]') - .click({ force: true }); - await page - .locator("div.q-item") - .getByText(`${stream}`) - .first() - .click({ force: true }); -}; - test.describe("Unflattened testcases", () => { + let logsPage; // let logData; function removeUTFCharacters(text) { // console.log(text, "tex"); @@ -103,6 +95,7 @@ test.describe("Unflattened testcases", () => { test.beforeEach(async ({ page }) => { await login(page); + logsPage = new LogsPage(page); await page.waitForTimeout(1000); await ingestion(page); await page.waitForTimeout(2000); @@ -111,7 +104,7 @@ test.describe("Unflattened testcases", () => { `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}` ); const allsearch = page.waitForResponse("**/api/default/_search**"); - await selectStreamAndStreamTypeForLogs(page, logData.Stream); + await logsPage.selectStreamAndStreamTypeForLogs("e2e_automate"); await applyQueryButton(page); });