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 da8e65cdb4..0c84b377de 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 @@ -20,7 +20,7 @@ describe("Git import flow", function() { cy.CreateAppForWorkspace(newWorkspaceName, newWorkspaceName); }); }); - it("Import an app from JSON with Postgres, MySQL, Mongo db", () => { + it("1. Import an app from JSON with Postgres, MySQL, Mongo db", () => { cy.NavigateToHome(); cy.get(homePage.optionsIcon) .first() @@ -69,7 +69,7 @@ describe("Git import flow", function() { }); }); }); - it("Import an app from Git and reconnect Postgres, MySQL and Mongo db ", () => { + it("2. Import an app from Git and reconnect Postgres, MySQL and Mongo db ", () => { cy.NavigateToHome(); cy.createWorkspace(); cy.wait("@createWorkspace").then((interception) => { @@ -114,8 +114,12 @@ describe("Git import flow", function() { "contain", "Application imported successfully", ); */ + cy.wait("@gitStatus").then((interception) => { + cy.log(interception.response.body.data); + cy.wait(1000); + }); }); - it("Verfiy imported app should have all the data binding visible in deploy and edit mode", () => { + it("3. Verfiy imported app should have all the data binding visible in view and edit mode", () => { // verify postgres data binded to table cy.get(".tbody") .first() @@ -129,7 +133,7 @@ describe("Git import flow", function() { // verify js object binded to input widget cy.xpath("//input[@value='Success']").should("be.visible"); }); - it("Create a new branch, clone page and validate data on that branch in deploy and edit mode", () => { + it("4. Create a new branch, clone page and validate data on that branch in view and edit mode", () => { cy.createGitBranch(newBranch); cy.get(".tbody") .first() @@ -169,7 +173,8 @@ describe("Git import flow", function() { cy.get(homePage.publishButton).click(); cy.get(gitSyncLocators.commitCommentInput).type("Initial Commit"); cy.get(gitSyncLocators.commitButton).click(); - cy.wait(8000); + cy.intercept("POST", "api/v1/git/commit/app/*").as("commit"); + cy.wait(10000); cy.get(gitSyncLocators.closeGitSyncModal).click(); cy.wait(2000); cy.merge(mainBranch); @@ -197,7 +202,7 @@ describe("Git import flow", function() { cy.get(commonlocators.backToEditor).click(); cy.wait(2000); }); - it("Switch to master and verify data in edit and deploy mode", () => { + it("5. Switch to master and verify data in edit and view mode", () => { cy.switchGitBranch("master"); cy.wait(2000); // validate data binding in edit and deploy mode @@ -219,7 +224,7 @@ describe("Git import flow", function() { cy.get(commonlocators.backToEditor).click(); cy.wait(2000); }); - it("Add widget to master, merge then checkout to child branch and verify data", () => { + it("6. Add widget to master, merge then checkout to child branch and verify data", () => { cy.get(explorer.widgetSwitchId).click(); cy.wait(2000); // wait for transition cy.dragAndDropToCanvas("buttonwidget", { x: 300, y: 600 }); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/OtherUIFeatures/Fork_Template_To_App_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/OtherUIFeatures/Fork_Template_To_App_spec.js deleted file mode 100644 index 47214db82f..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/OtherUIFeatures/Fork_Template_To_App_spec.js +++ /dev/null @@ -1,20 +0,0 @@ -import widgetLocators from "../../../../locators/Widgets.json"; - -describe("Fork a template to the current app", () => { - it("Fork a template to the current app", () => { - cy.intercept("GET", "/api/v1/users/features", { - fixture: "featureFlags.json", - }).as("featureFlags"); - cy.reload(); - cy.get("[data-cy=start-from-template]").click(); - - cy.xpath( - "//div[text()='Customer Support Dashboard']/following-sibling::div//button[contains(@class, 'fork-button')]", - ).click(); - - cy.get(widgetLocators.toastAction).should( - "contain", - "template added successfully", - ); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Templates/ForkTemplateToGitConnectedApp.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Templates/ForkTemplateToGitConnectedApp.js new file mode 100644 index 0000000000..59718911ec --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Templates/ForkTemplateToGitConnectedApp.js @@ -0,0 +1,97 @@ +import template from "../../../../locators/TemplatesLocators.json"; +import gitSyncLocators from "../../../../locators/gitSyncLocators"; +import widgetLocators from "../../../../locators/Widgets.json"; +let repoName; +let appId; +const branchName = "test/template"; +const mainBranch = "master"; +const jsObject = "Utils"; +const homePage = require("../../../../locators/HomePage"); + +describe("Fork a template to the current app", () => { + before(() => { + cy.NavigateToHome(); + cy.generateUUID().then((id) => { + appId = id; + cy.CreateAppInFirstListedWorkspace(id); + localStorage.setItem("AppName", appId); + }); + cy.generateUUID().then((uid) => { + repoName = uid; + + cy.createTestGithubRepo(repoName); + cy.connectToGitRepo(repoName); + }); + }); + + it("1.Bug #17002 Forking a template into an existing app which is connected to git makes the application go into a bad state ", function() { + cy.get(template.startFromTemplateCard).click(); + cy.wait("@fetchTemplate").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.wait(1000); + cy.get(template.templateDialogBox).should("be.visible"); + cy.xpath( + "//div[text()='Customer Support Dashboard']/following-sibling::div//button[contains(@class, 'fork-button')]", + ).click(); + cy.wait("@getTemplatePages").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.get(widgetLocators.toastAction).should( + "contain", + "template added successfully", + ); + cy.commitAndPush(); + }); + it("2. Bug #17262 On forking template to a child branch of git connected app is throwing Page not found error ", function() { + cy.createGitBranch(branchName); + cy.CreatePage(); + cy.get(template.startFromTemplateCard).click(); + + cy.wait(1000); + cy.get(template.templateDialogBox).should("be.visible"); + cy.xpath("//div[text()='Customer Support Dashboard']").click(); + + cy.xpath(template.selectAllPages) + .next() + .click(); + cy.wait(1000); + cy.xpath("//span[text()='SEARCH']") + .parent() + .next() + .click(); + // [Bug]: On forking selected pages from a template, resource not found error is shown #17270 + cy.get(template.templateViewForkButton).click(); + + cy.wait(3000); + cy.get(widgetLocators.toastAction).should( + "contain", + "template added successfully", + ); + // [Bug]: On forking a template the JS Objects are not cloned #17425 + cy.CheckAndUnfoldEntityItem("Queries/JS"); + cy.get(`.t--entity-name:contains(${jsObject})`).should("have.length", 1); + cy.NavigateToHome(); + cy.get(homePage.searchInput) + .clear() + .type(appId); + cy.wait(2000); + cy.get(homePage.applicationCard) + .first() + .trigger("mouseover"); + cy.get(homePage.appEditIcon) + .first() + .click({ force: true }); + cy.wait(5000); + cy.switchGitBranch(branchName); + cy.get(homePage.publishButton).click(); + cy.get(gitSyncLocators.commitCommentInput).type("Initial Commit"); + cy.get(gitSyncLocators.commitButton).click(); + cy.wait(10000); + cy.get(gitSyncLocators.closeGitSyncModal).click(); + }); +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Templates/Fork_Template_Existing_app_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Templates/Fork_Template_Existing_app_spec.js new file mode 100644 index 0000000000..8a260ade15 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Templates/Fork_Template_Existing_app_spec.js @@ -0,0 +1,55 @@ +import widgetLocators from "../../../../locators/Widgets.json"; +import template from "../../../../locators/TemplatesLocators.json"; +const publish = require("../../../../locators/publishWidgetspage.json"); + +describe("Fork a template to the current app from new page popover", () => { + it("1. Fork template from page section", () => { + cy.AddPageFromTemplate(); + cy.wait(1000); + cy.get(template.templateDialogBox).should("be.visible"); + cy.wait(4000); + cy.xpath( + "//div[text()='Customer Support Dashboard']/following-sibling::div//button[contains(@class, 'fork-button')]", + ).click(); + cy.wait(1000); + cy.wait("@getTemplatePages").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.get(widgetLocators.toastAction).should( + "contain", + "template added successfully", + ); + }); + + it("2. Add selected page of template from page section", () => { + cy.AddPageFromTemplate(); + cy.wait(1000); + cy.get(template.templateDialogBox).should("be.visible"); + cy.wait(4000); + cy.xpath("//div[text()='Customer Support Dashboard']").click(); + cy.wait("@getTemplatePages").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.xpath(template.selectAllPages) + .next() + .click(); + cy.xpath("//span[text()='DASHBOARD']") + .parent() + .next() + .click(); + cy.get(template.templateViewForkButton).click(); + cy.wait("@fetchTemplate").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.get(widgetLocators.toastAction).should( + "contain", + "template added successfully", + ); + }); +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Templates/Fork_Template_To_App_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Templates/Fork_Template_To_App_spec.js new file mode 100644 index 0000000000..06f565e627 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Templates/Fork_Template_To_App_spec.js @@ -0,0 +1,78 @@ +import widgetLocators from "../../../../locators/Widgets.json"; +import template from "../../../../locators/TemplatesLocators.json"; +const publish = require("../../../../locators/publishWidgetspage.json"); + +describe("Fork a template to the current app", () => { + it("1. Fork a template to the current app", () => { + cy.get(template.startFromTemplateCard).click(); + cy.wait("@fetchTemplate").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.wait(1000); + cy.get(template.templateDialogBox).should("be.visible"); + cy.xpath( + "//div[text()='Customer Support Dashboard']/following-sibling::div//button[contains(@class, 'fork-button')]", + ).click(); + cy.wait("@getTemplatePages").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.get(widgetLocators.toastAction).should( + "contain", + "template added successfully", + ); + // [Bug]: Getting 'Resource not found' error on deploying template #17477 + cy.PublishtheApp(); + cy.get(".t--page-switch-tab") + .contains("Dashboard") + .click({ force: true }); + cy.wait(4000); + cy.get(publish.backToEditor).click(); + cy.wait(2000); + }); + + it("2. Add selected pages from template to an app", () => { + cy.CheckAndUnfoldEntityItem("Pages"); + cy.get(`.t--entity-name:contains(Page1)`) + .trigger("mouseover") + .click({ force: true }); + cy.wait(1000); + cy.get(template.startFromTemplateCard).click(); + cy.wait("@fetchTemplate").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.wait(1000); + cy.get(template.templateDialogBox).should("be.visible"); + cy.xpath("//div[text()='Customer Support Dashboard']").click(); + cy.wait("@getTemplatePages").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.xpath(template.selectAllPages) + .next() + .click(); + cy.wait(1000); + cy.xpath("//span[text()='SEARCH']") + .parent() + .next() + .click(); + // [Bug]: On forking selected pages from a template, resource not found error is shown #17270 + cy.get(template.templateViewForkButton).click(); + cy.wait("@fetchTemplate").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.wait(3000); + cy.get(widgetLocators.toastAction).should( + "contain", + "template added successfully", + ); + }); +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/OtherUIFeatures/Fork_Template_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Templates/Fork_Template_spec.js similarity index 100% rename from app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/OtherUIFeatures/Fork_Template_spec.js rename to app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Templates/Fork_Template_spec.js diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/S3_Spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/S3_Spec.js index 1cab539f02..de296f836d 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/S3_Spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/S3_Spec.js @@ -245,4 +245,41 @@ describe("Generate New CRUD Page Inside from entity explorer", function() { //cy.isNotInViewport("//div[text()='haiiii hello']") //cy.isNotInViewport("//div[text()='No data to display']") }); + + it("4. Generate CRUD page from the page menu", function() { + cy.GenerateCRUD(); + cy.NavigateToDSGeneratePage(datasourceName); + // fetch bucket + cy.wait("@getDatasourceStructure").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + + cy.get(generatePage.selectTableDropdown).click(); + cy.get(generatePage.dropdownOption) + .contains("assets-test.appsmith.com") + .scrollIntoView() + .should("be.visible") + .click(); + cy.get(generatePage.generatePageFormSubmitBtn).click(); + + cy.wait("@post_replaceLayoutCRUD").should( + "have.nested.property", + "response.body.responseMeta.status", + 201, + ); + cy.wait("@get_Actions").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.wait("@post_Execute").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + + cy.get("span:contains('GOT IT')").click(); + }); }); diff --git a/app/client/cypress/locators/TemplatesLocators.json b/app/client/cypress/locators/TemplatesLocators.json index 7e76bc99db..fa8eb68e2b 100644 --- a/app/client/cypress/locators/TemplatesLocators.json +++ b/app/client/cypress/locators/TemplatesLocators.json @@ -3,5 +3,9 @@ "templateForkButton": ".t--fork-template", "dialogForkButton": ".t--fork-template-button", "templateCard": "[data-cy='template-card']", - "templateViewForkButton": "[data-cy='template-fork-button']" + "templateViewForkButton": "[data-cy='template-fork-button']", + "startFromTemplateCard": "[data-cy=start-from-template]", + "templateDialogBox": "[data-testid='t--dialog-component']", + "selectAllPages": "//span[text()='Select all']" + } \ No newline at end of file diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index a07f069119..b5c6990b72 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -1005,6 +1005,9 @@ Cypress.Commands.add("startServerAndRoutes", () => { cy.intercept("PUT", "/api/v1/layouts/refactor").as("updateWidgetName"); cy.intercept("GET", "/api/v1/workspaces/*/members").as("getMembers"); cy.intercept("POST", "/api/v1/datasources/mocks").as("getMockDb"); + cy.intercept("GET", "/api/v1/app-templates").as("fetchTemplate"); + cy.intercept("POST", "/api/v1/app-templates/*").as("importTemplate"); + cy.intercept("GET", "/api/v1/app-templates/*").as("getTemplatePages"); }); Cypress.Commands.add("startErrorRoutes", () => { @@ -1909,3 +1912,17 @@ Cypress.Commands.add("CreatePage", () => { .click({ force: true }); cy.get("[data-cy='add-page']").click(); }); + +Cypress.Commands.add("GenerateCRUD", () => { + cy.get(pages.AddPage) + .first() + .click({ force: true }); + cy.get("[data-cy='generate-page']").click(); +}); + +Cypress.Commands.add("AddPageFromTemplate", () => { + cy.get(pages.AddPage) + .first() + .click({ force: true }); + cy.get("[data-cy='add-page-from-template']").click(); +});