diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/BugTests/Bug16248_spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/BugTests/Bug16248_spec.ts deleted file mode 100644 index 81f05fb884..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/BugTests/Bug16248_spec.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ObjectsRegistry } from "../../../../support/Objects/Registry"; - -const gitSync = ObjectsRegistry.GitSync, - apiPage = ObjectsRegistry.ApiPage; - -describe("Block Shortcut Action Execution", function() { - it("Bug 16248, When GitSync modal is open, block action execution", function() { - const largeResponseApiUrl = "https://jsonplaceholder.typicode.com/users"; - const modifierKey = Cypress.platform === "darwin" ? "meta" : "ctrl"; - - apiPage.CreateAndFillApi(largeResponseApiUrl, "GitSyncTest"); - gitSync.openGitSyncModal(); - cy.get("body").type(`{${modifierKey}}{enter}`); - cy.get("@postExecute").should("not.exist"); - gitSync.closeGitSyncModal(); - cy.get("body").type(`{${modifierKey}}{enter}`); - cy.wait("@postExecute"); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/BugTests/GitBugs.ts b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/BugTests/GitBugs.ts new file mode 100644 index 0000000000..f23afc1108 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/BugTests/GitBugs.ts @@ -0,0 +1,66 @@ +import { ObjectsRegistry } from "../../../../support/Objects/Registry"; +import { WIDGET } from "../../../../locators/WidgetLocators"; + +let dataSources = ObjectsRegistry.DataSources, + gitSync = ObjectsRegistry.GitSync, + agHelper = ObjectsRegistry.AggregateHelper, + ee = ObjectsRegistry.EntityExplorer, + propPane = ObjectsRegistry.PropertyPane, + locator = ObjectsRegistry.CommonLocators, + apiPage = ObjectsRegistry.ApiPage; + +let testName: any; +describe("Git Bugs", function() { + it("1. Bug 16248, When GitSync modal is open, block shortcut action execution", function() { + const largeResponseApiUrl = "https://jsonplaceholder.typicode.com/users"; + const modifierKey = Cypress.platform === "darwin" ? "meta" : "ctrl"; + apiPage.CreateAndFillApi(largeResponseApiUrl, "GitSyncTest"); + gitSync.OpenGitSyncModal(); + cy.get("body").type(`{${modifierKey}}{enter}`); + cy.get("@postExecute").should("not.exist"); + gitSync.CloseGitSyncModal(); + cy.get("body").type(`{${modifierKey}}{enter}`); + agHelper.ValidateNetworkStatus("@postExecute"); + }); + + it("2. Bug 18665 : Creates a new Git branch, Create datasource, discard it and check current branch", function() { + gitSync.CreateNConnectToGit(); + gitSync.CreateGitBranch(); + dataSources.NavigateToDSCreateNew(); + dataSources.CreatePlugIn("PostgreSQL"); + dataSources.SaveDSFromDialog(false); + agHelper.AssertElementVisible(gitSync._branchButton); + cy.get("@gitRepoName").then((repoName) => { + testName = repoName; + }); + }); + + it("3. Bug 18376: navigateTo fails to set queryParams if the app is connected to Git", () => { + ee.AddNewPage(); + ee.DragDropWidgetNVerify(WIDGET.TEXT); + ee.SelectEntityByName("Page1", "Pages"); + ee.DragDropWidgetNVerify(WIDGET.BUTTON); + propPane.SelectPropertiesDropDown("onClick", "Navigate to"); + agHelper.Sleep(500); + propPane.SelectPropertiesDropDown("onClick", "Page2", "Page"); + agHelper.EnterActionValue("Query Params", `{{{testQP: "Yes"}}}`); + ee.SelectEntityByName("Page2", "Pages"); + ee.SelectEntityByName("Text1", "Widgets"); + propPane.UpdatePropertyFieldValue( + "Text", + "{{appsmith.URL.queryParams.testQP}}", + ); + ee.SelectEntityByName("Page1", "Pages"); + agHelper.ClickButton("Submit"); + agHelper.Sleep(500); + agHelper + .GetText(locator._textWidget) + .then(($qp) => expect($qp).to.eq("Yes")); + agHelper.ValidateURL("branch=" + testName); //Validate we are still in Git branch + agHelper.ValidateURL("testQP=Yes"); //Validate we also ve the Query Params from Page1 + }); + + after(() => { + gitSync.DeleteTestGithubRepo(testName); + }); +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Git/GitDatasourceChange/CreateBranch_DiscardDatasource_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Git/GitDatasourceChange/CreateBranch_DiscardDatasource_spec.js deleted file mode 100644 index baf0cf884f..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Git/GitDatasourceChange/CreateBranch_DiscardDatasource_spec.js +++ /dev/null @@ -1,45 +0,0 @@ -import commonLocators from "../../../../../locators/commonlocators.json"; -import { ObjectsRegistry } from "../../../../../support/Objects/Registry"; -import gitSyncLocators from "../../../../../locators/gitSyncLocators"; - -let dataSources = ObjectsRegistry.DataSources; -let testBranchName = "Test"; - -let repoName; -describe("Bug 18665: Git sync:", function() { - before(() => { - cy.NavigateToHome(); - cy.createWorkspace(); - cy.wait("@createWorkspace").then((interception) => { - const newWorkspaceName = interception.response.body.data.name; - cy.CreateAppForWorkspace(newWorkspaceName, newWorkspaceName); - }); - - cy.generateUUID().then((uid) => { - repoName = "test" + uid; - cy.createTestGithubRepo(repoName); - cy.connectToGitRepo(repoName); - }); - }); - - it("1. creates a new branch", function() { - cy.get(commonLocators.canvas).click({ force: true }); - cy.generateUUID().then((uid) => { - testBranchName += uid; - cy.createGitBranch(testBranchName + uid); - }); - }); - - it("2. Create datasource, discard it and check current branch", function() { - dataSources.NavigateToDSCreateNew(); - dataSources.CreatePlugIn("PostgreSQL"); - dataSources.SaveDSFromDialog(false); - cy.get(gitSyncLocators.branchButton) - .contains(testBranchName) - .should("be.visible"); - }); - - after(() => { - cy.deleteTestGithubRepo(repoName); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Git/GitImport/GitImport_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Git/GitImport/GitImport_spec.js index 4855d22357..6ad1e4b186 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Git/GitImport/GitImport_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Git/GitImport/GitImport_spec.js @@ -9,18 +9,18 @@ const datasourceEditor = require("../../../../../locators/DatasourcesEditor.json const jsObject = "JSObject1"; const newBranch = "feat/temp"; const mainBranch = "master"; -let repoName; +let repoName, newWorkspaceName; describe("Git import flow", function() { before(() => { cy.NavigateToHome(); cy.createWorkspace(); cy.wait("@createWorkspace").then((interception) => { - const newWorkspaceName = interception.response.body.data.name; + newWorkspaceName = interception.response.body.data.name; cy.CreateAppForWorkspace(newWorkspaceName, newWorkspaceName); }); }); - it("1. Import an app from JSON with Postgres, MySQL, Mongo db", () => { + it("1. Import an app from JSON with Postgres, MySQL, Mongo db & then connect it to Git", () => { cy.NavigateToHome(); cy.get(homePage.optionsIcon) .first() @@ -71,9 +71,10 @@ describe("Git import flow", function() { cy.connectToGitRepo(repoName); }); }); + cy.wait(4000); // for git connection to settle! }); - it("2. Import an app from Git and reconnect Postgres, MySQL and Mongo db ", () => { + it("2. Import the previous app connected to Git and reconnect Postgres, MySQL and Mongo db ", () => { cy.NavigateToHome(); cy.createWorkspace(); cy.wait("@createWorkspace").then((interception) => { @@ -116,7 +117,7 @@ describe("Git import flow", function() { cy.get(reconnectDatasourceModal.ImportSuccessModalCloseBtn).click({ force: true, }); - cy.wait(1000); + cy.wait(6000); //for git connection to settle /* cy.get(homePage.toastMessage).should( "contain", "Application imported successfully", diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OnLoadTests/APIOnLoad_Spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OnLoadTests/APIOnLoad_Spec.ts index 16a55605d0..3960719201 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OnLoadTests/APIOnLoad_Spec.ts +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OnLoadTests/APIOnLoad_Spec.ts @@ -38,6 +38,7 @@ describe("JSObjects OnLoad Actions tests", function() { "PageLoadApi2", ); apiPage.ToggleOnPageLoadRun(true); + ee.ExpandCollapseEntity("Widgets") ee.ExpandCollapseEntity("Container3"); ee.SelectEntityByName("Table1"); propPane.UpdatePropertyFieldValue( diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OnLoadTests/JSOnLoad1_Spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OnLoadTests/JSOnLoad1_Spec.ts index bb32f045d5..2bedbcf5b4 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OnLoadTests/JSOnLoad1_Spec.ts +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OnLoadTests/JSOnLoad1_Spec.ts @@ -24,9 +24,6 @@ describe("JSObjects OnLoad Actions tests", function() { cy.fixture("tablev1NewDsl").then((val: any) => { agHelper.AddDsl(val); }); - }); - - it("1. Create Postgress DS & the query", function() { ee.NavigateToSwitcher("explorer"); dataSources.CreateDataSource("Postgres"); cy.get("@dsName").then(($dsName) => { @@ -34,7 +31,7 @@ describe("JSObjects OnLoad Actions tests", function() { }); }); - it("2. Tc 54, 55 - Verify User enables only 'Before Function calling' & OnPage Load is Automatically enable after mapping done on JSOBject", function() { + it("1. Tc 54, 55 - Verify User enables only 'Before Function calling' & OnPage Load is Automatically enable after mapping done on JSOBject", function() { jsEditor.CreateJSObject( `export default { getEmployee: async () => { @@ -81,7 +78,7 @@ describe("JSObjects OnLoad Actions tests", function() { deployMode.NavigateBacktoEditor(); }); - it("3. Tc 54, 55 - Verify OnPage Load - auto enabled from above case for JSOBject", function() { + it("2. Tc 54, 55 - Verify OnPage Load - auto enabled from above case for JSOBject", function() { agHelper.AssertElementVisible(jsEditor._dialog("Confirmation Dialog")); agHelper.AssertElementVisible( jsEditor._dialogBody((jsName as string) + ".getEmployee"), @@ -93,62 +90,9 @@ describe("JSObjects OnLoad Actions tests", function() { jsEditor.VerifyAsyncFuncSettings("getEmployee", true, true); }); - it.skip("4. Tc 53 - Verify OnPage Load - Enabled & Disabling - Before Function calling for JSOBject", function() { - ee.SelectEntityByName(jsName as string, "Queries/JS"); - jsEditor.EnableDisableAsyncFuncSettings("getEmployee", true, false); - deployMode.DeployApp(); - agHelper.AssertElementAbsence(jsEditor._dialog("Confirmation Dialog")); - agHelper.AssertElementAbsence( - jsEditor._dialogBody((jsName as string) + ".getEmployee"), - ); - // assert that on view mode, we don't get "successful run" toast message for onpageload actions - agHelper.AssertElementAbsence(locator._specificToast("ran successfully")); - agHelper.ValidateNetworkExecutionSuccess("@postExecute"); - table.ReadTableRowColumnData(0, 0).then((cellData) => { - expect(cellData).to.be.equal("2"); - }); - deployMode.NavigateBacktoEditor(); - }); - - it("5. Verify Error for OnPage Load - disable & Before Function calling enabled for JSOBject", function() { - ee.SelectEntityByName(jsName as string, "Queries/JS"); - jsEditor.EnableDisableAsyncFuncSettings("getEmployee", false, true); - deployMode.DeployApp(locator._widgetInDeployed("tablewidget"), false); - agHelper.WaitUntilToastDisappear('The action "GetEmployee" has failed'); - deployMode.NavigateBacktoEditor(); - agHelper.WaitUntilToastDisappear('The action "GetEmployee" has failed'); - ee.ExpandCollapseEntity("Queries/JS"); - ee.SelectEntityByName(jsName as string); - jsEditor.EnableDisableAsyncFuncSettings("getEmployee", true, true); - }); - - it.skip("6. Tc 55 - Verify OnPage Load - Enabling & Before Function calling Enabling for JSOBject", function() { - // ee.ExpandCollapseEntity("Queries/JS"); - // ee.SelectEntityByName(jsName as string); - // jsEditor.EnableDisableAsyncFuncSettings("getEmployee", true, true); - deployMode.DeployApp(locator._widgetInDeployed("tablewidget"), false); - agHelper.Sleep(6000); //incase toast appears - agHelper.AssertElementVisible(jsEditor._dialog("Confirmation Dialog")); - agHelper.AssertElementVisible( - jsEditor._dialogBody((jsName as string) + ".getEmployee"), - ); - agHelper.ClickButton("Yes"); - agHelper.AssertElementAbsence(locator._toastMsg); - table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { - expect(cellData).to.be.equal("2"); - }); - //agHelper.ValidateNetworkExecutionSuccess("@postExecute"); - deployMode.NavigateBacktoEditor(); - agHelper.AssertElementVisible(jsEditor._dialog("Confirmation Dialog")); - agHelper.AssertElementVisible( - jsEditor._dialogBody((jsName as string) + ".getEmployee"), - ); - agHelper.ClickButton("Yes"); - agHelper.ValidateToastMessage("getEmployee ran successfully"); //Verify this toast comes in EDIT page only - }); - - it("7. Tc 56 - Verify OnPage Load - Enabled & Before Function calling Enabled for JSOBject & User clicks No & then Yes in Confirmation dialog", function() { - deployMode.DeployApp(); + it("3. Tc 56 - Verify OnPage Load - Enabled & Before Function calling Enabled for JSOBject & User clicks No & then Yes in Confirmation dialog", function() { + deployMode.DeployApp();//Adding this check since GetEmployee failure toast is always coming & making product flaky + //agHelper.WaitUntilAllToastsDisappear(); agHelper.AssertElementVisible(jsEditor._dialog("Confirmation Dialog")); agHelper.AssertElementVisible( jsEditor._dialogBody((jsName as string) + ".getEmployee"), @@ -157,6 +101,7 @@ describe("JSObjects OnLoad Actions tests", function() { agHelper.AssertContains(`${jsName + ".getEmployee"} was cancelled`); table.WaitForTableEmpty(); agHelper.WaitUntilAllToastsDisappear(); + agHelper.RefreshPage(); agHelper.AssertElementVisible(jsEditor._dialog("Confirmation Dialog")); agHelper.AssertElementVisible( @@ -175,6 +120,62 @@ describe("JSObjects OnLoad Actions tests", function() { ); agHelper.ClickButton("Yes"); agHelper.ValidateToastMessage("getEmployee ran successfully"); //Verify this toast comes in EDIT page only + }); + + //Skipping due to - "tableData":"ERROR: invalid input syntax for type smallint: "{}"" + it.skip("4. Tc 53 - Verify OnPage Load - Enabled & Disabling - Before Function calling for JSOBject", function() { + ee.SelectEntityByName(jsName as string, "Queries/JS"); + jsEditor.EnableDisableAsyncFuncSettings("getEmployee", true, false); + //jsEditor.RunJSObj(); //Even running JS functin before delpoying does not help + //agHelper.Sleep(2000); + deployMode.DeployApp(); + agHelper.AssertElementAbsence(jsEditor._dialog("Confirmation Dialog")); + agHelper.AssertElementAbsence( + jsEditor._dialogBody((jsName as string) + ".getEmployee"), + ); + // assert that on view mode, we don't get "successful run" toast message for onpageload actions + agHelper.AssertElementAbsence(locator._specificToast("ran successfully")); //failed toast is appearing hence skipping + agHelper.ValidateNetworkExecutionSuccess("@postExecute"); + table.ReadTableRowColumnData(0, 0).then((cellData) => { + expect(cellData).to.be.equal("2"); + }); + deployMode.NavigateBacktoEditor(); + }); + + it("5. Verify Error for OnPage Load - disable & Before Function calling enabled for JSOBject", function() { + ee.SelectEntityByName(jsName as string, "Queries/JS"); + jsEditor.EnableDisableAsyncFuncSettings("getEmployee", false, true); + deployMode.DeployApp(locator._widgetInDeployed("tablewidget"), false); + agHelper.WaitUntilToastDisappear('The action "GetEmployee" has failed'); + deployMode.NavigateBacktoEditor(); + agHelper.WaitUntilToastDisappear('The action "GetEmployee" has failed'); + // ee.ExpandCollapseEntity("Queries/JS"); + // ee.SelectEntityByName(jsName as string); + // jsEditor.EnableDisableAsyncFuncSettings("getEmployee", true, true); + // agHelper.GetNClick(jsEditor._runButton); + // agHelper.ClickButton("Yes"); + }); + + it("6. Tc 55 - Verify OnPage Load - Enabling & Before Function calling Enabling for JSOBject & deleting testdata", function() { + // deployMode.DeployApp(locator._widgetInDeployed("tablewidget"), false); + // agHelper.WaitUntilAllToastsDisappear(); //incase toast appears, GetEmployee failure toast is appearing + // agHelper.AssertElementVisible(jsEditor._dialog("Confirmation Dialog")); + // agHelper.AssertElementVisible( + // jsEditor._dialogBody((jsName as string) + ".getEmployee"), + // ); + // agHelper.ClickButton("Yes"); + // agHelper.AssertElementAbsence(locator._toastMsg); + // table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { + // expect(cellData).to.be.equal("2"); + // }); + // //agHelper.ValidateNetworkExecutionSuccess("@postExecute"); + // deployMode.NavigateBacktoEditor(); + // agHelper.AssertElementVisible(jsEditor._dialog("Confirmation Dialog")); + // agHelper.AssertElementVisible( + // jsEditor._dialogBody((jsName as string) + ".getEmployee"), + // ); + // agHelper.ClickButton("Yes"); + // agHelper.ValidateToastMessage("getEmployee ran successfully"); //Verify this toast comes in EDIT page only ee.SelectEntityByName(jsName as string, "Queries/JS"); ee.ActionContextMenuByEntityName( @@ -183,11 +184,10 @@ describe("JSObjects OnLoad Actions tests", function() { "Are you sure?", true, ); - ee.ActionContextMenuByEntityName("GetEmployee", "Delete", "Are you sure?"); }); - it("8. Tc 60, 1912 - Verify JSObj calling API - OnPageLoad calls & Confirmation No then Yes!", () => { + it("7. Tc 60, 1912 - Verify JSObj calling API - OnPageLoad calls & Confirmation No then Yes!", () => { ee.SelectEntityByName("Page1"); cy.fixture("JSApiOnLoadDsl").then((val: any) => { agHelper.AddDsl(val, locator._widgetInCanvas("imagewidget")); @@ -332,7 +332,7 @@ describe("JSObjects OnLoad Actions tests", function() { // cy.get("div.t--draggable-inputwidgetv2 > div.iPntND").invoke('attr', 'style', 'height: 304px') }); - it("9. Tc #1912 - API with OnPageLoad & Confirmation both enabled & called directly & setting previous Api's confirmation to false", () => { + it("8. Tc #1912 - API with OnPageLoad & Confirmation both enabled & called directly & setting previous Api's confirmation to false", () => { deployMode.NavigateBacktoEditor(); agHelper.AssertElementExist(jsEditor._dialogInDeployView); agHelper.ClickButton("No"); @@ -380,7 +380,7 @@ describe("JSObjects OnLoad Actions tests", function() { agHelper.ClickButton("No"); }); - it("10. Tc #1646, 60 - Honouring the order of execution & Bug 13826 + Bug 13646", () => { + it("9. Tc #1646, 60 - Honouring the order of execution & Bug 13826 + Bug 13646", () => { homePage.NavigateToHome(); homePage.ImportApp("JSObjOnLoadApp.json"); homePage.AssertImportToast(); @@ -498,7 +498,7 @@ describe("JSObjects OnLoad Actions tests", function() { }); }); - it("11. Tc #1646 - Honouring the order of execution & Bug 13826 + Bug 13646 - Delpoy page", () => { + it("10. Tc #1646 - Honouring the order of execution & Bug 13826 + Bug 13646 - Delpoy page", () => { deployMode.DeployApp(); agHelper.AssertElementVisible(jsEditor._dialogBody("getBooks")); agHelper.ClickButton("No"); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/Params/PassingParams_Spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/Params/PassingParams_Spec.ts index d08d339286..054070f3a1 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/Params/PassingParams_Spec.ts +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/Params/PassingParams_Spec.ts @@ -57,11 +57,10 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", table.ReadTableRowColumnData(0, 0, 3000).then((cellData) => { expect(cellData).to.be.equal("7"); }); - - deployMode.NavigateBacktoEditor(); }); it("2. With Optional chaining : {{ (function() { return this?.params?.condition })() }}", function() { + deployMode.NavigateBacktoEditor(); ee.SelectEntityByName("ParamsTest", "Queries/JS"); dataSources.EnterQuery( "SELECT * FROM public.users where id = {{(function() { return this?.params?.condition })() || '1=1'}} order by id", @@ -73,10 +72,10 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { expect(cellData).to.be.equal("9"); }); - deployMode.NavigateBacktoEditor(); }); it("3. With Optional chaining : {{ (() => { return this?.params?.condition })() }}", function() { + deployMode.NavigateBacktoEditor(); ee.SelectEntityByName("ParamsTest", "Queries/JS"); dataSources.EnterQuery( "SELECT * FROM public.users where id = {{(() => { return this?.params?.condition })() || '1=1'}} order by id", @@ -88,10 +87,10 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { expect(cellData).to.be.equal("7"); }); - deployMode.NavigateBacktoEditor(); }); it("4. With Optional chaining : {{ this?.params.condition }}", function() { + deployMode.NavigateBacktoEditor(); ee.SelectEntityByName("ParamsTest", "Queries/JS"); dataSources.EnterQuery( "SELECT * FROM public.users where id = {{this?.params.condition || '1=1'}} order by id", @@ -103,10 +102,10 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { expect(cellData).to.be.equal("9"); }); - deployMode.NavigateBacktoEditor(); }); it("5. With Optional chaining : {{ (function() { return this?.params.condition })() }}", function() { + deployMode.NavigateBacktoEditor(); ee.SelectEntityByName("ParamsTest", "Queries/JS"); dataSources.EnterQuery( "SELECT * FROM public.users where id = {{(function() { return this?.params.condition })() || '1=1'}} order by id", @@ -118,10 +117,10 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { expect(cellData).to.be.equal("7"); }); - deployMode.NavigateBacktoEditor(); }); it("6. With Optional chaining : {{ (() => { return this?.params.condition })() }}", function() { + deployMode.NavigateBacktoEditor(); ee.SelectEntityByName("ParamsTest", "Queries/JS"); dataSources.EnterQuery( "SELECT * FROM public.users where id = {{(() => { return this?.params.condition })() || '1=1'}} order by id", @@ -133,10 +132,10 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { expect(cellData).to.be.equal("9"); }); - deployMode.NavigateBacktoEditor(); }); it("7. With No Optional chaining : {{ this.params.condition }}", function() { + deployMode.NavigateBacktoEditor(); ee.SelectEntityByName("ParamsTest", "Queries/JS"); dataSources.EnterQuery( "SELECT * FROM public.users where id = {{this.params.condition || '1=1'}} order by id", @@ -148,10 +147,10 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { expect(cellData).to.be.equal("7"); }); - deployMode.NavigateBacktoEditor(); }); it("8. With No Optional chaining : {{ (function() { return this.params.condition })() }}", function() { + deployMode.NavigateBacktoEditor(); ee.SelectEntityByName("ParamsTest", "Queries/JS"); dataSources.EnterQuery( "SELECT * FROM public.users where id = {{(function() { return this.params.condition })() || '1=1'}} order by id", @@ -163,10 +162,10 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { expect(cellData).to.be.equal("8"); }); - deployMode.NavigateBacktoEditor(); }); it("9. With No Optional chaining : {{ (() => { return this.params.condition })() }}", function() { + deployMode.NavigateBacktoEditor(); ee.SelectEntityByName("ParamsTest", "Queries/JS"); dataSources.EnterQuery( "SELECT * FROM public.users where id = {{(() => { return this.params.condition })() || '1=1'}} order by id", @@ -178,10 +177,10 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { expect(cellData).to.be.equal("9"); }); - deployMode.NavigateBacktoEditor(); }); it("10. With Optional chaining : {{ this.params.condition }} && direct paramter passed", function() { + deployMode.NavigateBacktoEditor(); ee.SelectEntityByName("ParamsTest", "Queries/JS"); dataSources.EnterQuery( "SELECT * FROM public.users where id = {{(() => { return this.params.condition })() || '7'}} order by id", @@ -197,10 +196,10 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { expect(cellData).to.be.equal("7"); }); - deployMode.NavigateBacktoEditor(); }); it("11. With Optional chaining : {{ this.params.condition }} && no optional paramter passed", function() { + deployMode.NavigateBacktoEditor(); ee.SelectEntityByName("ParamsTest", "Queries/JS"); dataSources.EnterQuery( "SELECT * FROM public.users where id = {{(() => { return this.params.condition })()}} order by id", @@ -211,10 +210,10 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", table.ReadTableRowColumnData(0, 0, 2000).then((cellData) => { expect(cellData).to.be.equal("8"); }); - deployMode.NavigateBacktoEditor(); }); it("12. Delete all entities - Query, JSObjects, Datasource + Bug 12532", () => { + deployMode.NavigateBacktoEditor(); ee.ExpandCollapseEntity("Queries/JS"); ee.ActionContextMenuByEntityName("ParamsTest", "Delete", "Are you sure?"); agHelper.ValidateNetworkStatus("@deleteAction", 200); diff --git a/app/client/cypress/locators/gitSyncLocators.js b/app/client/cypress/locators/gitSyncLocators.js index d84a95b72d..cb71317f56 100644 --- a/app/client/cypress/locators/gitSyncLocators.js +++ b/app/client/cypress/locators/gitSyncLocators.js @@ -58,4 +58,6 @@ export default { regenerateSSHKeyECDSA: "[data-cy='t--regenerate-sshkey-ECDSA']", regenerateSSHKeyRSA: "[data-cy='t--regenerate-sshkey-RSA']", confirmButton: "//span[text()='Yes']", + mergeConflicts: + "//span[contains(text(), 'There are uncommitted changes present in your local branch master. Please commit them first and try again')]", }; diff --git a/app/client/cypress/support/Objects/CommonLocators.ts b/app/client/cypress/support/Objects/CommonLocators.ts index adefaa9b83..95b18b993d 100644 --- a/app/client/cypress/support/Objects/CommonLocators.ts +++ b/app/client/cypress/support/Objects/CommonLocators.ts @@ -20,7 +20,7 @@ export class CommonLocators { _codeEditorTarget = "div.CodeEditorTarget"; _entityExplorersearch = "#entity-explorer-search"; _propertyControl = ".t--property-control-"; - _textWidget = ".t--draggable-textwidget span"; + _textWidget = ".t--draggable-textwidget .t--text-widget-container span"; _inputWidget = ".t--draggable-inputwidgetv2 input"; _publishButton = ".t--application-publish-btn"; _widgetInCanvas = (widgetType: string) => `.t--draggable-${widgetType}`; @@ -72,6 +72,10 @@ export class CommonLocators { "//div[contains(@class, 't--property-control-" + ddName.replace(/ +/g, "").toLowerCase() + "')]//button[contains(@class, 't--open-dropdown-Select-Action')]"; + _selectPropPageDropdown = (ddName: string) => + "//div[contains(@class, 't--property-control-" + + ddName.replace(/ +/g, "").toLowerCase() + + "')]//button[contains(@class, 't--open-dropdown-Select-Page')]"; _dropDownValue = (dropdownOption: string) => ".single-select:contains('" + dropdownOption + "')"; _selectOptionValue = (dropdownOption: string) => diff --git a/app/client/cypress/support/Pages/AggregateHelper.ts b/app/client/cypress/support/Pages/AggregateHelper.ts index 443b9b896e..7435b16344 100644 --- a/app/client/cypress/support/Pages/AggregateHelper.ts +++ b/app/client/cypress/support/Pages/AggregateHelper.ts @@ -104,7 +104,7 @@ export class AggregateHelper { public RenameWithInPane(renameVal: string, query = true) { const name = query ? this.locator._queryName : this.locator._dsName; const text = query ? this.locator._queryNameTxt : this.locator._dsNameTxt; - cy.get(name).click({ force: true }); + this.GetNClick(name, 0, true); cy.get(text) .clear({ force: true }) .type(renameVal, { force: true }) @@ -530,7 +530,12 @@ export class AggregateHelper { return cy.get(selector).invoke("val"); } - public TypeText(selector: string, value: string, index = 0) { + public TypeText( + selector: string, + value: string, + index = 0, + parseSpecialCharSeq = false, + ) { const locator = selector.startsWith("//") ? cy.xpath(selector) : cy.get(selector); @@ -538,7 +543,7 @@ export class AggregateHelper { .eq(index) .focus() .type(value, { - parseSpecialCharSequences: false, + parseSpecialCharSequences: parseSpecialCharSeq, //delay: 3, //force: true, }); @@ -570,13 +575,14 @@ export class AggregateHelper { } public CheckUncheck(selector: string, check = true) { - const locator = selector.startsWith("//") - ? cy.xpath(selector) - : cy.get(selector); if (check) { - locator.check({ force: true }).should("be.checked"); + this.GetElement(selector) + .check({ force: true }) + .should("be.checked"); } else { - locator.uncheck({ force: true }).should("not.be.checked"); + this.GetElement(selector) + .uncheck({ force: true }) + .should("not.be.checked"); } this.Sleep(); } @@ -600,6 +606,18 @@ export class AggregateHelper { } } + public AssertAttribute( + selector: string, + attribName: string, + attribValue: string, + ) { + return this.GetElement(selector).should( + "have.attr", + attribName, + attribValue, + ); + } + public ToggleSwitch( switchName: string, toggle: "check" | "uncheck" = "check", @@ -945,6 +963,10 @@ export class AggregateHelper { .should(exists); } + public ValidateURL(url: string) { + cy.url().should("include", url); + } + public ScrollTo( selector: ElementType, position: diff --git a/app/client/cypress/support/Pages/ApiPage.ts b/app/client/cypress/support/Pages/ApiPage.ts index b0c7302c4c..18804bff85 100644 --- a/app/client/cypress/support/Pages/ApiPage.ts +++ b/app/client/cypress/support/Pages/ApiPage.ts @@ -196,25 +196,14 @@ export class ApiPage { ToggleOnPageLoadRun(enable = true || false) { this.SelectPaneTab("Settings"); if (enable) - cy.get(this._onPageLoad).check({ - force: true, - }); - else - cy.get(this._onPageLoad).uncheck({ - force: true, - }); + this.agHelper.CheckUncheck(this._onPageLoad, true); + else this.agHelper.CheckUncheck(this._onPageLoad, false); } ToggleConfirmBeforeRunningApi(enable = true || false) { this.SelectPaneTab("Settings"); - if (enable) - cy.get(this._confirmBeforeRunningAPI).check({ - force: true, - }); - else - cy.get(this._confirmBeforeRunningAPI).uncheck({ - force: true, - }); + if (enable) this.agHelper.CheckUncheck(this._confirmBeforeRunningAPI, true); + else this.agHelper.CheckUncheck(this._confirmBeforeRunningAPI, false); } SelectPaneTab( diff --git a/app/client/cypress/support/Pages/DataSources.ts b/app/client/cypress/support/Pages/DataSources.ts index 133f550aff..8be30fba49 100644 --- a/app/client/cypress/support/Pages/DataSources.ts +++ b/app/client/cypress/support/Pages/DataSources.ts @@ -217,6 +217,7 @@ export class DataSources { this.agHelper.AssertElementAbsence( this.locator._specificToast("Duplicate key error"), ); + this.agHelper.PressEscape(); // if (waitForToastDisappear) // this.agHelper.WaitUntilToastDisappear("datasource created"); // else this.agHelper.AssertContains("datasource created"); @@ -625,7 +626,6 @@ export class DataSources { } else { this.SaveDatasource(); } - cy.wrap(dataSourceName).as("dsName"); }); } diff --git a/app/client/cypress/support/Pages/EntityExplorer.ts b/app/client/cypress/support/Pages/EntityExplorer.ts index 76c1f7e45f..77a8c46824 100644 --- a/app/client/cypress/support/Pages/EntityExplorer.ts +++ b/app/client/cypress/support/Pages/EntityExplorer.ts @@ -56,6 +56,7 @@ export class EntityExplorer { "//div[contains(@class, 't--entity-name')][text()='" + modalName + "']/ancestor::div[contains(@class, 't--entity-item')]/following-sibling::div//div[contains(@class, 't--entity-name')][contains(text(), 'Text')]"; + private _newPageOptions = (option: string) => `[data-cy='${option}']`; public SelectEntityByName( entityNameinLeftSidebar: string, @@ -90,10 +91,8 @@ export class EntityExplorer { | "generate-page" | "add-page-from-template" = "add-page", ) { - cy.get(this.locator._newPage) - .first() - .click(); - cy.get(`[data-cy='${option}']`).click(); + this.agHelper.GetNClick(this.locator._newPage); + this.agHelper.GetNClick(this._newPageOptions(option)); if (option === "add-page") { this.agHelper.ValidateNetworkStatus("@createPage", 201); } @@ -232,7 +231,7 @@ export class EntityExplorer { } public RenameEntityFromExplorer(entityName: string, renameVal: string) { - cy.xpath(this._entityNameInExplorer(entityName)).dblclick() + cy.xpath(this._entityNameInExplorer(entityName)).dblclick(); cy.xpath(this.locator._entityNameEditing(entityName)).type( renameVal + "{enter}", ); diff --git a/app/client/cypress/support/Pages/GitSync.ts b/app/client/cypress/support/Pages/GitSync.ts index 5e2ef760d6..60e82d9015 100644 --- a/app/client/cypress/support/Pages/GitSync.ts +++ b/app/client/cypress/support/Pages/GitSync.ts @@ -1,4 +1,5 @@ import { ObjectsRegistry } from "../Objects/Registry"; +const GITHUB_API_BASE = "https://api.github.com"; export class GitSync { public agHelper = ObjectsRegistry.AggregateHelper; @@ -7,14 +8,139 @@ export class GitSync { private _connectGitBottomBar = ".t--connect-git-bottom-bar"; private _gitSyncModal = ".git-sync-modal"; private _closeGitSyncModal = ".t--close-git-sync-modal"; + private _gitRepoInput = ".t--git-repo-input"; + private _useDefaultConfig = + "//span[text()='Use default configuration']/parent::div"; + private _gitConfigNameInput = ".t--git-config-name-input"; + private _gitConfigEmailInput = ".t--git-config-email-input"; + _branchButton = "[data-testid=t--branch-button-container]"; + private _branchSearchInput = ".t--branch-search-input"; - openGitSyncModal() { - cy.get(this._connectGitBottomBar).click(); - cy.get(this._gitSyncModal).should("be.visible"); + + OpenGitSyncModal() { + this.agHelper.GetNClick(this._connectGitBottomBar); + this.agHelper.AssertElementVisible(this._gitSyncModal); } - closeGitSyncModal() { - cy.get(this._closeGitSyncModal).click(); - cy.get(this._gitSyncModal).should("not.exist"); + CloseGitSyncModal() { + this.agHelper.GetNClick(this._closeGitSyncModal); + this.agHelper.AssertElementAbsence(this._gitSyncModal); + } + + CreateNConnectToGit(repoName: string = "Test") { + this.agHelper.GenerateUUID(); + cy.get("@guid").then((uid) => { + repoName += uid; + this.CreateTestGithubRepo(repoName); + this.ConnectToGitRepo(repoName); + cy.wrap(repoName).as("gitRepoName"); + }); + } + + private ConnectToGitRepo(repo: string, assertConnect = true) { + // const testEmail = "test@test.com"; + // const testUsername = "testusername"; + const owner = Cypress.env("TEST_GITHUB_USER_NAME"); + let generatedKey; + this.OpenGitSyncModal(); + + cy.intercept( + { url: "api/v1/git/connect/app/*", hostname: window.location.host }, + (req) => { + req.headers["origin"] = "Cypress"; + }, + ); + + cy.intercept("POST", "/api/v1/applications/ssh-keypair/*").as( + `generateKey-${repo}`, + ); + + this.agHelper.AssertAttribute( + this._gitRepoInput, + "placeholder", + "git@example.com:user/repository.git", + ); + this.agHelper.TypeText( + this._gitRepoInput, + `git@github.com:${owner}/${repo}.git`, + ); + + this.agHelper.ClickButton("Generate key"); + + cy.wait(`@generateKey-${repo}`).then((result: any) => { + generatedKey = result.response.body.data.publicKey; + generatedKey = generatedKey.slice(0, generatedKey.length - 1); + // fetch the generated key and post to the github repo + cy.request({ + method: "POST", + url: `${GITHUB_API_BASE}/repos/${Cypress.env( + "TEST_GITHUB_USER_NAME", + )}/${repo}/keys`, + headers: { + Authorization: `token ${Cypress.env("GITHUB_PERSONAL_ACCESS_TOKEN")}`, + }, + body: { + title: "key0", + key: generatedKey, + }, + }); + + this.agHelper.GetNClick(this._useDefaultConfig); //Uncheck the Use default configuration + this.agHelper.TypeText( + this._gitConfigNameInput, + "testusername", + //`{selectall}${testUsername}`, + ); + this.agHelper.TypeText(this._gitConfigEmailInput, "test@test.com"); + this.agHelper.ClickButton("CONNECT"); + if (assertConnect) { + this.agHelper.ValidateNetworkStatus("@connectGitRepo"); + } + this.CloseGitSyncModal(); + }); + } + + private CreateTestGithubRepo(repo: string, privateFlag = false) { + cy.request({ + method: "POST", + url: `${GITHUB_API_BASE}/user/repos`, + headers: { + Authorization: `token ${Cypress.env("GITHUB_PERSONAL_ACCESS_TOKEN")}`, + }, + body: { + name: repo, + private: privateFlag, + }, + }); + } + + DeleteTestGithubRepo(repo: any) { + cy.request({ + method: "DELETE", + url: `${GITHUB_API_BASE}/repos/${Cypress.env( + "TEST_GITHUB_USER_NAME", + )}/${repo}`, + headers: { + Authorization: `token ${Cypress.env("GITHUB_PERSONAL_ACCESS_TOKEN")}`, + }, + }); + } + + CreateGitBranch(branch: string = "Test") { + //this.agHelper.GenerateUUID(); + this.agHelper.GetNClick(this._branchButton); + this.agHelper.Sleep(2000); //branch pop up to open + cy.get("@guid").then((uid) => { + //using the same uid as generated during CreateNConnectToGit + this.agHelper.TypeText( + this._branchSearchInput, + `{selectall}` + `${branch + uid}` + `{enter}`, + 0, + true, + ); + cy.wrap(branch + uid).as("gitbranchName"); + }); + this.agHelper.AssertElementExist(this.locator._spinner); + this.agHelper.AssertElementAbsence(this.locator._spinner, 30000); } } diff --git a/app/client/cypress/support/Pages/PropertyPane.ts b/app/client/cypress/support/Pages/PropertyPane.ts index 1c91d2612d..fdade19249 100644 --- a/app/client/cypress/support/Pages/PropertyPane.ts +++ b/app/client/cypress/support/Pages/PropertyPane.ts @@ -95,9 +95,15 @@ export class PropertyPane { this.agHelper.GetNClick(this._colorPickerV2Popover); this.agHelper.GetNClick(this._colorPickerV2Color, colorIndex); } else { - this.agHelper.GetElement(this._colorInput(type)).clear().wait(200); + this.agHelper + .GetElement(this._colorInput(type)) + .clear() + .wait(200); this.agHelper.TypeText(this._colorInput(type), colorIndex); - this.agHelper.GetElement(this._colorInput(type)).clear().wait(200); + this.agHelper + .GetElement(this._colorInput(type)) + .clear() + .wait(200); this.agHelper.TypeText(this._colorInput(type), colorIndex); //this.agHelper.UpdateInput(this._colorInputField(type), colorIndex);//not working! } @@ -163,11 +169,22 @@ export class PropertyPane { .click({ force: true }); } - public SelectPropertiesDropDown(endpoint: string, dropdownOption: string) { - cy.xpath(this.locator._selectPropDropdown(endpoint)) - .first() - .scrollIntoView() - .click(); + public SelectPropertiesDropDown( + endpoint: string, + dropdownOption: string, + action: "Action" | "Page" = "Action", + index = 0, + ) { + if (action == "Action") + this.agHelper.GetNClick( + this.locator._selectPropDropdown(endpoint), + index, + ); + else + this.agHelper.GetNClick( + this.locator._selectPropPageDropdown(endpoint), + index, + ); cy.get(this.locator._dropDownValue(dropdownOption)).click(); } diff --git a/app/client/cypress/support/gitSync.js b/app/client/cypress/support/gitSync.js index 8965f1d1a7..9281bbc07a 100644 --- a/app/client/cypress/support/gitSync.js +++ b/app/client/cypress/support/gitSync.js @@ -32,6 +32,7 @@ Cypress.Commands.add("revokeAccessGit", (appName) => { expect(id).to.eq(""); }); }); + Cypress.Commands.add( "connectToGitRepo", (repo, shouldCommit = true, assertConnectFailure) => { @@ -123,6 +124,7 @@ Cypress.Commands.add( }); }, ); + Cypress.Commands.add("latestDeployPreview", () => { cy.server(); cy.route("POST", "/api/v1/applications/publish/*").as("publishApp");