diff --git a/tests/ui-testing/cypress/e2e/allfunctions/logs.js b/tests/ui-testing/cypress/e2e/allfunctions/logs.js deleted file mode 100644 index 5121868aeb..0000000000 --- a/tests/ui-testing/cypress/e2e/allfunctions/logs.js +++ /dev/null @@ -1,292 +0,0 @@ -import { getTestId, getRandomText } from "../utils"; -import logData from "../../fixtures/log.json"; - -function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); -} - -const showHistogramToggle = getTestId( - "logs-search-bar-show-histogram-toggle-btn" -); -const showSQLModeHistogramToggle = getTestId( - "logs-search-bar-show-histogram-toggle-sqlmode-btn" -); -const logsSearchBarChart = getTestId("logs-search-result-bar-chart"); -const vrlFunctionEditor = getTestId("logs-vrl-function-editor"); -const searchBarSqlModeButton = getTestId("logs-search-bar-sql-mode-toggle-btn"); -const logsSearchQueryToggle = getTestId( - "logs-search-bar-show-query-toggle-btn" -); -const queryEditor = getTestId("logs-search-bar-query-editor"); -const saveFunctionDropdown = getTestId("logs-search-bar-function-dropdown") -const vrlQueryToggle = getTestId("logs-search-bar-show-query-toggle-btn") -const functionNameField = getTestId("saved-function-name-input") -const savedViewDialogButton = getTestId("saved-view-dialog-save-btn") -const functionsViaMenu = getTestId("menu-link-/functions-item") -const function_delete_confirm = getTestId("confirm-button") - - -const firstVrlEditor = `${vrlFunctionEditor}:first` -const LOGS_SEARCH_EXPAND = `[data-test="log-search-expand-${logData.expandedFieldValue.field}-field-btn]`; -const SAVED_FUNCTION_BUTTON = `${saveFunctionDropdown} > .q-btn-dropdown--current > .q-btn__content > :nth-child(1)` - - -const NOTIFICATION_MESSAGE = ".q-notification__message" -const DELETE_FUNCTION = '[title="Delete Function"]' - - -/** Verify if histogram toggle button is clicked */ -export function clickHistogramToggle() { - cy.get(showHistogramToggle, { timeout: 2000 }).click({ force: true }); -} - -/** Verify if the chart is hidden */ -export function confirmLogsSearchHidden() { - cy.get(logsSearchBarChart, { timeout: 2000 }).should("not.exist",{ timeout: 10000, interval: 1000 }); -} - -/** Verify if vrl function editor is visible */ -export function displayVrlFunctionEditor() { - cy.get(vrlFunctionEditor, { timeout: 2000 }).should("be.visible"); -} - -/** Verify if logs search query toggle is clicked*/ -export function clickSearchBarSqlMode() { - cy.get(searchBarSqlModeButton, { timeout: 2000 }) - .eq(0) - .click({ force: true }); -} - -/** Verify if logs search query toggle is clicked*/ -export function clickLogsSearchQueryToggle() { - cy.get(logsSearchQueryToggle, { timeout: 2000 }).click({ force: true }); -} - -/** Verify if the vrl function editor is hidden */ -export function vrlFunctionEditorHidden() { - cy.get(vrlFunctionEditor, { timeout: 2000 }).should("be.hidden"); -} - -/** Verify if the vrl function editor is hidden */ -export function histogramToggleDisabled() { - cy.get(showSQLModeHistogramToggle, { timeout: 2000 }).should( - "have.attr", - "aria-disabled", - "true" - ); -} - -export function histogramToggleEnabled() { - cy.get(showSQLModeHistogramToggle, { timeout: 2000 }).should( - "not.have.attr", - "aria-disabled", - "true" - ); -} - - -//** Type the value of a variable into an input field*/ -export function enterVrlFunctionvalue() { - cy.get('[data-test="logs-vrl-function-editor"]:first', { timeout: 2000 }) - .click() - .type(logData.vrlFunctionValue); -} - -//** Verify that the input field no longer has the attribute "data-test" with the value of the variable */ -export function attributeToNotHaveVrlFunctionvalue() { - cy.get(vrlFunctionEditor, { timeout: 2000 }).should( - "not.have.attr", - "data-test", - logData.vrlFunctionValue - ); -} - -//** Verify that the input field no longer has the attribute "data-test" with the value of the variable */ -export function expandLogsSearch() { - cy.get( - `[data-test="log-search-expand-${logData.expandedFieldValue.field}-field-btn"]`, - { timeout: 2000 } - ).trigger("mouseover", { force: true }); -} - -//** Verify that the input field no longer has the attribute "data-test" with the value of the variable */ -export function verifyLogsStatusCode() { - cy.get( - `[data-test="log-search-expand-${logData.expandedFieldValue.field}-field-btn"]`, - { timeout: 2000 } - ).click({ force: true }); -} - -// get the value of the field name -export function clickValueEditor() { - cy.get( - `[data-test="log-search-expand-${logData.addEditorFieldValue.field}-field-btn"]`, - { timeout: 2000 } - ).trigger("mouseover", { force: true }); -} -// ** click on the + button on expanded view/ -export function clickExpandedViewplusButton() { - cy.get( - `[data-test="log-search-expand-${logData.addEditorFieldValue.field}-field-btn"] [data-test="log-search-index-list-filter-${logData.addEditorFieldValue.field}-field-btn"]`, - { timeout: 2000 } - ).click({ force: true }); -} - -//** Verify that a value is added under query editor */ -export function addValueInQueryEditor() { - cy.get(queryEditor, { timeout: 2000 }).type( - `{backspace}${logData.addEditorFieldValue.value}'` - ); -} - -//** Verify that a value is added under query editor */ -export function verifyAddedValue() { - cy.get(queryEditor).then((editor) => { - let text = editor.text(); - const expectedString = `${logData.addEditorFieldValue.field}='${logData.addEditorFieldValue.value},'`; - text = removeUTFCharacters(text); - expect(text.includes(expectedString)).to.be.false; - }); -} - -//** add second value in query */ -export function addMoreValueQueryEditor() { - cy.get( - `[data-test="log-search-expand-${logData.addEditorFieldValue.field1}-field-btn"] [data-test="log-search-index-list-filter-${logData.addEditorFieldValue.field1}-field-btn"]`, - { timeout: 3000 } - ).click({ force: true }); -} - -//** Verify if value is added on the editor when = is clicked*/ -export function addSecondValues() { - cy.get(queryEditor, { timeout: 2000 }).type( - `{backspace}${logData.addEditorFieldValue.value1}'` - ); -} - -//** Verify if value is added on the editor when = is clicked*/ -export function valueAddedInSqlMode() { - cy.get(queryEditor, { timeout: 2000 }).then((editor) => { - let text = editor.text(); - const expectedString = `${logData.addEditorFieldValue.field}='${logData.addEditorFieldValue.value}' and ${logData.addEditorFieldValue.field1}='${logData.addEditorFieldValue.value1}'`; - text = removeUTFCharacters(text); - expect(text.includes(expectedString)).to.be.true; - }); -} - -//** Verify if add value field is clicked*/ -export function addFeildandSubValue() { - cy.get( - `[data-test="log-search-expand-${logData.addFieldAndSubFieldValueWithEqual.field}-field-btn"]` - ).click({ force: true }); -} - -export function addsubFieldValue() { - cy.get( - `[data-test="logs-search-subfield-add-${logData.addFieldAndSubFieldValueWithEqual.field}-${logData.addFieldAndSubFieldValueWithEqual.subFieldValue}"] ` - ).trigger("mouseover", { force: true }); -} - -export function clickFieldSubvalue() { - cy.get( - `[data-test="logs-search-subfield-add-${logData.addFieldAndSubFieldValueWithEqual.field}-${logData.addFieldAndSubFieldValueWithEqual.subFieldValue}"] [data-test="log-search-subfield-list-equal-${logData.addFieldAndSubFieldValueWithEqual.field}-field-btn"]` - ).click({ force: true }); -} - - - -//** Verify if value is added on the editor when = is clicked*/ -export function valueAddedOnPlusClick() { - cy.get('[data-test="logs-search-bar-query-editor"]').then((editor) => { - let text = editor.text(); - expect( - text.includes( - `${logData.addFieldAndSubFieldValueWithEqual.field}='${logData.addFieldAndSubFieldValueWithEqual.subFieldValue}'` - ) - ).to.be.true; - }); - -} - - -//** Verify if value is added on the editor when = is clicked*/ -export function clickOnFirstField() { - cy.get( - `[data-test="log-search-expand-${logData.addFieldAndSubFieldValueWithEqual.field1}-field-btn"]` - ).click({ force: true }); - - -} - - -// //** Verify if value is added on the editor when = is clicked*/ - export function addSecondFieldOnEditor() { - cy.get( - `[data-test="logs-search-subfield-add-${logData.addFieldAndSubFieldValueWithEqual.field}-${logData.addFieldAndSubFieldValueWithEqual.subFieldValue}"] ` - ).trigger("mouseover", { force: true }); - - - } - - - export function clickOnEqualToButton() { - cy.get( - `[data-test="logs-search-subfield-add-${logData.addFieldAndSubFieldValueWithEqual.field}-${logData.addFieldAndSubFieldValueWithEqual.subFieldValue}"] [data-test="log-search-subfield-list-equal-${logData.addFieldAndSubFieldValueWithEqual.field}-field-btn"]` - ).click({ force: true }); - - - } - -//**assertion for added both field value is added on the editor when = is clicked*/ - export function bothFieldAddedOnEqualToClick() { - cy.get('[data-test="logs-search-bar-query-editor"]').then((editor) => { - let text = editor.text(); - const expectedString = `${logData.addFieldAndSubFieldValueWithEqual.field}='${logData.addFieldAndSubFieldValueWithEqual.subFieldValue}' and ${logData.addFieldAndSubFieldValueWithEqual.field1}='${logData.addFieldAndSubFieldValueWithEqual.subFieldValue1}'`; - text = removeUTFCharacters(text); - expect(text.includes(expectedString)).to.be.false; - }); - - } - - - export function clickSaveFunctionButton() { - cy.get(SAVED_FUNCTION_BUTTON,{timeout:2000}).click({ force: true }); -} - - -export function clickVrlQueryToggle() { - cy.get(vrlQueryToggle,{timeout:2000}).click({ force: true }); -} - -export function enterTextVrlQueryEditor(vrlQueryText) { - cy.get(firstVrlEditor,{timeout:2000}).type(vrlQueryText) -} - - -export function noFunctionFoundMessage() { - cy.get(NOTIFICATION_MESSAGE,{timeout:2000}) - .should('be.visible') - .contains('No function definition found') -} - -export function enterFunctionName(functiontext) { - cy.get(functionNameField,{timeout:2000}).type(functiontext) -} - -export function clickSavedOkButton() { - cy.get(savedViewDialogButton,{timeout:2000}).click({ force: true }); -} - -export function clickFunctionsViaMenu() { - cy.get(functionsViaMenu,{timeout:2000}).click({ force: true }); -} - -export function deleteCreatedFunction() { - cy.get(DELETE_FUNCTION,{timeout:2000}).click({ multiple: true }); -} - -export function confirmFunctionDeleteButton() { - cy.get(function_delete_confirm,{timeout:2000}).click({ force: true }); -} \ No newline at end of file diff --git a/tests/ui-testing/cypress/e2e/allfunctions/menufunctions.js b/tests/ui-testing/cypress/e2e/allfunctions/menufunctions.js deleted file mode 100644 index 29e4e201e7..0000000000 --- a/tests/ui-testing/cypress/e2e/allfunctions/menufunctions.js +++ /dev/null @@ -1,17 +0,0 @@ -import { getTestId, getRandomText } from "../utils"; -import logData from "../../fixtures/log.json"; - - -const showHistogramToggle = getTestId( - "logs-search-bar-show-histogram-toggle-btn" - ); - - const queryEditor = getTestId("query-editor"); - - const LOGS_SEARCH_EXPAND = `[data-test="log-search-expand-${logData.expandedFieldValue.field}-field-btn]`; - const MENU = ('q-drawer__content > .q-list') - - export function menuDisplayed() { - cy.get(MENU, { timeout: 2000 }).should('be.visible'); - } - \ No newline at end of file diff --git a/tests/ui-testing/cypress/e2e/dashboard/AddDashboard.cy.js b/tests/ui-testing/cypress/e2e/dashboard/AddDashboard.cy.js deleted file mode 100644 index d40aed332f..0000000000 --- a/tests/ui-testing/cypress/e2e/dashboard/AddDashboard.cy.js +++ /dev/null @@ -1,74 +0,0 @@ -/// -import { fieldType } from "../../support/commons"; -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); -describe("Create a new dashboard", () => { - let dashboardData; - let dashboardName; - - function getRandomInt(min, max) { - return Math.floor(Math.random() * (max - min + 1)) + min; - } - // Generate a random number - const randomNumber = getRandomInt(1000, 9999); - - before(function () { - cy.fixture("dashboard").then(function (data) { - dashboardData = data; - }); - }); - - beforeEach(() => { - cy.login(); - cy.get('[data-test="menu-link-/dashboards-item"]').trigger("mouseover"); - cy.get('[data-test="menu-link-/dashboards-item"]') - .contains(dashboardData.ModuleDashboard) - .click(); - cy.get("table.q-table", { timeout: 3000 }).should("be.visible"); - - }); - - it("Add dashboard", () => { - // Create dynamic dashboard name - dashboardName = `${dashboardData.DashboardName}_${randomNumber}`; - console.log("==dashboardName==", dashboardName); - cy.get('[data-test="dashboard-add"]').click(); - cy.get('[data-test="dashboard-name"]').type(dashboardName); - cy.get('[data-test="dashboard-add-submit"]').click(); - cy.url().should("include", dashboardData.ViewDashboardUrl); - }); - - - it("Delete dashboard", () => { - // find the dashboard name and click on the delete dashboard button. We can see that confirm dialog and click on cancel button - cy.contains('[data-test="dashboard-table"] td', dashboardName) // gives you the cell - .siblings() // gives you all the other cells in the row - .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - .click(); - cy.get('[data-test="dashboard-confirm-dialog"]').should("be.visible"); // check that the dialog is visible - cy.wait(2000); // wait for 2ms for the dialogues - cy.get('[data-test="cancel-button"]').click(); // click on the cancel button - cy.reload(); // reload the window - cy.get('[data-test="dashboard-table"] td').should( - "contain", - dashboardName - ); - - // find the dashboard name and click on the delete dashboard button. we cab see the confirm dialog and click on the confirm button - cy.contains('[data-test="dashboard-table"] td', dashboardName) // gives you the cell - .siblings() // gives you all the other cells in the row - .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - .click(); - cy.get('[data-test="dashboard-confirm-dialog"]').should("be.visible"); // check that the dialog is visible - cy.wait(2000); // wait for 2ms for the dialogues - cy.get('[data-test="confirm-button"]').click(); // click on the confirm button - cy.wait(1000) - cy.reload(); // reload the window - cy.get('[data-test="dashboard-table"] td').should( - "not.contain", - dashboardName - ); // check that the dashboard is not available - }); - -}) diff --git a/tests/ui-testing/cypress/e2e/dashboard/Dashboard.cy.js b/tests/ui-testing/cypress/e2e/dashboard/Dashboard.cy.js deleted file mode 100644 index 71f379dd6f..0000000000 --- a/tests/ui-testing/cypress/e2e/dashboard/Dashboard.cy.js +++ /dev/null @@ -1,662 +0,0 @@ -/// -import { fieldType } from "../../support/commons"; -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); - -describe("Create a new dashboard", () => { - let dashboardData; - function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); - } - before(function () { - cy.fixture("dashboard").then(function (data) { - dashboardData = data; - }); - }); - beforeEach(() => { - // cy.origin(Cypress.env('CYPRESS_BASEURL'),{args:{dashboardData}},({dashboardData})=> - // { - cy.login(); - cy.wait(4000); - cy.get('[data-test="menu-link-/dashboards-item"]').trigger("mouseover"); - cy.get('[data-test="menu-link-/dashboards-item"]') - .contains(dashboardData.ModuleDashboard) - .click(); - // cy.wait(2000) - // cy.get('[data-test="menu-link-/dashboards-item"]').click(); - // .contains(dashboardData.ModuleDashboard) - - cy.get("table.q-table", { timeout: 3000 }).should("be.visible"); - // }) - }); - - it("Add dashboard", () => { - cy.addDashboard(); - }); - - it("Add area chart panel", () => { - cy.addAreaChartPanel(); - }); - - it("Add panel errors without fields", () => { - cy.addDashboardPanel(); - cy.get('[data-test="dashboard-apply"]').click(); - cy.get('[data-test="dashboard-error"]').should("exist"); - }); - - it("drag and drop element", () => { - cy.addDashboardPanel(); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - cy.get("[data-test='index-field-search-input']") - .click() - .clear() - .type(dashboardData.fields.XAxisValue1); - // Get the draggable element - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-${dashboardData.fields.XAxisValue1}"] [data-test="dashboard-add-data-indicator"]` - ).as("draggable"); - - // Get the droppable area - cy.get('[data-test="dashboard-x-layout"]').as("droppable"); - - cy.get("@draggable").trigger("dragstart"); - cy.get("@droppable").trigger("drop"); - - //cy.wait(5000); - cy.get('[data-test="dashboard-x-layout"]').should("contain", "_timestamp"); - - //--------------------------------------------------------- - // Get the draggable element - cy.get("[data-test='index-field-search-input']") - .click() - .clear() - .type(dashboardData.fields.YAxisValue2); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-${dashboardData.fields.YAxisValue2}"] [data-test="dashboard-add-data-indicator"]` - ).as("draggable"); - - // Get the droppable area - cy.get('[data-test="dashboard-y-layout"]').as("droppable"); - - cy.get("@draggable").trigger("dragstart"); - cy.get("@droppable").trigger("drop"); - - //cy.wait(3000); - cy.get('[data-test="dashboard-y-layout"]').should( - "contain", - dashboardData.fields.YAxisValue2 - ); - cy.addAndSavePanel(); - }); - - it("Verify query generation on the when fields are added and removed from axis", () => { - cy.addDashboardPanel(); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - - cy.get( - `[data-test="dashboard-x-item-${dashboardData.fields.XAxisValue1}-remove"]` - ).click(); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue2 - ); - - cy.get( - `[data-test="dashboard-x-item-${dashboardData.fields.XAxisValue2}-remove"]` - ).click(); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - cy.addFieldToAxis( - fieldType.Y, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue1 - ); - cy.get('[data-test="dashboard-query-data"]').click(); - cy.wait(5000); - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - console.log(text, "text"); - text = removeUTFCharacters(text); - console.log(text); - console.log(dashboardData.QueryValue); - expect(text.includes(dashboardData.QueryValue)).to.be.true; - }); - // cy.get('[data-test="dashboard-panel-query-editor"]').should( - // "have.value", - // dashboardData.QueryValue - // ) - }); - - it("should update the chart when field configurations are updated including filters", () => { - cy.addDashboardPanel(); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - cy.get( - `[data-test="dashboard-x-item-${dashboardData.fields.XAxisValue1}"]` - ).click(); - // Click to open the inner dropdown - cy.get( - `[data-test="dashboard-x-item-${dashboardData.fields.XAxisValue1}-menu"]` - ).within(() => { - cy.get('[data-test="dashboard-x-item-dropdown"]').click(); - }); - - // get the dropdown value - cy.get("div.q-item").contains("Histogram").click(); - - // change the label value - cy.get('[data-test="dashboard-x-item-input"]').clear().type("X-value"); - // Assert that the input field has the updated value - cy.get('[data-test="dashboard-x-item-input"]').should( - "have.value", - "X-value" - ); - cy.addFieldToAxis( - fieldType.Y, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue1 - ); - // add y drop down value - cy.get( - `[data-test="dashboard-y-item-${dashboardData.fields.YAxisValue1}"]` - ).click(); - // Click to open the inner dropdown - cy.get( - `[data-test="dashboard-y-item-${dashboardData.fields.YAxisValue1}-menu"]` - ).within(() => { - cy.get('[data-test="dashboard-y-item-dropdown"]') - .children() - .first() - .should("have.text", "Count"); - cy.get('[data-test="dashboard-y-item-dropdown"]').click(); - }); - // get the dropdown value - cy.get("div.q-item").contains("Sum").click(); - // change the label value - cy.get('[data-test="dashboard-y-item-input"]').clear().type("Y-value"); - // Assert that the input field has the updated value - cy.get('[data-test="dashboard-y-item-input"]').should( - "have.value", - "Y-value" - ); - // change the color picker color - cy.get('[data-test="dashboard-y-item-color"]').click(); - cy.wait(1000); - // Set the color value in the color picker dialog - cy.get('input[type="color"]').invoke("val", "#ff0000").trigger("input"); - - // Close the color picker dialog (optional, if needed) - // cy.get('input[type="color"]').blur(); - //Assert that input field color has the updated value - cy.get('[data-test="dashboard-y-item-color"]').should( - "have.value", - "#ff0000" - ); - cy.addFieldToAxis( - fieldType.F, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.FilterValue1 - ); - cy.get( - `[data-test="dashboard-filter-item-${dashboardData.fields.FilterValue1}"]` - ).click(); - cy.get( - `[data-test="dashboard-filter-item-${dashboardData.fields.FilterValue1}-menu"] .q-tab[data-test="dashboard-filter-list-tab"]` - ).click(); - // get the dropdown value - cy.get( - '[data-test="dashboard-filter-list-panel"] [data-test="dashboard-filter-list-dropdown"]' - ).click(); - // select check box value - cy.get("div.q-item__section") - .contains(dashboardData.FilterDropdownValue) - .as("filter-checkbox"); - cy.get("@filter-checkbox").click({ force: true }); - cy.intercept("POST", dashboardData.SearchQuery).as("search"); - cy.get('[data-test="dashboard-apply"]').click(); - cy.wait(2000); - cy.get('[data-test="dashboard-error"]').should("not.exist"); - cy.wait("@search", { timeout: 3000 }) - .its("response.statusCode") - .should("eq", 200); - cy.get("@search").its("response.body.hits").should("be.an", "array"); - // cy.wait("@search").then(({ response }) => { - // expect(response.statusCode).to.eq(200); - // expect(response.body.hits).to.be.an("array"); - // }); - cy.get("#chart1").should("exist").and("be.visible"); - cy.get("[data-test='dashboard-x-label']").should( - "contain", - dashboardData.filterLabel.XLabel - ); - cy.get("[data-test='dashboard-y-label']").should( - "contain", - dashboardData.filterLabel.YLabel - ); - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - // console.log(text, "text"); - // let modifiedQueryString = queryString.replace(/_1/g, ""); - // console.log(modifiedQueryString,"modifiedQueryString"); - const expectedString = dashboardData.FilterQueryValue; - // console.log(expectedString, "expectedString"); - expect(text.includes(expectedString)).to.be.true; - }); - - }); - - it("should update the value automatically when trying to save the chart after switching from the auto to custom mode", () => { - cy.addDashboardPanel(); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - // check for the auto field generated - cy.get('[data-test="dashboard-auto"]'); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - cy.addFieldToAxis( - fieldType.Y, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue1 - ); - cy.get('[data-test="dashboard-panel-query-editor"]').should("exist"); - cy.wait(5000); - cy.get('[data-test="dashboard-query-data"]').click({ force: true }); - // assertion for value is added on the editor when = is clicked - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - console.log(text, "text"); - // let modifiedQueryString = queryString.replace(/_1/g, ""); - // console.log(modifiedQueryString,"modifiedQueryString"); - const expectedString = dashboardData.QueryValue; - console.log(expectedString, "expectedString"); - expect(text.includes(expectedString)).to.be.true; - }); - // check for the custom sql button - cy.get('[data-test="dashboard-customSql"]').click(); - // Assertion for field is automatically on the x-axis and y-axis layout - cy.get('[data-test="dashboard-x-layout"]').should( - "contain", - dashboardData.customQueryValue.field1 - ); - cy.get('[data-test="dashboard-y-layout"]').should( - "contain", - dashboardData.customQueryValue.field2 - ); - // cy.get('[data-test="dashboard-query-data"]').click({force:true}); - cy.get('[data-test="dashboard-panel-query-editor"]') - .contains(dashboardData.customQueryValue.field1) // Find the specific word within the editor - .click({ force: true }) - .wait(100) - .type(`{ctrl+d}{ctrl+d}{ctrl+d}${dashboardData.addCustomQueryValue.field1}`, { force: true }); // Select the desired text - - // cy.get('[data-test="dashboard-x-layout"]').should( - // "contain", - // dashboardData.addCustomQueryValue.field1 - // ); - const updatedQuery = `SELECT histogram(_timestamp) as "${dashboardData.addCustomQueryValue.field1}", count(code) as "${dashboardData.customQueryValue.field2}" FROM "default" GROUP BY ${dashboardData.addCustomQueryValue.field1} ORDER BY ${dashboardData.addCustomQueryValue.field1}`; - // console.log(updatedQuery); - cy.intercept("POST", dashboardData.SearchQuery).as("search"); - cy.wait(2000); - cy.get('[data-test="dashboard-error"]').should("not.exist"); - cy.get('[data-test="dashboard-apply"]').click(); - cy.get('[data-test="dashboard-panel-query-editor"]').should( - "contain", - updatedQuery - ); - cy.wait("@search", { timeout: 5000 }).then(({ response }) => { - expect(response.statusCode).to.eq(200); - expect(response.body.hits).to.be.an("array"); - }); - cy.get("#chart1").should("exist").and("be.visible"); - cy.get("[data-test='dashboard-x-label']").should( - "contain", - dashboardData.XLabel - ); - cy.get("[data-test='dashboard-y-label']").should( - "contain", - dashboardData.YLabel - ); - }); - - // it("should be able to generate chart with custom query mode after switching from the auto mode", () => { - // cy.addDashboardPanel(); - // cy.get( - // `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - // ).click(); - - // // check for the auto field generated - // cy.get('[data-test="dashboard-auto"]'); - // cy.selectStream(dashboardData.Stream); - // cy.addFieldToAxis( - // fieldType.X, - // dashboardData.StreamType, - // dashboardData.Stream, - // dashboardData.fields.XAxisValue1 - // ); - - // cy.addFieldToAxis( - // fieldType.Y, - // dashboardData.StreamType, - // dashboardData.Stream, - // dashboardData.fields.YAxisValue1 - // ); - // cy.get('[data-test="dashboard-query"]').should( - // "contain", - // dashboardData.QueryValue - // ); - // // check for the custom sql button - // cy.get('[data-test="dashboard-customSql"]').click(); - // //check for the popup cancel button - // cy.get('[data-test="cancel-button"]').click(); - // cy.get('[data-test="dashboard-customSql"]').click(); - // cy.wait(4000); - // //check for the popup confirm button - // cy.get('[data-test="confirm-button"]').click(); - // cy.get('[data-test="dashboard-panel-searchbar"]').click(); - // cy.get('[data-test="dashboard-panel-query-editor"]') - // .click() - // .type("{selectall}{backspace}") - // .type(dashboardData.QueryValue); - // cy.get( - // `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"]` - // ).trigger("mouseover"); - // cy.get( - // `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"] [data-test="dashboard-add-x-data"]` - // ).click(); - // cy.get( - // `[data-test="field-list-item-logs-${dashboardData.Stream}-y_axis_1"] [data-test="dashboard-add-y-data"]` - // ).click(); - // cy.addAndSavePanel(); - // }); - it("should clear the field after switch from custom to auto mode", () => { - cy.addDashboardPanel(); - - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - - cy.get('[data-test="dashboard-customSql"]').click(); - // cy.get('[data-test="dashboard-query-data"]').click({force:true}); - cy.get('[data-test="dashboard-panel-query-editor"]').type( - dashboardData.QueryValue - ); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"]` - ).trigger("mouseover"); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"] [data-test="dashboard-add-x-data"]` - ).click(); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-y_axis_1"] [data-test="dashboard-add-y-data"]` - ).click(); - cy.get("[data-test='dashboard-auto']").click(); - cy.get('[data-test="dialog-box"]').should("be.visible"); - //check for the popup cancel button - cy.get('[data-test="cancel-button"]').click(); - cy.get('[data-test="dashboard-auto"]').click(); - // cy.wait(4000); - // check for the popup confirm button - cy.get('[data-test="confirm-button"]').click(); - cy.get('[data-test="dashboard-panel-searchbar"]').should("be.visible"); - cy.get('[data-test="dashboard-panel-query-editor"]').should( - "have.value", - "" - ); - // Assertion for the clear value in the x and y layout - cy.get( - `[data-test='dashboard-x-item-${dashboardData.customQueryValue.field1}']` - ).should("not.exist"); - cy.get( - `[data-test='dashboard-x-item-${dashboardData.customQueryValue.field2}']` - ).should("not.exist"); - }); - it("should be able to generate chart with the custom query mode", () => { - cy.addDashboardPanel(); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - - // check for the custom sql button - cy.get('[data-test="dashboard-customSql"]').click(); - // //check for the popup cancel button - // cy.get('[data-test="cancel-button"]').click(); - // cy.get('[data-test="dashboard-customSql"]').click(); - // // cy.wait(4000); - // //check for the popup confirm button - // cy.get('[data-test="confirm-button"]').click(); - // cy.get('[data-test="dashboard-query-data"]').click({ force: true }); - cy.get('[data-test="dashboard-panel-query-editor"]').type( - dashboardData.QueryValue - ); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"]` - ).trigger("mouseover"); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"] [data-test="dashboard-add-x-data"]` - ).click(); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-y_axis_1"] [data-test="dashboard-add-y-data"]` - ).click(); - cy.addAndSavePanel(); - }); - it("should display error when add new chartype with existing chart type value", () => { - cy.addDashboardPanel(); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - cy.addFieldToAxis( - fieldType.Y, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue1 - ); - cy.addFieldToAxis( - fieldType.Y, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue2 - ); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType2}-item"]` - ).click(); - cy.get('[data-test="dashboard-panel-name"]').type( - dashboardData.DashboardPanelName - ); - cy.get('[data-test="dashboard-panel-save"]').click(); - cy.get('[data-test="dashboard-error"] ul > li') - .contains("Only one values field is allowed for donut and pie charts") - .should("exist"); - }); - it("Delete dashboard", () => { - cy.get('[data-test="dashboard-table"]') // Assuming your table is represented by the element - .should("be.visible"); // Ensure the table is visible on the page - // find the dashboard name and click on the delete dashboard button. We can see that confirm dialog and click on cancel button - cy.get('[data-test="dashboard-table"]') // Step 1: Locate the table element - .find("tr") // Step 2: Select all rows - .eq(6) // Step 2: Select the 6th row (zero-based) - .should("exist") // Step 3: Assert that the row exists - .within(() => { - // Perform actions or assertions on the row's contents - // For example, check if a specific cell contains expected text - cy.get('[data-test="dashboard-delete"]').click(); - }); - // cy.get('[data-test="dashboard-table"] td') - // .first() - // .trigger("mouseover", { force: true }) - // .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - // .click(); - // cy.contains('[data-test="dashboard-table"] td', dashboardData.DashboardName) // gives you the cell - // .siblings() // gives you all the other cells in the row - // .first() - // .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - // .click(); - cy.get('[data-test="dashboard-confirm-dialog"]').should("be.visible"); // check that the dialog is visible - cy.wait(2000); // wait for 2ms for the dialogues - cy.get('[data-test="cancel-button"]').click(); // click on the cancel button - cy.reload(); // reload the window - cy.get('[data-test="dashboard-table"] td').should( - "contain", - dashboardData.DashboardName - ); - - // find the dashboard name and click on the delete dashboard button. we cab see the confirm dialog and click on the confirm button - // cy.contains('[data-test="dashboard-table"] td', dashboardData.DashboardName) // gives you the cell - // .siblings() // gives you all the other cells in the row - // .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - // .click(); - cy.get('[data-test="dashboard-table"]') // Step 1: Locate the table element - .find("tr") // Step 2: Select all rows - .eq(6) // Step 2: Select the 6th row (zero-based) - .should("exist") // Step 3: Assert that the row exists - .within(() => { - // Perform actions or assertions on the row's contents - // For example, check if a specific cell contains expected text - cy.get('[data-test="dashboard-delete"]').click(); - }); - cy.get('[data-test="dashboard-confirm-dialog"]').should("be.visible"); // check that the dialog is visible - cy.wait(2000); // wait for 2ms for the dialogues - cy.get('[data-test="confirm-button"]').click(); // click on the confirm button - cy.reload(); // reload the window - cy.wait(5000); - - // cy.get('[data-test="dashboard-table"] td').should( - // "not.contain", - // dashboardData.DashboardName - // ); // check that the dashboard is not available - }); - - it.skip("Delete All", () => { - cy.get('[data-test="dashboard-table"]') - .find("td") - .filter((index, element) => - Cypress.$(element).text().includes(dashboardData.DashboardName) - ) - .each((item) => { - console.log("==", item); - // cy.wrap(item).contains(dashboardData.DashboardName).then(($el)=>{ - cy.wrap(item) - .siblings() - .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - .click(); - cy.get('[data-test="confirm-button"]').click(); - // }) - }); - }); - - // it("should add multiple charts in dashboard", () => { - // addDashboard(); - // cy.get( - // `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - // ).click(); - // selectStream(dashboardData.Stream); - // addFieldToAxis( - // fieldType.X, - // dashboardData.StreamType, - // dashboardData.Stream, - // dashboardData.fields.XAxisValue1 - // ); - // addFieldToAxis( - // fieldType.Y, - // dashboardData.StreamType, - // dashboardData.Stream, - // dashboardData.fields.YAxisValue1 - // ); - // cy.intercept("POST", dashboardData.SearchQuery).as("search"); - // cy.get('[data-test="dashboard-apply"]').click(); - // cy.wait(2000); - // cy.get('[data-test="dashboard-error"]').should("not.exist"); - // cy.wait("@search").then(({ response }) => { - // expect(response.statusCode).to.eq(200); - // expect(response.body.hits).to.be.an("array"); - // }); - // cy.get("#chart1").should("exist").and("be.visible"); - // cy.get('[data-test="dashboard-panel-name"]').type( - // dashboardData.DashboardPanelName - // ); - // cy.get('[data-test="dashboard-panel-save"]').click(); - // cy.url().should("include", dashboardData.ViewDashboardUrl); - // cy.get('[data-test="dashboard-panel-add"]').click(); - // cy.url().should("include", dashboardData.AddPanel); - // cy.get( - // `[data-test="selected-chart-${dashboardData.ChartType2}-item"]` - // ).click(); - // selectStream(dashboardData.Stream); - // addFieldToAxis( - // fieldType.X, - // dashboardData.StreamType, - // dashboardData.Stream, - // dashboardData.fields.XAxisValue2 - // ); - // addFieldToAxis( - // fieldType.Y, - // dashboardData.StreamType, - // dashboardData.Stream, - // dashboardData.fields.YAxisValue2 - // ); - // cy.intercept("POST", dashboardData.SearchQuery).as("search"); - // cy.get('[data-test="dashboard-apply"]').click(); - // cy.wait(2000); - // cy.get('[data-test="dashboard-error"]').should("not.exist"); - // cy.wait("@search").then(({ response }) => { - // expect(response.statusCode).to.eq(200); - // expect(response.body.hits).to.be.an("array"); - // }); - // cy.get("#chart1").should("exist").and("be.visible"); - // cy.get('[data-test="dashboard-panel-name"]').type( - // dashboardData.DashboardPanelName - // ); - // cy.get('[data-test="dashboard-panel-save"]').click(); - // cy.url().should("include", dashboardData.ViewDashboardUrl); - // }); -}); diff --git a/tests/ui-testing/cypress/e2e/dashboard/EditDashboard.cy.js b/tests/ui-testing/cypress/e2e/dashboard/EditDashboard.cy.js deleted file mode 100644 index 90eaa9c58b..0000000000 --- a/tests/ui-testing/cypress/e2e/dashboard/EditDashboard.cy.js +++ /dev/null @@ -1,651 +0,0 @@ -/// -import { fieldType } from "../../support/commons"; -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); - -describe("Create a new dashboard", () => { - let dashboardData; - function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); - } - before(function () { - cy.fixture("dashboard").then(function (data) { - dashboardData = data; - }); - }); - function editDashboard(panelname) { - //click on dashboard name - cy.contains( - '[data-test="dashboard-table"] td', - dashboardData.DashboardName - ).click(); - cy.url().should("include", dashboardData.ViewDashboardUrl); - // Click on edit dashboard panel - cy.wait(2000); - cy.get( - '[data-test="dashboard-edit-panel-' + panelname + '-dropdown"]' - ).click(); - cy.get('[data-test="dashboard-edit-panel"]').click(); - cy.url().should("include", dashboardData.AddPanel); - } - beforeEach(() => { - cy.login(); - // cy.origin(Cypress.env('CYPRESS_BASEURL'),{args:{dashboardData}},({dashboardData})=> - // { - cy.get('[data-test="menu-link-/dashboards-item"]').trigger("mouseover"); - cy.get('[data-test="menu-link-/dashboards-item"]') - .contains(dashboardData.ModuleDashboard) - .click(); - cy.get("table.q-table", { timeout: 30000 }).should("be.visible"); - // }) - }); - - it("Add dashboard", () => { - cy.addDashboard(); - }); - - it("Add area chart panel", () => { - cy.addAreaChartPanel(); - }); - - it("Edit area chart panel", () => { - editDashboard(dashboardData.DashboardPanelName); - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue1 + - '-remove"]' - ).click(); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue3 - ); - cy.editAndSavePanel(); - }); - - it("Edit panel errors without fields", () => { - editDashboard(dashboardData.EditPanelName); - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue3 + - '-remove"]' - ).click(); - cy.get( - '[data-test="dashboard-y-item-' + - dashboardData.fields.YAxisValue1 + - '-remove"]' - ).click(); - cy.get('[data-test="dashboard-apply"]').click(); - cy.get('[data-test="dashboard-error"]').should("exist"); - }); - - it("drag and drop element", () => { - editDashboard(dashboardData.EditPanelName); - //select bar chart - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - - // remove x and y axis values - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue3 + - '-remove"]' - ).click(); - cy.get( - '[data-test="dashboard-y-item-' + - dashboardData.fields.YAxisValue1 + - '-remove"]' - ).click(); - // search field value - cy.get("[data-test='index-field-search-input']") - .click() - .clear() - .type(dashboardData.fields.XAxisValue1); - // Get the draggable element - cy.get( - '[data-test="field-list-item-' + - dashboardData.StreamType + - "-" + - dashboardData.Stream + - "-" + - dashboardData.fields.XAxisValue1 + - '"] [data-test="dashboard-add-data-indicator"]' - ).as("draggable"); - - // Get the droppable area - cy.get('[data-test="dashboard-x-layout"]').as("droppable"); - - cy.get("@draggable").trigger("dragstart"); - cy.get("@droppable").trigger("drop"); - - cy.wait(5000); - cy.get('[data-test="dashboard-x-layout"]').should( - "contain", - dashboardData.fields.XAxisValue1 - ); - - //--------------------------------------------------------- - // Get the draggable element - cy.get("[data-test='index-field-search-input']") - .click() - .clear() - .type(dashboardData.fields.YAxisValue2); - cy.get( - '[data-test="field-list-item-' + - dashboardData.StreamType + - "-" + - dashboardData.Stream + - "-" + - dashboardData.fields.YAxisValue2 + - '"] [data-test="dashboard-add-data-indicator"]' - ).as("draggable"); - - // Get the droppable area - cy.get('[data-test="dashboard-y-layout"]').as("droppable"); - - cy.get("@draggable").trigger("dragstart"); - cy.get("@droppable").trigger("drop"); - - cy.wait(5000); - cy.get('[data-test="dashboard-y-layout"]').should( - "contain", - dashboardData.fields.YAxisValue2 - ); - - //------------------------------------------------------------ - cy.editAndSavePanel(); - // cy.intercept("POST", dashboardData.SearchQuery).as("search"); - // cy.get('[data-test="dashboard-apply"]').click(); - // cy.wait(2000); - // cy.get('[data-test="dashboard-error"]').should("not.exist"); - // cy.wait("@search").then(({ response }) => { - // expect(response.statusCode).to.eq(200); - // expect(response.body.hits).to.be.an("array"); - // }); - // cy.get("#chart1").should("exist").and("be.visible"); - // // cy.get('[data-test="dashboard-panel-name"]').type(dashboardData.DashboardPanelName) - // cy.get('[data-test="dashboard-panel-save"]').click(); - // cy.url().should("include", dashboardData.ViewDashboardUrl); - }); - - it("Verify query generation on the when fields are added and removed from axis", () => { - editDashboard(dashboardData.EditPanelName); - //select bar chart - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - - // remove x axis value and add other value and check query - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue1 + - '-remove"]' - ).click(); - cy.selectStream(dashboardData.Stream,dashboardData.StreamType); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue1 - ); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + dashboardData.Stream + '-'+ dashboardData.fields.YAxisValue1 +'"]' - // ).trigger("mouseover"); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType +'-' + - // dashboardData.Stream + - // '-'+ dashboardData.fields.YAxisValue1 +'"] [data-test="dashboard-add-x-data"]' - // ).click(); - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.YAxisValue1 + - '-remove"]' - ).click(); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + - // dashboardData.Stream + - // '-'+ dashboardData.fields.XAxisValue1 +'"] [data-test="dashboard-add-x-data"]' - // ).click(); - - cy.get('[data-test="dashboard-query-data"]').click(); - cy.wait(2000); - const expectedString = `SELECT histogram(_timestamp) as "x_axis_1", count(log) as "y_axis_1" FROM "default" GROUP BY x_axis_1 ORDER BY x_axis_1`; - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - // console.log(text, "text"); - text = removeUTFCharacters(text); - console.log(text,"txt"); - console.log(expectedString); - // console.log(dashboardData.QueryValue); - expect(text.includes(expectedString)).to.be.true; - }); - // cy.get('[data-test="dashboard-query"]').should( - // "contain", - // dashboardData.QueryValue - // ); - }); - - it("Should update the chart when field configurations are updated including filters", () => { - editDashboard(dashboardData.EditPanelName); - //select bar chart - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - - cy.get( - '[data-test="dashboard-x-item-' + dashboardData.fields.XAxisValue1 + '"]' - ).click(); - // Click to open the inner dropdown - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue1 + - '-menu"]' - ).within(() => { - cy.get('[data-test="dashboard-x-item-dropdown"]').click(); - }); - - // get the dropdown value - cy.get("div.q-item").contains("Histogram").click(); - - // change the label value - cy.get('[data-test="dashboard-x-item-input"]') - .clear() - .type(dashboardData.XLabel); - // Assert that the input field has the updated value - cy.get('[data-test="dashboard-x-item-input"]').should( - "have.value", - dashboardData.XLabel - ); - - cy.get('[data-test="dashboard-x-layout"]').click(); - // add y drop down value - cy.get( - '[data-test="dashboard-y-item-' + dashboardData.fields.YAxisValue2 + '"]' - ).click(); - - // Click to open the inner dropdown - cy.get( - '[data-test="dashboard-y-item-' + - dashboardData.fields.YAxisValue2 + - '-menu"]' - ).within(() => { - cy.get('[data-test="dashboard-y-item-dropdown"]') - .children() - .first() - .should("have.text", "Count"); - cy.get('[data-test="dashboard-y-item-dropdown"]').click(); - }); - - // get the dropdown value - cy.get("div.q-item").contains("Count (Distinct)").click(); - - // change the label value - cy.get('[data-test="dashboard-y-item-input"]') - .clear() - .type(dashboardData.YLabel); - // Assert that the input field has the updated value - cy.get('[data-test="dashboard-y-item-input"]').should( - "have.value", - dashboardData.YLabel - ); - - // change the color picker color - cy.get('[data-test="dashboard-y-item-color"]').click(); - cy.wait(4000); - // Set the color value in the color picker dialog - cy.get('input[type="color"]').invoke("val", "#ff0000").trigger("input"); - - //Assert that input field color has the updated value - cy.get('[data-test="dashboard-y-item-color"]').should( - "have.value", - "#ff0000" - ); - cy.addFieldToAxis( - fieldType.F, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.FilterValue1 - ); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + dashboardData.Stream + '-'+ dashboardData.fields.FilterValue1 +'"]' - // ).trigger("mouseover"); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + - // dashboardData.Stream + - // '-'+ dashboardData.fields.FilterValue1 +'"] [data-test="dashboard-add-filter-data"]' - // ).click(); - cy.get( - '[data-test="dashboard-filter-item-' + - dashboardData.fields.FilterValue1 + - '"]' - ).click(); - cy.get( - '[data-test="dashboard-filter-item-' + - dashboardData.fields.FilterValue1 + - '-menu"] .q-tab[data-test="dashboard-filter-list-tab"]' - ).click(); - - // get the dropdown value - cy.get( - '[data-test="dashboard-filter-list-panel"] [data-test="dashboard-filter-list-dropdown"]' - ).click(); - - // select check box value - cy.get("div.q-item__section") - .contains(dashboardData.FilterDropdownValue) - .as("filter-checkbox"); - cy.get("@filter-checkbox").click({ force: true }); - - cy.intercept("POST", dashboardData.SearchQuery).as("search"); - cy.get('[data-test="dashboard-apply"]').click(); - cy.wait(2000); - cy.get('[data-test="dashboard-error"]').should("not.exist"); - cy.wait("@search").its("response.statusCode").should("eq", 200); - cy.get("@search").its("response.body.hits").should("be.an", "array"); - // cy.wait("@search").then(({ response }) => { - // expect(response.statusCode).to.eq(200); - // expect(response.body.hits).to.be.an("array"); - // }); - cy.get("#chart1").should("exist").and("be.visible"); - cy.get("#chart1").should("contain", dashboardData.XLabel); - cy.get("#chart1").should("contain", dashboardData.YLabel); - cy.get('[data-test="dashboard-query-data"]').click(); - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - console.log(text, "text"); - text = removeUTFCharacters(text); - console.log(text); - console.log(dashboardData.FilterQueryValue); - expect(text.includes(dashboardData.FilterQueryValue)).to.be.true; - }); - // cy.get('[data-test="dashboard-query"]').should( - // "contain", - // dashboardData.FilterQueryValue - // ); - }); - - it("should update the value automatically when trying to save the chart after switching from the auto to custom mode", () => { - //click on dashboard name - editDashboard(dashboardData.EditPanelName); - //select bar chart - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - - // check for the auto field generated - cy.get('[data-test="dashboard-auto"]'); - cy.get('[data-test="dashboard-query-data"]').click({ force: true }); - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - console.log(text, "text"); - // let modifiedQueryString = queryString.replace(/_1/g, ""); - // console.log(modifiedQueryString,"modifiedQueryString"); - const expectedString = dashboardData.EditQuery; - console.log(expectedString, "expectedString"); - expect(text.includes(expectedString)).to.be.true; - }); - // cy.get('[data-test="dashboard-panel-query-editor"]').should( - // "contain", - - // ); - // check for the custom sql button - cy.get('[data-test="dashboard-customSql"]').click(); - cy.wait(4000); - // Assertion for field is automatically on the x-axis and y-axis layout - cy.get('[data-test="dashboard-x-layout"]').should( - "contain", - dashboardData.customQueryValue.field1 - ); - cy.get('[data-test="dashboard-y-layout"]').should( - "contain", - dashboardData.customQueryValue.field2 - ); - // cy.get('[data-test="dashboard-panel-searchbar"]').click(); - cy.get('[data-test="dashboard-panel-query-editor"]') - .contains(dashboardData.customQueryValue.field1) // Find the specific word within the editor - .click() - .type( - `{ctrl+d}{ctrl+d}{ctrl+d}${dashboardData.editCustomQueryValue.field1}` - ); // Select the desired text - - // cy.get('[data-test="dashboard-x-layout"]').should( - // "contain", - // dashboardData.addCustomQueryValue.field1 - // ); - const updatedQuery = `SELECT histogram(_timestamp) as "${dashboardData.editCustomQueryValue.field1}", count(log) as "${dashboardData.customQueryValue.field2}" FROM "default" GROUP BY ${dashboardData.editCustomQueryValue.field1} ORDER BY ${dashboardData.editCustomQueryValue.field1}`; - console.log(updatedQuery); - cy.intercept("POST", dashboardData.SearchQuery).as("search"); - cy.wait(2000); - cy.get('[data-test="dashboard-error"]').should("not.exist"); - cy.get('[data-test="dashboard-apply"]').click(); - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - console.log(text, "text"); - // let modifiedQueryString = queryString.replace(/_1/g, ""); - // console.log(modifiedQueryString,"modifiedQueryString"); - expect(text.includes(updatedQuery)).to.be.true; - }); - cy.wait("@search", { timeout: 5000 }).then(({ response }) => { - expect(response.statusCode).to.eq(200); - expect(response.body.hits).to.be.an("array"); - }); - cy.get("#chart1").should("exist").and("be.visible"); - cy.get("[data-test='dashboard-x-label']").should( - "contain", - dashboardData.editXLabel - ); - cy.get("[data-test='dashboard-y-label']").should( - "contain", - dashboardData.editYLabel - ); - }); - it("should clear the field after switch from custom to auto mode", () => { - editDashboard(dashboardData.EditPanelName); - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - cy.selectStream(dashboardData.Stream,dashboardData.StreamType); - cy.get('[data-test="dashboard-customSql"]').click(); - // cy.get('[data-test="dashboard-panel-searchbar"]').click(); - // cy.get('[data-test="dashboard-panel-query-editor"]').type( - // dashboardData.QueryValue - // ); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"]` - ).trigger("mouseover"); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"] [data-test="dashboard-add-x-data"]` - ).click(); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-y_axis_1"]` - ).trigger("mouseover"); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-y_axis_1"] [data-test="dashboard-add-y-data"]` - ).click(); - cy.get("[data-test='dashboard-auto']").click(); - cy.get('[data-test="dialog-box"]').should("be.visible"); - //check for the popup cancel button - cy.get('[data-test="cancel-button"]').click(); - cy.get('[data-test="dashboard-auto"]').click(); - // cy.wait(4000); - // check for the popup confirm button - cy.get('[data-test="confirm-button"]').click(); - cy.get('[data-test="dashboard-panel-searchbar"]').should("be.visible"); - // Assertion for the clear value in the editor - cy.get('[data-test="dashboard-panel-query-editor"]').should( - "have.value", - "" - ); - // Assertion for the clear value in the x and y layout - cy.get( - `[data-test='dashboard-x-item-${dashboardData.customQueryValue.field1}']` - ).should("not.exist"); - cy.get( - `[data-test='dashboard-x-item-${dashboardData.customQueryValue.field2}']` - ).should("not.exist"); - }); - // it("Should be able to generate chart with custom query mode after switching from the auto mode", () => { - // //click on dashboard name - // editDashboard(dashboardData.EditPanelName); - // //select bar chart - // cy.get( - // '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - // ).click(); - - // // check for the auto field generated - // cy.get('[data-test="dashboard-auto"]'); - - // cy.get('[data-test="dashboard-query"]').should( - // "contain", - // dashboardData.QueryValue - // ); - // // check for the custom sql button - // cy.get('[data-test="dashboard-customSql"]').click(); - // //check for the popup cancel button - // cy.get('[data-test="cancel-button"]').click(); - // cy.get('[data-test="dashboard-customSql"]').click(); - // cy.wait(4000); - // //check for the popup confirm button - // cy.get('[data-test="confirm-button"]').click(); - // cy.get('[data-test="dashboard-panel-searchbar"]').click(); - // cy.get('[data-test="dashboard-panel-query-editor"]') - // .click() - // .type("{selectall}{backspace}") - // .type(dashboardData.QueryValue); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + dashboardData.Stream + '-x_axis_1"]' - // ).trigger("mouseover"); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + - // dashboardData.Stream + - // '-x_axis_1"] [data-test="dashboard-add-x-data"]' - // ).click(); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + - // dashboardData.Stream + - // '-y_axis_1"] [data-test="dashboard-add-y-data"]' - // ).click(); - // cy.editAndSavePanel(); - // // cy.intercept("POST", dashboardData.SearchQuery).as("search"); - // // cy.get('[data-test="dashboard-apply"]').click(); - // // // cy.get('[data-test="dashboard-error"]').should('exist'); - // // cy.wait(2000); - // // cy.get('[data-test="dashboard-error"]').should("not.exist"); - // // cy.wait("@search").then(({ response }) => { - // // expect(response.statusCode).to.eq(200); - // // expect(response.body.hits).to.be.an("array"); - // // }); - // // cy.get("#chart1").should("exist").and("be.visible"); - // // // cy.get('[data-test="dashboard-panel-name"]').type(dashboardData.DashboardPanelName) - // // cy.get('[data-test="dashboard-panel-save"]').click(); - // // cy.url().should("include", dashboardData.ViewDashboardUrl); - // }); - - it("Should be able to generate chart with the custom query mode", () => { - //click on dashboard name - editDashboard(dashboardData.EditPanelName); - //select bar chart - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - - // check for the custom sql button - cy.get('[data-test="dashboard-customSql"]').click(); - // cy.get('[data-test="dashboard-query-data"]').click({force: true}); - cy.get('[data-test="dashboard-panel-query-editor"]') - .click() - .type("{selectall}{backspace}") - .type(dashboardData.QueryValue); - cy.wait(4000); - cy.get( - '[data-test="field-list-item-' + - dashboardData.StreamType + - "-" + - dashboardData.Stream + - '-x_axis_1"]' - ).trigger("mouseover"); - cy.get( - '[data-test="field-list-item-' + - dashboardData.StreamType + - "-" + - dashboardData.Stream + - '-x_axis_1"] [data-test="dashboard-add-x-data"]' - ).click(); - cy.get( - '[data-test="field-list-item-' + - dashboardData.StreamType + - "-" + - dashboardData.Stream + - '-y_axis_1"] [data-test="dashboard-add-y-data"]' - ).click(); - cy.editAndSavePanel(); - // cy.intercept("POST", dashboardData.SearchQuery).as("search"); - // cy.get('[data-test="dashboard-apply"]').click(); - // cy.wait(2000); - // cy.get('[data-test="dashboard-error"]').should("not.exist"); - // cy.wait("@search").then(({ response }) => { - // expect(response.statusCode).to.eq(200); - // expect(response.body.hits).to.be.an("array"); - // }); - // cy.get("#chart1").should("exist").and("be.visible"); - // cy.get('[data-test="dashboard-panel-save"]').click(); - // cy.url().should("include", dashboardData.ViewDashboardUrl); - }); - - it("Delete panel", () => { - cy.contains( - '[data-test="dashboard-table"] td', - dashboardData.DashboardName - ).click(); - cy.url().should("include", dashboardData.ViewDashboardUrl); - cy.get( - '[data-test="dashboard-edit-panel-' + - dashboardData.EditPanelName + - '-dropdown"]' - ).click(); - cy.get('[data-test="dashboard-delete-panel"]').click(); - cy.reload(); - // cy.get('[data-test="dashboard-panel-title"]').should( - // "not.contain", - // dashboardData.EditPanelName - // ); - // cy.get('[data-test="panels-grid"]') - // .contains(dashboardData.EditPanelName) - // .should("not.be.visible"); - }); - - it.skip("Delete All", () => { - cy.get('[data-test="dashboard-table"]') - .find("td") - .filter((index, element) => - Cypress.$(element).text().includes(dashboardData.DashboardName) - ) - .each((item) => { - console.log("==", item); - // cy.wrap(item).contains(dashboardData.DashboardName).then(($el)=>{ - cy.wrap(item) - .siblings() - .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - .click(); - cy.get('[data-test="confirm-button"]').click(); - // }) - }); - }); -}); diff --git a/tests/ui-testing/cypress/e2e/tests/alerts_tests.cy.js b/tests/ui-testing/cypress/e2e/tests/alerts_tests.cy.js deleted file mode 100644 index 496d1f82b2..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/alerts_tests.cy.js +++ /dev/null @@ -1,328 +0,0 @@ -// -import * as logstests from "../allfunctions/logs"; -import logsdata from "../../../../test-data/logs_data.json" -// import logsdata from "../../data/logs_data.json"; -// import { login } from "../../support/commons" -// import { selectStreamAndStreamType } from "../../support/log-commons"; - -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); -describe("Alerts testcases", () => { - let logData; - function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); - } - - function applyQueryButton() { - // click on the run query button - // Type the value of a variable into an input field - cy.intercept("POST", logData.applyQuery).as("search"); - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // get the data from the search variable - cy.wait("@search").its("response.statusCode").should("eq", 200); - cy.get("@search").its("response.body.hits").should("be.an", "array"); - } - - before(function () { - cy.fixture("log").then(function (data) { - logData = data; - }); - console.log("--logData--", logData); - }); - - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - cy.login(); - // ("ingests logs via API", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - - // }); - cy.intercept("GET", "**/api/default/organizations**").as("allorgs"); - cy.intercept("GET", "**/api/default/functions**").as("functions"); - cy.intercept("GET", "**/api/default/alerts/templates**").as("templates"); - - - cy.visit(`web/alerts/templates??org_identifier=${Cypress.env("ORGNAME")}`); - // cy.intercept('GET', '**/api/default/_search**').as('allsearch') - }); - - it("should display Create template on destination page and clicking on it to navigate template page", () => { - cy.wait(2000); - cy.get('[data-test="alert-destinations-tab"]').click({ force: true }); - cy.wait(100); - cy.contains("Create Template").should("be.visible").click({ force: true }); - cy.contains("Add Template").should("be.visible"); - }); - - it("should display Create template on alerts page and clicking on it to navigate template page", () => { - cy.wait(2000); - cy.get('[data-test="alert-alerts-tab"]').click({ force: true }); - cy.wait(100); - cy.contains("Create Template").should("be.visible").click({ force: true }); - cy.contains("Add Template").should("be.visible"); - }); - - // This test checks if the histogram toggle button works correctly by clicking it and verifying that the chart is hidden. - it("should display error when body not added under templates", () => { - cy.wait(2000); - cy.get('[data-test="alert-template-list-add-alert-btn"]').click({ - force: true, - }); - cy.wait(100); - cy.get('[data-test="add-template-name-input"]').type("test"); - cy.get('[data-test="add-template-submit-btn"]').click({ force: true }); - cy.get(".q-notification__message") - .contains("Please fill required fields") - .should("be.visible"); - }); - - it("should display error when body added but name left blank under templates", () => { - cy.wait(2000); - cy.get('[data-test="alert-template-list-add-alert-btn"]').click({ - force: true, - }); - cy.wait(100); - cy.get(".view-line").type("test"); - cy.get('[data-test="add-template-submit-btn"]').click({ force: true }); - cy.get(".q-notification__message") - .contains("Please fill required fields") - .should("be.visible"); - }); - - it("should display error only blank spaces added under template name", () => { - cy.wait(2000); - cy.get('[data-test="alert-template-list-add-alert-btn"]').click({ - force: true, - }); - cy.wait(100); - cy.get('[data-test="add-template-name-input"]').type(" "); - cy.get('[data-test="add-template-submit-btn"]').click({ force: true }); - cy.contains("Field is required").should("be.visible"); - cy.get(".q-notification__message") - .contains("Please fill required fields") - .should("be.visible"); - }); - - it("should saved template successfully", () => { - cy.wait(2000); - cy.get('[data-test="alert-template-list-add-alert-btn"]').click({ - force: true, - }); - cy.wait(100); - cy.get('[data-test="add-template-name-input"]').type("automationalert"); - const jsonString = '{"text": "{alert_name} is active"}'; - cy.get(".view-line").type(jsonString, { parseSpecialCharSequences: false }); - cy.get('[data-test="add-template-submit-btn"]').click({ force: true }); - cy.get(".q-notification__message") - .contains("Template Saved Successfully") - .should("be.visible"); - - }); - - it("should display error when valid JSON not entered under template body", () => { - cy.wait(2000); - cy.get('[data-test="alert-template-list-add-alert-btn"]').click({ - force: true, - }); - cy.wait(100); - cy.get('[data-test="add-template-name-input"]').type("test"); - cy.get(".view-line").type("test"); - cy.get('[data-test="add-template-submit-btn"]').click({ force: true }); - cy.get(".q-notification__message") - .contains("Please enter valid JSON") - .should("be.visible"); - }); - - it("should click on add destination button and display error if user clicks directly on save", () => { - cy.wait(2000); - cy.get('[data-test="alert-destinations-tab"]').click({ force: true }); - cy.wait(100); - cy.get('[data-test="alert-destination-list-add-alert-btn"]').click({ - force: true, - }); - cy.get('[data-test="add-destination-submit-btn"]').click({ force: true }); - cy.get(".q-notification__message") - .contains("Please fill required fields") - .should("be.visible"); - }); - - it("should display error if name has only spaces under destination", () => { - cy.wait(2000); - cy.get('[data-test="alert-destinations-tab"]').click({ force: true }); - cy.wait(100); - cy.get('[data-test="alert-destination-list-add-alert-btn"]').click({ - force: true, - }); - cy.get('[data-test="add-destination-name-input"]').type(" "); - cy.get('[data-test="add-destination-submit-btn"]').click({ force: true }); - cy.contains("Field is required").should("be.visible"); - cy.get(".q-notification__message") - .contains("Please fill required fields") - .should("be.visible"); - }); - - it("should display error if name has only spaces under destination", () => { - cy.wait(2000); - cy.get('[data-test="alert-destinations-tab"]').click({ force: true }); - cy.wait(1000); - cy.get('[data-test="alert-destination-list-add-alert-btn"]').click({ - force: true, - }); - cy.wait(1000); - cy.get('[data-test="add-destination-name-input"]').type(" "); - cy.wait(1000); - cy.get('[data-test="add-destination-submit-btn"]').click({ force: true }); - - cy.get(".q-notification__message") - .contains("Please fill required fields") - .should("be.visible"); - }); - - - it("should click cancel button under destinations", () => { - cy.wait(2000); - cy.get('[data-test="alert-destinations-tab"]').click({ force: true }); - cy.wait(1000); - cy.get('[data-test="alert-destination-list-add-alert-btn"]').click({ - force: true, - }); - cy.get('[data-test="add-destination-name-input"]').type("cy-destination"); - cy.get('[data-test="add-destination-cancel-btn"]').click({ force: true }); - cy.get('[data-test="alert-destinations-tab"]').should("be.visible"); - }); - - it("should display error when stream name is not added under alerts", () => { - cy.wait(2000); - cy.get('[data-test="alert-alerts-tab"]').click({ force: true }); - cy.get('[data-test="alert-list-add-alert-btn"]').click({ force: true }); - cy.get('[data-test="add-alert-name-input"]').type("cy-alert"); - cy.get( - ".alert-stream-type > .q-field > .q-field__inner > .q-field__control > .q-field__append > .q-icon" - ).click({ force: true }); - // Find and click on the item with text 'logs' - cy.contains(".q-item__label", "logs").click({ force: true }); - cy.get('[data-test="add-alert-submit-btn"]').click({ force: true }); - cy.contains("Field is required").should("be.visible"); - }); - - - it("should display error when directly Save button clicked on alerts page", () => { - cy.wait(2000); - cy.get('[data-test="alert-alerts-tab"]').click({ force: true }); - cy.get('[data-test="alert-list-add-alert-btn"]').click({ force: true }); - cy.get('[data-test="add-alert-submit-btn"]').click({ force: true }); - cy.contains("Field is required").should("be.visible"); - }); - - it.skip("should create template, destination, logs-alerts and then delete all successfully", () => { - // cy.wait(2000); - cy.wait("@templates"); - cy.get('[data-test="alert-template-list-add-alert-btn"]').click({ - force: true, - }); - cy.wait(2000); - cy.get('[data-test="add-template-name-input"]').type("automationalertest"); - const jsonString = '{"text": "{alert_name} is active"}'; - cy.get(".view-line").type(jsonString, { parseSpecialCharSequences: false }); - cy.get('[data-test="add-template-submit-btn"]').click({ force: true }); - cy.get(".q-notification__message") - .contains("Template Saved Successfully") - .should("be.visible"); - cy.wait(2000); - cy.get('[data-test="alert-destinations-tab"]').click({ force: true }); - cy.wait(1000); - cy.get('[data-test="alert-destination-list-add-alert-btn"]').click({ - force: true, - }); - cy.get('[data-test="add-destination-name-input"]').type("cy-destinations"); - cy.get('[data-test="add-destination-template-select"]').click({ - force: true, - }); - cy.contains(".q-item__label span", "automationalertest").click(); - cy.get('[data-test="add-destination-url-input"]').type( - "https://slack.com/api" - ); - cy.get('[data-test="add-destination-method-select"]').click({ - force: true, - }); - cy.get(".q-menu").should("be.visible"); - cy.contains(".q-item__label span", "get").click(); - cy.get(".q-toggle__inner").click({ force: true }); - cy.get('[data-test="add-destination-submit-btn"]').click({ force: true }); - cy.get(".q-notification__message") - .contains("Destination saved successfully") - .should("be.visible"); - cy.wait(2000); - cy.get('[data-test="alert-alerts-tab"]').click({ force: true }); - cy.get('[data-test="alert-list-add-alert-btn"]').click({ force: true }); - cy.get('[data-test="add-alert-name-input"]').type("cy-alert"); - cy.get('[data-test="add-alert-stream-type-select"] > .q-field > .q-field__inner > .q-field__control > .q-field__append > .q-icon').click({ force: true }); - // Find and click on the item with text 'logs' - cy.contains(".q-item__label", "logs").click({ force: true }); - cy.get('[data-test="add-alert-stream-select"] > .q-field > .q-field__inner > .q-field__control > .q-field__append > .q-icon').click({ force: true }); - cy.contains(".q-item__label", "e2e_automate").click(); - cy.get('[data-test="add-alert-scheduled-alert-radio"]').click({ - force: true, - }); - cy.wait(1000); - cy.get('[data-test="alert-conditions-select-column"] > .q-field > .q-field__inner > .q-field__control > .q-field__append > .q-icon').click({ force: true }); - cy.contains(".q-item__label", "_timestamp").click(); - cy.get('[data-test="alert-conditions-operator-select"] > .q-field > .q-field__inner > .q-field__control > .q-field__append > .q-icon').click({ force: true }); - cy.contains(".q-item__label", "=").click(); - cy.get('.justify-start > .flex > .q-field').type("200"); - cy.get('[data-test="add-alert-destination-select"] > .q-field > .q-field__inner > .q-field__control > .q-field__append > .q-icon').click({ force: true }); - cy.contains(".q-item__label", "cy-destination").click(); - cy.get('[data-test="add-alert-submit-btn"]').click({ force: true }); - cy.get('[data-test$="-delete-alert"]').first().scrollIntoView(); - cy.get('[data-test$="-delete-alert"]').first().click(); - cy.get('[data-test="cancel-button"] ').click({ force: true }); - cy.get('[data-test$="-delete-alert"]').each(($button) => { - cy.wrap($button).click(); - cy.get('[data-test="confirm-button"]').click({ force: true }); - }); - cy.get('[data-test="alert-destinations-tab"]').click({ force: true }); - cy.get("tbody tr").each(($row) => { - // Delete each row - cy.wrap($row).find('[data-test*="-delete-destination"]').click(); - cy.get('[data-test="confirm-button"]').click({ force: true }); - }); - cy.get('[data-test="alert-templates-tab"]').click({ force: true }); - cy.get('tbody [data-test$="-delete-template"]').each(($button) => { - cy.wrap($button).click({force:true}).then(() => { - cy.get('[data-test="confirm-button"]').click({ force: true }); - }); - }); - }); -}); diff --git a/tests/ui-testing/cypress/e2e/tests/dashboard/add_dashboard.cy.js b/tests/ui-testing/cypress/e2e/tests/dashboard/add_dashboard.cy.js deleted file mode 100644 index 80a1fbc51a..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/dashboard/add_dashboard.cy.js +++ /dev/null @@ -1,160 +0,0 @@ -/// -import { fieldType } from "../../../support/commons"; -import logsdata from "../../../../../test-data/logs_data.json" - -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); -describe("Create a new dashboard", () => { - let dashboardData; - let dashboardName; - - function getRandomInt(min, max) { - return Math.floor(Math.random() * (max - min + 1)) + min; - } - - // Generate a random number - const randomNumber = getRandomInt(1000, 9999); - - before(function () { - cy.fixture("dashboard").then(function (data) { - dashboardData = data; - }); - }); - - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - - cy.login(); - // ("ingests logs via API", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa(`${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}`); - - - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().baseUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - cy.intercept('GET', '**/api/default/organizations**').as('allorgs'); - cy.intercept('GET', '/api/default/settings').as('settings') - cy.intercept('GET', '/api/default/folders').as('folders') - cy.intercept('GET', '**/api/default/dashboards**').as('dashboards'); - cy.get('[data-test="menu-link-/dashboards-item"]').trigger("mouseover"); - cy.get('[data-test="menu-link-/dashboards-item"]') - .contains(dashboardData.ModuleDashboard) - .click(); - cy.get("table.q-table", { timeout: 3000 }).should("be.visible") - - - }); - - it("Add dashboard", () => { - // Create dynamic dashboard name - cy.wait('@folders') - dashboardName = `${dashboardData.DashboardName}_${randomNumber}`; - console.log("==dashboardName==", dashboardName); - cy.wait('@dashboards') - cy.contains("New Dashboard").click() - cy.wait(1000) - cy.get('[data-test="add-dashboard-name"]').type(dashboardName); - cy.get('[data-test="dashboard-add-submit"]').click(); - cy.url().should("include", dashboardData.ViewDashboardUrl); - }); - - - it("Delete dashboard", () => { - - dashboardName = `${dashboardData.DashboardName}_${randomNumber}`; - console.log("==dashboardName==", dashboardName); - cy.wait('@dashboards') - cy.contains("New Dashboard").click() - cy.wait(1000) - cy.get('[data-test="add-dashboard-name"]').type(dashboardName); - cy.get('[data-test="dashboard-add-submit"]').click({force:true}); - cy.url().should("include", dashboardData.ViewDashboardUrl); - cy.wait(300) - cy.get('.flex.justify-between > :nth-child(1) > .q-btn > .q-btn__content > .q-icon').click({force:true}) - - // find the dashboard name and click on the delete dashboard button. We can see that confirm dialog and click on cancel button - - // cy.contains('[data-test="dashboard-table"] td', dashboardName) // gives you the cell - cy.get('[data-test="dashboard-delete"]:first').click({force:true}) - // cy.get('tbody > :nth-child(1) > :nth-child(2)') - // .siblings() // gives you all the other cells in the row - // .find(':nth-child(1) >> [data-test="dashboard-delete"]:first') // finds the delete button and clicks on it - // .click(); - cy.get('[data-test="dashboard-confirm-dialog"]').should("be.visible"); // check that the dialog is visible - cy.wait(2000); // wait for 2ms for the dialogues - cy.get('[data-test="cancel-button"]').click(); // click on the cancel button - cy.reload(); // reload the window - // TODO: Change locator ID here - // cy.get('[data-test="dashboard-table"] td').should( - // "contain", - // dashboardName - // ); - // TODO: Change locator ID here - // find the dashboard name and click on the delete dashboard button. we cab see the confirm dialog and click on the confirm button - // cy.contains('[data-test="dashboard-table"] td', dashboardName) // gives you the cell - // .siblings() // gives you all the other cells in the row - // .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - // .click(); - cy.get('[data-test="dashboard-delete"]:first').click({force:true}) - cy.get('[data-test="dashboard-confirm-dialog"]').should("be.visible"); // check that the dialog is visible - cy.wait(2000); // wait for 2ms for the dialogues - cy.get('[data-test="confirm-button"]').click({force:true}); // click on the confirm button - cy.wait(1000) - cy.reload(); // reload the window - // cy.get('[data-test="dashboard-table"] td').should( - // "not.contain", - // dashboardName - // ); // check that the dashboard is not available - }); - - - it("Delete All", () => { - cy.get('[data-test="dashboard-table"]') - .find("td") - .filter((index, element) => - Cypress.$(element).text().includes(dashboardData.DashboardName) - ) - .each((item) => { - console.log("==", item); - // cy.wrap(item).contains(dashboardData.DashboardName).then(($el)=>{ - cy.wrap(item) - .siblings() - .wait(2000) - .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - .click({ force: true }); - cy.get('[data-test="confirm-button"]').click(); - // }) - }); - }); - - it("should display save button disabled if dashboard name is blank", () => { - - cy.wait('@dashboards') - cy.contains("New Dashboard").click({force:true}) - cy.wait(2000) - cy.get('[data-test="add-dashboard-name"]').type(' '); - cy.get('[data-test="dashboard-add-submit"]').should('be.disabled'); - }); - -}) diff --git a/tests/ui-testing/cypress/e2e/tests/dashboard/create_dashboard.cy.js b/tests/ui-testing/cypress/e2e/tests/dashboard/create_dashboard.cy.js deleted file mode 100644 index dc58a69831..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/dashboard/create_dashboard.cy.js +++ /dev/null @@ -1,609 +0,0 @@ -/// -// import logsdata from "../../../data/logs_data.json"; -import logsdata from "../../../../../test-data/logs_data.json" - -import { fieldType } from "../../../support/commons"; -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); - -describe("Create a new dashboard", () => { - let dashboardData; - function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); - } - before(function () { - cy.fixture("dashboard").then(function (data) { - dashboardData = data; - }); - }); - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - - // cy.origin(Cypress.env('CYPRESS_BASEURL'),{args:{dashboardData}},({dashboardData})=> - // { - cy.login(); - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().baseUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - - cy.wait(4000); - cy.intercept("GET", "**/api/default/organizations**").as("allorgs"); - cy.intercept("GET", "/api/default/settings").as("settings"); - cy.intercept("GET", "/api/default/folders").as("folders"); - cy.get('[data-test="menu-link-/dashboards-item"]').trigger("mouseover"); - cy.get('[data-test="menu-link-/dashboards-item"]') - .contains(dashboardData.ModuleDashboard) - .click(); - // cy.wait(2000) - // cy.get('[data-test="menu-link-/dashboards-item"]').click(); - // .contains(dashboardData.ModuleDashboard) - - cy.get("table.q-table", { timeout: 3000 }).should("be.visible"); - - // }) - }); - - // it("Add dashboard", () => { - // cy.addDashboard(); - // }); - - it.skip("Add area chart panel", () => { - cy.addDashboard(); - cy.wait(1000); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }); - cy.wait(2000); - cy.addAreaChartPanel(); - }); - - it.skip("Add panel errors without fields", () => { - cy.addDashboard(); - cy.wait(1000); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }); - cy.wait(2000); - cy.addDashboardPanel(); - cy.get('[data-test="dashboard-apply"]').click(); - cy.get('[data-test="dashboard-error"]').should("exist"); - }); - - it.skip("drag and drop element", () => { - cy.addDashboard(); - cy.wait(1000); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }); - cy.wait(2000); - cy.addDashboardPanel(); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - cy.get("[data-test='index-field-search-input']") - .click() - .clear() - .type(dashboardData.fields.XAxisValue1); - // Get the draggable element - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-${dashboardData.fields.XAxisValue1}"] [data-test="dashboard-add-data-indicator"]` - ).as("draggable"); - - // Get the droppable area - cy.get('[data-test="dashboard-x-layout"]').as("droppable"); - - cy.get("@draggable").trigger("dragstart"); - cy.get("@droppable").trigger("drop"); - - //cy.wait(5000); - cy.get('[data-test="dashboard-x-layout"]').should("contain", "_timestamp"); - - //--------------------------------------------------------- - // Get the draggable element - cy.get("[data-test='index-field-search-input']") - .click() - .clear() - .type(dashboardData.fields.YAxisValue2); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-${dashboardData.fields.YAxisValue2}"] [data-test="dashboard-add-data-indicator"]` - ).as("draggable"); - - // Get the droppable area - cy.get('[data-test="dashboard-y-layout"]').as("droppable"); - - cy.get("@draggable").trigger("dragstart"); - cy.get("@droppable").trigger("drop"); - - //cy.wait(3000); - cy.get('[data-test="dashboard-y-layout"]').should( - "contain", - dashboardData.fields.YAxisValue2 - ); - cy.addAndSavePanel(); - }); - - it.skip("Verify query generation on the when fields are added and removed from axis", () => { - cy.addDashboard(); - cy.wait(1000); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }); - cy.wait(2000); - cy.addDashboardPanel(); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - - cy.get( - `[data-test="dashboard-x-item-${dashboardData.fields.XAxisValue1}-remove"]` - ).click(); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue2 - ); - - cy.get( - `[data-test="dashboard-x-item-${dashboardData.fields.XAxisValue2}-remove"]` - ).click(); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - cy.addFieldToAxis( - fieldType.Y, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue1 - ); - cy.get('[data-test="dashboard-query-data"]').click(); - cy.wait(5000); - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - console.log(text, "text"); - text = removeUTFCharacters(text); - console.log(text); - console.log(dashboardData.QueryValue); - expect(text.includes(dashboardData.QueryValue)).to.be.true; - }); - // cy.get('[data-test="dashboard-panel-query-editor"]').should( - // "have.value", - // dashboardData.QueryValue - // ) - }); - - it.skip("should update the chart when field configurations are updated including filters", () => { - cy.addDashboard(); - cy.get('[data-test="menu-link-/dashboards-item"]').click(); - cy.wait(2000); - cy.addDashboardPanel(); - cy.get('[data-cy="date-time-button"]').click(); - cy.get('[data-test="date-time-relative-6-w-btn"]').click(); - cy.get('[data-test="dashboard-apply"]').click(); - cy.get("div.q-item__section"); - cy.wait(3000); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - cy.get( - `[data-test="dashboard-x-item-${dashboardData.fields.XAxisValue1}"]` - ).click(); - // Click to open the inner dropdown - cy.get( - `[data-test="dashboard-x-item-${dashboardData.fields.XAxisValue1}-menu"]` - ).within(() => { - cy.get('[data-test="dashboard-x-item-dropdown"]').click(); - }); - - // get the dropdown value - cy.get("div.q-item").contains("Histogram").click(); - cy.wait(1000); - - // change the label value - cy.get('[data-test="dashboard-x-item-input"]', {timeout:2000}).clear().type("X-value"); - // Assert that the input field has the updated value - cy.get('[data-test="dashboard-x-item-input"]').should( - "have.value", - "X-value" - ); - cy.addFieldToAxis( - fieldType.Y, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue1 - ); - // add y drop down value - cy.get( - `[data-test="dashboard-y-item-${dashboardData.fields.YAxisValue1}"]` - ).click(); - // Click to open the inner dropdown - cy.get( - `[data-test="dashboard-y-item-${dashboardData.fields.YAxisValue1}-menu"]` - ).within(() => { - cy.get('[data-test="dashboard-y-item-dropdown"]') - .children() - .first() - .should("have.text", "Count"); - cy.get('[data-test="dashboard-y-item-dropdown"]').click(); - }); - // get the dropdown value - cy.get("div.q-item").contains("Sum").click(); - // change the label value - cy.get('[data-test="dashboard-y-item-input"]').clear().type("Y-value"); - // Assert that the input field has the updated value - cy.get('[data-test="dashboard-y-item-input"]').should( - "have.value", - "Y-value" - ); - // change the color picker color - cy.get('[data-test="dashboard-y-item-color"]').click(); - cy.wait(1000); - // Set the color value in the color picker dialog - cy.get('input[type="color"]').invoke("val", "#ff0000").trigger("input"); - - // Close the color picker dialog (optional, if needed) - // cy.get('input[type="color"]').blur(); - //Assert that input field color has the updated value - cy.get('[data-test="dashboard-y-item-color"]').should( - "have.value", - "#ff0000" - ); - cy.addFieldToAxis( - fieldType.F, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.FilterValue1 - ); - cy.get( - `[data-test="dashboard-filter-item-${dashboardData.fields.FilterValue1}"]` - ).click(); - cy.get( - `[data-test="dashboard-filter-item-${dashboardData.fields.FilterValue1}-menu"] .q-tab[data-test="dashboard-filter-list-tab"]` - ).click(); - // get the dropdown value - cy.get( - '[data-test="dashboard-filter-list-panel"] [data-test="dashboard-filter-list-dropdown"]' - ).click(); - // select check box value - cy.get("div.q-item__section") - .contains(dashboardData.FilterDropdownValue) - .as("filter-checkbox"); - cy.get("@filter-checkbox").click({ force: true }); - cy.intercept("POST", dashboardData.SearchQuery).as("search"); - cy.get('[data-test="dashboard-apply"]').click(); - cy.wait(2000); - cy.get('[data-test="dashboard-error"]').should("not.exist"); - cy.wait("@search", { timeout: 3000 }) - .its("response.statusCode") - .should("eq", 200); - cy.get("@search").its("response.body.hits").should("be.an", "array"); - // cy.wait("@search").then(({ response }) => { - // expect(response.statusCode).to.eq(200); - // expect(response.body.hits).to.be.an("array"); - // }); - cy.get("#chart1").should("exist").and("be.visible"); - // cy.get('[data-test="dashboard-x-item-_timestamp"]').click() - // cy.get('[data-test="dashboard-x-item-input"]') - // .contains("X-value") - - // cy.get("[data-test='dashboard-y-label']").should( - // "contain", - // dashboardData.filterLabel.YLabel - // ); - // cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - // let text = editor.text(); - // text = removeUTFCharacters(text); - // // console.log(text, "text"); - // // let modifiedQueryString = queryString.replace(/_1/g, ""); - // // console.log(modifiedQueryString,"modifiedQueryString"); - // const expectedString = dashboardData.FilterQueryValue; - // // console.log(expectedString, "expectedString"); - // expect(text.includes(expectedString)).to.be.true; - // }); - }); - - it.skip("should update the value automatically when trying to save the chart after switching from the auto to custom mode", () => { - cy.addDashboard(); - cy.wait(1000); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }); - cy.wait(2000); - cy.addDashboardPanel(); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - // check for the auto field generated - cy.get('[data-test="dashboard-auto"]'); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - cy.addFieldToAxis( - fieldType.Y, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue1 - ); - cy.get('[data-test="dashboard-panel-query-editor"]').should("exist"); - cy.wait(5000); - cy.get('[data-test="dashboard-query-data"]').click({ force: true }); - // assertion for value is added on the editor when = is clicked - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - console.log(text, "text"); - // let modifiedQueryString = queryString.replace(/_1/g, ""); - // console.log(modifiedQueryString,"modifiedQueryString"); - const expectedString = dashboardData.QueryValue; - console.log(expectedString, "expectedString"); - expect(text.includes(expectedString)).to.be.true; - }); - // check for the custom sql button - cy.get('[data-test="dashboard-customSql"]').click(); - // Assertion for field is automatically on the x-axis and y-axis layout - cy.get('[data-test="dashboard-x-layout"]').should( - "contain", - dashboardData.customQueryValue.field1 - ); - cy.get('[data-test="dashboard-y-layout"]').should( - "contain", - dashboardData.customQueryValue.field2 - ); - // cy.get('[data-test="dashboard-query-data"]').click({force:true}); - cy.get('[data-test="dashboard-panel-query-editor"]') - .contains(dashboardData.customQueryValue.field1) // Find the specific word within the editor - .click({ force: true }) - .wait(100) - .type(`{cmd+d}{cmd+d}{cmd+d}${dashboardData.addCustomQueryValue.field1}`); // Select the desired text - - // cy.get('[data-test="dashboard-x-layout"]').should( - // "contain", - // dashboardData.addCustomQueryValue.field1 - // ); - const updatedQuery = `SELECT histogram(_timestamp) as "${dashboardData.addCustomQueryValue.field1}", count(code) as "${dashboardData.customQueryValue.field2}" FROM "e2e_automate" GROUP BY ${dashboardData.addCustomQueryValue.field1} ORDER BY ${dashboardData.addCustomQueryValue.field1} ASC`; - // console.log(updatedQuery); - cy.intercept("POST", dashboardData.SearchQuery).as("search"); - cy.wait(2000); - cy.get('[data-test="dashboard-error"]').should("not.exist"); - cy.get('[data-test="dashboard-apply"]').click(); - cy.get('[data-test="dashboard-panel-query-editor"]').contains(updatedQuery) - // should( - // "contain", - // updatedQuery - // ); - cy.wait("@search", { timeout: 5000 }).then(({ response }) => { - expect(response.statusCode).to.eq(200); - expect(response.body.hits).to.be.an("array"); - }); - // cy.get("#chart1").should("exist").and("be.visible"); - // cy.get("[data-test='dashboard-x-label']").should( - // "contain", - // dashboardData.XLabel - // ); - // cy.get("[data-test='dashboard-y-label']").should( - // "contain", - // dashboardData.YLabel - // ); - }); - - // it("should be able to generate chart with custom query mode after switching from the auto mode", () => { - // cy.addDashboardPanel(); - // cy.get( - // `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - // ).click(); - - // // check for the auto field generated - // cy.get('[data-test="dashboard-auto"]'); - // cy.selectStream(dashboardData.Stream); - // cy.addFieldToAxis( - // fieldType.X, - // dashboardData.StreamType, - // dashboardData.Stream, - // dashboardData.fields.XAxisValue1 - // ); - - // cy.addFieldToAxis( - // fieldType.Y, - // dashboardData.StreamType, - // dashboardData.Stream, - // dashboardData.fields.YAxisValue1 - // ); - // cy.get('[data-test="dashboard-query"]').should( - // "contain", - // dashboardData.QueryValue - // ); - // // check for the custom sql button - // cy.get('[data-test="dashboard-customSql"]').click(); - // //check for the popup cancel button - // cy.get('[data-test="cancel-button"]').click(); - // cy.get('[data-test="dashboard-customSql"]').click(); - // cy.wait(4000); - // //check for the popup confirm button - // cy.get('[data-test="confirm-button"]').click(); - // cy.get('[data-test="dashboard-panel-searchbar"]').click(); - // cy.get('[data-test="dashboard-panel-query-editor"]') - // .click() - // .type("{selectall}{backspace}") - // .type(dashboardData.QueryValue); - // cy.get( - // `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"]` - // ).trigger("mouseover"); - // cy.get( - // `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"] [data-test="dashboard-add-x-data"]` - // ).click(); - // cy.get( - // `[data-test="field-list-item-logs-${dashboardData.Stream}-y_axis_1"] [data-test="dashboard-add-y-data"]` - // ).click(); - // cy.addAndSavePanel(); - // }); - it.skip("should clear the field after switch from custom to auto mode", () => { - cy.addDashboard(); - cy.wait(1000); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }); - cy.wait(2000); - cy.addDashboardPanel(); - - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - - cy.get('[data-test="dashboard-customSql"]').click(); - // cy.get('[data-test="dashboard-query-data"]').click({force:true}); - cy.get('[data-test="dashboard-panel-query-editor"]',{timeout:2000}).type( - dashboardData.QueryValue - ); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"]` - ).trigger("mouseover"); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"] [data-test="dashboard-add-x-data"]` - ).click(); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-y_axis_1"] [data-test="dashboard-add-y-data"]` - ).click(); - cy.get("[data-test='dashboard-auto']").click(); - cy.get('[data-test="dialog-box"]').should("be.visible"); - //check for the popup cancel button - cy.get('[data-test="cancel-button"]').click(); - cy.get('[data-test="dashboard-auto"]').click(); - // cy.wait(4000); - // check for the popup confirm button - cy.get('[data-test="confirm-button"]').click(); - cy.get('[data-test="dashboard-panel-searchbar"]').should("be.visible"); - cy.get('[data-test="dashboard-panel-query-editor"]').should( - "have.value", - "" - ); - // Assertion for the clear value in the x and y layout - cy.get( - `[data-test='dashboard-x-item-${dashboardData.customQueryValue.field1}']` - ).should("not.exist"); - cy.get( - `[data-test='dashboard-x-item-${dashboardData.customQueryValue.field2}']` - ).should("not.exist"); - }); - it.skip("should be able to generate chart with the custom query mode", () => { - cy.addDashboardPanel(); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - - // check for the custom sql button - cy.get('[data-test="dashboard-customSql"]').click(); - // //check for the popup cancel button - // cy.get('[data-test="cancel-button"]').click(); - // cy.get('[data-test="dashboard-customSql"]').click(); - // // cy.wait(4000); - // //check for the popup confirm button - // cy.get('[data-test="confirm-button"]').click(); - // cy.get('[data-test="dashboard-query-data"]').click({ force: true }); - cy.get('[data-test="dashboard-panel-query-editor"]').type( - dashboardData.QueryValue - ); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"]` - ).trigger("mouseover"); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"] [data-test="dashboard-add-x-data"]` - ).click(); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-y_axis_1"] [data-test="dashboard-add-y-data"]` - ).click(); - cy.addAndSavePanel(); - }); - it.skip("should display error when add new chartype with existing chart type value", () => { - cy.addDashboardPanel(); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType}-item"]` - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - cy.addFieldToAxis( - fieldType.Y, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue1 - ); - cy.addFieldToAxis( - fieldType.Y, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue2 - ); - cy.get( - `[data-test="selected-chart-${dashboardData.ChartType2}-item"]` - ).click(); - cy.get('[data-test="dashboard-panel-name"]').type( - dashboardData.DashboardPanelName - ); - cy.get('[data-test="dashboard-panel-save"]').click(); - cy.get('[data-test="dashboard-error"] ul > li') - .contains("Add one value field for donut and pie charts") - .should("exist"); - }); - it.skip("Delete All", () => { - cy.get('[data-test="dashboard-table"]') - .find("td") - .filter((index, element) => - Cypress.$(element).text().includes(dashboardData.DashboardName) - ) - .each((item) => { - console.log("==", item); - // cy.wrap(item).contains(dashboardData.DashboardName).then(($el)=>{ - cy.wrap(item) - .siblings() - .wait(2000) - .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - .click({ force: true }); - cy.get('[data-test="confirm-button"]').click(); - // }) - }); - }); -}); diff --git a/tests/ui-testing/cypress/e2e/tests/dashboard/drilldown.cy.js b/tests/ui-testing/cypress/e2e/tests/dashboard/drilldown.cy.js deleted file mode 100644 index 2415edd23d..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/dashboard/drilldown.cy.js +++ /dev/null @@ -1,257 +0,0 @@ -/// -import { fieldType } from "../../../support/commons"; -import {getRandomText } from "../../utils"; -import logsdata from "../../../../../test-data/logs_data.json" -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); -describe("Drilldown testcases", () => { - let dashboardData; - let dashboardName; - - function getRandomInt(min, max) { - return Math.floor(Math.random() * (max - min + 1)) + min; - } - - // Generate a random number - const randomNumber = getRandomInt(1000, 9999); - // function editDashboard(panelname) { - // //click on dashboard name - // cy.contains( - // '[data-test="dashboard-table"] td', - // dashboardData.DashboardName - // ).click({force:true}); - // cy.url().should("include", dashboardData.ViewDashboardUrl); - // // Click on edit dashboard panel - // cy.wait(5000); - // cy.get( - // '[data-test="dashboard-edit-panel-' + panelname + '-dropdown"]' - // ).click({force:true}); - // cy.get('[data-test="dashboard-edit-panel"]').click(); - // cy.url().should("include", dashboardData.AddPanel); - // } - - before(function () { - cy.fixture("dashboard").then(function (data) { - dashboardData = data; - }); - }); -function deleteDashboard(){ - cy.get('[data-test="dashboard-table"]') - .find("td") - .filter((index, element) => - Cypress.$(element).text().includes(dashboardData.DashboardName) - ) - .each((item) => { - console.log("==", item); - // cy.wrap(item).contains(dashboardData.DashboardName).then(($el)=>{ - cy.wrap(item) - .siblings() - .wait(2000) - .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - .click({ force: true }); - cy.get('[data-test="confirm-button"]').click(); - // }) - }); -} - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - - cy.login(); - // ("ingests logs via API", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa(`${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}`); - - - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().baseUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - cy.intercept('GET', '**/api/default/organizations**').as('allorgs'); - cy.intercept('GET', '/api/default/settings').as('settings') - cy.intercept('GET', '/api/default/folders').as('folders') - cy.intercept('GET', '**/api/default/dashboards**').as('dashboards'); - cy.get('[data-test="menu-link-/dashboards-item"]').trigger("mouseover"); - cy.get('[data-test="menu-link-/dashboards-item"]') - .contains(dashboardData.ModuleDashboard) - .click(); - cy.get("table.q-table", { timeout: 3000 }).should("be.visible") - - - }); - - - it.skip("Delete dashboard", () => { - - dashboardName = `${dashboardData.DashboardName}_${randomNumber}`; - console.log("==dashboardName==", dashboardName); - cy.wait('@dashboards') - cy.contains("New Dashboard").click() - cy.wait(1000) - cy.get('[data-test="add-dashboard-name"]').type(dashboardName); - cy.get('[data-test="dashboard-add-submit"]').click({force:true}); - cy.url().should("include", dashboardData.ViewDashboardUrl); - cy.wait(300) - cy.get('.flex.justify-between > :nth-child(1) > .q-btn > .q-btn__content > .q-icon').click({force:true}) - - // find the dashboard name and click on the delete dashboard button. We can see that confirm dialog and click on cancel button - - // cy.contains('[data-test="dashboard-table"] td', dashboardName) // gives you the cell - cy.get('[data-test="dashboard-delete"]:first').click({force:true}) - // cy.get('tbody > :nth-child(1) > :nth-child(2)') - // .siblings() // gives you all the other cells in the row - // .find(':nth-child(1) >> [data-test="dashboard-delete"]:first') // finds the delete button and clicks on it - // .click(); - cy.get('[data-test="dashboard-confirm-dialog"]').should("be.visible"); // check that the dialog is visible - cy.wait(2000); // wait for 2ms for the dialogues - cy.get('[data-test="cancel-button"]').click(); // click on the cancel button - cy.reload(); // reload the window - // TODO: Change locator ID here - // cy.get('[data-test="dashboard-table"] td').should( - // "contain", - // dashboardName - // ); - // TODO: Change locator ID here - // find the dashboard name and click on the delete dashboard button. we cab see the confirm dialog and click on the confirm button - // cy.contains('[data-test="dashboard-table"] td', dashboardName) // gives you the cell - // .siblings() // gives you all the other cells in the row - // .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - // .click(); - cy.get('[data-test="dashboard-delete"]:first').click({force:true}) - cy.get('[data-test="dashboard-confirm-dialog"]').should("be.visible"); // check that the dialog is visible - cy.wait(2000); // wait for 2ms for the dialogues - cy.get('[data-test="confirm-button"]').click({force:true}); // click on the confirm button - cy.wait(1000) - cy.reload(); // reload the window - // cy.get('[data-test="dashboard-table"] td').should( - // "not.contain", - // dashboardName - // ); // check that the dashboard is not available - }); - - - it("should not enable Add button on drilldown UI if name is blank", () => { - cy.addDashboard(); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - cy.addAreaChartPanel(); - cy.get('[data-test="dashboard-edit-panel-Automated Testing Panel-dropdown"] > .q-btn__content > .q-icon').click({ force: true }) - cy.get('[data-test="dashboard-edit-panel"]').click(); - cy.get("[data-test='dashboard-sidebar']").click(); - cy.get('[data-test="dashboard-addpanel-config-drilldown-add-btn"] > .q-btn__content > .block').click(); - cy.get('[data-test="dashboard-drilldown-folder-select"]').click({force: true}); - cy.get(".q-item__label").contains("default").click({force: true}); - - cy.get('[data-test="confirm-button"]').should('be.disabled'); - cy.get('[data-test="dashboard-panel-save"]').click( {force: true}); - cy.wait(2000) - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true}) - cy.wait(2000) - deleteDashboard() - - }); - - - it("should save the drilldown successfully", () => { - cy.addDashboard(); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - cy.addAreaChartPanel(); - cy.get('[data-test="dashboard-edit-panel-Automated Testing Panel-dropdown"] > .q-btn__content > .q-icon').click({ force: true }) - cy.get('[data-test="dashboard-edit-panel"]').click(); - cy.get("[data-test='dashboard-sidebar']").click(); - cy.get('[data-test="dashboard-addpanel-config-drilldown-add-btn"] > .q-btn__content > .block').click(); - cy.get('[data-test="dashboard-drilldown-folder-select"]').click(); - - cy.get(".q-item__label").contains("default").click(); - - cy.get('[data-test="dashboard-config-panel-drilldown-name"]').type('drilldown'); - cy.wait(3000) - - cy.get('[data-test="confirm-button"]').should('be.visible').click(); - cy.get('[data-test="dashboard-addpanel-config-drilldown-name-0"]').should('contain', 'drilldown'); - cy.get('[data-test="dashboard-panel-save"]').click(); - cy.wait(2000) - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - cy.wait(2000) - deleteDashboard() - - - }); - - it.skip("should save the drilldown successfully", () => { - cy.addDashboard(); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - cy.addAreaChartPanel(); - cy.get('[data-test="dashboard-edit-panel-Automated Testing Panel-dropdown"] > .q-btn__content > .q-icon').click({ force: true }) - cy.get('[data-test="dashboard-edit-panel"]').click(); - cy.get("[data-test='dashboard-sidebar']").click(); - cy.get('[data-test="dashboard-addpanel-config-drilldown-add-btn"] > .q-btn__content > .block').click(); - cy.get('[data-test="dashboard-drilldown-folder-select"]').click(); - - cy.get(".q-item__label").contains("default").click(); - - cy.get('[data-test="dashboard-config-panel-drilldown-name"]').type('drilldown'); - cy.get('[data-test="dashboard-drilldown-variable-name-0"]').type('test'); - cy.get('[data-test="dashboard-drilldown-variable-value-0"]').type('${var-test}',{parseSpecialCharSequences: false}) - - cy.wait(2000) - - cy.get('[data-test="confirm-button"]').should('be.visible').click(); - cy.get('[data-test="dashboard-addpanel-config-drilldown-name-0"]').should('contain', 'drilldown'); - cy.get('[data-test="dashboard-panel-save"]').click(); - cy.wait(2000) - cy.get("xpath///*[@data-test=\"date-time-btn\"]/span[2]").click(); - cy.get("[data-test='date-time-absolute-tab'] > span.q-btn__content").click(); - cy.get("div:nth-of-type(27) span.q-btn__content > span").click(); - cy.get('canvas[data-zr-dom-id="zr_0"]').then($canvas => { - const canvas = $canvas[0]; - // Coordinates of the drilldown dot within the canvas - const dotX = 100; // Adjust this value according to the dot's X coordinate - const dotY = 100; // Adjust this value according to the dot's Y coordinate - - // Create a custom event object with the coordinates - const event = new MouseEvent('click', { - bubbles: true, - cancelable: true, - clientX: dotX, - clientY: dotY - }); - - // Dispatch the click event on the canvas element - canvas.dispatchEvent(event); - }); - - // cy.get('canvas[data-zr-dom-id="zr_0"]').then($canvas => { - // const canvas = $canvas[0]; - // const rect = canvas.getBoundingClientRect(); // Get the position of the canvas relative to the viewport - // const x = rect.left + canvas.width / 2; // Adjust X coordinate as needed - // const y = rect.top + canvas.height / 2; // Adjust Y coordinate as needed - - // cy.wrap(canvas).trigger('mousedown', { button: 0, clientX: x, clientY: y }) - // .trigger('mouseup', { button: 0, clientX: x, clientY: y }); - // }); - // cy.wait(2000) - // cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - // cy.wait(2000) - // deleteDashboard() - - - }); -}) \ No newline at end of file diff --git a/tests/ui-testing/cypress/e2e/tests/dashboard/edit_dashboard.cy.js b/tests/ui-testing/cypress/e2e/tests/dashboard/edit_dashboard.cy.js deleted file mode 100644 index 9ae6af9b1e..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/dashboard/edit_dashboard.cy.js +++ /dev/null @@ -1,778 +0,0 @@ -/// -import { fieldType } from "../../../support/commons"; -// import logsdata from "../../../data/logs_data.json" -import logsdata from "../../../../../test-data/logs_data.json" -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); - -describe("Create a new dashboard", () => { - let dashboardData; - function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); - } - before(function () { - cy.fixture("dashboard").then(function (data) { - dashboardData = data; - }); - }); - function editDashboard(panelname) { - //click on dashboard name - cy.contains( - '[data-test="dashboard-table"] td', - dashboardData.DashboardName - ).click({force:true}); - cy.url().should("include", dashboardData.ViewDashboardUrl); - // Click on edit dashboard panel - cy.wait(3000); - cy.get( - '[data-test="dashboard-edit-panel-' + panelname + '-dropdown"]' - ).click({force:true}); - cy.get('[data-test="dashboard-edit-panel"]').click(); - cy.url().should("include", dashboardData.AddPanel); - } - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - cy.login(); - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - // cy.origin(Cypress.env('CYPRESS_BASEURL'),{args:{dashboardData}},({dashboardData})=> - // { - cy.get('[data-test="menu-link-/dashboards-item"]').trigger("mouseover"); - cy.get('[data-test="menu-link-/dashboards-item"]') - .contains(dashboardData.ModuleDashboard) - .click(); - cy.get("table.q-table", { timeout: 30000 }).should("be.visible"); - // }) - }); - -// it("Add dashboard", () => { -// cy.addDashboard(); -// }); - -// it("Add area chart panel", () => { -// cy.addAreaChartPanel(); -// }); - - it.skip("Edit area chart panel", () => { - cy.addDashboard(); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - cy.addAreaChartPanel(); - - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }); - cy.get('[data-test="menu-link-/dashboards-item"]').trigger("mouseover"); - editDashboard(dashboardData.DashboardPanelName); - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue1 + - '-remove"]' - ).click(); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue3 - ); - cy.editAndSavePanel(); - cy.wait(300) - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - - editDashboard(dashboardData.EditPanelName); - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue3 + - '-remove"]' - ).click(); - cy.get( - '[data-test="dashboard-y-item-' + - dashboardData.fields.YAxisValue1 + - '-remove"]' - ).click(); - cy.get('[data-test="dashboard-apply"]').click(); - cy.get('[data-test="dashboard-error"]').should("exist"); - - - }); - -// it("Edit panel errors without fields", () => { -// editDashboard(dashboardData.EditPanelName); -// cy.get( -// '[data-test="dashboard-x-item-' + -// dashboardData.fields.XAxisValue3 + -// '-remove"]' -// ).click(); -// cy.get( -// '[data-test="dashboard-y-item-' + -// dashboardData.fields.YAxisValue1 + -// '-remove"]' -// ).click(); -// cy.get('[data-test="dashboard-apply"]').click(); -// cy.get('[data-test="dashboard-error"]').should("exist"); -// }) - - it.skip("drag and drop element", () => { - cy.addDashboard(); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - cy.addAreaChartPanel(); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - cy.get('[data-test="menu-link-/dashboards-item"]').trigger("mouseover"); - cy.wait(200) - editDashboard(dashboardData.DashboardPanelName); - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue1 + - '-remove"]' - ).click(); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue3 - ); - cy.editAndSavePanel(); - cy.wait(200) - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - // cy.get('.flex.justify-between > :nth-child(2) > :nth-child(4)').click({force:true}) - - editDashboard(dashboardData.EditPanelName); - //select bar chart - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - - // remove x and y axis values - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue3 + - '-remove"]' - ).click(); - cy.get( - '[data-test="dashboard-y-item-' + - dashboardData.fields.YAxisValue1 + - '-remove"]' - ).click(); - // search field value - cy.get("[data-test='index-field-search-input']") - .click() - .clear() - .type(dashboardData.fields.XAxisValue1); - // Get the draggable element - cy.get( - '[data-test="field-list-item-' + - dashboardData.StreamType + - "-" + - dashboardData.Stream + - "-" + - dashboardData.fields.XAxisValue1 + - '"] [data-test="dashboard-add-data-indicator"]' - ).as("draggable"); - - // Get the droppable area - cy.get('[data-test="dashboard-x-layout"]').as("droppable"); - - cy.get("@draggable").trigger("dragstart"); - cy.get("@droppable").trigger("drop"); - - cy.wait(5000); - cy.get('[data-test="dashboard-x-layout"]').should( - "contain", - dashboardData.fields.XAxisValue1 - ); - - //--------------------------------------------------------- - // Get the draggable element - cy.get("[data-test='index-field-search-input']") - .click() - .clear() - .type(dashboardData.fields.YAxisValue2); - cy.get( - '[data-test="field-list-item-' + - dashboardData.StreamType + - "-" + - dashboardData.Stream + - "-" + - dashboardData.fields.YAxisValue2 + - '"] [data-test="dashboard-add-data-indicator"]' - ).as("draggable"); - - // Get the droppable area - cy.get('[data-test="dashboard-y-layout"]').as("droppable"); - - cy.get("@draggable").trigger("dragstart"); - cy.get("@droppable").trigger("drop"); - - cy.wait(5000); - cy.get('[data-test="dashboard-y-layout"]').should( - "contain", - dashboardData.fields.YAxisValue2 - ); - - //------------------------------------------------------------ - cy.editAndSavePanel(); - // cy.intercept("POST", dashboardData.SearchQuery).as("search"); - // cy.get('[data-test="dashboard-apply"]').click(); - // cy.wait(2000); - // cy.get('[data-test="dashboard-error"]').should("not.exist"); - // cy.wait("@search").then(({ response }) => { - // expect(response.statusCode).to.eq(200); - // expect(response.body.hits).to.be.an("array"); - // }); - // cy.get("#chart1").should("exist").and("be.visible"); - // // cy.get('[data-test="dashboard-panel-name"]').type(dashboardData.DashboardPanelName) - // cy.get('[data-test="dashboard-panel-save"]').click(); - // cy.url().should("include", dashboardData.ViewDashboardUrl); - }); - - it.skip("should verify query generation on the when fields are added and removed from axis", () => { - editDashboard(dashboardData.EditPanelName); - //select bar chart - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - - // remove x axis value and add other value and check query - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue1 + - '-remove"]' - ).click(); - cy.selectStream(dashboardData.Stream,dashboardData.StreamType); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.YAxisValue1 - ); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + dashboardData.Stream + '-'+ dashboardData.fields.YAxisValue1 +'"]' - // ).trigger("mouseover"); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType +'-' + - // dashboardData.Stream + - // '-'+ dashboardData.fields.YAxisValue1 +'"] [data-test="dashboard-add-x-data"]' - // ).click(); - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.YAxisValue1 + - '-remove"]' - ).click(); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue1 - ); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + - // dashboardData.Stream + - // '-'+ dashboardData.fields.XAxisValue1 +'"] [data-test="dashboard-add-x-data"]' - // ).click(); - - cy.get('[data-test="dashboard-query-data"]').click(); - cy.wait(2000); - const expectedString = `SELECT histogram(_timestamp) as "x_axis_1", count(log) as "y_axis_1" FROM "default" GROUP BY x_axis_1 ORDER BY x_axis_1`; - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - // console.log(text, "text"); - text = removeUTFCharacters(text); - console.log(text,"txt"); - console.log(expectedString); - // console.log(dashboardData.QueryValue); - expect(text.includes(expectedString)).to.be.true; - }); - // cy.get('[data-test="dashboard-query"]').should( - // "contain", - // dashboardData.QueryValue - // ); - }); - - it.skip("Should update the chart when field configurations are updated including filters", () => { - editDashboard(dashboardData.EditPanelName); - //select bar chart - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - - cy.get( - '[data-test="dashboard-x-item-' + dashboardData.fields.XAxisValue1 + '"]' - ).click(); - // Click to open the inner dropdown - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue1 + - '-menu"]' - ).within(() => { - cy.get('[data-test="dashboard-x-item-dropdown"]').click(); - }); - - // get the dropdown value - cy.get("div.q-item").contains("Histogram").click(); - - // change the label value - // cy.get('[data-test="dashboard-x-item-input"]') - // .clear() - // .type(dashboardData.XLabel); - - // TODO: change this when devs change the locators - // Assert that the input field has the updated value - // cy.get('[data-test="dashboard-x-item-input"]').should( - // "have.value", - // dashboardData.XLabel - // ); - - // cy.get('[data-test="dashboard-x-layout"]').click(); - // // add y drop down value - // cy.get( - // '[data-test="dashboard-y-item-' + dashboardData.fields.YAxisValue2 + '"]' - // ).click(); - - // // Click to open the inner dropdown - // cy.get( - // '[data-test="dashboard-y-item-' + - // dashboardData.fields.YAxisValue2 + - // '-menu"]' - // ).within(() => { - // cy.get('[data-test="dashboard-y-item-dropdown"]') - // .children() - // .first() - // .should("have.text", "Count"); - // cy.get('[data-test="dashboard-y-item-dropdown"]').click(); - // }); - - // // get the dropdown value - // cy.get("div.q-item").contains("Count (Distinct)").click(); - - // // change the label value - // cy.get('[data-test="dashboard-y-item-input"]') - // .clear() - // .type(dashboardData.YLabel); - // // Assert that the input field has the updated value - // cy.get('[data-test="dashboard-y-item-input"]').should( - // "have.value", - // dashboardData.YLabel - // ); - - // // change the color picker color - // cy.get('[data-test="dashboard-y-item-color"]').click(); - // cy.wait(4000); - // // Set the color value in the color picker dialog - // cy.get('input[type="color"]').invoke("val", "#ff0000").trigger("input"); - - // //Assert that input field color has the updated value - // cy.get('[data-test="dashboard-y-item-color"]').should( - // "have.value", - // "#ff0000" - // ); - // cy.addFieldToAxis( - // fieldType.F, - // dashboardData.StreamType, - // dashboardData.Stream, - // dashboardData.fields.FilterValue1 - // ); - // // cy.get( - // // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + dashboardData.Stream + '-'+ dashboardData.fields.FilterValue1 +'"]' - // // ).trigger("mouseover"); - // // cy.get( - // // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + - // // dashboardData.Stream + - // // '-'+ dashboardData.fields.FilterValue1 +'"] [data-test="dashboard-add-filter-data"]' - // // ).click(); - // cy.get( - // '[data-test="dashboard-filter-item-' + - // dashboardData.fields.FilterValue1 + - // '"]' - // ).click(); - // cy.get( - // '[data-test="dashboard-filter-item-' + - // dashboardData.fields.FilterValue1 + - // '-menu"] .q-tab[data-test="dashboard-filter-list-tab"]' - // ).click(); - - // // get the dropdown value - // cy.get( - // '[data-test="dashboard-filter-list-panel"] [data-test="dashboard-filter-list-dropdown"]' - // ).click(); - - // // select check box value - // cy.get("div.q-item__section") - // .contains(dashboardData.FilterDropdownValue) - // .as("filter-checkbox"); - // cy.get("@filter-checkbox").click({ force: true }); - - // cy.intercept("POST", dashboardData.SearchQuery).as("search"); - // cy.get('[data-test="dashboard-apply"]').click(); - // cy.wait(2000); - // cy.get('[data-test="dashboard-error"]').should("not.exist"); - // cy.wait("@search").its("response.statusCode").should("eq", 200); - // cy.get("@search").its("response.body.hits").should("be.an", "array"); - // // cy.wait("@search").then(({ response }) => { - // // expect(response.statusCode).to.eq(200); - // // expect(response.body.hits).to.be.an("array"); - // // }); - // cy.get("#chart1").should("exist").and("be.visible"); - // cy.get("#chart1").should("contain", dashboardData.XLabel); - // cy.get("#chart1").should("contain", dashboardData.YLabel); - // cy.get('[data-test="dashboard-query-data"]').click(); - // cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - // let text = editor.text(); - // console.log(text, "text"); - // text = removeUTFCharacters(text); - // console.log(text); - // console.log(dashboardData.FilterQueryValue); - // expect(text.includes(dashboardData.FilterQueryValue)).to.be.true; - // }); - // // cy.get('[data-test="dashboard-query"]').should( - // // "contain", - // // dashboardData.FilterQueryValue - // // ); - }); - - it.skip("should update the value automatically when trying to save the chart after switching from the auto to custom mode", () => { - //click on dashboard name - editDashboard(dashboardData.EditPanelName); - //select bar chart - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - - // check for the auto field generated - cy.get('[data-test="dashboard-auto"]'); - cy.get('[data-test="dashboard-query-data"]').click({ force: true }); - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - console.log(text, "text"); - // let modifiedQueryString = queryString.replace(/_1/g, ""); - // console.log(modifiedQueryString,"modifiedQueryString"); - const expectedString = dashboardData.EditQuery; - console.log(expectedString, "expectedString"); - expect(text.includes(expectedString)).to.be.true; - }); - // cy.get('[data-test="dashboard-panel-query-editor"]').should( - // "contain", - - // ); - // check for the custom sql button - cy.get('[data-test="dashboard-customSql"]').click(); - cy.wait(4000); - // Assertion for field is automatically on the x-axis and y-axis layout - cy.get('[data-test="dashboard-x-layout"]').should( - "contain", - dashboardData.customQueryValue.field1 - ); - cy.get('[data-test="dashboard-y-layout"]').should( - "contain", - dashboardData.customQueryValue.field2 - ); - // cy.get('[data-test="dashboard-panel-searchbar"]').click(); - cy.get('[data-test="dashboard-panel-query-editor"]') - .contains(dashboardData.customQueryValue.field1) // Find the specific word within the editor - .click() - .type( - `{cmd+d}{cmd+d}{cmd+d}${dashboardData.editCustomQueryValue.field1}` - ); // Select the desired text - - // cy.get('[data-test="dashboard-x-layout"]').should( - // "contain", - // dashboardData.addCustomQueryValue.field1 - // ); - const updatedQuery = 'SELECT stream as "x_axis_12", count(code) as "y_axis_1" FROM "e2e_automate" GROUP BY x_axis_12' - console.log(updatedQuery); - cy.intercept("POST", dashboardData.SearchQuery).as("search"); - cy.wait(2000); - cy.get('[data-test="dashboard-error"]').should("not.exist"); - cy.get('[data-test="dashboard-apply"]').click(); - cy.get('[data-test="dashboard-panel-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - console.log(text, "text"); - // let modifiedQueryString = queryString.replace(/_1/g, ""); - // console.log(modifiedQueryString,"modifiedQueryString"); - expect(text.includes(updatedQuery)).to.be.true; - }); - cy.wait("@search", { timeout: 5000 }).then(({ response }) => { - expect(response.statusCode).to.eq(200); - expect(response.body.hits).to.be.an("array"); - }); - cy.get("#chart1").should("exist").and("be.visible"); - // TODO: change this when devs change the locators - // cy.get("[data-test='dashboard-x-label']").should( - // "contain", - // dashboardData.editXLabel - // ); - // cy.get("[data-test='dashboard-y-label']").should( - // "contain", - // dashboardData.editYLabel - // ); - }); - it.skip("should clear the field after switch from custom to auto mode", () => { - cy.addDashboard(); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - cy.addAreaChartPanel(); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - editDashboard(dashboardData.DashboardPanelName); - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue1 + - '-remove"]' - ).click(); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue3 - ); - cy.editAndSavePanel(); - cy.wait(200) - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - editDashboard(dashboardData.EditPanelName); - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - cy.selectStream(dashboardData.Stream,dashboardData.StreamType); - cy.get('[data-test="dashboard-customSql"]').click(); - // cy.get('[data-test="dashboard-panel-searchbar"]').click(); - // cy.get('[data-test="dashboard-panel-query-editor"]').type( - // dashboardData.QueryValue - // ); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"]` - ).trigger("mouseover"); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-x_axis_1"] [data-test="dashboard-add-x-data"]` - ).click(); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-y_axis_1"]` - ).trigger("mouseover"); - cy.get( - `[data-test="field-list-item-logs-${dashboardData.Stream}-y_axis_1"] [data-test="dashboard-add-y-data"]` - ).click(); - cy.get("[data-test='dashboard-auto']").click(); - cy.get('[data-test="dialog-box"]').should("be.visible"); - //check for the popup cancel button - cy.get('[data-test="cancel-button"]').click(); - cy.get('[data-test="dashboard-auto"]').click(); - // cy.wait(4000); - // check for the popup confirm button - cy.get('[data-test="confirm-button"]').click(); - cy.get('[data-test="dashboard-panel-searchbar"]').should("be.visible"); - // Assertion for the clear value in the editor - cy.get('[data-test="dashboard-panel-query-editor"]').should( - "have.value", - "" - ); - // Assertion for the clear value in the x and y layout - cy.get( - `[data-test='dashboard-x-item-${dashboardData.customQueryValue.field1}']` - ).should("not.exist"); - cy.get( - `[data-test='dashboard-x-item-${dashboardData.customQueryValue.field2}']` - ).should("not.exist"); - }); - // it("Should be able to generate chart with custom query mode after switching from the auto mode", () => { - // //click on dashboard name - // editDashboard(dashboardData.EditPanelName); - // //select bar chart - // cy.get( - // '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - // ).click(); - - // // check for the auto field generated - // cy.get('[data-test="dashboard-auto"]'); - - // cy.get('[data-test="dashboard-query"]').should( - // "contain", - // dashboardData.QueryValue - // ); - // // check for the custom sql button - // cy.get('[data-test="dashboard-customSql"]').click(); - // //check for the popup cancel button - // cy.get('[data-test="cancel-button"]').click(); - // cy.get('[data-test="dashboard-customSql"]').click(); - // cy.wait(4000); - // //check for the popup confirm button - // cy.get('[data-test="confirm-button"]').click(); - // cy.get('[data-test="dashboard-panel-searchbar"]').click(); - // cy.get('[data-test="dashboard-panel-query-editor"]') - // .click() - // .type("{selectall}{backspace}") - // .type(dashboardData.QueryValue); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + dashboardData.Stream + '-x_axis_1"]' - // ).trigger("mouseover"); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + - // dashboardData.Stream + - // '-x_axis_1"] [data-test="dashboard-add-x-data"]' - // ).click(); - // cy.get( - // '[data-test="field-list-item-'+ dashboardData.StreamType + '-' + - // dashboardData.Stream + - // '-y_axis_1"] [data-test="dashboard-add-y-data"]' - // ).click(); - // cy.editAndSavePanel(); - // // cy.intercept("POST", dashboardData.SearchQuery).as("search"); - // // cy.get('[data-test="dashboard-apply"]').click(); - // // // cy.get('[data-test="dashboard-error"]').should('exist'); - // // cy.wait(2000); - // // cy.get('[data-test="dashboard-error"]').should("not.exist"); - // // cy.wait("@search").then(({ response }) => { - // // expect(response.statusCode).to.eq(200); - // // expect(response.body.hits).to.be.an("array"); - // // }); - // // cy.get("#chart1").should("exist").and("be.visible"); - // // // cy.get('[data-test="dashboard-panel-name"]').type(dashboardData.DashboardPanelName) - // // cy.get('[data-test="dashboard-panel-save"]').click(); - // // cy.url().should("include", dashboardData.ViewDashboardUrl); - // }); - - it.skip("Should be able to generate chart with the custom query mode", () => { - cy.addDashboard(); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - cy.addAreaChartPanel(); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - editDashboard(dashboardData.DashboardPanelName); - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - cy.get( - '[data-test="dashboard-x-item-' + - dashboardData.fields.XAxisValue1 + - '-remove"]' - ).click(); - cy.addFieldToAxis( - fieldType.X, - dashboardData.StreamType, - dashboardData.Stream, - dashboardData.fields.XAxisValue3 - ); - cy.editAndSavePanel(); - cy.wait(400) - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - //click on dashboard name - editDashboard(dashboardData.EditPanelName); - //select bar chart - cy.get( - '[data-test="selected-chart-' + dashboardData.EditChartType + '-item"]' - ).click(); - cy.selectStream(dashboardData.Stream, dashboardData.StreamType); - - // check for the custom sql button - cy.get('[data-test="dashboard-customSql"]').click(); - // cy.get('[data-test="dashboard-query-data"]').click({force: true}); - cy.get('[data-test="dashboard-panel-query-editor"]') - .click() - .type("{selectall}{backspace}") - .type(dashboardData.QueryValue); - cy.wait(4000); - cy.get( - '[data-test="field-list-item-' + - dashboardData.StreamType + - "-" + - dashboardData.Stream + - '-x_axis_1"]' - ).trigger("mouseover"); - cy.get( - '[data-test="field-list-item-' + - dashboardData.StreamType + - "-" + - dashboardData.Stream + - '-x_axis_1"] [data-test="dashboard-add-x-data"]' - ).click(); - cy.get( - '[data-test="field-list-item-' + - dashboardData.StreamType + - "-" + - dashboardData.Stream + - '-y_axis_1"] [data-test="dashboard-add-y-data"]' - ).click(); - cy.editAndSavePanel(); - // cy.intercept("POST", dashboardData.SearchQuery).as("search"); - // cy.get('[data-test="dashboard-apply"]').click(); - // cy.wait(2000); - // cy.get('[data-test="dashboard-error"]').should("not.exist"); - // cy.wait("@search").then(({ response }) => { - // expect(response.statusCode).to.eq(200); - // expect(response.body.hits).to.be.an("array"); - // }); - // cy.get("#chart1").should("exist").and("be.visible"); - // cy.get('[data-test="dashboard-panel-save"]').click(); - // cy.url().should("include", dashboardData.ViewDashboardUrl); - }); - - it.skip("Delete panel", () => { - cy.contains( - '[data-test="dashboard-table"] td', - dashboardData.DashboardName - ).click(); - cy.url().should("include", dashboardData.ViewDashboardUrl); - cy.get( - '[data-test="dashboard-edit-panel-' + - dashboardData.EditPanelName + - '-dropdown"]' - ).click(); - cy.get('[data-test="dashboard-delete-panel"]').click(); - cy.reload(); - // cy.get('[data-test="dashboard-panel-title"]').should( - // "not.contain", - // dashboardData.EditPanelName - // ); - // cy.get('[data-test="panels-grid"]') - // .contains(dashboardData.EditPanelName) - // .should("not.be.visible"); - }); - - it.skip("Delete All", () => { - cy.get('[data-test="dashboard-table"]') - .find("td") - .filter((index, element) => - Cypress.$(element).text().includes(dashboardData.DashboardName) - ) - .each((item) => { - console.log("==", item); - // cy.wrap(item).contains(dashboardData.DashboardName).then(($el)=>{ - cy.wrap(item) - .siblings() - .find('[data-test="dashboard-delete"]') // finds the delete button and clicks on it - .click(); - cy.get('[data-test="confirm-button"]').click(); - // }) - }); - }); -}); diff --git a/tests/ui-testing/cypress/e2e/tests/dashboard/folders.cy.js b/tests/ui-testing/cypress/e2e/tests/dashboard/folders.cy.js deleted file mode 100644 index f5b811c2af..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/dashboard/folders.cy.js +++ /dev/null @@ -1,213 +0,0 @@ -/// -import { fieldType } from "../../../support/commons"; -import logsdata from "../../../../../test-data/logs_data.json" -// import logsdata from "../../../data/logs_data.json"; -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); -describe("Folders testcases", () => { - let dashboardData; - let dashboardName; - const randomFolderName = `folder_${Math.floor(Math.random() * 100000)}`; - - function getRandomInt(min, max) { - return Math.floor(Math.random() * (max - min + 1)) + min; - } - - // Generate a random number - const randomNumber = getRandomInt(1000, 9999); - - before(function () { - cy.fixture("dashboard").then(function (data) { - dashboardData = data; - }); - }); - - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - - cy.login(); - // ("ingests logs via API", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().baseUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - cy.intercept("GET", "**/api/default/organizations**").as("allorgs"); - cy.intercept("GET", "/api/default/settings").as("settings"); - - cy.intercept("GET", "**/api/default/dashboards**").as("dashboards"); - cy.wait(200) - cy.get('[data-test="menu-link-/dashboards-item"]').trigger("mouseover"); - cy.get('[data-test="menu-link-/dashboards-item"]') - .contains(dashboardData.ModuleDashboard) - .click(); - cy.get("table.q-table", { timeout: 3000 }).should("be.visible"); - cy.intercept("GET", "**/api/default/folders**").as("folders"); - }); - - it("should create and delete a new folder", () => { - // Create dynamic dashboard name - cy.wait(1000); - cy.get('[data-test="dashboard-new-folder-btn"]').click({ force: true }); - cy.wait(100); - cy.get('[data-test="dashboard-folder-add-name"]') - .click({ force: true }) - .type(randomFolderName); - cy.get('[data-test="dashboard-folder-add-save"]').click({ force: true }); - cy.wait("@folders"); - cy.get('[data-test="dashboard-delete-folder-icon"]').each(($deleteIcon) => { - // Get the parent div and click the delete icon - cy.wrap($deleteIcon).parents('.q-tab').find('[data-test="dashboard-delete-folder-icon"]').click({ force: true }); - cy.get('[data-test="confirm-button"]').click({ force: true }); - }); - cy.wait(100); - cy.get(".q-notification__message") - .contains("Folder deleted successfully") - .should("be.visible"); - }); - - it("should create a dashboard within a folder and then delete dashboard and folder", () => { - // Create dynamic dashboard name - cy.wait(1000); - cy.get('[data-test="dashboard-new-folder-btn"]').click({ force: true }); - cy.wait(100); - cy.get('[data-test="dashboard-folder-add-name"]') - .click({ force: true }) - .type(randomFolderName); - cy.get('[data-test="dashboard-folder-add-save"]').click({ force: true }); - cy.get('[data-test="dashboard-add"]').click({ force: true }); - cy.contains(randomFolderName).click({ force: true }); - dashboardName = `${dashboardData.DashboardName}_${randomNumber}`; - cy.wait("@dashboards"); - cy.wait(1000); - cy.get('[data-test="dashboard-add"]').click({ force: true }); - cy.wait(2000); - cy.get('[data-test="add-dashboard-name"]').type(dashboardName); - cy.get('[data-test="dashboard-add-submit"]').click(); - cy.url().should("include", dashboardData.ViewDashboardUrl); - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }); - cy.contains(randomFolderName).click({ force: true }); - cy.wait(200); - cy.get('[data-test="dashboard-delete"]:first').click({ force: true }); - cy.get('[data-test="confirm-button"]').click({ force: true }); - cy.wait(200); - cy.get('[data-test="dashboard-delete-folder-icon"]').each(($deleteIcon) => { - // Get the parent div and click the delete icon - cy.wrap($deleteIcon).parents('.q-tab').find('[data-test="dashboard-delete-folder-icon"]').click({ force: true }); - cy.get('[data-test="confirm-button"]').click({ force: true }); - }); - cy.wait(100); - cy.get(".q-notification__message") - .contains("Folder deleted successfully") - .should("be.visible"); - }); - - it("should display error if user creates folder with only spaces under folder name", () => { - // Create dynamic dashboard name - cy.wait(1000); - cy.get('[data-test="dashboard-new-folder-btn"]').click({ force: true }); - cy.wait(100); - cy.get('[data-test="dashboard-folder-add-name"]') - .click({ force: true }) - .type(" "); - cy.get('[data-test="dashboard-folder-add-save"]').click({ force: true }); - cy.contains("Name is required").should("be.visible"); - }); - - it("should click on cancel on folder creation UI", () => { - // Create dynamic dashboard name - cy.wait(1000); - cy.get('[data-test="dashboard-new-folder-btn"]').click({ force: true }); - cy.wait(100); - cy.get('[data-test="dashboard-folder-add-cancel"]').click({ force: true }); - cy.get('[data-test="dashboard-table"] > .q-table__top').should('be.visible') - }); - - it('should create folders and move a dashboard, then delete dashboard and folders', () => { - // Function to generate a random folder name - const randomFolderName = 'Folder' + Math.floor(Math.random() * 1000); - - // Create a new folder with a random name - cy.wait(100); - cy.get('[data-test="dashboard-new-folder-btn"]').click({ force: true }); - cy.wait(100); - cy.get('[data-test="dashboard-folder-add-name"]') - .click({ force: true }) - .type(randomFolderName); - cy.get('[data-test="dashboard-folder-add-save"]').click({ force: true }); - cy.wait(100); - cy.get('[data-test="dashboard-new-folder-btn"]').click({ force: true }); - cy.wait(100); - cy.get('[data-test="dashboard-folder-add-name"]') - .click({ force: true }) - .type(randomFolderName + "move folder"); - cy.get('[data-test="dashboard-folder-add-save"]').click({ force: true }); - - // Go to the newly created folder - cy.contains(randomFolderName).click({ force: true }); - - // Create a dashboard in the new folder - cy.wait(1000); - cy.get('[data-test="dashboard-add"]').click({ force: true }); - cy.wait(1000); - cy.get('[data-test="add-dashboard-name"]').type('Dashboard in ' + randomFolderName); - cy.get('[data-test="dashboard-add-submit"]').click(); - cy.url().should("include", dashboardData.ViewDashboardUrl); - cy.get('.flex.justify-between > :nth-child(1) > .q-btn > .q-btn__content > .q-icon').click(); - cy.wait(200) - - // Move the dashboard from the new folder to Folder 2 - cy.contains('Dashboard in ' + randomFolderName) - .parent('tr') - .within(() => { - // Click on the Move to another Folder button - cy.wait(1000); - cy.get('[data-test="dashboard-move-to-another-folder"]').click({ force: true }); - }); - cy.get('.items-baseline > .q-field > .q-field__inner > .q-field__control > .q-field__append').click() - cy.get('.q-virtual-scroll__content').within(() => { - // Find the specific option and click on it - cy.contains(randomFolderName + "move folder").click({ force: true }); - }); - cy.get('[data-test="dashboard-folder-move"]').click({ force: true }); - cy.contains(randomFolderName + "move folder").click({ force: true }); - cy.wait(200); - cy.get('[data-test="dashboard-delete"]:first').click({ force: true }); - cy.get('[data-test="confirm-button"]').click({ force: true }); - cy.wait(200); - cy.get('[data-test="dashboard-delete-folder-icon"]').each(($deleteIcon) => { - // Get the parent div and click the delete icon - cy.wrap($deleteIcon).parents('.q-tab').find('[data-test="dashboard-delete-folder-icon"]').click({ force: true }); - cy.get('[data-test="confirm-button"]').click({ force: true }); - }); - cy.wait(100); - cy.get(".q-notification__message") - .contains("Folder deleted successfully") - .should("be.visible"); - - -}); -}); diff --git a/tests/ui-testing/cypress/e2e/tests/functions_tests.cy.js b/tests/ui-testing/cypress/e2e/tests/functions_tests.cy.js deleted file mode 100644 index f45ab91542..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/functions_tests.cy.js +++ /dev/null @@ -1,258 +0,0 @@ -/// -import * as logstests from "../allfunctions/logs"; -import "cypress-file-upload"; -import logsdata from "../../../../test-data/logs_data.json" -// import logsdata from "../../data/logs_data.json"; -import { getRandomText } from "../utils"; -// import { login } from "../../support/commons" -// import { selectStreamAndStreamType } from "../../support/log-commons"; -const { v4: uuidv4 } = require("uuid"); - -// Generate UUID -const uuid = uuidv4(); - -// Remove non-alphabetic characters from UUID -const alphaUuid = uuid.replace(/[^a-zA-Z]/g, ""); - -// Construct function name -const functionName = `automate${alphaUuid}`; - -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); -describe("Functions testcases", () => { - let logData; - function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); - } - - function applyQueryButton() { - // click on the run query button - // Type the value of a variable into an input field - cy.intercept("POST", logData.applyQuery).as("search"); - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // get the data from the search variable - cy.wait("@search").its("response.statusCode").should("eq", 200); - cy.get("@search").its("response.body.hits").should("be.an", "array"); - } - - before(function () { - cy.fixture("log").then(function (data) { - logData = data; - }); - console.log("--logData--", logData); - }); - - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - cy.login(); - // ("ingests logs via API", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().baseUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - - // }); - cy.intercept("GET", "**/api/default/organizations**").as("allorgs"); - cy.intercept("GET", "**/api/default/functions**").as("functions"); - - cy.visit( - `web/pipeline/functions?org_identifier=${Cypress.env("ORGNAME")}` - ); - - cy.intercept("GET", "**/api/default/streams**").as("streams"); - // cy.intercept('GET', '**/api/default/_search**').as('allsearch') - }); - - // This is a test case to navigate to the logs page - it("should display error when creating function without mandatory fields", () => { - // cy.get('[data-test="menu-link-pipeline-item"]').click({ force: true }); - cy.contains("Create new function").click({ force: true }); - cy.contains("Save").should("be.visible").click({ force: true }); - cy.contains("Field is required").should("be.visible"); - }); - - it("should display error on entering invalid name under function and save", () => { - // cy.get('[data-test="menu-link-pipeline-item"]').click({ force: true }); - cy.contains("Create new function").click({ force: true }); - cy.get(".q-pb-sm > .q-field > .q-field__inner > .q-field__control").type( - getRandomText - ); - cy.contains("Save").should("be.visible").click({ force: true }); - cy.contains("Invalid method name.").should("be.visible"); - }); - - it("should display error on entering invalid function and save", () => { - // cy.get('[data-test="menu-link-pipeline-item"]').click({ force: true }); - cy.contains("Create new function").click({ force: true }); - cy.get(".q-pb-sm > .q-field > .q-field__inner > .q-field__control").type( - functionName - ); - cy.get(".view-lines").type(".test=1"); - cy.contains("Save").should("be.visible").click({ force: true }); - cy.get(".q-notification__message") - .contains("Function saved successfully") - .should("be.visible"); - cy.get('[data-test="functions-list-search-input"]').type(functionName); - cy.get("tr") - .contains(functionName) - .parent("tr") - .within(() => { - // Click the delete button - cy.get('button[title="Delete Function"]').click(); - }); - cy.get('[data-test="confirm-button"] > .q-btn__content').click(); - }); - - it("should display error on adding function with same name", () => { - // cy.get('[data-test="menu-link-pipeline-item"]').click({ force: true }); - cy.contains("Create new function").click({ force: true }); - cy.get(".q-pb-sm > .q-field > .q-field__inner > .q-field__control").type( - functionName - ); - cy.get(".view-lines").type(".test=1"); - cy.contains("Save").should("be.visible").click({ force: true }); - cy.get(".q-notification__message") - .contains("Function saved successfully") - .should("be.visible"); - cy.contains("Create new function").click({ force: true }); - cy.get(".q-pb-sm > .q-field > .q-field__inner > .q-field__control").type( - functionName - ); - cy.get(".view-lines").type(".test=1"); - cy.contains("Save").should("be.visible").click({ force: true }); - cy.get(".q-notification__message") - .contains("Function creation failed") - .should("be.visible"); - cy.contains("Cancel").click({ force: true }); - cy.get('[data-test="functions-list-search-input"]').type(functionName); - cy.get("tr") - .contains(functionName) - .parent("tr") - .within(() => { - // Click the delete button - cy.get('button[title="Delete Function"]').click(); - }); - cy.get('[data-test="confirm-button"] > .q-btn__content').click(); - }); - - it.skip("should add a function and associate a stream with the same", () => { - cy.contains("Create new function").click({ force: true }); - cy.get(".q-pb-sm > .q-field > .q-field__inner > .q-field__control").type( - functionName - ); - cy.get(".view-lines").type(".test=1"); - cy.contains("Save").should("be.visible").click({ force: true }); - cy.get(".q-notification__message") - .contains("Function saved successfully") - .should("be.visible"); - cy.get('[data-test="function-stream-tab"]').click({ force: true }); - cy.wait(2000); - cy.get('[data-test="stream-association-search-input"]').type( - "e2e_automate" - ); - cy.get( - '[data-test="log-stream-table"] >>> :nth-child(2) > :nth-child(1) > :nth-child(2)' - ).click(); - // cy.get('[style="cursor: pointer;"] > :nth-child(3)').click({ force: true }); - cy.contains("Associate Function").click({ force: true }); - cy.get( - '[style="height: min-content; border: 1px solid black;"] > [colspan="100%"] > [style=""] > .q-table__container > .q-table__middle > .q-table > tbody > .q-tr > :nth-child(2) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container' - ).type(functionName); - cy.wait(2000); - cy.get(".q-item__label > span").click({ force: true }); - cy.wait(1000); - cy.get("tr.q-tr") - .contains(functionName) - .parent("tr") - .within(() => { - // Click the delete button - cy.get( - 'button[data-test="stream-association-delete-function-btn"]' - ).click(); - }); - cy.get( - '[href="/web/functions/functions?org_identifier=default"] > .q-tab__content' - ).click({ force: true }); - cy.get('[data-test="functions-list-search-input"]').type(functionName); - cy.get("tr") - .contains(functionName) - .parent("tr") - .within(() => { - // Click the delete button - cy.get('button[title="Delete Function"]').click(); - }); - cy.get('[data-test="confirm-button"] > .q-btn__content').click(); - }); - - it("should upload a enrichment table under functions", () => { - cy.wait(2000); - // cy.contains('Create new function').click({ force: true }) - cy.get( - '[data-test="function-enrichment-table-tab"] > .q-tab__content > .q-tab__label' - ).click({ force: true }); - cy.contains("Add Enrichment Table").click({ force: true }); - - const { v4: uuidv4 } = require("uuid"); - - cy.fixture("enrichment_info.csv").then((fileContent) => { - const fileName = `enrichment_info_${uuidv4()}.csv`; - - cy.get('input[type="file"]').attachFile({ - fileContent: fileContent.toString(), - fileName: fileName, - mimeType: "text/csv", - }); - cy.wait(5000); - cy.get(".q-input > .q-field__inner > .q-field__control").type(fileName); - cy.contains("Save").click({ force: true }); - cy.wait(3000); - cy.reload(); - // cy.get('[title="Delete Function"]').click({ force: true }); - // cy.get('[data-test="confirm-button"]').click({ force: true }); - cy.get("tbody tr").each(($row) => { - const functionName = $row.find("td.text-left:eq(1)").text(); - - - // Check if the function name contains "enrichment_info" - if (functionName.includes("enrichment_info")) { - // Click the "Delete Function" button - cy.wrap($row) - .find('[title="Delete Function"]') // finds the delete function button and clicks on it - .click(); - - // You may need to handle any confirmation dialog that appears - cy.get('[data-test="confirm-button"]').click(); - } - }); - }); - }); -}); diff --git a/tests/ui-testing/cypress/e2e/tests/logs_fastmode.cy.js b/tests/ui-testing/cypress/e2e/tests/logs_fastmode.cy.js deleted file mode 100644 index e0fbbe6910..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/logs_fastmode.cy.js +++ /dev/null @@ -1,311 +0,0 @@ -/// -import * as logstests from "../allfunctions/logs"; -import logsdata from "../../../../test-data/logs_data.json" -// import { login } from "../../support/commons" -// import { selectStreamAndStreamType } from "../../support/log-commons"; - -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); -describe("Logs testcases", () => { - let logData; - function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); - } - - function applyQueryButton() { - // click on the run query button - // Type the value of a variable into an input field - cy.intercept("POST", logData.applyQuery).as("search"); - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // get the data from the search variable - cy.wait("@search").its("response.statusCode").should("eq", 200); - cy.get("@search").its("response.body.hits").should("be.an", "array"); - cy.get("@search") - .its("response.body.hits") - .should("be.an", "array") - .then((hits) => { - console.log(hits, "hits"); - if (hits.length > 0) { - expect(Object.keys(hits[0]).length).to.be.at.most(5); - // Add more assertions if needed - } - - }); - - } - - - function quickModeOff() { - // click on the run query button - // Type the value of a variable into an input field - cy.intercept("POST", logData.applyQuery).as("search"); - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // get the data from the search variable - cy.wait("@search").its("response.statusCode").should("eq", 200); - cy.get("@search").its("response.body.hits").should("be.an", "array"); - cy.get("@search") - .its("response.body.hits") - .should("be.an", "array") - .then((hits) => { - console.log(hits, "hits"); - if (hits.length > 0) { - expect(Object.keys(hits[0]).length).greaterThan(5) - // Add more assertions if needed - } - - }); - - - - } - before(function () { - cy.fixture("log").then(function (data) { - logData = data; - }); - console.log("--logData--", logData); - }); - - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - cy.login(); - // ("ingests logs via API", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - - // }); - cy.intercept("GET", "**/api/default/organizations**").as("allorgs"); - cy.intercept("GET", "**/api/default/functions**").as("functions"); - cy.visit(`${logData.logsUrl}?org_identifier=${Cypress.env("ORGNAME")}`); - cy.intercept("POST", "**/api/default/_search**").as("allsearch"); - cy.wait("@allsearch"); - cy.selectStreamAndStreamTypeForLogs(logData.Stream); - cy.intercept("GET", "**/api/default/streams**").as("streams"); - }); - - - it("should display results for fast mode off for match all case", () => { - - cy.get('[data-test="logs-search-bar-query-editor"] > .monaco-editor') - .click() // Click on the editor to focus - .type("match_all('provide_credentials')") - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content') - cy.get('[data-test="logs-search-bar-quick-mode-toggle-btn"]').click() - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // Type the value of a variable into an input field - cy.wait(3000); - quickModeOff() - - }); - - it("should display results for fast mode off and match all", () => { - - cy.get('[data-test="logs-search-bar-query-editor"] > .monaco-editor') - .click() // Click on the editor to focus - .type("match_all('provide_credentials')") - cy.get('[data-test="logs-search-bar-quick-mode-toggle-btn"]').click() - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content') - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // Type the value of a variable into an input field - cy.wait(3000); - quickModeOff() - - }); - - - it("should display results for fast mode on and match all", () => { - - cy.get('[data-test="logs-search-bar-query-editor"] > .monaco-editor') - .click() // Click on the editor to focus - .type("match_all('provide_credentials')") - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content') - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // Type the value of a variable into an input field - cy.wait(3000); - applyQueryButton() - - }); - - it("should display results for fast mode on and match all raw ignore case", () => { - - cy.get('[data-test="logs-search-bar-query-editor"] > .monaco-editor') - .click() // Click on the editor to focus - .type("match_all_raw_ignore_case('provide_credentials')") - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content') - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // Type the value of a variable into an input field - cy.wait(3000); - applyQueryButton() - - }); - - - it("should display results for fast mode on and run query", () => { - - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content') - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // Type the value of a variable into an input field - cy.wait(3000); - applyQueryButton() - }); - - it("should display results for fast mode on with sql mode on and run query", () => { - cy.get('[aria-label="SQL Mode"]').click({force:true}) - - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content') - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // Type the value of a variable into an input field - cy.wait(3000); - applyQueryButton() - - }); - - -it("should display correct results when fast mode on", () => { - // Wait for 2 seconds - cy.wait(2000); - // Type the value of a variable into an input field - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get( - '[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block' - ).click({ - force: true, - }); - logstests.addFeildandSubValue(); - logstests.addsubFieldValue(); - //click on the field - // get the data from the value variable - cy.wait("@value", { timeout: 5000 }) - .its("response.statusCode") - .should("eq", 200); - logstests.addsubFieldValue(); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.clickFieldSubvalue(); - cy.wait(2000); - logstests.valueAddedOnPlusClick(); - cy.intercept("GET", logData.ValueQuery).as("value"); - logstests.clickOnFirstField(); - cy.wait("@value", { timeout: 4000 }) - .its("response.statusCode") - .should("eq", 200); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.addSecondFieldOnEditor(); - logstests.clickOnEqualToButton(); - logstests.bothFieldAddedOnEqualToClick(); - cy.wait(2000); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(1) - .click({ force: true }); - cy.wait(300); - cy.get( - '[data-test="log-detail-json-content"] >>> [data-test="log-details-include-exclude-field-btn"] :first' - ).click({ force: true }); - cy.get('[data-test="log-details-include-field-btn"]').click({ - force: true, - }); - cy.get('[data-test="logs-search-bar-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - const cleanedText = removeUTFCharacters(text); - // Confirm that the text contains 'code' not equal to '200' - expect(cleanedText).to.include( - "code='200' and code='200' and _timestamp=" - ); - }); - applyQueryButton(); - cy.get('[data-test="logs-search-bar-query-editor"]').type( - "{selectall}{del}" - ); - applyQueryButton(); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(2) - .click({ force: true }); - cy.wait(2000); - cy.get( - '[data-test="log-detail-json-content"] >>> [data-test="log-details-include-exclude-field-btn"] :first' - ).click({ force: true }); - cy.get('[data-test="log-details-exclude-field-btn"]', { - timeout: 2000, - }).click({ force: true }); - // cy.wait(2000); - cy.get('[data-test="logs-search-bar-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - const cleanedText = removeUTFCharacters(text); - // Confirm that the text contains 'code' not equal to '200' - expect(cleanedText).to.include("_timestamp!="); - applyQueryButton(); - cy.wait(200); - // cy.get('[data-test="[data-test="logs-search-bar-query-editor"]"]').type("{selectall}{del}"); - // applyQueryButton(); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(2) - .click({ force: true }); - cy.wait(2000); - cy.get( - '[data-test="log-detail-json-content"] >>> [data-test="log-details-include-exclude-field-btn"] :first' - ).click({ force: true }); - cy.contains("Add field to table").click({ force: true }); - applyQueryButton(); - }); - }); - - -}); diff --git a/tests/ui-testing/cypress/e2e/tests/logs_queries.cy.js b/tests/ui-testing/cypress/e2e/tests/logs_queries.cy.js deleted file mode 100644 index 6692b4d212..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/logs_queries.cy.js +++ /dev/null @@ -1,571 +0,0 @@ -/// -import * as logstests from "../allfunctions/logs"; -import logsdata from "../../../../test-data/logs_data.json" -// import logsdata from "../../data/logs_data.json"; -// import { login } from "../../support/commons" -// import { selectStreamAndStreamType } from "../../support/log-commons"; - -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); -describe("Logs testcases", () => { - let logData; - function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); - } - - function applyQueryButton() { - // click on the run query button - // Type the value of a variable into an input field - cy.intercept("POST", logData.applyQuery).as("search"); - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // get the data from the search variable - cy.wait("@search").its("response.statusCode").should("eq", 200); - cy.get("@search").its("response.body.hits").should("be.an", "array"); - } - - before(function () { - cy.fixture("log").then(function (data) { - logData = data; - }); - console.log("--logData--", logData); - }); - - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - cy.login(); - // ("ingests logs via API", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - - // }); - cy.intercept("GET", "**/api/default/organizations**").as("allorgs"); - cy.intercept("GET", "**/api/default/functions**").as("functions"); - cy.visit(`${logData.logsUrl}?org_identifier=${Cypress.env("ORGNAME")}`); - cy.intercept("POST", "**/api/default/_search**").as("allsearch"); - cy.selectStreamAndStreamTypeForLogs(logData.Stream); - applyQueryButton() - cy.wait("@allsearch"); - cy.intercept("GET", "**/api/default/streams**").as("streams"); - }); - - it.skip("should display results for limit query", () => { - cy.get('[data-test="logs-search-bar-query-editor"] > .monaco-editor') - .click() // Click on the editor to focus - .type("match_all('provide_credentials') limit 5"); - cy.wait(2000); - cy.get('[aria-label="SQL Mode"]').click({ force: true }); - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content'); - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - cy.wait(2000); - cy.get(".search-list > :nth-child(1) > .text-left").contains( - "Showing 1 to 5 out of 5" - ); - - cy.get('[aria-label="SQL Mode"]').click({ force: true }); - cy.get('[data-test="logs-search-bar-query-editor"] > .monaco-editor') - .click() // Click on the editor to focus - .type("match_all('provide_credentials')"); - cy.get('[aria-label="SQL Mode"]').click({ force: true }); - - cy.wait(2000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - cy.get('[data-test="logs-search-result-records-per-page"]').click(); - cy.get(".q-virtual-scroll__content:last").click(); - - // Select "25" from the dropdown using contains - cy.wait(2000); - cy.contains(".q-item__label", "25").should("be.visible").click(); - cy.get(".search-list > :nth-child(1) > .text-left") - .contains("Showing 1 to 5 out of 5") - .should("not.exist"); - }); - - it("should redirect to logs after clicking on stream explorer via stream page", () => { - applyQueryButton() - cy.wait(2000); - cy.get('[data-cy="index-field-search-input"]').type("code"); - - cy.get('[data-test="log-search-expand-code-field-btn"]').click(); - cy.wait(2000); - cy.get('[data-test="logs-search-subfield-add-code-200"]').click({ - force: true, - }); - cy.get('[data-cy="date-time-button"] > .q-btn__content').click(); - cy.get('[data-test="date-time-relative-15-m-btn"]').click(); - cy.get('[data-cy="search-bar-refresh-button"]').click(); - cy.get('[data-test="logs-search-saved-views-btn"]').click(); - cy.wait(2000); - cy.get('[data-test="add-alert-name-input"]').type("streamlogsnavigate"); - cy.get('[data-test="saved-view-dialog-save-btn"]').click(); - cy.get('[data-test="menu-link-/streams-item"]').click({ force: true }); - cy.get('[title="Explore"]:first').click({ force: true }); - cy.url().should("include", "logs"); - cy.wait(2000); - cy.wait("@allsearch"); - cy.get( - '[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown__arrow-container > .q-btn__content > .q-icon' - ).click({ force: true }); - cy.wait(2000); - cy.contains("streamlogsnavigate").click(); - cy.wait(200); - cy.get('[data-test="logs-search-bar-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - const cleanedText = removeUTFCharacters(text); - expect(cleanedText).to.include("code='200'"); - }); - cy.get( - '[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown__arrow-container > .q-btn__content > .q-icon' - ).click(); - cy.get( - '[data-test="logs-search-bar-delete-streamlogsnavigate-saved-view-btn"]' - ).each(($button, index) => { - if (index === 2) { - // Click on the delete button for the first item - cy.wrap($button).click(); - cy.get('[data-test="confirm-button"]').click({ force: true }); - } - }); - }); - it("should reset the editor on clicking reset filter button", () => { - // Wait for 2 seconds - cy.wait(2000); - // Type the value of a variable into an input field - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get( - '[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block' - ).click({ - force: true, - }); - cy.get('[data-test="logs-search-bar-query-editor"] > .monaco-editor') - .click() // Click on the editor to focus - .type("match_all_raw_ignore_case('provide_credentials')"); - cy.wait(2000); - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content'); - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - cy.contains("Reset Filters").click({ force: true }); - cy.get('[data-test="logs-search-bar-query-editor"]').should( - "have.value", - "" - ); - }); - -// Remove Skip after bug fix - it.skip("should enter query, reset and then again click the field from LHS", () => { - // cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[aria-label="SQL Mode"]').click({ force: true }); - // cy.get('[data-cy="index-field-search-input"]').type("kubernetes_host") - // cy.wait(3000) - // cy.get( - // '[data-test="log-search-expand-kubernetes_annotations_kubectl_kubernetes_io_default_container-field-btn"]' - // ).click({ force: true }); - // cy.contains("Reset Filters").click({ force: true }); - // cy.get( - // '[data-test="log-search-expand-kubernetes_annotations_kubectl_kubernetes_io_default_container-field-btn"]' - // ).click({ force: true }); - // cy.get(".q-notification__message").should("not.exist"); - }); - - it("should add invalid query and display error", () => { - // Type the value of a variable into an input field - cy.intercept("GET", logData.ValueQuery).as("value"); - - applyQueryButton(); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get( - '[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block' - ).click({ - force: true, - }); - cy.get('[data-test="logs-search-bar-query-editor"]', { - timeout: 2000, - }).type("kubernetes"); - cy.wait(2000); - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content').click({ - force: true, - }); - cy.wait("@allsearch"); - cy.get('[data-test="logs-search-error-message"]', { timeout: 2000 }).should( - "exist" - ); - }); - - it("should not display error if match all case added in log query search", () => { - // Type the value of a variable into an input field - cy.intercept("GET", logData.ValueQuery).as("value"); - - applyQueryButton(); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get( - '[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block' - ).click({ - force: true, - }); - cy.get('[data-test="logs-search-bar-query-editor"]', { - timeout: 2000, - }).type("match_all('code')"); - cy.wait(200); - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content').click({ - force: true, - }); - cy.wait("@allsearch"); - cy.get('[data-test="log-table-column-1-@timestamp"]', { - timeout: 2000, - }).should("exist"); - }); - - it("should change stream settings and click on search stream", () => { - // Type the value of a variable into an input field - - cy.get('[data-test="menu-link-/streams-item"]').click({ force: true }); - cy.get('[data-test="streams-search-stream-input"]').type("e2e_automate"); - cy.get('[title="Stream Detail"]:first').click({ force: true }); - cy.get(':nth-child(2) > [data-test="schema-stream-index-select"]').click(); - cy.get(".q-virtual-scroll__content").within(() => { - cy.contains("Full text search").click(); - }); - - cy.get('[data-test="schema-update-settings-button"]').click({ - force: true, - }); - cy.get(".col-auto > .q-btn > .q-btn__content").click({ force: true }); - cy.get('[title="Explore"]:first').click({ force: true }); - cy.get('[data-test="log-table-column-0-@timestamp"]').should("exist"); - }); - it("should display error if blank spaces added under stream name and clicked create stream ", () => { - cy.get('[data-test="menu-link-/streams-item"]').click({ force: true }); - cy.get('[data-test="log-stream-add-stream-btn"]').click({ force: true }); - cy.get('[data-test="add-stream-name-input"]').type(" "); - cy.get('[data-test="save-stream-btn"]').click({ force: true }); - cy.contains("Field is required").should("exist"); - }); - - it("should display error if create stream is clicked without adding name", () => { - cy.get('[data-test="menu-link-/streams-item"]').click({ force: true }); - cy.get('[data-test="log-stream-add-stream-btn"]').click({ force: true }); - cy.get('[data-test="save-stream-btn"]').click({ force: true }); - cy.contains("Field is required").should("exist"); - }); - - it.skip("should match total - SQL mode ignore case for normal and index search", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - // First query - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/_search?type=logs`, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - body: { - query: { - sql: "SELECT * FROM \"e2e_automate\" where match_all_raw_ignore_case('logger')", - start_time: 1709726643160000, - end_time: 1710072243160000, - from: 0, - size: 250, - quick_mode: true, - sql_mode: "full", - track_total_hits: true, - }, - }, - }).then((response1) => { - const totalLogs1 = response1.body.total; - - // Second query - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/_search?type=logs`, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - - body: { - query: { - sql: "SELECT * FROM \"e2e_automate\" where match_all('logger')", - start_time: 1709726508369000, - end_time: 1710072108369000, - from: 0, - size: 250, - quick_mode: true, - sql_mode: "full", - track_total_hits: true, - }, - }, - }).then((response2) => { - const totalLogs2 = response2.body.total; - - // Assertion - expect(totalLogs1).to.equal(totalLogs2); - }); - }); - }); - - it.skip("should match total - SQL mode match_all for normal and index search", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - // First query - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/_search?type=logs`, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - body: { - query: { - sql: "SELECT * FROM \"e2e_automate\" where match_all('logger')", - start_time: 1709705928581000, - end_time: 1710051528581000, - from: 0, - size: 250, - quick_mode: true, - sql_mode: "full", - track_total_hits: true, - }, - }, - }).then((response1) => { - const totalLogs1 = response1.body.total; - - // Second query - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/_search?type=logs`, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - - body: { - query: { - sql: "SELECT * FROM \"e2e_automate\" where match_all_raw('logger')", - start_time: 1709706092870000, - end_time: 1710051692870000, - from: 0, - size: 250, - quick_mode: true, - sql_mode: "full", - track_total_hits: true, - }, - }, - }).then((response2) => { - const totalLogs2 = response2.body.total; - - // Assertion - expect(totalLogs1).to.equal(totalLogs2); - }); - }); - }); - - it("should match total - histogram mode match all for normal and index search", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - // First query - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/_search?type=logs`, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - body: { - query: { - sql: "select * from \"e2e_automate\" WHERE match_all('logger')", - start_time: 1709725454701000, - end_time: 1710071054701000, - from: 0, - size: 0, - quick_mode: true, - track_total_hits: true, - }, - aggs: { - histogram: - "select histogram(_timestamp, '30 minute') AS zo_sql_key, count(*) AS zo_sql_num from query GROUP BY zo_sql_key ORDER BY zo_sql_key", - }, - }, - }).then((response1) => { - const totalLogs1 = response1.body.total; - - // Second query - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/_search?type=logs`, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - - body: { - query: { - sql: "select * from \"e2e_automate\" WHERE match_all_raw('logger')", - start_time: 1709725511382000, - end_time: 1710071111382000, - from: 0, - size: 0, - quick_mode: true, - track_total_hits: true, - }, - aggs: { - histogram: - "select histogram(_timestamp, '30 minute') AS zo_sql_key, count(*) AS zo_sql_num from query GROUP BY zo_sql_key ORDER BY zo_sql_key", - }, - }, - }).then((response2) => { - const totalLogs2 = response2.body.total; - - // Assertion - expect(totalLogs1).to.equal(totalLogs2); - }); - }); - }); - - it("should match total - histogram mode ignore case for normal and index search test", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - // First query - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/_search?type=logs`, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - body: { - query: { - sql: "select * from \"e2e_automate\" WHERE match_all('logger')", - start_time: 1709725454701000, - end_time: 1710071054701000, - from: 0, - size: 0, - quick_mode: true, - track_total_hits: true, - }, - aggs: { - histogram: - "select histogram(_timestamp, '30 minute') AS zo_sql_key, count(*) AS zo_sql_num from query GROUP BY zo_sql_key ORDER BY zo_sql_key", - }, - }, - }).then((response1) => { - const totalLogs1 = response1.body.total; - - // Second query - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/_search?type=logs`, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - - body: { - query: { - sql: "select * from \"e2e_automate\" WHERE match_all_raw_ignore_case('logger')", - start_time: 1709725511382000, - end_time: 1710071111382000, - from: 0, - size: 0, - quick_mode: true, - track_total_hits: true, - }, - aggs: { - histogram: - "select histogram(_timestamp, '30 minute') AS zo_sql_key, count(*) AS zo_sql_num from query GROUP BY zo_sql_key ORDER BY zo_sql_key", - }, - }, - }).then((response2) => { - const totalLogs2 = response2.body.total; - - // Assertion - expect(totalLogs1).to.equal(totalLogs2); - }); - }); - }); - - - it("should add timestamp to editor save this view and switch", () => { - cy.wait(1000) - cy.get('[data-test="log-table-column-1-@timestamp"] > .flex > .ellipsis').click(); - cy.get(':nth-child(1) > [data-test="log-details-include-exclude-field-btn"] > .q-btn__content > .q-icon').click(); - cy.get('[data-test="log-details-include-field-btn"]').click(); - cy.get('[data-test="close-dialog"] > .q-btn__content').click(); - cy.get('[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown--current > .q-btn__content > :nth-child(1)').click(); - cy.get('[data-test="add-alert-name-input"]').type("e2etimestamp"); - cy.get('[data-test="saved-view-dialog-save-btn"] > .q-btn__content').click() - - cy.get('[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown__arrow-container > .q-btn__content > .q-icon').click() - cy.get('.q-item__label').contains('timestamp').click(); - cy.get(".q-notification__message").should( - "contain", - "e2etimestamp view applied successfully" - ); - cy.wait(3000) - cy.get( - '[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown__arrow-container > .q-btn__content > .q-icon' - ).click({force:true}); - cy.get(".saved-view-item") - .first() - .within(() => { - cy.get( - '[data-test="logs-search-bar-delete-e2etimestamp-saved-view-btn"]' - ).click({ force: true }); - }); - - cy.get('[data-test="confirm-button"] > .q-btn__content').click({ - force: true, - }); - }); -}); \ No newline at end of file diff --git a/tests/ui-testing/cypress/e2e/tests/logs_quickmode.cy.js b/tests/ui-testing/cypress/e2e/tests/logs_quickmode.cy.js deleted file mode 100644 index 037cd855e0..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/logs_quickmode.cy.js +++ /dev/null @@ -1,190 +0,0 @@ -// -import * as logstests from "../allfunctions/logs"; -import logsdata from "../../../../test-data/logs_data.json"; -// import logsdata from "../../data/logs_data.json"; -// import { login } from "../../support/commons" -// import { selectStreamAndStreamType } from "../../support/log-commons"; -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); - -function generateRandomName() { - const characters = "abcdefghijklmnopqrstuvwxyz0123456789"; - let randomName = "e2e_automate-"; - for (let i = 0; i < 5; i++) { - randomName += characters.charAt( - Math.floor(Math.random() * characters.length) - ); - } - randomName += "-1"; - return randomName; -} -describe("Logs Quickmode testcases", () => { - let logData; - function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); - } - function applyQueryButton() { - // click on the run query button - // Type the value of a variable into an input field - cy.intercept("POST", logData.applyQuery).as("search"); - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // get the data from the search variable - cy.wait("@search").its("response.statusCode").should("eq", 200); - cy.get("@search").its("response.body.hits").should("be.an", "array"); - } - before(function () { - cy.fixture("log").then(function (data) { - logData = data; - }); - console.log("--logData--", logData); - }); - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - cy.login(); - // ("ingests logs via API", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - // }); - cy.intercept("GET", "**/api/default/organizations**").as("allorgs"); - cy.intercept("GET", "**/api/default/functions**").as("functions"); - cy.visit(`${logData.logsUrl}?org_identifier=${Cypress.env("ORGNAME")}`); - cy.intercept("POST", "**/api/default/_search**").as("allsearch"); - cy.selectStreamAndStreamTypeForLogs(logData.Stream); - applyQueryButton(); - cy.wait(2000); - cy.get('[data-test="logs-search-bar-quick-mode-toggle-btn"]').then(($el) => { - if ($el.find('.q-toggle__inner--falsy').length > 0) { - cy.wrap($el).click({ force: true }); - } - }); - // cy.get('[data-test="logs-search-bar-quick-mode-toggle-btn"]').click({force:true}) - cy.wait("@allsearch"); - cy.intercept("GET", "**/api/default/streams**").as("streams"); - }); - it("should click on interesting fields icon and display query in editor", () => { - cy.get('[data-cy="index-field-search-input"]').type("_timestamp"); - cy.wait(2000); - cy.get(".field-container") - .find( - '[data-test="log-search-index-list-interesting-_timestamp-field-btn"]:last' - ) - .click({ force: true }); - cy.get('[aria-label="SQL Mode"] > .q-toggle__inner').click(); - cy.get('[data-test="logs-search-bar-query-editor"]').contains("_timestamp"); - }); - it("should display quick mode toggle button", () => { - cy.get('[data-test="logs-search-bar-quick-mode-toggle-btn"]').should( - "be.visible" - ); - }); - - it("should click on interesting fields icon in histogram mode and run query", () => { - cy.get('[data-cy="index-field-search-input"]').type("_timestamp"); - cy.wait(2000); - cy.get(".field-container") - .find( - '[data-test="log-search-index-list-interesting-_timestamp-field-btn"]:last' - ) - .click({ force: true }); - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content').click(); - cy.get('[data-test="log-table-column-0-source"]').contains("_timestamp"); - }); - - it("should display error on entering random text in histogram mode when quick mode is on", () => { - cy.get('[data-test="logs-search-bar-query-editor"]').type("oooo"); - cy.wait(2000); - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content').click(); - cy.get('[data-test="logs-search-error-message"]').contains( - "Error: Search field not found." - ); - }); - - it("should display selected interestesing field and order by - as default in editor", () => { - cy.get(".field-container") - .find( - '[data-test="log-search-index-list-interesting-_timestamp-field-btn"]:last' - ) - .click({ force: true }); - cy.get('[aria-label="SQL Mode"] > .q-toggle__inner').click(); - cy.get('[data-test="logs-search-bar-query-editor"]').contains( - '_timestamp FROM "e2e_automate" ORDER BY _timestamp DESC' - ); - }); - - it("should adding/removing interesting field removes it from editor and results too", () => { - cy.get('[data-cy="index-field-search-input"]').type("_timestamp"); - cy.wait(2000); - cy.get(".field-container") - .find( - '[data-test="log-search-index-list-interesting-_timestamp-field-btn"]:last' - ) - .click({ force: true }); - cy.get('[data-cy="index-field-search-input"]').clear(); - cy.get('[data-cy="index-field-search-input"]').type("kubernetes_pod_id"); - cy.wait(2000); - cy.get( - '[data-test="log-search-index-list-interesting-kubernetes_pod_id-field-btn"]:last' - ).click({ force: true }); - cy.get('[aria-label="SQL Mode"] > .q-toggle__inner').click(); - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content').click(); - cy.get('[data-test="log-table-column-0-source"]').contains( - "kubernetes_pod_id" - ); - cy.get( - '[data-test="log-search-index-list-interesting-kubernetes_pod_id-field-btn"]:last' - ).click({ force: true }); - cy.wait(2000); - cy.get('[data-test="logs-search-bar-query-editor"]').should( - "not.contain", - "kubernetes_pod_id" - ); - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content').click(); - cy.get('[data-test="log-table-column-0-source"]').should( - "not.contain", - "kubernetes_pod_id" - ); - }); - - it("should display order by in sql mode by default even after page reload", () => { - cy.get('[data-cy="index-field-search-input"]').type("_timestamp"); - cy.wait(2000); - cy.get(".field-container") - .find( - '[data-test="log-search-index-list-interesting-_timestamp-field-btn"]:last' - ) - .click({ force: true }); - cy.get('[aria-label="SQL Mode"] > .q-toggle__inner').click(); - cy.reload(); - cy.wait(4000) - cy.get('[data-test="logs-search-bar-query-editor"]').contains('SELECT _timestamp FROM "e2e_automate" ORDER BY _timestamp DESC') - }); -}); diff --git a/tests/ui-testing/cypress/e2e/tests/logs_tests.cy.js b/tests/ui-testing/cypress/e2e/tests/logs_tests.cy.js deleted file mode 100644 index 678433a6b2..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/logs_tests.cy.js +++ /dev/null @@ -1,1038 +0,0 @@ -/// -import * as logstests from "../allfunctions/logs"; -import logsdata from "../../../../test-data/logs_data.json" -// import logsdata from "../../data/logs_data.json"; -// import { login } from "../../support/commons" -// import { selectStreamAndStreamType } from "../../support/log-commons"; - -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); -describe("Logs testcases", () => { - let logData; - function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); - } - - function applyQueryButton() { - // click on the run query button - // Type the value of a variable into an input field - cy.intercept("POST", logData.applyQuery).as("search"); - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // get the data from the search variable - cy.wait("@search").its("response.statusCode").should("eq", 200); - cy.get("@search").its("response.body.hits").should("be.an", "array"); - } - - before(function () { - cy.fixture("log").then(function (data) { - logData = data; - }); - console.log("--logData--", logData); - }); - - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - cy.login(); - // ("ingests logs via API", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - - // }); - cy.intercept("GET", "**/api/default/organizations**").as("allorgs"); - cy.intercept("GET", "**/api/default/functions**").as("functions"); - cy.visit(`${logData.logsUrl}?org_identifier=${Cypress.env("ORGNAME")}`); - cy.intercept("POST", "**/api/default/_search**").as("allsearch"); - cy.selectStreamAndStreamTypeForLogs(logData.Stream); - applyQueryButton() - cy.wait("@allsearch"); - cy.intercept("GET", "**/api/default/streams**").as("streams") - cy.intercept('GET', '/api/default/e2e_automate/_values?').as('getValues') - - - }); - - // This is a test case to navigate to the logs page - it("Navigate to the logs page", () => { - // Visit the base URL - // cy.visit("/"); - // // Trigger a mouseover event on the logs menu link - // cy.get('[data-test="menu-link-/logs-item"]').trigger("mouseover"); - // // Click on the logs menu link that contains the module log data - // cy.get('[data-test="menu-link-/logs-item"]') - // .contains(logData.moduleLog) - // .click(); - }); - - // This test checks if the histogram toggle button works correctly by clicking it and verifying that the chart is hidden. - - // This test checks that clicking on the histogram toggle button in SQL mode does not toggle the chart - it.skip("should not toggle chart when clicking on the histogram toggle in the sql mode", () => { - logstests.clickHistogramToggle(); - cy.wait(3000); - logstests.clickSearchBarSqlMode(); - cy.wait(3000); - logstests.confirmLogsSearchHidden(); - cy.wait(3000); - logstests.histogramToggleEnabled(); - }); - it.skip("should toggle chart when clicking on the histogram toggle", () => { - cy.wait(3000); - logstests.clickHistogramToggle(); - cy.wait(3000); - logstests.confirmLogsSearchHidden(); - }); - - // This test case checks if the function editor is toggled on/off when the 'functions toggle' button is clicked - it("should toggle the function editor on functions toggle click", () => { - logstests.displayVrlFunctionEditor(); - logstests.clickLogsSearchQueryToggle(); - logstests.vrlFunctionEditorHidden(); - logstests.clickLogsSearchQueryToggle(); - logstests.displayVrlFunctionEditor(); - }); - - it("should clear the value of a function on functions toggle click", () => { - // Wait for 5 seconds - cy.wait(5000); - logstests.enterVrlFunctionvalue(); - logstests.clickLogsSearchQueryToggle(); - logstests.clickLogsSearchQueryToggle(); - logstests.attributeToNotHaveVrlFunctionvalue(); - }); - - it.skip("should load the values of a field when the field is expanded", () => { - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - applyQueryButton(); - cy.wait(2000); - logstests.expandLogsSearch(); - logstests.verifyLogsStatusCode(); - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-test="logs-search-subfield-add-code-200"]').should( - "be.visible" - ); - }); - - it("should add the field to the editor when + is clicked", () => { - // Wait for 5 seconds - cy.wait(4000); - // get the value of the field name - logstests.clickValueEditor(); - logstests.clickExpandedViewplusButton(); - logstests.addValueInQueryEditor(); - logstests.verifyAddedValue(); - // add second field to the editor - cy.wait(4000); - logstests.clickValueEditor(); - logstests.addMoreValueQueryEditor(); - logstests.addSecondValues(); - logstests.valueAddedInSqlMode(); - applyQueryButton(); - }); - - it("should add the value to the editor when the = is clicked next to the field value", () => { - // Wait for 2 seconds - cy.wait(2000); - // Type the value of a variable into an input field - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get( - '[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block' - ).click({ - force: true, - }); - logstests.addFeildandSubValue(); - logstests.addsubFieldValue(); - //click on the field - // get the data from the value variable - cy.wait("@value", { timeout: 5000 }) - .its("response.statusCode") - .should("eq", 200); - logstests.addsubFieldValue(); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.clickFieldSubvalue(); - cy.wait(2000); - logstests.valueAddedOnPlusClick(); - cy.intercept("GET", logData.ValueQuery).as("value"); - logstests.clickOnFirstField(); - cy.wait("@value", { timeout: 5000 }) - .its("response.statusCode") - .should("eq", 200); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.addSecondFieldOnEditor(); - logstests.clickOnEqualToButton(); - logstests.bothFieldAddedOnEqualToClick(); - applyQueryButton(); - }); - - it.skip("should add the value to the editor when the != is clicked next to the field value", () => { - // Wait for 2 seconds - cy.wait(5000); - // Type the value of a variable into an input field - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - //click on the field - cy.get( - `[data-test="log-search-expand-${logData.addFieldAndSubFieldValueWithNotEqual.field}-field-btn"]` - ).click({ force: true }); - // get the data from the value variable - cy.wait("@value", { timeout: 15000 }) - .its("response.statusCode") - .should("eq", 200); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - - cy.get( - `[data-test="logs-search-subfield-add-${logData.addFieldAndSubFieldValueWithNotEqual.field}-${logData.addFieldAndSubFieldValueWithNotEqual.subFieldValue}"] ` - ).trigger("mouseover", { force: true }); - // click on = button - cy.get( - `[data-test="logs-search-subfield-add-${logData.addFieldAndSubFieldValueWithNotEqual.field}-${logData.addFieldAndSubFieldValueWithNotEqual.subFieldValue}"] [data-test="log-search-subfield-list-not-equal-${logData.addFieldAndSubFieldValueWithNotEqual.field}-field-btn"]` - ).click({ force: true }); - - // assertion for value is added on the editor when = is clicked - cy.get('[data-test="logs-search-bar-query-editor"]') - .invoke("text") - .then((text) => { - expect( - text.includes( - `${logData.addFieldAndSubFieldValueWithNotEqual.field}!='${logData.addFieldAndSubFieldValueWithNotEqual.subFieldValue}'` - ) - ).to.be.true; - }); - cy.wait(2000); - // Type the value of a variable into an input field - cy.intercept("GET", logData.ValueQuery).as("value"); - //click on the field - cy.get( - `[data-test="log-search-expand-${logData.expandedFieldValue.field1}-field-btn"]` - ).click({ force: true }); - // get the data from the value variable - cy.wait("@value", { timeout: 4000 }) - .its("response.statusCode") - .should("eq", 200); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - cy.get( - '[data-test="logs-search-subfield-add-code-401"] > .text-black > [data-test="log-search-subfield-list-equal-code-field-btn"]' - ).click({ force: true }); - cy.get( - '[data-test="log-search-subfield-list-not-equal-stream-field-btn"]' - ).click({ force: true }); - cy.get('[data-test="logs-search-bar-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - const cleanedText = removeUTFCharacters(text); - // Confirm that the text contains 'code' not equal to '200' - expect(cleanedText).to.not.include("code: 200"); - // Confirm that the text contains 'stream' not equal to 'stderr' - expect(cleanedText).to.not.include("stream: stderr"); - }); - applyQueryButton(); - }); - - it("should click run query after SQL toggle on but without any query", () => { - // Wait for 2 seconds - cy.wait(3000); - // Type the value of a variable into an input field - cy.get('[aria-label="SQL Mode"]').click({ force: true }); - cy.get('[data-test="logs-search-bar-query-editor"]').type( - "{selectall}{del}" - ); - cy.wait(3000); - cy.get('[data-cy="search-bar-refresh-button"]', { timeout: 2000 }).click({ - force: true, - }); - cy.contains("Invalid SQL Syntax").should("be.visible"); - }); - - it("should enter a valid SQL query", () => { - // Wait for 2 seconds - cy.wait(2000); - // Type the value of a variable into an input field - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get( - '[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block' - ).click({ - force: true, - }); - logstests.addFeildandSubValue(); - logstests.addsubFieldValue(); - //click on the field - // get the data from the value variable - cy.wait("@value", { timeout: 5000 }) - .its("response.statusCode") - .should("eq", 200); - logstests.addsubFieldValue(); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.clickFieldSubvalue(); - cy.wait(2000); - logstests.valueAddedOnPlusClick(); - cy.intercept("GET", logData.ValueQuery).as("value"); - logstests.clickOnFirstField(); - cy.wait("@value", { timeout: 4000 }) - .its("response.statusCode") - .should("eq", 200); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.bothFieldAddedOnEqualToClick(); - cy.get('[aria-label="SQL Mode"]').click({ force: true }); - cy.get('[data-test="logs-search-bar-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - const cleanedText = removeUTFCharacters(text); - // Confirm that the text contains 'code' not equal to '200' - expect(cleanedText).to.include( - "SELECT * FROM \"e2e_automate\" WHERE code = '200' ORDER BY _timestamp DESC" - ); - }); - applyQueryButton(); - }); - - it.skip("should contain options to include, exclude and add field to table under Json", () => { - // Wait for 2 seconds - cy.wait(2000); - // Type the value of a variable into an input field - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get( - '[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block' - ).click({ - force: true, - }); - logstests.addFeildandSubValue(); - logstests.addsubFieldValue(); - //click on the field - // get the data from the value variable - cy.wait("@value", { timeout: 5000 }) - .its("response.statusCode") - .should("eq", 200); - logstests.addsubFieldValue(); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.clickFieldSubvalue(); - cy.wait(2000); - logstests.valueAddedOnPlusClick(); - cy.intercept("GET", logData.ValueQuery).as("value"); - logstests.clickOnFirstField(); - cy.wait("@value", { timeout: 4000 }) - .its("response.statusCode") - .should("eq", 200); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.addSecondFieldOnEditor(); - logstests.clickOnEqualToButton(); - logstests.bothFieldAddedOnEqualToClick(); - cy.wait(2000); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(1) - .click({ force: true }); - cy.wait(300); - cy.get( - '[data-test="log-detail-json-content"] >>> [data-test="log-details-include-exclude-field-btn"] :first' - ).click({ force: true }); - cy.get('[data-test="log-details-include-field-btn"]').click({ - force: true, - }); - cy.get('[data-test="logs-search-bar-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - const cleanedText = removeUTFCharacters(text); - // Confirm that the text contains 'code' not equal to '200' - expect(cleanedText).to.include( - "code='200' and code='200' and _timestamp=" - ); - }); - applyQueryButton(); - cy.get('[data-test="logs-search-bar-query-editor"]').type( - "{selectall}{del}" - ); - applyQueryButton(); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(2) - .click({ force: true }); - cy.wait(2000); - cy.get( - '[data-test="log-detail-json-content"] >>> [data-test="log-details-include-exclude-field-btn"] :first' - ).click({ force: true }); - cy.get('[data-test="log-details-exclude-field-btn"]', { - timeout: 2000, - }).click({ force: true }); - // cy.wait(2000); - cy.get('[data-test="logs-search-bar-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - const cleanedText = removeUTFCharacters(text); - // Confirm that the text contains 'code' not equal to '200' - expect(cleanedText).to.include("_timestamp!="); - applyQueryButton(); - cy.wait(200); - // cy.get('[data-test="[data-test="logs-search-bar-query-editor"]"]').type("{selectall}{del}"); - // applyQueryButton(); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(2) - .click({ force: true }); - cy.wait(2000); - cy.get( - '[data-test="log-detail-json-content"] >>> [data-test="log-details-include-exclude-field-btn"] :first' - ).click({ force: true }); - cy.contains("Add field to table").click({ force: true }); - applyQueryButton(); - }); - }); - - it("should contain options to include, exclude and add field to table under TABLE", () => { - // Wait for 2 seconds - cy.wait(2000); - // Type the value of a variable into an input field - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get( - '[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block' - ).click({ - force: true, - }); - logstests.addFeildandSubValue(); - logstests.addsubFieldValue(); - //click on the field - // get the data from the value variable - cy.wait("@value", { timeout: 5000 }) - .its("response.statusCode") - .should("eq", 200); - logstests.addsubFieldValue(); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.clickFieldSubvalue(); - cy.wait(2000); - logstests.valueAddedOnPlusClick(); - cy.intercept("GET", logData.ValueQuery).as("value"); - logstests.clickOnFirstField(); - cy.wait("@value", { timeout: 4000 }) - .its("response.statusCode") - .should("eq", 200); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.addSecondFieldOnEditor(); - logstests.clickOnEqualToButton(); - logstests.bothFieldAddedOnEqualToClick(); - cy.get('[data-test="logs-search-result-logs-table"]', { timeout: 2000 }) - .find("tbody") - .find("tr") - .eq(1) - .trigger("mouseover", { force: true }); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(1) - .click({ force: true }); // select first row from the table - cy.get('[data-test="log-detail-table-tab"]').click({ force: true }); - cy.get( - '[data-test="log-details-include-exclude-field-btn-_timestamp"]' - ).click({ force: true }); - cy.get('[data-test="log-details-include-field-btn"]:first').click({ - force: true, - }); - cy.get('[data-test="logs-search-bar-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - const cleanedText = removeUTFCharacters(text); - // Confirm that the text contains 'code' not equal to '200' - expect(cleanedText).to.include("code='200' and _timestamp="); - }); - applyQueryButton(); - - cy.get('[data-test="logs-search-bar-query-editor"]').type( - "{selectall}{del}" - ); - applyQueryButton(); - cy.wait(2000); - // cy.get('[data-test="logs-search-result-logs-table"]') - // .find("tbody") - // .find("tr") - // .eq(1) - // .trigger("mouseover", { force: true }); - cy.get('[data-test="logs-search-result-logs-table"]', { timeout: 2000 }) - .find("tbody") - .find("tr") - .eq(1) - .click({ force: true }); // select first row from the table - cy.get('[data-test="log-detail-table-tab"]').click({ force: true }); - cy.get( - '[data-test="log-details-include-exclude-field-btn-_timestamp"]' - ).click({ force: true }); - cy.get('[data-test="log-details-exclude-field-btn"]').click({ - force: true, - }); - cy.get('[data-test="logs-search-bar-query-editor"]').then((editor) => { - let text = editor.text(); - text = removeUTFCharacters(text); - const cleanedText = removeUTFCharacters(text); - // Confirm that the text contains 'code' not equal to '200' - expect(cleanedText).to.include("_timestamp!="); - }); - applyQueryButton(); - cy.get('[data-test="logs-search-bar-query-editor"]').type( - "{selectall}{del}" - ); - applyQueryButton(); - cy.wait(2000); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(1) - .trigger("mouseover", { force: true }); - cy.get('[data-test="logs-search-result-logs-table"]', { timeout: 2000 }) - .find("tbody") - .find("tr") - .eq(1) - .click({ force: true }); // select first row from the table - cy.wait(2000); - cy.get('[data-test="log-detail-table-tab"]').click({ force: true }); - cy.get( - '[data-test="log-details-include-exclude-field-btn-_timestamp"]' - ).click({ force: true }); - cy.contains("Add field to table").click({ force: true }); - applyQueryButton(); - }); - - it("should be able to search around logs from the sidebar", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - applyQueryButton(); - - cy.wait(2000); - cy.get('[data-test="logs-search-result-logs-table"]') // Assuming your table is represented by the
element - .should("be.visible"); - cy.wait(4000); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(1) - .trigger("mouseover", { force: true }); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(1) - .click({ force: true }); // select first row from the table - cy.wait(4000); - cy.get('[data-test="dialog-box"]').should("be.visible"); // Assertion for the dialog-box is open - cy.intercept("GET", logData.SearchQuery).as("code"); - cy.get("[data-test='logs-detail-table-search-around-btn']").click(); // click on search around btn - cy.wait("@code").its("response.statusCode").should("eq", 200); - }); - - it("should be able to toggle to the json tab and see json log", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - applyQueryButton(); - cy.get('[data-test="logs-search-result-logs-table"]') // Assuming your table is represented by the
element - .should("be.visible"); - cy.wait(2000); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(1) - .trigger("mouseover", { force: true }); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(1) - .click({ force: true }); // select first row from the table - cy.wait(2000); - cy.get('[data-test="dialog-box"]').should("be.visible"); // Assertion for the dialog-box is open - cy.get("[data-test='log-detail-json-tab']").click(""); // click on json tab - cy.get('[data-test="log-detail-tab-container"]').should("be.visible"); // Assertion for the json tab is open - }); - - it("should be able to navigate to the next and previous logs from the next and previous button", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - applyQueryButton(); - cy.get('[data-test="logs-search-result-logs-table"]') // Assuming your table is represented by the
element - .should("be.visible"); - cy.wait(2000); - cy.get('[data-test="logs-search-result-logs-table"]', { timeout: 2000 }) - .find("tbody") - .find("tr") - .eq(1) - .trigger("mouseover", { force: true }); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(1) - .click({ force: true }); // select first row from the table - cy.get('[data-test="dialog-box"]', { timeout: 3000 }).should("be.visible"); // Assertion for the dialog-box is open - cy.get('[data-test="log-detail-previous-detail-btn"]') - .trigger("mouseover", { force: true }) - .should("be.disabled"); // button is disabled when first click - cy.get('[data-test="log-detail-next-detail-btn"]').click({ force: true }); // click on next btn - cy.get('[data-test="log-detail-next-detail-btn"]').click({ force: true }); // click on next btn - cy.get('[data-test="log-detail-previous-detail-btn"]').click({ - force: true, - }); // click on previous btn - cy.get('[data-test="log-detail-previous-detail-btn"]').click({ - force: true, - }); // click on previous btn - cy.get('[data-test="log-detail-previous-detail-btn"]') - .trigger("mouseover", { force: true }) - .should("be.disabled"); // button is disabled when first click - }); - - it("should be able to enter valid text in VRL and run query", () => { - // cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - applyQueryButton(); - cy.get( - "#fnEditor > .monaco-editor > .overflow-guard > .monaco-scrollable-element > .lines-content > .view-lines" - ).type(".a=2"); - applyQueryButton(); - cy.get(' [data-test="table-row-expand-menu"]') - .first() - .click({ force: true }); - cy.contains("a:2").should("be.visible"); - cy.get('[data-test="logs-search-result-logs-table"]').should("be.visible"); - }); - - it("should hide and display again after clicking the arrow ", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - cy.get('[data-test="logs-search-bar-show-query-toggle-btn"] ').click({ - force: true, - }); - cy.get(".bg-primary > .q-btn__content > .q-icon").click({ force: true }); - cy.wait(2000); - cy.get(".bg-primary > .q-btn__content > .q-icon").click({ force: true }); - cy.get('[data-cy="index-field-search-input"]').should("be.visible"); - }); - - // TODO: Need to change the locators for Saved views once added - it("should verify if special characters allowed saved views name ", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - cy.get('[data-test="logs-search-bar-show-query-toggle-btn"] ').click({ - force: true, - }); - cy.get( - '[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown--current > .q-btn__content > :nth-child(1)' - ).click({ force: true }); - cy.get('[data-test="add-alert-name-input"]').type("e2e@@@@@"); - cy.wait(2000); - cy.get(".q-card__actions > .bg-primary > .q-btn__content").click({ - force: true, - }); - cy.get(".q-notification__message").should( - "contain", - "Please provide valid view name" - ); - }); - - // TODO: Need to change the locators for Saved views once added - it("should allow alphanumeric name under saved view ", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - cy.get('[data-test="logs-search-bar-show-query-toggle-btn"] ').click({ - force: true, - }); - cy.get( - '[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown--current > .q-btn__content > :nth-child(1)' - ).click({ force: true }); - cy.get('[data-test="add-alert-name-input"]').type("e2etest2"); - cy.wait(2000); - cy.get('[data-test="saved-view-dialog-save-btn"]').click({ - force: true, - }); - cy.get(".q-notification__message").should( - "contain", - "View created successfully" - ); - cy.wait(2000); - cy.get( - '[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown__arrow-container > .q-btn__content > .q-icon' - ).click({ force: true }); - cy.wait(2000); - cy.get(":nth-child(1) > .q-item__section--main > .q-item__label").click({ - force: true, - }); - cy.contains("e2etest2").click({ force: true }); - cy.get(".q-notification__message").should( - "contain", - "e2etest2 view applied successfully" - ); - cy.get( - '[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown__arrow-container > .q-btn__content > .q-icon' - ).click(); - cy.get(".saved-view-item") - .first() - .within(() => { - cy.get( - '[data-test="logs-search-bar-delete-e2etest2-saved-view-btn"]' - ).click({ force: true }); - }); - - cy.get('[data-test="confirm-button"] > .q-btn__content').click({ - force: true, - }); - }); - - // TODO: Need to change the locators for Saved views once added - it("should display error when user directly clicks on OK without adding name ", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - cy.get('[data-test="logs-search-bar-show-query-toggle-btn"] ').click({ - force: true, - }); - cy.get( - '[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown--current > .q-btn__content > :nth-child(1)' - ).click({ force: true }); - cy.get('[data-test="saved-view-dialog-save-btn"]').click({ - force: true, - }); - cy.get(".q-notification__message").should( - "contain", - "Please provide valid view name" - ); - }); - - // TODO: Need to change the locators for Saved views once added - it("should display the details of logs results on graph ", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - applyQueryButton(); - cy.get(".search-list > :nth-child(1) > .text-left").should("be.visible"); - cy.wait(2000); - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .find("tr") - .eq(1) - .click({ force: true }); - cy.get('[data-test="close-dialog"] > .q-btn__content > .q-icon').click({ - force: true, - }); - cy.get(".search-list > :nth-child(1) > .text-left").should("not.be.hidden"); - }); - - it("should click on live mode on button and select 5 sec, switch off and then click run query ", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - cy.get(".q-pl-sm > .q-btn > .q-btn__content").click({ force: true }); - cy.get('[data-test="logs-search-bar-refresh-time-5"]').click({ - force: true, - }); - cy.get(".q-notification__message").should( - "contain", - "Live mode is enabled" - ); - cy.get(".q-pl-sm > .q-btn > .q-btn__content").click({ force: true }); - cy.get( - '[data-test="logs-search-off-refresh-interval"] > .q-btn__content' - ).click({ force: true }); - applyQueryButton(); - }); - - it("should click on vrl toggle and display the field and on disable toggle the VRL field to disappear ", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - // cy.get( - // '[data-test="logs-search-bar-show-query-toggle-btn"] > .q-toggle__inner' - // ).click({ force: true }); - cy.get("#fnEditor >>>>> .view-lines").should("be.visible"); - cy.get( - '[data-test="logs-search-bar-show-query-toggle-btn"] > .q-toggle__inner' - ).click({ force: true }); - cy.get("#fnEditor >>>>> .view-lines").should("not.be.visible"); - }); - - it("should switch from past 6 weeks to past 6 days on date-time UI ", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - cy.get('[data-cy="date-time-button"]').should("contain", "Past 6 Weeks"); - applyQueryButton(); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-d-btn"]').click({ force: true }); - cy.get('[data-cy="date-time-button"]').should("contain", "Past 6 Days"); - applyQueryButton(); - }); - - it.skip("should only display results for selected date time ", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-absolute-tab"]').click({ force: true }); - const date = new Date().getDate(); - cy.get(".q-date").contains(date).click({ force: true }); - cy.wait(100); - cy.get(".q-date").contains(date).click({ force: true }); - cy.get(".startEndTime td:nth-child(1) input") - .click({ force: true }) - .wait(200) - .clear() - .type("{ctrl+a}", { delay: 10 }) - .type("0000", { delay: 10 }); - cy.get(".startEndTime td:nth-child(2) input") - .click({ force: true }) - .wait(200) - .clear() - .type("{ctrl+a}", { delay: 10 }) - .type("2359", { delay: 10 }); - applyQueryButton(); - // wait for the query results to appear - cy.wait(2000); - - // const children = cy.get('[data-test="logs-search-result-logs-table"]') - // .find("tbody:last()") - // .find("tr") - // .children.length - - const startDate = new Date(); - startDate.setHours(0); - startDate.setMinutes(0); - startDate.setSeconds(0); - - const endDate = new Date(); - endDate.setHours(0); - endDate.setMinutes(0); - endDate.setSeconds(0); - - const startDateStr = - startDate.getFullYear() + - "-" + - String(startDate.getMonth() + 1).padStart(2, "0") + - "-" + - String(startDate.getDate()).padStart(2, "0") + - " 00:00:00"; - const endDateStr = - endDate.getFullYear() + - "-" + - String(endDate.getMonth() + 1).padStart(2, "0") + - "-" + - String(endDate.getDate()).padStart(2, "0") + - " 23:59:59"; - cy.get('[data-test="logs-search-result-logs-table"]') - .find("tbody") - .eq(1) - .find("tr") - .each(($el, index, $list) => { - if (index > 1) { - // skip the first row - cy.wrap($el) - .find("td:first() div div:nth-child(2) span span") - .should(($el) => { - const date = $el.text(); - expect(date >= startDateStr && date <= endDateStr).to.be.true; - }); - } - }); - }); - - // TODO: change the last line to '.should('be.visible')' when bug https://github.com/openobserve/openobserve/issues/2210 is fixed - it("should display SQL query on switching between Menu options & navigating to Logs again", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[aria-label="SQL Mode"]').click({ force: true }); - cy.contains("SELECT * FROM").should("be.visible"); - cy.get('[data-test="menu-link-/-item"]').click({ force: true }); - cy.get('[data-test="menu-link-/logs-item"]').click({ force: true }); - cy.contains("SELECT * FROM").should("be.visible"); - }); - - it("should display error when save function is clicked without any VRL function", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - logstests.clickSaveFunctionButton(); - logstests.noFunctionFoundMessage(); - }); - - it.skip("should save a function and then delete it", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.wait(2000); - logstests.enterTextVrlQueryEditor(".a=1"); - logstests.clickSaveFunctionButton(); - logstests.enterFunctionName("e2e_function"); - logstests.clickSavedOkButton(); - cy.wait(4000); - cy.wait("@functions"); - cy.get('[data-test="menu-link-pipeline-item"]').click({ force: true }); - cy.wait(4000); - cy.get("tbody") - .should("be.visible") - .contains("e2e_function") - .parent("tr") - .find('[title="Delete Function"]') - .click({ force: true }); - cy.get('[data-test="confirm-button"]').click({ force: true }); - }); - - it.skip("should display error on adding only blank spaces under function name", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.wait(2000); - logstests.enterTextVrlQueryEditor(".a=1"); - logstests.clickSaveFunctionButton(); - logstests.enterFunctionName(" "); - logstests.clickSavedOkButton(); - cy.get(".q-notification__message") - .contains("Function name is not valid") - .should("be.visible"); - }); - - it.skip("should display error on special characters under function name", () => { - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.wait(2000); - logstests.enterTextVrlQueryEditor("a=1"); - logstests.clickSaveFunctionButton(); - logstests.enterFunctionName("e2e@@@@@"); - logstests.clickSavedOkButton(); - cy.get(".q-notification__message") - .contains("Function name is not valid") - .should("be.visible"); - }); - - // TODO: change the last line to '.should('be.visible')' when bug is resolved - it("should display added function on switching between tabs and again navigate to logs", () => { - // cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="date-time-relative-6-w-btn"] > .q-btn__content').click({ - force: true, - }); - applyQueryButton(); - cy.get( - "#fnEditor > .monaco-editor > .overflow-guard > .monaco-scrollable-element > .lines-content > .view-lines" - ).type(".a=2"); - applyQueryButton(); - cy.get('[data-test="menu-link-/metrics-item"]').click({ force: true }); - cy.wait(100); - cy.get('[data-test="menu-link-/logs-item"]').click({ force: true }); - cy.contains(".a=2").should("be.visible"); - }); - - it.skip("should verify if user searches a value and graph appears when user selects SQL toggle and switches off again", () => { - // Wait for 2 seconds - cy.wait(2000); - // Type the value of a variable into an input field - cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get( - '[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block' - ).click({ - force: true, - }); - applyQueryButton() - cy.wait(2000); - - logstests.addFeildandSubValue(); - logstests.addsubFieldValue(); - //click on the field - // get the data from the value variable - cy.wait("@value", { timeout: 5000 }) - .its("response.statusCode") - .should("eq", 200); - logstests.addsubFieldValue(); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.clickFieldSubvalue(); - cy.wait(2000); - logstests.valueAddedOnPlusClick(); - cy.intercept("GET", logData.ValueQuery).as("value"); - logstests.clickOnFirstField(); - cy.wait("@value", { timeout: 5000 }) - .its("response.statusCode") - .should("eq", 200); - cy.get("@value").its("response.body.hits").should("be.an", "array"); - logstests.addSecondFieldOnEditor(); - logstests.clickOnEqualToButton(); - logstests.bothFieldAddedOnEqualToClick(); - cy.get('[aria-label="SQL Mode"] > .q-toggle__label').click({ force: true }); - applyQueryButton(); - cy.get('[aria-label="SQL Mode"] > .q-toggle__label').click({ force: true }); - cy.get(".q-spinner").should("not.exist"); - }); - - it("should display ingested logs - search logs, navigate on another tab, revisit logs page", () => { - // cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get( - '[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block' - ).click({ - force: true, - }); - applyQueryButton(); - cy.get('[data-test="menu-link-/traces-item"]').click({ force: true }); - cy.wait(100); - cy.get('[data-test="menu-link-/logs-item"]').click({ force: true }); - cy.get('[data-test="logs-search-result-bar-chart"]').should("exist"); - }); - - it("should redirect to logs after clicking on stream explorer via stream page", () => { - // cy.intercept("GET", logData.ValueQuery).as("value"); - cy.get('[data-cy="date-time-button"]').click({ force: true }); - cy.get('[data-test="menu-link-/streams-item"]').click({ force: true }); - cy.wait(1000) - cy.get('[title="Explore"]:last').click({ force: true }); - cy.url().should("include", "logs"); - }); - -}); diff --git a/tests/ui-testing/cypress/e2e/tests/menu_tests.cy.js b/tests/ui-testing/cypress/e2e/tests/menu_tests.cy.js deleted file mode 100644 index dd0fd44225..0000000000 --- a/tests/ui-testing/cypress/e2e/tests/menu_tests.cy.js +++ /dev/null @@ -1,126 +0,0 @@ -/// -import * as menutests from "../allfunctions/menufunctions"; -import logsdata from "../../../../test-data/logs_data.json" -// import logsdata from "../../data/logs_data.json"; -// import { login } from "../../support/commons" -// import { selectStreamAndStreamType } from "../../support/log-commons"; - -Cypress.on("uncaught:exception", (err, runnable) => { - return false; -}); -describe("Logs testcases", () => { - let logData; - function removeUTFCharacters(text) { - // console.log(text, "tex"); - // Remove UTF characters using regular expression - return text.replace(/[^\x00-\x7F]/g, " "); - } - - function applyQueryButton() { - // click on the run query button - // Type the value of a variable into an input field - cy.intercept("POST", logData.applyQuery).as("search"); - cy.wait(3000); - cy.get("[data-test='logs-search-bar-refresh-btn']", { - timeout: 2000, - }).click({ force: true }); - // get the data from the search variable - cy.wait("@search").its("response.statusCode").should("eq", 200); - cy.get("@search").its("response.body.hits").should("be.an", "array"); - } - - before(function () { - cy.fixture("log").then(function (data) { - logData = data; - }); - console.log("--logData--", logData); - }); - - beforeEach(() => { - cy.intercept("*", (req) => { - delete req.headers["if-none-match"]; - }); - cy.login(); - // ("ingests logs via API", () => { - const orgId = Cypress.env("ORGNAME"); - const streamName = "e2e_automate"; - const basicAuthCredentials = btoa( - `${Cypress.env("EMAIL")}:${Cypress.env("PASSWORD")}` - ); - - // Making a POST request using cy.request() - cy.request({ - method: "POST", - url: `${Cypress.config().ingestionUrl}/api/${orgId}/${streamName}/_json`, - body: logsdata, - headers: { - Authorization: `Basic ${basicAuthCredentials}`, - "Content-Type": "application/json", - }, - }).then((response) => { - // Logging response content to the Cypress console - cy.log(response.body); - - // Assertion: Ensure the response status is 200 OK - expect(response.status).to.eq( - 200, - `Expected status code 200, but got ${response.status}` - ); - }); - - // }); - cy.intercept("GET", "**/api/default/organizations**").as("allorgs"); - cy.intercept("GET", "**/api/default/functions**").as("functions"); - cy.visit(`${logData.logsUrl}?org_identifier=${Cypress.env("ORGNAME")}`); - cy.intercept("POST", "**/api/default/_search**").as("allsearch"); - cy.wait("@allsearch"); - cy.selectStreamAndStreamTypeForLogs(logData.Stream); - applyQueryButton() - cy.intercept("GET", "**/api/default/streams**").as("streams") - cy.intercept('GET', '/api/default/e2e_automate/_values?').as('getValues') - - - }); - - // This test checks if menu items load and pag url is updated as per menu - it.skip("Should click on all options under Menu", () => { - cy.get('.q-list').should('be.visible') - // cy.get('.q-drawer__content > .q-list').should('be.visible') - cy.get('[data-test="menu-link-/logs-item"]').click({force:true}) - cy.url().should("include", "logs") - cy.get('[data-test="logs-search-bar-show-histogram-toggle-btn"]').should('be.visible') - cy.get('[data-test="menu-link-/metrics-item"]').click({ force: true }) - cy.intercept("POST", logData.applyQuery).as("search"); - cy.url().should("include", "metrics") - cy.contains('Add to dashboard').should('be.visible') - cy.get('[data-test="menu-link-/traces-item"]').click({ force: true }) - cy.url().should("include", "traces") - cy.get('[data-cy="search-bar-refresh-button"] > .q-btn__content').should('be.visible') - cy.contains('Dashboard').click({ force: true }) - cy.url().should("include", "dashboard") - cy.get('[data-test="dashboard-add"]').should('be.be.visible') - cy.wait(2000) - cy.get('[data-test="menu-link-/functions-item"]').click({ force: true }) - cy.url().should("include", "functions") - cy.contains('Create new function').should('be.visible') - cy.wait(2000) - cy.get('[data-test="menu-link-/dashboards-item"]').click({ force: true }) - cy.url().should("include", "dashboards") - cy.get('[data-test="dashboard-add"]').should('be.visible') - cy.wait(2000) - cy.get('[data-test="menu-link-/streams-item"]').click() - cy.url().should("include", "streams") - cy.get('[data-test="log-stream-refresh-stats-btn"]').should('be.visible') - cy.get('[data-test="menu-link-/alerts-item"]').click({ force: true }) - cy.url().should("include", "alerts") - cy.get('[data-test="alert-list-add-alert-btn"]').should('be.visible') - cy.get('[data-test="menu-link-/ingestion-item"]').click({ force: true }) - cy.url().should("include", "ingestion") - cy.contains('Reset Token').should('be.visible') - cy.get('[data-test="menu-link-/iam-item"]').click({ force: true }) - cy.url().should("include", "users") - cy.get('[data-test="iam-users-tab"]').should('be.visible') - - }); - -}); \ No newline at end of file diff --git a/tests/ui-testing/pages/unflattened.js b/tests/ui-testing/pages/unflattened.js new file mode 100644 index 0000000000..14e1c535c6 --- /dev/null +++ b/tests/ui-testing/pages/unflattened.js @@ -0,0 +1,75 @@ +class UnflattenedPage { + constructor(page) { + this.page = page; + } + + get streamsMenu() { + return this.page.locator('[data-test="menu-link-\\/streams-item"]'); + } + + get searchStreamInput() { + return this.page.getByPlaceholder('Search Stream'); + } + + get streamDetailButton() { + return this.page.getByRole('button', { name: 'Stream Detail' }).first(); + } + + get storeOriginalDataToggle() { + return this.page.locator('[data-test="log-stream-store-original-data-toggle-btn"] div').nth(2); + } + + get schemaUpdateButton() { + return this.page.locator('[data-test="schema-update-settings-button"]'); + } + + get closeButton() { + return this.page.locator('button').filter({ hasText: 'close' }); + } + + get exploreButton() { + return this.page.getByRole('button', { name: 'Explore' }).first(); + } + + get dateTimeButton() { + return this.page.locator('[data-test="date-time-btn"]'); + } + + get relativeTab() { + return this.page.locator('[data-test="date-time-relative-tab"]'); + } + + get logTableRowExpandMenu() { + return this.page.locator('[data-test="log-table-column-1-_timestamp"] [data-test="table-row-expand-menu"]'); + } + + get logSourceColumn() { + return this.page.locator('[data-test="log-table-column-0-source"]'); + } + + get o2IdText() { + return this.page.locator('[data-test="log-detail-json-content"] [data-test="log-expand-detail-key-_o2_id-text"]'); + } + + get unflattenedTab() { + return this.page.locator('[data-test="log-detail-json-content"] [data-test="tab-unflattened"]'); + } + + get closeDialog() { + return this.page.locator('[data-test="close-dialog"]'); + } + + get indexFieldSearchInput() { + return this.page.locator('[data-cy="index-field-search-input"]'); + } + + get sqlModeToggle() { + return this.page.locator('[aria-label="SQL Mode"] > .q-toggle__inner'); + } + + get logsSearchBarQueryEditor() { + return this.page.locator('[data-test="logs-search-bar-query-editor"]'); + } +} +export default UnflattenedPage; + diff --git a/tests/ui-testing/playwright-tests/unflattened.spec.js b/tests/ui-testing/playwright-tests/unflattened.spec.js index 67b512e7ea..cff0c97c84 100644 --- a/tests/ui-testing/playwright-tests/unflattened.spec.js +++ b/tests/ui-testing/playwright-tests/unflattened.spec.js @@ -2,58 +2,85 @@ import { test, expect } from "@playwright/test"; import logData from "../../ui-testing/cypress/fixtures/log.json"; import { log } from "console"; import logsdata from "../../test-data/logs_data.json"; +import UnflattenedPage from "../pages/unflattened"; -test.describe.configure({ mode: 'parallel' }); +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(); +// await page.getByText("Login as internal user").click(); await page.waitForTimeout(1000); await page .locator('[data-cy="login-user-id"]') .fill(process.env["ZO_ROOT_USER_EMAIL"]); //Enter Password - await page.locator('label').filter({ hasText: 'Password *' }).click(); + await page.locator("label").filter({ hasText: "Password *" }).click(); await page .locator('[data-cy="login-password"]') .fill(process.env["ZO_ROOT_USER_PASSWORD"]); await page.locator('[data-cy="login-sign-in"]').click(); } +async function toggleQuickModeIfOff(page) { + await page.waitForSelector( + '[data-test="logs-search-bar-quick-mode-toggle-btn"]' + ); + const toggleButton = await page.$( + '[data-test="logs-search-bar-quick-mode-toggle-btn"] > .q-toggle__inner' + ); + const isSwitchedOff = await toggleButton.evaluate((node) => + node.classList.contains("q-toggle__inner--falsy") + ); + + if (isSwitchedOff) { + await toggleButton.click(); + } +} 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'); + ).toString("base64"); const headers = { - "Authorization": `Basic ${basicAuthCredentials}`, + 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', + 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, - body: JSON.stringify(logsdata) - }); - return await fetchResponse.json(); - }, { - url: process.env.INGESTION_URL, - headers: headers, - orgId: orgId, - streamName: streamName, - logsdata: logsdata - }); + orgId: orgId, + streamName: streamName, + logsdata: logsdata, + } + ); 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 }); + 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", () => { @@ -77,9 +104,9 @@ test.describe("Unflattened testcases", () => { test.beforeEach(async ({ page }) => { await login(page); - await page.waitForTimeout(1000) + await page.waitForTimeout(1000); await ingestion(page); - await page.waitForTimeout(2000) + await page.waitForTimeout(2000); await page.goto( `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}` @@ -89,47 +116,215 @@ test.describe("Unflattened testcases", () => { await applyQueryButton(page); }); - test('stream to toggle store orginal data toggle and display o2 id', async ({ page }) => { - 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: 'Stream Detail' }).first().click(); - await page.locator('[data-test="log-stream-store-original-data-toggle-btn"] div').nth(2).click(); - await page.locator('[data-test="schema-update-settings-button"]').click(); - await page.waitForTimeout(1000); - await ingestion(page); - await page.waitForTimeout(2000); - await page.locator('button').filter({ hasText: 'close' }).click(); - await page.getByRole('button', { name: 'Explore' }).first().click(); - await page.waitForTimeout(1000); - await page.locator('[data-test="date-time-btn"]').click(); - await page.locator('[data-test="date-time-relative-tab"]').click(); - await page.waitForTimeout(2000); - await page.locator('[data-test="log-table-column-1-_timestamp"] [data-test="table-row-expand-menu"]').click(); - await page.locator('[data-test="log-table-column-0-source"]').click() - await page.waitForTimeout(1000); - await page.locator('[data-test="log-detail-json-content"] [data-test="log-expand-detail-key-_o2_id-text"]').click(); - await page.locator('[data-test="log-detail-json-content"] [data-test="tab-unflattened"]').click(); - await page.waitForTimeout(1000); - await page.locator('[data-test="close-dialog"]').click(); - 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: 'Stream Detail' }).first().click(); - await page.locator('[data-test="log-stream-store-original-data-toggle-btn"] div').nth(2).click(); - await page.locator('[data-test="schema-update-settings-button"]').click(); - await page.locator('button').filter({ hasText: 'close' }).click(); - await page.waitForTimeout(1000); - await ingestion(page); - await page.waitForTimeout(2000); - await page.getByRole('button', { name: 'Explore' }).first().click(); - await page.waitForTimeout(3000); - await page.locator('[data-test="date-time-btn"]').click(); - await page.locator('[data-test="date-time-relative-tab"]').click(); - await page.waitForTimeout(2000); - await page.locator('[data-test="log-table-column-1-_timestamp"] [data-test="table-row-expand-menu"]').click(); - await page.waitForTimeout(2000); - await page.getByText('arrow_drop_down_timestamp:').click(); + test("stream to toggle store original data toggle and display o2 id", async ({ page }) => { + const unflattenedPage = new UnflattenedPage(page); + + // Navigate to Streams Menu + await unflattenedPage.streamsMenu.waitFor(); // Wait for the streams menu to be visible + await unflattenedPage.streamsMenu.click(); + + // Search for Stream and access details + await unflattenedPage.searchStreamInput.waitFor(); // Wait for the search input to be ready + await unflattenedPage.searchStreamInput.click(); + await unflattenedPage.searchStreamInput.fill("e2e_automate"); + + await unflattenedPage.streamDetailButton.waitFor(); // Ensure the stream detail button is visible + await unflattenedPage.streamDetailButton.click(); + + // Toggle 'Store Original Data' and update schema + await unflattenedPage.storeOriginalDataToggle.waitFor(); // Wait for the toggle to be visible + await unflattenedPage.storeOriginalDataToggle.click(); + + await unflattenedPage.schemaUpdateButton.waitFor(); // Wait for the schema update button to be clickable + await unflattenedPage.schemaUpdateButton.click(); + + await page.waitForTimeout(1000); // Ensure the schema update is processed + await ingestion(page); // Custom ingestion function + await page.waitForTimeout(2000); // Allow time for ingestion + + // Close the dialog and explore the stream + await unflattenedPage.closeButton.waitFor(); // Wait for the close button to be visible + await unflattenedPage.closeButton.click(); + + await unflattenedPage.exploreButton.waitFor(); // Wait for the explore button to be clickable + await unflattenedPage.exploreButton.click(); + + await page.waitForTimeout(1000); // Small delay to ensure page readiness + + // Select date and time + await unflattenedPage.dateTimeButton.waitFor(); // Wait for the date-time button + await unflattenedPage.dateTimeButton.click(); + + await unflattenedPage.relativeTab.waitFor(); // Wait for the relative tab to be visible + await unflattenedPage.relativeTab.click(); + + await page.waitForTimeout(2000); // Wait for the relative tab to load + + // Expand log table row and verify details + await unflattenedPage.logTableRowExpandMenu.waitFor(); // Wait for the expand menu to appear + await unflattenedPage.logTableRowExpandMenu.click(); + + await unflattenedPage.logSourceColumn.waitFor(); // Ensure the source column is ready + await unflattenedPage.logSourceColumn.click(); + + await page.waitForTimeout(1000); // Small delay to ensure UI updates + + await unflattenedPage.o2IdText.waitFor(); // Wait for the o2 ID text to be visible + await unflattenedPage.o2IdText.click(); + + await unflattenedPage.unflattenedTab.waitFor(); // Wait for the unflattened tab to be visible + await unflattenedPage.unflattenedTab.click(); + + await page.waitForTimeout(1000); // Small delay before closing + + // Close the dialog + await unflattenedPage.closeDialog.waitFor(); // Wait for the close button in the dialog + await unflattenedPage.closeDialog.click(); }); -}) \ No newline at end of file + + test("stream to display o2 id when quick mode is on and select * query is added", async ({ page }) => { + const unflattenedPage = new UnflattenedPage(page); // Instantiate the Page Object + + // Navigate to Streams Menu + await unflattenedPage.streamsMenu.waitFor(); + await unflattenedPage.streamsMenu.click(); + + // Search for Stream and access details + await unflattenedPage.searchStreamInput.waitFor(); + await unflattenedPage.searchStreamInput.click(); + await unflattenedPage.searchStreamInput.fill("e2e_automate"); + + await unflattenedPage.streamDetailButton.waitFor(); + await unflattenedPage.streamDetailButton.click(); + + // Toggle 'Store Original Data' and update schema + await unflattenedPage.storeOriginalDataToggle.waitFor(); + await unflattenedPage.storeOriginalDataToggle.click(); + + await unflattenedPage.schemaUpdateButton.waitFor(); + await unflattenedPage.schemaUpdateButton.click(); + + await page.waitForTimeout(1000); // Timeout to ensure process completes + await ingestion(page); + await page.waitForTimeout(2000); + + // Close the dialog and explore the stream + await unflattenedPage.closeButton.waitFor(); + await unflattenedPage.closeButton.click(); + + await unflattenedPage.exploreButton.waitFor(); + await unflattenedPage.exploreButton.click(); + await page.waitForTimeout(2000); + + // Toggle Quick Mode if it's off + await toggleQuickModeIfOff(page); + await page.waitForTimeout(1000); + + // Select date and time + await unflattenedPage.dateTimeButton.waitFor(); + await unflattenedPage.dateTimeButton.click(); + + await unflattenedPage.relativeTab.waitFor(); + await unflattenedPage.relativeTab.click(); + await page.waitForTimeout(2000); + + // Search for 'kubernetes_pod_id' field + await unflattenedPage.indexFieldSearchInput.waitFor(); + await unflattenedPage.indexFieldSearchInput.fill("kubernetes_pod_id"); + + await page.waitForTimeout(2000); + await page + .locator('[data-test="log-search-index-list-interesting-kubernetes_pod_id-field-btn"]') + .first() + .waitFor(); // Wait for the specific button to be visible + await page + .locator('[data-test="log-search-index-list-interesting-kubernetes_pod_id-field-btn"]') + .first() + .click(); + + // Switch to SQL mode and validate query editor content + await unflattenedPage.sqlModeToggle.waitFor(); + await unflattenedPage.sqlModeToggle.click(); + + await page.waitForTimeout(2000); + await expect( + unflattenedPage.logsSearchBarQueryEditor + .getByText(/kubernetes_pod_id/) + .first() + ).toBeVisible(); + + // Update the query editor with 'SELECT * FROM "e2e_automate"' + await unflattenedPage.logsSearchBarQueryEditor.waitFor(); + await unflattenedPage.logsSearchBarQueryEditor.click(); + await page.keyboard.press("Control+A"); + await page.keyboard.press("Delete"); + await page.keyboard.type('SELECT * FROM "e2e_automate"'); + await page.waitForTimeout(2000); + + // Interact with log table rows and verify details + await unflattenedPage.logTableRowExpandMenu.waitFor(); + await unflattenedPage.logTableRowExpandMenu.click(); + + await unflattenedPage.logSourceColumn.waitFor(); + await unflattenedPage.logSourceColumn.click(); + + await page.waitForTimeout(1000); + await unflattenedPage.o2IdText.waitFor(); + await unflattenedPage.o2IdText.click(); + + await page.waitForTimeout(1000); + await unflattenedPage.unflattenedTab.waitFor(); + await unflattenedPage.unflattenedTab.click(); + await page.waitForTimeout(1000); + + // Close the dialog + await unflattenedPage.closeDialog.waitFor(); + await unflattenedPage.closeDialog.click(); + + // Repeat the process: Navigate back to Streams Menu, search, toggle, etc. + await unflattenedPage.streamsMenu.waitFor(); + await unflattenedPage.streamsMenu.click(); + + await unflattenedPage.searchStreamInput.waitFor(); + await unflattenedPage.searchStreamInput.click(); + await unflattenedPage.searchStreamInput.fill("e2e_automate"); + + await unflattenedPage.streamDetailButton.waitFor(); + await unflattenedPage.streamDetailButton.click(); + + await unflattenedPage.storeOriginalDataToggle.waitFor(); + await unflattenedPage.storeOriginalDataToggle.click(); + + await unflattenedPage.schemaUpdateButton.waitFor(); + await unflattenedPage.schemaUpdateButton.click(); + + await unflattenedPage.closeButton.waitFor(); + await unflattenedPage.closeButton.click(); + + await page.waitForTimeout(1000); + await ingestion(page); + + await page.waitForTimeout(2000); + await unflattenedPage.exploreButton.waitFor(); + await unflattenedPage.exploreButton.click(); + + await page.waitForTimeout(3000); + await unflattenedPage.dateTimeButton.waitFor(); + await unflattenedPage.dateTimeButton.click(); + + await unflattenedPage.relativeTab.waitFor(); + await unflattenedPage.relativeTab.click(); + await page.waitForTimeout(2000); + + // Final log row interaction + await unflattenedPage.logTableRowExpandMenu.waitFor(); + await unflattenedPage.logTableRowExpandMenu.click(); + + await page.waitForTimeout(2000); + await page.getByText("arrow_drop_down_timestamp:").waitFor(); + await page.getByText("arrow_drop_down_timestamp:").click(); +}); + + +})