diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index a888f44863a0..1d58f9575ad5 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -107,56 +107,6 @@ export const addIndexedDBKey = (key, value) => { // }); // }); -Cypress.Commands.add( - "dragTo", - { prevSubject: "element" }, - (subject, targetEl) => { - cy.wrap(subject).trigger("dragstart"); - cy.get(targetEl).trigger("drop"); - }, -); - -Cypress.Commands.add("downloadData", (filetype) => { - cy.get(publishWidgetspage.downloadBtn).click({ force: true }); - - cy.get(publishWidgetspage.downloadOption) - .contains(filetype) - .click({ force: true }); -}); - -Cypress.Commands.add("validateDownload", (fileName) => { - // const downloadedFilename = Cypress.config("downloadsFolder") - // .concat("/") - // .concat(fileName); - // cy.readFile(downloadedFilename, "binary", { - // timeout: 15000, - // }).should((buffer) => expect(buffer.length).to.be.gt(100)); - - let downloadsFolder = Cypress.config("downloadsFolder"); - cy.log("downloadsFolder is:" + downloadsFolder); - cy.readFile(path.join(downloadsFolder, fileName)).should("exist"); -}); - -Cypress.Commands.add( - "AddFilterWithOperator", - (operator, option, condition, value) => { - cy.get(publishWidgetspage.addFilter).click(); - cy.get(publishWidgetspage.operatorsDropdown).click({ force: true }); - cy.get(publishWidgetspage.attributeValue) - .contains(operator) - .click({ force: true }); - cy.get(publishWidgetspage.attributesDropdown).last().click({ force: true }); - cy.get(publishWidgetspage.attributeValue) - .contains(option) - .click({ force: true }); - cy.get(publishWidgetspage.conditionDropdown).last().click({ force: true }); - cy.get(publishWidgetspage.attributeValue) - .contains(condition) - .click({ force: true }); - cy.get(publishWidgetspage.inputValue).last().type(value); - }, -); - Cypress.Commands.add("stubPostHeaderReq", () => { cy.intercept("POST", "/api/v1/users/invite", (req) => { req.headers["origin"] = "Cypress"; @@ -166,50 +116,6 @@ Cypress.Commands.add("stubPostHeaderReq", () => { }).as("mockPostAppInvite"); }); -Cypress.Commands.add( - "addOAuth2AuthorizationCodeDetails", - (accessTokenUrl, clientId, clientSecret, authURL) => { - cy.get(datasource.authType).click(); - cy.get(datasource.OAuth2).click(); - cy.get(datasource.grantType).click(); - cy.get(datasource.authorizationCode).click(); - cy.get(datasource.accessTokenUrl).type(accessTokenUrl); - cy.get(datasource.clienID).type(clientId); - cy.get(datasource.clientSecret).type(clientSecret); - cy.get(datasource.authorizationURL).type(authURL); - cy.xpath('//input[contains(@value,"api/v1/datasources/authorize")]') - .first() - .invoke("attr", "value") - .then((text) => { - const firstTxt = text; - cy.log("date time : ", firstTxt); - const expectedvalue = Cypress.config().baseUrl.concat( - "api/v1/datasources/authorize", - ); - expect(firstTxt).to.equal(expectedvalue); - }); - cy.testSelfSignedCertificateSettingsInREST(true); - }, -); - -Cypress.Commands.add( - "addOAuth2ClientCredentialsDetails", - (accessTokenUrl, clientId, clientSecret, scope) => { - cy.get(datasource.authType).click(); - cy.get(datasource.OAuth2).click(); - cy.xpath("//span[text()='Client Credentials']").should("be.visible"); - cy.get(datasource.accessTokenUrl).type(accessTokenUrl); - cy.get(datasource.clienID).type(clientId); - cy.get(datasource.clientSecret).type(clientSecret); - cy.get(datasource.scope).type(scope); - cy.get(datasource.clientAuthentication).should("be.visible"); - cy.xpath("//span[text()='Send client credentials in body']").should( - "be.visible", - ); - cy.testSelfSignedCertificateSettingsInREST(true); - }, -); - Cypress.Commands.add("testSelfSignedCertificateSettingsInREST", (isOAuth2) => { cy.get(datasource.useCertInAuth).should("not.exist"); cy.get(datasource.certificateDetails).should("not.exist"); @@ -231,29 +137,6 @@ Cypress.Commands.add("addBasicProfileDetails", (username, password) => { cy.get(datasource.basicPassword).type(password); }); -Cypress.Commands.add("DeleteApp", (appName) => { - cy.get(commonlocators.homeIcon).click({ force: true }); - cy.wait("@applications").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - cy.wait("@workspaces").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - cy.get('button span[icon="chevron-down"]').should("be.visible"); - cy.get(homePage.searchInput).clear().type(appName, { force: true }); - cy.get(homePage.applicationCard).trigger("mouseover"); - cy.get("[data-testid=t--application-card-context-menu]") - .should("have.length", 1) - .first() - .click({ force: true }); - cy.get(homePage.deleteAppConfirm).should("be.visible").click({ force: true }); - cy.get(homePage.deleteApp).should("be.visible").click({ force: true }); -}); - Cypress.Commands.add("GetUrlQueryParams", () => { return cy.url().then((url) => { const arr = url.split("?")[1]?.split("&"); @@ -298,35 +181,6 @@ Cypress.Commands.add("LogintoApp", (uname, pword) => { initLocalstorage(); }); -Cypress.Commands.add("LogintoAppTestUser", (uname, pword) => { - cy.LogOutUser(); - cy.LoginUser(uname, pword); - initLocalstorage(); -}); - -Cypress.Commands.add("Signup", (uname, pword) => { - homePageTS.InvokeDispatchOnStore(); - cy.wait("@postLogout"); - cy.visit("/user/signup", { timeout: 60000 }); - cy.wait("@getConsolidatedData") - .its("response.body.responseMeta.status") - .should("eq", 200); - agHelper.WaitUntilEleAppear(signupPage.username); - cy.get(signupPage.username).type(uname); - cy.get(signupPage.password).type(pword); - agHelper.GetNClick(signupPage.submitBtn); - agHelper.GetElement("body").then(($body) => { - if ($body.find(signupPage.proficiencyGroupButton).length > 0) { - cy.get(signupPage.proficiencyGroupButton).first().click(); - cy.get(signupPage.useCaseGroupButton).first().click(); - cy.get(signupPage.getStartedSubmit).click({ force: true }); - } - }); - cy.wait("@getConsolidatedData"); - cy.wait(3000); - initLocalstorage(); -}); - Cypress.Commands.add("LoginFromAPI", (uname, pword) => { let baseURL = Cypress.config().baseUrl; baseURL = baseURL.endsWith("/") ? baseURL.slice(0, -1) : baseURL; @@ -375,19 +229,6 @@ Cypress.Commands.add("LoginFromAPI", (uname, pword) => { }); }); -Cypress.Commands.add("DeleteApp", (appName) => { - cy.get(commonlocators.homeIcon).click({ force: true }); - cy.get(homePage.searchInput).type(appName); - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(2000); - cy.get(homePage.applicationCard).first().trigger("mouseover"); - cy.get("[data-testid=t--application-card-context-menu]") - .first() - .click({ force: true }); - cy.get(homePage.deleteAppConfirm).should("be.visible").click({ force: true }); - cy.get(homePage.deleteApp).contains("Are you sure?").click({ force: true }); -}); - Cypress.Commands.add("LogOut", (toCheckgetPluginForm = true) => { agHelper.WaitUntilAllToastsDisappear(); //Since these are coming in every self-hosted 1st time login, commenting for CI runs @@ -447,27 +288,6 @@ Cypress.Commands.add("ClearSearch", () => { cy.get(commonlocators.entityExplorersearch).clear({ force: true }); }); -Cypress.Commands.add( - "paste", - { - prevSubject: true, - element: true, - }, - ($element, text) => { - const subString = text.slice(0, -1); - const lastChar = text.slice(-1); - - cy.get(commonlocators.entityExplorersearch) - .clear({ force: true }) - .click({ force: true }) - .then(() => { - $element.text(subString); - $element.val(subString); - cy.get($element).type(lastChar); - }); - }, -); - Cypress.Commands.add("clickTest", (testbutton) => { // eslint-disable-next-line cypress/no-unnecessary-waiting cy.wait(2000); @@ -627,42 +447,6 @@ Cypress.Commands.add("togglebar", (value) => { cy.get(value).check({ force: true }).should("be.checked"); }); -Cypress.Commands.add("radiovalue", (value, value2) => { - cy.get(value).click().clear().type(value2); -}); - -Cypress.Commands.add("optionValue", (value, value2) => { - cy.get(value).click().clear().type(value2); -}); - -Cypress.Commands.add("typeIntoDraftEditor", (selector, text) => { - cy.get(selector).then((input) => { - var textarea = input.get(0); - textarea.dispatchEvent(new Event("focus")); - - var textEvent = document.createEvent("TextEvent"); - textEvent.initTextEvent("textInput", true, true, null, text); - textarea.dispatchEvent(textEvent); - - textarea.dispatchEvent(new Event("blur")); - }); -}); - -Cypress.Commands.add("getPluginFormsAndCreateDatasource", () => { - /* - cy.wait("@getPluginForm").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - cy.wait("@saveDatasource").should( - "have.nested.property", - "response.body.responseMeta.status", - 201, - ); - */ -}); - Cypress.Commands.add("NavigateToJSEditor", () => { PageLeftPane.switchSegment(PagePaneSegment.JS); PageLeftPane.switchToAddNew(); @@ -684,33 +468,6 @@ Cypress.Commands.add("selectAction", (option) => { .click({ force: true }); }); -Cypress.Commands.add("deleteActionAndConfirm", () => { - cy.selectAction("Delete"); - cy.selectAction("Are you sure?"); -}); - -Cypress.Commands.add("deleteJSObject", () => { - cy.hoverAndClick(); - cy.get(jsEditorLocators.delete).click({ force: true }); - cy.get(jsEditorLocators.deleteConfirm).click({ force: true }); - cy.wait("@deleteJSCollection").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); -}); - -Cypress.Commands.add("deleteDataSource", () => { - cy.hoverAndClick(); - cy.get(apiwidget.delete).click({ force: true }); - cy.get(apiwidget.deleteConfirm).click({ force: true }); - cy.wait("@deleteDatasource").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); -}); - Cypress.Commands.add("dragAndDropToCanvas", (widgetType, { x, y }) => { PageLeftPane.switchSegment(PagePaneSegment.UI); PageLeftPane.switchToAddNew(); @@ -837,16 +594,6 @@ Cypress.Commands.add("setDate", (date, dateFormate) => { cy.get(sel).click(); }); -Cypress.Commands.add("pageNo", (index) => { - cy.get(".page-item").first().click({ force: true }); -}); - -Cypress.Commands.add("pageNoValidate", (index) => { - const data = '.e-numericcontainer a[index="' + index + '"]'; - const pageVal = cy.get(data); - return pageVal; -}); - Cypress.Commands.add("validateDisableWidget", (widgetCss, disableCss) => { cy.get(widgetCss + disableCss).should("exist"); }); @@ -1122,38 +869,6 @@ Cypress.Commands.add("NavigateToPaginationTab", () => { agHelper.GetNClick(ApiEditor.apiPaginationTab); }); -Cypress.Commands.add("ValidateTableData", (value) => { - // cy.isSelectRow(0); - cy.readTabledata("0", "0").then((tabData) => { - const tableData = tabData; - expect(tableData).to.equal(value.toString()); - }); -}); - -Cypress.Commands.add("ValidateTableV2Data", (value) => { - // cy.isSelectRow(0); - cy.readTableV2data("0", "0").then((tabData) => { - const tableData = tabData; - expect(tableData).to.equal(value.toString()); - }); -}); - -Cypress.Commands.add("ValidatePublishTableData", (value) => { - cy.isSelectRow(0); - cy.readTabledataPublish("0", "0").then((tabData) => { - const tableData = tabData; - expect(tableData).to.equal(value); - }); -}); - -Cypress.Commands.add("ValidatePublishTableV2Data", (value) => { - cy.isSelectRow(0); - cy.readTableV2dataPublish("0", "0").then((tabData) => { - const tableData = tabData; - expect(tableData).to.equal(value); - }); -}); - Cypress.Commands.add("ValidatePaginateResponseUrlData", (runTestCss) => { EditorNavigation.SelectEntityByName("Api2", EntityType.Api); cy.wait(3000); @@ -1206,22 +921,6 @@ Cypress.Commands.add("ValidatePaginateResponseUrlDataV2", (runTestCss) => { }); }); -Cypress.Commands.add("ValidatePaginationInputData", (valueToTest) => { - cy.isSelectRow(0); - cy.readTabledataPublish("0", "5").then((tabData) => { - const tableData = tabData; - expect(`\"${tableData}\"`).to.equal(valueToTest); - }); -}); - -Cypress.Commands.add("ValidatePaginationInputDataV2", (valueToTest) => { - cy.isSelectRow(0); - cy.readTableV2dataPublish("0", "5").then((tabData) => { - const tableData = tabData; - expect(`\"${tableData}\"`).to.equal(valueToTest); - }); -}); - Cypress.Commands.add("CheckForPageSaveError", () => { // Wait for "saving" status to disappear cy.get(commonlocators.statusSaving, { @@ -1254,29 +953,6 @@ Cypress.Commands.add( }, ); -Cypress.Commands.add("updateMapType", (mapType) => { - // Command to change the map chart type if the property pane of the map chart widget is opened. - cy.get(viewWidgetsPage.mapType).last().click({ force: true }); - cy.get(commonlocators.dropdownmenu) - .children() - .contains(mapType) - .click({ force: true }); - - cy.get(viewWidgetsPage.mapType).should("have.text", mapType); -}); - -Cypress.Commands.add("createJSObject", (JSCode) => { - cy.NavigateToJSEditor(); - cy.wait(1000); - cy.get(".CodeMirror textarea") - .first() - .focus() - .type("{downarrow}{downarrow}{downarrow}{downarrow} ") - .type(JSCode); - cy.wait(1000); - cy.get(jsEditorLocators.runButton).first().click(); -}); - Cypress.Commands.add("createSuperUser", () => { cy.wait(1000); cy.get(welcomePage.firstName).should("be.visible"); @@ -1355,59 +1031,6 @@ Cypress.Commands.add("SignupFromAPI", (uname, pword) => { }); }); -Cypress.Commands.add("startInterceptRoutesForMySQL", () => { - //All stubbing - updating app id to current app id for Delete app by api call to be successfull: - - cy.replaceApplicationIdForInterceptPages( - "cypress/fixtures/mySQL_PUT_replaceLayoutWithCRUD.json", - ); - - cy.intercept("POST", "/api/v1/datasources/test", { - fixture: "testAction.json", - }).as("testDatasource"); - cy.intercept("GET", "/api/v1/datasources/*/structure?ignoreCache=*", { - fixture: "mySQL_GET_selectTableDropdown.json", - }).as("getDatasourceStructure"); - cy.intercept("PUT", "/api/v1/pages/crud-page/*", { - fixture: "mySQL_PUT_replaceLayoutWithCRUD.json", - }).as("replaceLayoutWithCRUDPage"); - cy.intercept("GET", "/api/v1/actions*", { - fixture: "mySQL_GET_Actions.json", - }).as("getActions"); - cy.intercept("POST", "/api/v1/actions/execute", { - fixture: "mySQL_POST_Execute.json", - }).as("postExecute"); - cy.intercept("POST", "/api/v1/pages/crud-page", { - fixture: "mySQL_PUT_replaceLayoutWithCRUD.json", - }).as("replaceLayoutWithCRUDPage"); -}); - -Cypress.Commands.add("startInterceptRoutesForMongo", () => { - //All stubbing - cy.replaceApplicationIdForInterceptPages( - "cypress/fixtures/mongo_PUT_replaceLayoutWithCRUD.json", - ); - - cy.intercept("POST", "/api/v1/datasources/test", { - fixture: "testAction.json", - }).as("testDatasource"); - cy.intercept("GET", "/api/v1/datasources/*/structure?ignoreCache=*", { - fixture: "mongo_GET_selectTableDropdown.json", - }).as("getDatasourceStructure"); - cy.intercept("PUT", "/api/v1/pages/crud-page/*", { - fixture: "mongo_PUT_replaceLayoutWithCRUD.json", - }).as("replaceLayoutWithCRUDPage"); - cy.intercept("GET", "/api/v1/actions*", { - fixture: "mongo_GET_Actions.json", - }).as("getActions"); - cy.intercept("POST", "/api/v1/actions/execute", { - fixture: "mongo_POST_Actions.json", - }).as("postExecute"); - cy.intercept("POST", "/api/v1/pages/crud-page", { - fixture: "mongo_PUT_replaceLayoutWithCRUD.json", - }).as("post_replaceLayoutCRUDStub"); -}); - Cypress.Commands.add("startInterceptRoutesForS3", () => { cy.intercept("POST", "/api/v1/datasources/test").as("testDatasource"); cy.intercept("PUT", "/api/v1/datasources/datasource-query/*").as( @@ -1422,43 +1045,6 @@ Cypress.Commands.add("startInterceptRoutesForS3", () => { cy.intercept("POST", "/api/v1/actions/execute").as("post_Execute"); }); -Cypress.Commands.add("replaceApplicationIdForInterceptPages", (fixtureFile) => { - let currentAppId, currentURL; - cy.readFile(fixtureFile, (err, data) => { - if (err) { - return console.error(err); - } - }).then((data) => { - cy.url().then((url) => { - currentURL = url; - const myRegexp = /applications(.*)/; - const match = myRegexp.exec(currentURL); - cy.log(currentURL + "currentURL from intercept is"); - currentAppId = match ? match[1].split("/")[1] : null; - data.data.page.applicationId = currentAppId; - cy.writeFile(fixtureFile, JSON.stringify(data)); - }); - }); -}); - -Cypress.Commands.add( - "paste", - { prevSubject: true }, - (selector, pastePayload) => { - cy.wrap(selector).then(($destination) => { - const pasteEvent = Object.assign( - new Event("paste", { bubbles: true, cancelable: true }), - { - clipboardData: { - getData: () => pastePayload, - }, - }, - ); - $destination[0].dispatchEvent(pasteEvent); - }); - }, -); - // the way we target form controls from now on has to change // we would be getting the form controls by their class names and not their xpaths. // the xpath method is flaky and highly subjected to change. @@ -1485,25 +1071,6 @@ Cypress.Commands.add( }, ); -Cypress.Commands.add("checkCodeInputValue", (selector) => { - let inputVal = ""; - cy.get(selector).then(($field) => { - cy.wrap($field) - .find(".CodeMirror-code span") - .first() - .invoke("text") - .then((text1) => { - inputVal = text1; - cy.log("checkCodeInputValue is:::: " + inputVal); - // const input = ins[0].CodeMirror; - // inputVal = input.getValue(); - }); - - // to be chained with another cy command. - return cy.wrap(inputVal); - }); -}); - Cypress.Commands.add("clickButton", (btnVisibleText, toForceClick = true) => { cy.xpath("//span[text()='" + btnVisibleText + "']/ancestor::button") .first() @@ -1511,66 +1078,6 @@ Cypress.Commands.add("clickButton", (btnVisibleText, toForceClick = true) => { .click({ force: toForceClick }); }); -Cypress.Commands.add( - "actionContextMenuByEntityName", - (entityNameinLeftSidebar, action = "Delete", subAction) => { - cy.wait(2000); - // cy.get( - // commonlocators.entitySearchResult - // .concat(entityNameinLeftSidebar) - // .concat("')"), - // ) - // .parents(commonlocators.entityItem) - // .first() - // .trigger("mouseover") - // .find(commonlocators.entityContextMenu) - // .last() - // .click({ force: true }); - - cy.xpath( - "//div[text()='" + - entityNameinLeftSidebar + - "']/ancestor::div[1]/following-sibling::div//div[contains(@class, 'entity-context-menu-icon')]", - ) - .last() - .click({ force: true }); - - cy.xpath( - "//div[text()='" + - action + - "']/ancestor::a[contains(@class, 'single-select')]", - ) - .click({ force: true }) - .wait(500); - - if (subAction) { - cy.xpath( - "//div[text()='" + - subAction + - "']/parent::a[contains(@class, 'single-select')]", - ) - .click({ force: true }) - .wait(500); - } - - if (action === "Delete") - cy.xpath("//div[text()='" + entityNameinLeftSidebar + "']").should( - "not.exist", - ); - }, -); - -Cypress.Commands.add("selectEntityByName", (entityNameinLeftSidebar) => { - cy.xpath( - "//div[contains(@class, 't--entity-name')][text()='" + - entityNameinLeftSidebar + - "']", - ) - .last() - .click({ force: true }) - .wait(2000); -}); - Cypress.Commands.add( "EvaluatFieldValue", (fieldName = "", currentValue = "") => { @@ -1636,15 +1143,6 @@ cy.all = function (...commands) { return p; }; -Cypress.Commands.add("renameWithInPane", (renameVal) => { - cy.get(apiwidget.ApiName).click({ force: true }); - cy.get(apiwidget.apiTxt) - .clear() - .type(renameVal, { force: true }) - .should("have.value", renameVal) - .blur(); -}); - Cypress.Commands.add("getEntityName", () => { let entityName = cy.get(apiwidget.ApiName).invoke("text"); return entityName; @@ -1678,19 +1176,6 @@ Cypress.Commands.add("setQueryTimeout", (timeout) => { cy.xpath(queryLocators.query).click(); }); -//Usage: If in need to type {enter} {esc} etc then .text('sometext').type('{enter}') -Cypress.Commands.add("text", { prevSubject: true }, (subject, text) => { - subject.val(text); - return cy.wrap(subject); -}); - -//Not Used! -Cypress.Commands.add("VerifyNoDataDisplayAbsence", () => { - cy.xpath("//div[text()='No data to display']", { timeout: 0 }).should( - "not.exist", - ); -}); - // Cypress.Commands.add('isNotInViewport', element => { // cy.xpath(element).then($el => { // const bottom = Cypress.$(cy.state('window')).height() @@ -1703,19 +1188,6 @@ Cypress.Commands.add("VerifyNoDataDisplayAbsence", () => { // }) // }) -Cypress.Commands.add("isNotInViewport", (element) => { - cy.xpath(element).should(($el) => { - const bottom = Cypress.$(cy.state("window")).height(); - const right = Cypress.$(cy.state("window")).width(); - const rect = $el[0].getBoundingClientRect(); - - expect(rect).to.satisfy( - (rect) => - rect.top < 0 || rect.top > bottom || rect.left < 0 || rect.left > right, - ); - }); -}); - Cypress.Commands.add("isInViewport", (element) => { cy.xpath(element) .scrollIntoView() @@ -1734,10 +1206,6 @@ Cypress.Commands.add("validateEvaluatedValue", (value) => { cy.get(".t-property-evaluated-value").should("contain", value); }); -Cypress.Commands.add("CheckAndUnfoldEntityItem", (item) => { - PageLeftPane.expandCollapseItem(item); -}); - // Cypress.Commands.overwrite("type", (originalFn, element, text, options) => { // const clearedText = '{selectall}{backspace}'+`${text}`; // return originalFn(element, clearedText, options); @@ -1812,18 +1280,6 @@ Cypress.Commands.add("checkLabelForWidget", (options) => { }); let LOCAL_STORAGE_MEMORY = {}; -Cypress.Commands.add("saveLocalStorageCache", () => { - Object.keys(localStorage).forEach((key) => { - LOCAL_STORAGE_MEMORY[key] = localStorage[key]; - }); -}); - -Cypress.Commands.add("restoreLocalStorageCache", () => { - Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => { - localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]); - }); -}); - Cypress.Commands.add("StopContainer", (path, containerName) => { cy.request({ method: "GET", @@ -1837,31 +1293,6 @@ Cypress.Commands.add("StopContainer", (path, containerName) => { }); }); -Cypress.Commands.add("StopAllContainer", (path) => { - cy.request({ - method: "GET", - url: path, - qs: { - cmd: "docker kill $(docker ps -q)", - }, - }).then((res) => { - expect(res.status).equal(200); - }); -}); - -Cypress.Commands.add("StartContainer", (path, containerName) => { - cy.request({ - method: "GET", - url: path, - qs: { - cmd: "docker restart " + containerName, - }, - }).then((res) => { - cy.log(res.body.stdout, res.body.stderr); - expect(res.status).equal(200); - }); -}); - Cypress.Commands.add( "StartNewContainer", (url, path, version, containerName) => { @@ -1903,19 +1334,6 @@ Cypress.Commands.add("GetPath", (path, containerName) => { }); }); -Cypress.Commands.add("GetCWD", (path) => { - cy.request({ - method: "GET", - url: path, - qs: { - cmd: "pwd", - }, - }).then((res) => { - cy.log(res.body.stdout); - expect(res.status).equal(200); - }); -}); - Cypress.Commands.add("GetAndVerifyLogs", (path, containerName) => { cy.request({ method: "GET", @@ -1929,53 +1347,6 @@ Cypress.Commands.add("GetAndVerifyLogs", (path, containerName) => { }); }); -Cypress.Commands.add( - "typeTab", - { prevSubject: "element" }, - (subject, shiftKey, ctrlKey) => { - cy.wrap(subject).trigger("keydown", { - keyCode: 9, - which: 9, - shiftKey: shiftKey, - ctrlKey: ctrlKey, - }); - }, -); - -Cypress.Commands.add(`verifyCallCount`, (alias, expectedNumberOfCalls) => { - cy.wait(alias); - cy.get(`${alias}.all`).should("have.length", expectedNumberOfCalls); -}); - -Cypress.Commands.add( - "RenameWidgetFromPropertyPane", - (widgetType, oldName, newName) => { - cy.openPropertyPaneByWidgetName(oldName, widgetType); - cy.get(".t--property-pane-title").click({ force: true }); - cy.get(".t--property-pane-title") - .type(newName, { delay: 300 }) - .type("{enter}"); - cy.wait("@updateWidgetName").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - }, -); - -Cypress.Commands.add("execute", (url, command) => { - cy.request({ - method: "GET", - url: url, - qs: { - cmd: command, - }, - }).then((res) => { - cy.log(res.body.stdout, res.body.error); - expect(res.status).equal(200); - }); -}); - Cypress.Commands.add("forceVisit", (url) => { cy.window().then((win) => { return win.open(url, "_self"); @@ -1999,15 +1370,6 @@ Cypress.Commands.add("SelectDropDown", (dropdownOption) => { .wait(1000); }); -Cypress.Commands.add("RemoveMultiSelectItems", (dropdownOptions) => { - dropdownOptions.forEach(($each) => { - cy.get(`.rc-select-selection-overflow-item [title=${$each}] .remove-icon`) - .eq(0) - .click({ force: true }) - .wait(1000); - }); -}); - Cypress.Commands.add("RemoveAllSelections", () => { cy.get(`.rc-select-selection-overflow-item .remove-icon`).each(($each) => { cy.wrap($each).click({ force: true }).wait(1000); @@ -2084,19 +1446,6 @@ Cypress.Commands.add("stubCustomerPortalPage", () => { }); }); -/** - * @param testID - * @returns - * - * This function act as a data-testid selector. In - * any case it is decided to rename the data-testid, - * it's thing single function that needs to be updated. - * - */ -Cypress.Commands.add("selectByTestId", (testId) => { - return cy.get(`[data-testid="${testId}"]`); -}); - /** * @param tooltipSelector * @param expectedText @@ -2110,3 +1459,21 @@ Cypress.Commands.add( cy.get(tooltipSelector).should("be.visible").and("contain", expectedText); }, ); + +Cypress.Commands.add( + "paste", + { prevSubject: true }, + (selector, pastePayload) => { + cy.wrap(selector).then(($destination) => { + const pasteEvent = Object.assign( + new Event("paste", { bubbles: true, cancelable: true }), + { + clipboardData: { + getData: () => pastePayload, + }, + }, + ); + $destination[0].dispatchEvent(pasteEvent); + }); + }, +);