From cd22fc10871390230aba04f2530f1256cbc85e5e Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Tue, 23 Apr 2024 10:01:14 +0530 Subject: [PATCH] test: Some cleanup for Git Cypress tests (#32836) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Change usage of ports bound to 3000, 5000 and 8000 to 4200, which will be the canonical port for TED in the future. 2. Switch to using TED's native git repo management APIs, instead of the Gitea compatibility layer. 3. Remove code from GitHub ages. /ok-to-test tags="@tag.Sanity, @tag.Git" > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: b38f4eb388716f7fcfc2a032d788c2ebb951568b > Cypress dashboard url: Click here! ## Summary by CodeRabbit - **Refactor** - Enhanced Git integration by shifting from GitHub to Gitea for repository operations in test environments. - Updated URLs and endpoints across various test scripts and data fixtures to align with new configurations. - **Tests** - Modified test scenarios to reflect changes in Git operations and URL configurations. - **Chores** - Updated CI workflows by replacing old secrets with new ones for better configuration management. --- .github/workflows/ci-test-custom-script.yml | 3 - .github/workflows/ci-test-hosted.yml | 3 - .github/workflows/ci-test-limited.yml | 3 - .../Git/GitImport/ImportEmptyRepo_spec.js | 3 - .../ClientSide/Git/GitSync/Deploy_spec.js | 1 - .../Git/GitSync/DisconnectGit_spec.js | 1 - .../ClientSide/Git/GitSync/GitBugs_spec.js | 2 +- .../Git/GitSync/MergeViaRemote_spec.ts | 23 -- .../Git/GitSync/SwitchBranches_spec.js | 3 +- .../Git/GitWithTheming/GitWithTheming_spec.js | 7 +- .../ClientSide/Widgets/Image/Image_spec.js | 2 +- .../fixtures/Listv2/Listv2JSObjects.json | 4 +- app/client/cypress/fixtures/datasources.json | 2 +- .../fixtures/tableResizedColumnsDsl.json | 4 +- .../fixtures/tableV2ResizedColumnsDsl.json | 4 +- .../cypress/support/Objects/DataManager.ts | 14 +- app/client/cypress/support/Pages/GitSync.ts | 129 +-------- app/client/cypress/support/gitSync.js | 252 +----------------- 18 files changed, 39 insertions(+), 421 deletions(-) diff --git a/.github/workflows/ci-test-custom-script.yml b/.github/workflows/ci-test-custom-script.yml index 12f78abe4b..229a4b7055 100644 --- a/.github/workflows/ci-test-custom-script.yml +++ b/.github/workflows/ci-test-custom-script.yml @@ -299,15 +299,12 @@ jobs: CYPRESS_TESTPASSWORD4: ${{ secrets.CYPRESS_TESTPASSWORD4 }} CYPRESS_S3_ACCESS_KEY: ${{ secrets.CYPRESS_S3_ACCESS_KEY }} CYPRESS_S3_SECRET_KEY: ${{ secrets.CYPRESS_S3_SECRET_KEY }} - CYPRESS_GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} CYPRESS_AIRTABLE_BEARER: ${{ secrets.AIRTABLE_BEARER }} CYPRESS_ORACLE_HOST: ${{ secrets.ORACLE_HOST }} CYPRESS_ORACLE_SERVICE: ${{ secrets.ORACLE_SERVICE }} CYPRESS_ORACLE_USERNAME: ${{ secrets.ORACLE_USERNAME }} CYPRESS_ORACLE_PASSWORD: ${{ secrets.ORACLE_PASSWORD }} CYPRESS_FIRESTORE_PRIVATE_KEY: ${{ secrets.FIRESTORE_PRIVATE_KEY }} - CYPRESS_GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.CYPRESS_GITHUB_PERSONAL_ACCESS_TOKEN }} - CYPRESS_TEST_GITHUB_USER_NAME: ${{ secrets.CYPRESS_TEST_GITHUB_USER_NAME }} CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_ID: ${{ secrets.CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_ID }} CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET: ${{ secrets.CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET }} CYPRESS_APPSMITH_OAUTH2_GITHUB_CLIENT_ID: ${{ secrets.CYPRESS_APPSMITH_OAUTH2_GITHUB_CLIENT_ID }} diff --git a/.github/workflows/ci-test-hosted.yml b/.github/workflows/ci-test-hosted.yml index 060683542f..5b97f064af 100644 --- a/.github/workflows/ci-test-hosted.yml +++ b/.github/workflows/ci-test-hosted.yml @@ -195,15 +195,12 @@ jobs: CYPRESS_TESTPASSWORD4: ${{ secrets.CYPRESS_TESTPASSWORD4 }} CYPRESS_S3_ACCESS_KEY: ${{ secrets.CYPRESS_S3_ACCESS_KEY }} CYPRESS_S3_SECRET_KEY: ${{ secrets.CYPRESS_S3_SECRET_KEY }} - CYPRESS_GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} CYPRESS_AIRTABLE_BEARER: ${{ secrets.AIRTABLE_BEARER }} CYPRESS_ORACLE_HOST: ${{ secrets.ORACLE_HOST }} CYPRESS_ORACLE_SERVICE: ${{ secrets.ORACLE_SERVICE }} CYPRESS_ORACLE_USERNAME: ${{ secrets.ORACLE_USERNAME }} CYPRESS_ORACLE_PASSWORD: ${{ secrets.ORACLE_PASSWORD }} CYPRESS_FIRESTORE_PRIVATE_KEY: ${{ secrets.FIRESTORE_PRIVATE_KEY }} - CYPRESS_GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.CYPRESS_GITHUB_PERSONAL_ACCESS_TOKEN }} - CYPRESS_TEST_GITHUB_USER_NAME: ${{ secrets.CYPRESS_TEST_GITHUB_USER_NAME }} CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_ID: ${{ secrets.CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_ID }} CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET: ${{ secrets.CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET }} CYPRESS_APPSMITH_OAUTH2_GITHUB_CLIENT_ID: ${{ secrets.CYPRESS_APPSMITH_OAUTH2_GITHUB_CLIENT_ID }} diff --git a/.github/workflows/ci-test-limited.yml b/.github/workflows/ci-test-limited.yml index cbd0c4a35b..fcdf38a7fc 100644 --- a/.github/workflows/ci-test-limited.yml +++ b/.github/workflows/ci-test-limited.yml @@ -303,15 +303,12 @@ jobs: CYPRESS_TESTPASSWORD4: ${{ secrets.CYPRESS_TESTPASSWORD4 }} CYPRESS_S3_ACCESS_KEY: ${{ secrets.CYPRESS_S3_ACCESS_KEY }} CYPRESS_S3_SECRET_KEY: ${{ secrets.CYPRESS_S3_SECRET_KEY }} - CYPRESS_GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} CYPRESS_AIRTABLE_BEARER: ${{ secrets.AIRTABLE_BEARER }} CYPRESS_ORACLE_HOST: ${{ secrets.ORACLE_HOST }} CYPRESS_ORACLE_SERVICE: ${{ secrets.ORACLE_SERVICE }} CYPRESS_ORACLE_USERNAME: ${{ secrets.ORACLE_USERNAME }} CYPRESS_ORACLE_PASSWORD: ${{ secrets.ORACLE_PASSWORD }} CYPRESS_FIRESTORE_PRIVATE_KEY: ${{ secrets.FIRESTORE_PRIVATE_KEY }} - CYPRESS_GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.CYPRESS_GITHUB_PERSONAL_ACCESS_TOKEN }} - CYPRESS_TEST_GITHUB_USER_NAME: ${{ secrets.CYPRESS_TEST_GITHUB_USER_NAME }} CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_ID: ${{ secrets.CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_ID }} CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET: ${{ secrets.CYPRESS_APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET }} CYPRESS_APPSMITH_OAUTH2_GITHUB_CLIENT_ID: ${{ secrets.CYPRESS_APPSMITH_OAUTH2_GITHUB_CLIENT_ID }} diff --git a/app/client/cypress/e2e/Regression/ClientSide/Git/GitImport/ImportEmptyRepo_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Git/GitImport/ImportEmptyRepo_spec.js index b297cda4aa..50ba0fb3a3 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Git/GitImport/ImportEmptyRepo_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Git/GitImport/ImportEmptyRepo_spec.js @@ -17,14 +17,12 @@ describe("Git import empty repository", { tags: ["@tag.Git"] }, function () { cy.generateUUID().then((uid) => { repoName = uid; _.gitSync.CreateTestGiteaRepo(repoName); - //cy.createTestGithubRepo(repoName); }); }); it("1. Bug #12749 Git Import - Empty Repo NullPointerException", () => { cy.generateUUID().then((uid) => { repoName = uid; - //cy.createTestGithubRepo(repoName); _.gitSync.CreateTestGiteaRepo(repoName); _.gitSync.ImportAppFromGit(undefined, repoName, false); cy.wait("@importFromGit").then((interception) => { @@ -38,6 +36,5 @@ describe("Git import empty repository", { tags: ["@tag.Git"] }, function () { }); after(() => { _.gitSync.DeleteTestGithubRepo(repoName); - //cy.deleteTestGithubRepo(repoName); }); }); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/Deploy_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/Deploy_spec.js index 6095644f6e..14f34e7831 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/Deploy_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/Deploy_spec.js @@ -55,6 +55,5 @@ describe("Git sync modal: deploy tab", { tags: ["@tag.Git"] }, function () { after(() => { _.gitSync.DeleteTestGithubRepo(repoName); - //cy.deleteTestGithubRepo(repoName); }); }); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/DisconnectGit_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/DisconnectGit_spec.js index ed258bb5db..1b69edeef3 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/DisconnectGit_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/DisconnectGit_spec.js @@ -111,6 +111,5 @@ describe("Git disconnect modal:", { tags: ["@tag.Git"] }, function () { after(() => { _.gitSync.DeleteTestGithubRepo(repoName); - //cy.deleteTestGithubRepo(repoName); }); }); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/GitBugs_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/GitBugs_spec.js index fe1d2dde83..65c3ebb47a 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/GitBugs_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/GitBugs_spec.js @@ -265,7 +265,7 @@ describe("Git sync Bug #10773", { tags: ["@tag.Git"] }, function () { agHelper.GetNClick(gitSync.gitConnectNextBtn); agHelper.TypeText( gitSync.remoteUrlInput, - `${dataManager.GITEA_API_URL_TED}/${repoName}.git`, + `${dataManager.GIT_CLONE_URL}/${repoName}.git`, ); agHelper.GetNClick(gitSync.gitConnectNextBtn); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/MergeViaRemote_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/MergeViaRemote_spec.ts index 4f7e10a9d0..b93ce987a4 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/MergeViaRemote_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/MergeViaRemote_spec.ts @@ -121,28 +121,5 @@ describe( expect(location.pathname).includes(legacyPathname); }); }); - - // // _.gitSync.DeleteTestGithubRepo(repoName); - // // //cy.deleteTestGithubRepo(repoName); - // // // TODO remove when app deletion with conflicts is fixed - // // cy.get(homePage.homeIcon).click({ force: true }); - // // cy.get(homePage.createNew) - // // .first() - // // .click({ force: true }); - // // cy.wait("@createNewApplication").should( - // // "have.nested.property", - // // "response.body.responseMeta.status", - // // 201, - // // ); - // // cy.get("#loading").should("not.exist"); - // // cy.wait(2000); - // // cy.AppSetupForRename(); - // // cy.get(homePage.applicationName).type(repoName + "{enter}"); - // // cy.wait("@updateApplication").should( - // // "have.nested.property", - // // "response.body.responseMeta.status", - // // 200, - // // ); - // }); }, ); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js index 88bba0d08a..6c908c5b3d 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js @@ -187,7 +187,8 @@ describe("Git sync:", { tags: ["@tag.Git"] }, function () { // cy.get("@gitbranchName").then((branName) => { // tempBranch = branName; // }); - cy.renameBranchViaGithubApi(repoName, tempBranch, tempBranchRenamed); + // rename branch API missing in TED. + // cy.renameBranchViaGithubApi(repoName, tempBranch, tempBranchRenamed); cy.get(gitSyncLocators.branchButton).click(); cy.get(gitSyncLocators.branchSearchInput).type(`{selectall}${tempBranch}`); const tempBranchRegex = new RegExp(`^${tempBranch}$`); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Git/GitWithTheming/GitWithTheming_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Git/GitWithTheming/GitWithTheming_spec.js index f3caec116e..87b4f1f14b 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Git/GitWithTheming/GitWithTheming_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Git/GitWithTheming/GitWithTheming_spec.js @@ -22,17 +22,12 @@ describe("Git with Theming:", { tags: ["@tag.Git"] }, function () { ); }); }); - // cy.generateUUID().then((uid) => { - // repoName = uid; + _.gitSync.CreateNConnectToGit(); cy.get("@gitRepoName").then((repName) => { repoName = repName; _.gitSync.CreateGitBranch(repoName); }); - - // cy.createTestGithubRepo(repoName); - // cy.connectToGitRepo(repoName); - //}); }); it("1. Bug #13860 Theming is not getting applied on view mode when the app is connected to Git", function () { _.appSettings.OpenAppSettings(); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Widgets/Image/Image_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Widgets/Image/Image_spec.js index e115343124..20074af741 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Widgets/Image/Image_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Widgets/Image/Image_spec.js @@ -74,7 +74,7 @@ describe( cy.openPropertyPane("imagewidget"); // Invalid image url const invalidImageUrl = - "http://host.docker.internal:5000/photo-not-exists.jpeg"; + "http://host.docker.internal:4200/photo-not-exists.jpeg"; cy.testCodeMirror(invalidImageUrl); // Show off error message diff --git a/app/client/cypress/fixtures/Listv2/Listv2JSObjects.json b/app/client/cypress/fixtures/Listv2/Listv2JSObjects.json index b621c04914..bb01cb8df1 100644 --- a/app/client/cypress/fixtures/Listv2/Listv2JSObjects.json +++ b/app/client/cypress/fixtures/Listv2/Listv2JSObjects.json @@ -391,7 +391,7 @@ "longitude": "134.8", "phone": "1234 456 789", "email": "erewt@etewt.com", - "image": "http://host.docker.internal:8000/photo-1492529029602-33e53698f407.jpeg", + "image": "http://host.docker.internal:4200/photo-1492529029602-33e53698f407.jpeg", "country": "India" } }, @@ -812,7 +812,7 @@ "rightColumn": 64, "textSize": "0.875rem", "widgetId": "hasf62rs16", - "tableData": "[\n {\n \"id\": 8,\n \"gender\": \"Male2\",\n \"latitude\": \"-46.799\",\n \"longitude\": \"134.8\",\n \"dob\": null,\n \"phone\": \"1234 456 789\",\n \"email\": \"erewt@etewt.com\",\n \"image\": \"http://host.docker.internal:8000/photo-1492529029602-33e53698f407.jpeg\",\n \"country\": \"India\",\n \"name\": \"Perry234\"\n },\n {\n \"id\": 14,\n \"gender\": \"Female\",\n \"latitude\": \"-55.3277\",\n \"longitude\": \"14.598\",\n \"dob\": \"1960-06-11T04:07:44.187Z\",\n \"phone\": \"(480)-579-1070\",\n \"email\": \"lucille.martinez@example.com\",\n \"image\": \"http://host.docker.internal:8000/photo-1503469432756-4aae2e18d881.jpeg\",\n \"country\": \"Myanmar\",\n \"name\": \"Aliess123\"\n },\n {\n \"id\": 20,\n \"gender\": \"female\",\n \"latitude\": \"50.3512\",\n \"longitude\": \"-144.4759\",\n \"dob\": \"1989-03-18T05:45:11.987Z\",\n \"phone\": \"03-7420-3707\",\n \"email\": \"jennie.james@example.com\",\n \"image\": \"http://host.docker.internal:8000/photo-1547401208-4e3278cb1488.jpeg\",\n \"country\": \"Australia\",\n \"name\": \"Jennie James\"\n },\n {\n \"id\": 538,\n \"gender\": \"Female\",\n \"latitude\": \"234\",\n \"longitude\": \"34354534\",\n \"dob\": null,\n \"phone\": null,\n \"email\": \"prapulla.c@moolya.com\",\n \"image\": null,\n \"country\": null,\n \"name\": null\n },\n {\n \"id\": 539,\n \"gender\": \"Female\",\n \"latitude\": \"234\",\n \"longitude\": \"34354534\",\n \"dob\": null,\n \"phone\": null,\n \"email\": \"prapulla.c@moolya.com\",\n \"image\": null,\n \"country\": null,\n \"name\": null\n },\n {\n \"id\": 542,\n \"gender\": \"male\",\n \"latitude\": \"10\",\n \"longitude\": \"10\",\n \"dob\": \"2000-10-10T00:00:00Z\",\n \"phone\": null,\n \"email\": null,\n \"image\": null,\n \"country\": null,\n \"name\": null\n },\n {\n \"id\": 543,\n \"gender\": \"test\",\n \"latitude\": \"0.88\",\n \"longitude\": \"0.88\",\n \"dob\": \"2000-12-12T00:00:00Z\",\n \"phone\": null,\n \"email\": null,\n \"image\": null,\n \"country\": null,\n \"name\": null\n },\n {\n \"id\": 553,\n \"gender\": \"female\",\n \"latitude\": \"55\",\n \"longitude\": \"33\",\n \"dob\": \"2019-07-01T05:30:00Z\",\n \"phone\": \"12345678\",\n \"email\": \"1026033274@qq.com\",\n \"image\": \"\",\n \"country\": \"india\",\n \"name\": \"test\"\n },\n {\n \"id\": 554,\n \"gender\": \"male\",\n \"latitude\": \"55\",\n \"longitude\": \"22\",\n \"dob\": \"2019-07-01T05:30:00Z\",\n \"phone\": \"1234567\",\n \"email\": \"1026033274@qq.com\",\n \"image\": \"\",\n \"country\": \"state\",\n \"name\": \"teest\"\n },\n {\n \"id\": 555,\n \"gender\": \"male\",\n \"latitude\": \"55\",\n \"longitude\": \"44\",\n \"dob\": \"2019-07-01T05:30:00Z\",\n \"phone\": \"12345678\",\n \"email\": \"1026033274@qq.com\",\n \"image\": \"\",\n \"country\": \"state\",\n \"name\": \"111222\"\n },\n {\n \"id\": 556,\n \"gender\": \"female\",\n \"latitude\": \"22\",\n \"longitude\": \"11\",\n \"dob\": \"2019-07-01T05:30:00Z\",\n \"phone\": \"1234567\",\n \"email\": \"1026033274@qq.com\",\n \"image\": \"1\",\n \"country\": \"brail\",\n \"name\": \"test1\"\n },\n {\n \"id\": 558,\n \"gender\": \"Male\",\n \"latitude\": \"123,45,67.32\",\n \"longitude\": null,\n \"dob\": null,\n \"phone\": null,\n \"email\": \"subrata@appsmith.com\",\n \"image\": null,\n \"country\": null,\n \"name\": \"Subrata\"\n },\n {\n \"id\": 561,\n \"gender\": \"Male\",\n \"latitude\": null,\n \"longitude\": null,\n \"dob\": null,\n \"phone\": null,\n \"email\": \"will@gmail.com\",\n \"image\": null,\n \"country\": null,\n \"name\": \"Maro\"\n },\n {\n \"id\": 562,\n \"gender\": \"female\",\n \"latitude\": \"-46.799\",\n \"longitude\": \"134.8\",\n \"dob\": \"2020-09-09T00:00:00Z\",\n \"phone\": \"1234 456 789\",\n \"email\": \"test@gmail.com\",\n \"image\": \"http://host.docker.internal:8000/photo-1492529029602-33e53698f407.jpeg\",\n \"country\": \"Australia\",\n \"name\": \"oktest\"\n },\n {\n \"id\": 566,\n \"gender\": \"femal\",\n \"latitude\": \"66\",\n \"longitude\": \"33\",\n \"dob\": \"2019-07-01T05:30:00Z\",\n \"phone\": \"123456\",\n \"email\": \"1026033274@qq.com\",\n \"image\": \"\",\n \"country\": \"china\",\n \"name\": \"test1\"\n },\n {\n \"id\": 570,\n \"gender\": \"male\",\n \"latitude\": null,\n \"longitude\": null,\n \"dob\": null,\n \"phone\": null,\n \"email\": \"balaji@appsmith.com\",\n \"image\": null,\n \"country\": null,\n \"name\": \"Balaji\"\n },\n {\n \"id\": 571,\n \"gender\": \"male\",\n \"latitude\": null,\n \"longitude\": null,\n \"dob\": null,\n \"phone\": null,\n \"email\": \"123\",\n \"image\": null,\n \"country\": null,\n \"name\": \"AAAA\"\n },\n {\n \"id\": 572,\n \"gender\": \"male\",\n \"latitude\": null,\n \"longitude\": null,\n \"dob\": null,\n \"phone\": null,\n \"email\": \"123@12.com\",\n \"image\": null,\n \"country\": null,\n \"name\": \"balaji app viewer\"\n }\n]", + "tableData": "[\n {\n \"id\": 8,\n \"gender\": \"Male2\",\n \"latitude\": \"-46.799\",\n \"longitude\": \"134.8\",\n \"dob\": null,\n \"phone\": \"1234 456 789\",\n \"email\": \"erewt@etewt.com\",\n \"image\": \"http://host.docker.internal:4200/photo-1492529029602-33e53698f407.jpeg\",\n \"country\": \"India\",\n \"name\": \"Perry234\"\n },\n {\n \"id\": 14,\n \"gender\": \"Female\",\n \"latitude\": \"-55.3277\",\n \"longitude\": \"14.598\",\n \"dob\": \"1960-06-11T04:07:44.187Z\",\n \"phone\": \"(480)-579-1070\",\n \"email\": \"lucille.martinez@example.com\",\n \"image\": \"http://host.docker.internal:8000/photo-1503469432756-4aae2e18d881.jpeg\",\n \"country\": \"Myanmar\",\n \"name\": \"Aliess123\"\n },\n {\n \"id\": 20,\n \"gender\": \"female\",\n \"latitude\": \"50.3512\",\n \"longitude\": \"-144.4759\",\n \"dob\": \"1989-03-18T05:45:11.987Z\",\n \"phone\": \"03-7420-3707\",\n \"email\": \"jennie.james@example.com\",\n \"image\": \"http://host.docker.internal:8000/photo-1547401208-4e3278cb1488.jpeg\",\n \"country\": \"Australia\",\n \"name\": \"Jennie James\"\n },\n {\n \"id\": 538,\n \"gender\": \"Female\",\n \"latitude\": \"234\",\n \"longitude\": \"34354534\",\n \"dob\": null,\n \"phone\": null,\n \"email\": \"prapulla.c@moolya.com\",\n \"image\": null,\n \"country\": null,\n \"name\": null\n },\n {\n \"id\": 539,\n \"gender\": \"Female\",\n \"latitude\": \"234\",\n \"longitude\": \"34354534\",\n \"dob\": null,\n \"phone\": null,\n \"email\": \"prapulla.c@moolya.com\",\n \"image\": null,\n \"country\": null,\n \"name\": null\n },\n {\n \"id\": 542,\n \"gender\": \"male\",\n \"latitude\": \"10\",\n \"longitude\": \"10\",\n \"dob\": \"2000-10-10T00:00:00Z\",\n \"phone\": null,\n \"email\": null,\n \"image\": null,\n \"country\": null,\n \"name\": null\n },\n {\n \"id\": 543,\n \"gender\": \"test\",\n \"latitude\": \"0.88\",\n \"longitude\": \"0.88\",\n \"dob\": \"2000-12-12T00:00:00Z\",\n \"phone\": null,\n \"email\": null,\n \"image\": null,\n \"country\": null,\n \"name\": null\n },\n {\n \"id\": 553,\n \"gender\": \"female\",\n \"latitude\": \"55\",\n \"longitude\": \"33\",\n \"dob\": \"2019-07-01T05:30:00Z\",\n \"phone\": \"12345678\",\n \"email\": \"1026033274@qq.com\",\n \"image\": \"\",\n \"country\": \"india\",\n \"name\": \"test\"\n },\n {\n \"id\": 554,\n \"gender\": \"male\",\n \"latitude\": \"55\",\n \"longitude\": \"22\",\n \"dob\": \"2019-07-01T05:30:00Z\",\n \"phone\": \"1234567\",\n \"email\": \"1026033274@qq.com\",\n \"image\": \"\",\n \"country\": \"state\",\n \"name\": \"teest\"\n },\n {\n \"id\": 555,\n \"gender\": \"male\",\n \"latitude\": \"55\",\n \"longitude\": \"44\",\n \"dob\": \"2019-07-01T05:30:00Z\",\n \"phone\": \"12345678\",\n \"email\": \"1026033274@qq.com\",\n \"image\": \"\",\n \"country\": \"state\",\n \"name\": \"111222\"\n },\n {\n \"id\": 556,\n \"gender\": \"female\",\n \"latitude\": \"22\",\n \"longitude\": \"11\",\n \"dob\": \"2019-07-01T05:30:00Z\",\n \"phone\": \"1234567\",\n \"email\": \"1026033274@qq.com\",\n \"image\": \"1\",\n \"country\": \"brail\",\n \"name\": \"test1\"\n },\n {\n \"id\": 558,\n \"gender\": \"Male\",\n \"latitude\": \"123,45,67.32\",\n \"longitude\": null,\n \"dob\": null,\n \"phone\": null,\n \"email\": \"subrata@appsmith.com\",\n \"image\": null,\n \"country\": null,\n \"name\": \"Subrata\"\n },\n {\n \"id\": 561,\n \"gender\": \"Male\",\n \"latitude\": null,\n \"longitude\": null,\n \"dob\": null,\n \"phone\": null,\n \"email\": \"will@gmail.com\",\n \"image\": null,\n \"country\": null,\n \"name\": \"Maro\"\n },\n {\n \"id\": 562,\n \"gender\": \"female\",\n \"latitude\": \"-46.799\",\n \"longitude\": \"134.8\",\n \"dob\": \"2020-09-09T00:00:00Z\",\n \"phone\": \"1234 456 789\",\n \"email\": \"test@gmail.com\",\n \"image\": \"http://host.docker.internal:8000/photo-1492529029602-33e53698f407.jpeg\",\n \"country\": \"Australia\",\n \"name\": \"oktest\"\n },\n {\n \"id\": 566,\n \"gender\": \"femal\",\n \"latitude\": \"66\",\n \"longitude\": \"33\",\n \"dob\": \"2019-07-01T05:30:00Z\",\n \"phone\": \"123456\",\n \"email\": \"1026033274@qq.com\",\n \"image\": \"\",\n \"country\": \"china\",\n \"name\": \"test1\"\n },\n {\n \"id\": 570,\n \"gender\": \"male\",\n \"latitude\": null,\n \"longitude\": null,\n \"dob\": null,\n \"phone\": null,\n \"email\": \"balaji@appsmith.com\",\n \"image\": null,\n \"country\": null,\n \"name\": \"Balaji\"\n },\n {\n \"id\": 571,\n \"gender\": \"male\",\n \"latitude\": null,\n \"longitude\": null,\n \"dob\": null,\n \"phone\": null,\n \"email\": \"123\",\n \"image\": null,\n \"country\": null,\n \"name\": \"AAAA\"\n },\n {\n \"id\": 572,\n \"gender\": \"male\",\n \"latitude\": null,\n \"longitude\": null,\n \"dob\": null,\n \"phone\": null,\n \"email\": \"123@12.com\",\n \"image\": null,\n \"country\": null,\n \"name\": \"balaji app viewer\"\n }\n]", "label": "Data", "searchKey": "", "parentId": "0", diff --git a/app/client/cypress/fixtures/datasources.json b/app/client/cypress/fixtures/datasources.json index 86d6f6f066..9a448613ce 100644 --- a/app/client/cypress/fixtures/datasources.json +++ b/app/client/cypress/fixtures/datasources.json @@ -85,7 +85,7 @@ "readonly": "readonly", "authenticatedApiUrl": "https://fakeapi.com", - "GraphqlApiUrl_TED": "http://host.docker.internal:5000/graphql", + "GraphqlApiUrl_TED": "http://host.docker.internal:4200/graphql", "GITEA_API_BASE_TED": "localhost", "GITEA_API_PORT_TED": "3001", "GITEA_API_URL_TED": "git@host.docker.internal:Cypress" diff --git a/app/client/cypress/fixtures/tableResizedColumnsDsl.json b/app/client/cypress/fixtures/tableResizedColumnsDsl.json index 8747f449d3..ead31f7a73 100644 --- a/app/client/cypress/fixtures/tableResizedColumnsDsl.json +++ b/app/client/cypress/fixtures/tableResizedColumnsDsl.json @@ -62,7 +62,7 @@ ] }, { - "image": "http://host.docker.internal:8000/photo-1492529029602-33e53698f407.jpeg", + "image": "http://host.docker.internal:4200/photo-1492529029602-33e53698f407.jpeg", "widgetName": "Image1", "rightColumn": 64, "widgetId": "ah4cbb9o2e", @@ -502,4 +502,4 @@ } ] } -} \ No newline at end of file +} diff --git a/app/client/cypress/fixtures/tableV2ResizedColumnsDsl.json b/app/client/cypress/fixtures/tableV2ResizedColumnsDsl.json index cdf9c50cbf..1e9bc9d942 100644 --- a/app/client/cypress/fixtures/tableV2ResizedColumnsDsl.json +++ b/app/client/cypress/fixtures/tableV2ResizedColumnsDsl.json @@ -62,7 +62,7 @@ ] }, { - "image": "http://host.docker.internal:8000/photo-1503469432756-4aae2e18d881.jpeg", + "image": "http://host.docker.internal:4200/photo-1503469432756-4aae2e18d881.jpeg", "widgetName": "Image1", "rightColumn": 64, "widgetId": "ah4cbb9o2e", @@ -545,4 +545,4 @@ } ] } -} \ No newline at end of file +} diff --git a/app/client/cypress/support/Objects/DataManager.ts b/app/client/cypress/support/Objects/DataManager.ts index bdd741ddcd..e5e8a84ee0 100644 --- a/app/client/cypress/support/Objects/DataManager.ts +++ b/app/client/cypress/support/Objects/DataManager.ts @@ -1,9 +1,9 @@ export class DataManager { environments = ["Production", "Staging"]; defaultEnviorment = this.environments[0]; - GITEA_API_BASE_TED = "localhost"; - GITEA_API_PORT_TED = "3001"; - GITEA_API_URL_TED = "git@host.docker.internal:Cypress"; + + GIT_API_BASE = "localhost:4200"; + GIT_CLONE_URL = "git@host.docker.internal:Cypress"; dsValues: Record = { Production: { @@ -84,9 +84,9 @@ export class DataManager { "http://host.docker.internal:5001/v1/whatdoestrumpthink/random", mockHttpCodeUrl: "http://host.docker.internal:5001/v1/mock-http-codes/", flowerImageUrl1: - "http://host.docker.internal:5000/photo-1503469432756-4aae2e18d881.jpeg", + "http://host.docker.internal:4200/photo-1503469432756-4aae2e18d881.jpeg", flowerImageUrl2: - "http://host.docker.internal:5000/photo-1492529029602-33e53698f407.jpeg", + "http://host.docker.internal:4200/photo-1492529029602-33e53698f407.jpeg", AirtableBaseForME: "appubHrVbovcudwN6", AirtableTableForME: "tblsFCQSskVFf7xNd", ApiUrlME: "http://host.docker.internal:5001/v1/production", @@ -105,7 +105,7 @@ export class DataManager { readonly: "readonly", authenticatedApiUrl: "https://fakeapi.com", - GraphqlApiUrl_TED: "http://host.docker.internal:5000/graphql", + GraphqlApiUrl_TED: "http://host.docker.internal:4200/graphql", twilio_username: "random-username", twilio_password: "random-password", @@ -198,7 +198,7 @@ export class DataManager { readonly: "readonly", authenticatedApiUrl: "https://fakeapi.com", - GraphqlApiUrl_TED: "http://host.docker.internal:5000/graphql", + GraphqlApiUrl_TED: "http://host.docker.internal:4200/graphql", twilio_username: "random-username", twilio_password: "random-password", diff --git a/app/client/cypress/support/Pages/GitSync.ts b/app/client/cypress/support/Pages/GitSync.ts index 7a409b0251..b40cb9b335 100644 --- a/app/client/cypress/support/Pages/GitSync.ts +++ b/app/client/cypress/support/Pages/GitSync.ts @@ -96,10 +96,7 @@ export class GitSync { public CreateTestGiteaRepo(repo: string, privateFlag = false) { cy.request({ method: "POST", - url: `${this.dataManager.GITEA_API_BASE_TED}:${this.dataManager.GITEA_API_PORT_TED}/api/v1/org/Cypress/repos`, - headers: { - Authorization: `token ${Cypress.env("GITEA_TOKEN")}`, - }, + url: `${this.dataManager.GIT_API_BASE}/api/v1/git/repos`, body: { name: repo, private: privateFlag, @@ -152,7 +149,7 @@ export class GitSync { ); this.agHelper.TypeText( this.remoteUrlInput, - `${this.dataManager.GITEA_API_URL_TED}/${repoName}.git`, + `${this.dataManager.GIT_CLONE_URL}/${repoName}.git`, ); this.agHelper.GetNClick(this.gitConnectNextBtn); @@ -164,10 +161,7 @@ export class GitSync { // fetch the generated key and post to the github repo cy.request({ method: "POST", - url: `${this.dataManager.GITEA_API_BASE_TED}:${this.dataManager.GITEA_API_PORT_TED}/api/v1/repos/Cypress/${repoName}/keys`, - headers: { - Authorization: `token ${Cypress.env("GITEA_TOKEN")}`, - }, + url: `${this.dataManager.GIT_API_BASE}/api/v1/git/keys/${repoName}`, body: { title: "key_" + uid, key: generatedKey, @@ -226,7 +220,7 @@ export class GitSync { ); this.agHelper.TypeText( this.remoteUrlInput, - `${this.dataManager.GITEA_API_URL_TED}/${repoName}.git`, + `${this.dataManager.GIT_CLONE_URL}/${repoName}.git`, ); this.agHelper.GetNClick(this.gitConnectNextBtn); @@ -238,10 +232,7 @@ export class GitSync { // fetch the generated key and post to the github repo cy.request({ method: "POST", - url: `${this.dataManager.GITEA_API_BASE_TED}:${this.dataManager.GITEA_API_PORT_TED}/api/v1/repos/Cypress/${repoName}/keys`, - headers: { - Authorization: `token ${Cypress.env("GITEA_TOKEN")}`, - }, + url: `${this.dataManager.GIT_API_BASE}/api/v1/git/keys/${repoName}`, body: { title: "key_" + uid, key: generatedKey, @@ -281,30 +272,21 @@ export class GitSync { DeleteTestGithubRepo(repo: any) { cy.request({ method: "DELETE", - url: `${this.dataManager.GITEA_API_BASE_TED}:${this.dataManager.GITEA_API_PORT_TED}/api/v1/repos/Cypress/${repo}`, - headers: { - Authorization: `token ${Cypress.env("GITEA_TOKEN")}`, - }, + url: `${this.dataManager.GIT_API_BASE}/api/v1/git/repos/${repo}`, }); } DeleteDeployKey(repo: any, id: number) { cy.request({ method: "DELETE", - url: `${this.dataManager.GITEA_API_BASE_TED}:${this.dataManager.GITEA_API_PORT_TED}/api/v1/repos/Cypress/${repo}/keys/${id}`, - headers: { - Authorization: `token ${Cypress.env("GITEA_TOKEN")}`, - }, + url: `${this.dataManager.GIT_API_BASE}/api/v1/git/keys/${id}`, }); } public CreateRemoteBranch(repo: string, branchName: string) { cy.request({ method: "POST", - url: `${this.dataManager.GITEA_API_BASE_TED}:${this.dataManager.GITEA_API_PORT_TED}/api/v1/repos/Cypress/${repo}/branches`, - headers: { - Authorization: `token ${Cypress.env("GITEA_TOKEN")}`, - }, + url: `${this.dataManager.GIT_API_BASE}/api/v1/git/repos/${repo}/branches`, body: { new_branch_name: branchName, }, @@ -469,99 +451,4 @@ export class GitSync { } this.CloseGitSyncModal(); } - //#region Unused methods - - private AuthorizeLocalGitSSH(remoteUrl: string, assertConnect = true) { - let generatedKey; - this.OpenGitSyncModal(); - this.agHelper.AssertAttribute( - this._gitRepoInput, - "placeholder", - "git@example.com:user/repository.git", - ); - this.agHelper.TypeText(this._gitRepoInput, remoteUrl); - - this.agHelper.ClickButton("Generate key"); - - cy.wait(`@generateKey`).then((result: any) => { - generatedKey = result.response.body.data.publicKey; - generatedKey = generatedKey.slice(0, generatedKey.length - 1); - let formdata = new FormData(); - cy.log("generatedKey is " + generatedKey); - formdata.set("sshkey", generatedKey); - // fetch the generated key and post to the github repo - cy.request({ - method: "POST", - url: `http://${this.dataManager.GITEA_API_BASE_TED}:${this.dataManager.GITEA_API_PORT_TED}/v1/gitserver/addgitssh`, - //body: formdata, - body: { - sshkey: generatedKey, - }, - form: true, - // headers: { - // "Content-Type": "application/x-www-form-urlencoded" - // }, - }).then((response) => { - expect(response.status).to.equal(200); - }); - 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.ReplaceForGit("cypress/fixtures/Bugs/GitConnectResponse.json", remoteUrl); - //cy.get('@connectGitLocalRepo').its('response.statusCode').should('equal', 200); - // cy.intercept("POST", "/api/v1/git/connect/app/*", { - // fixture: "/Bugs/GitConnectResponse.json", - // }); - this.assertHelper.AssertNetworkStatus("@connectGitLocalRepo"); - } - this.CloseGitSyncModal(); - }); - } - - private ReplaceForGit(fixtureFile: any, remoteUrl: string) { - let currentAppId, currentURL; - cy.readFile( - fixtureFile, - // (err: string) => { - // if (err) { - // return console.error(err); - // }} - ).then((data) => { - cy.url().then((url) => { - currentURL = url; - const myRegexp = /page-1(.*)/; - const match = myRegexp.exec(currentURL); - cy.log(currentURL + "currentURL from intercept is"); - currentAppId = match ? match[1].split("/")[1] : null; - data.data.id = currentAppId; - data.data.gitApplicationMetadata.defaultApplicationId = currentAppId; - data.data.gitApplicationMetadata.remoteUrl = remoteUrl; - cy.writeFile(fixtureFile, JSON.stringify(data)); - }); - }); - } - - private CreateLocalGithubRepo(repo: string) { - let remoteUrl = ""; - cy.request({ - method: "GET", - url: - `http://${this.dataManager.GITEA_API_BASE_TED}:${this.dataManager.GITEA_API_PORT_TED}/v1/gitserver/addrepo?reponame=` + - repo, - }).then((response) => { - remoteUrl = JSON.stringify(response.body).replace(/['"]+/g, ""); - expect(response.status).to.equal(200); - //cy.log("remoteUrl is"+ remoteUrl); - cy.wrap(remoteUrl).as("remoteUrl"); - }); - } - - //#endregion } diff --git a/app/client/cypress/support/gitSync.js b/app/client/cypress/support/gitSync.js index 957498898f..3994de9845 100644 --- a/app/client/cypress/support/gitSync.js +++ b/app/client/cypress/support/gitSync.js @@ -7,16 +7,14 @@ require("cy-verify-downloads").addCustomCommand(); require("cypress-file-upload"); import gitSyncLocators from "../locators/gitSyncLocators"; import homePage from "../locators/HomePage"; -import { ObjectsRegistry } from "../support/Objects/Registry"; +import { ObjectsRegistry } from "./Objects/Registry"; -let gitSync = ObjectsRegistry.GitSync, - agHelper = ObjectsRegistry.AggregateHelper, - dataManager = ObjectsRegistry.DataManager, - assertHelper = ObjectsRegistry.AssertHelper, - homePageTS = ObjectsRegistry.HomePage; +const gitSync = ObjectsRegistry.GitSync; +const agHelper = ObjectsRegistry.AggregateHelper; +const dataManager = ObjectsRegistry.DataManager; +const assertHelper = ObjectsRegistry.AssertHelper; const commonLocators = require("../locators/commonlocators.json"); -const GITHUB_API_BASE = "https://api.github.com"; Cypress.Commands.add("revokeAccessGit", (appName) => { cy.xpath("//span[text()= `${appName}`]").parent().next().click(); @@ -39,98 +37,6 @@ Cypress.Commands.add("revokeAccessGit", (appName) => { }); }); -Cypress.Commands.add( - "connectToGitRepo", - (repo, shouldCommit = true, assertConnectFailure) => { - const testEmail = "test@test.com"; - const testUsername = "testusername"; - const owner = Cypress.env("TEST_GITHUB_USER_NAME"); - - let generatedKey; - // open gitSync modal - cy.get(homePage.deployPopupOptionTrigger).click(); - cy.get(homePage.connectToGitBtn).click({ force: true }); - - // 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}`, - ); - - cy.get(gitSyncLocators.gitRepoInput).type( - `git@github.com:${owner}/${repo}.git`, - ); - cy.get(gitSyncLocators.generateDeployKeyBtn).click(); - cy.wait(`@generateKey-${repo}`).then((result) => { - 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, - }, - }); - - cy.get(gitSyncLocators.useGlobalGitConfig).click({ force: true }); - - cy.get(gitSyncLocators.gitConfigNameInput).type( - `{selectall}${testUsername}`, - ); - cy.get(gitSyncLocators.gitConfigEmailInput).type( - `{selectall}${testEmail}`, - ); - // click on the connect button and verify - cy.get(gitSyncLocators.connectSubmitBtn).click(); - - if (!assertConnectFailure) { - // check for connect success - cy.wait("@connectGitLocalRepo").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - } - - // click commit button - /* if (shouldCommit) { - cy.get(gitSyncLocators.commitCommentInput).type("Initial Commit"); - cy.get(gitSyncLocators.commitButton).click(); - // check for commit success - cy.wait("@commit").should( - "have.nested.property", - "response.body.responseMeta.status", - 201, - ); - - cy.get(gitSyncLocators.closeGitSyncModal).click(); - } - } else { - cy.wait("@connectGitLocalRepo").then((interception) => { - const status = interception.response.body.responseMeta.status; - expect(status).to.be.gte(400); - }); - } */ - cy.get(gitSyncLocators.closeGitSyncModal).click(); - }); - }, -); - Cypress.Commands.add("latestDeployPreview", () => { cy.intercept("POST", "/api/v1/applications/publish/*").as("publishApp"); // Wait before publish @@ -187,65 +93,6 @@ Cypress.Commands.add("switchGitBranch", (branch, expectError) => { AppSidebar.assertVisible(Cypress.config().pageLoadTimeout); }); -Cypress.Commands.add("createTestGithubRepo", (repo, 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, - }, - }); -}); - -Cypress.Commands.add("mergeViaGithubApi", ({ base, head, repo }) => { - const owner = Cypress.env("TEST_GITHUB_USER_NAME"); - cy.request({ - method: "POST", - url: `${GITHUB_API_BASE}/repos/${owner}/${repo}/merges`, - headers: { - Authorization: `token ${Cypress.env("GITHUB_PERSONAL_ACCESS_TOKEN")}`, - }, - body: { - base, - head, - }, - }); -}); - -Cypress.Commands.add("deleteTestGithubRepo", (repo) => { - 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")}`, - }, - }); -}); - -Cypress.Commands.add( - "renameBranchViaGithubApi", - (repo, currentName, newName) => { - cy.request({ - method: "POST", - url: `${GITHUB_API_BASE}/repos/${Cypress.env( - "TEST_GITHUB_USER_NAME", - )}/${repo}/branches/${currentName}/rename`, - headers: { - Authorization: `token ${Cypress.env("GITHUB_PERSONAL_ACCESS_TOKEN")}`, - }, - body: { - new_name: newName, - }, - }); - }, -); - Cypress.Commands.add("commitAndPush", (assertFailure) => { cy.get(homePage.publishButton).click(); agHelper.AssertElementExist(gitSync._bottomBarPull); @@ -270,29 +117,6 @@ Cypress.Commands.add("commitAndPush", (assertFailure) => { cy.get(gitSyncLocators.closeGitSyncModal).click(); }); -// todo rishabh s: refactor -Cypress.Commands.add( - "createAppAndConnectGit", - (appname, shouldConnect = true, assertConnectFailure) => { - cy.get(homePage.homeIcon).click({ force: true }); - cy.get(homePage.createNew).first().click({ force: true }); - cy.wait("@createNewApplication").should( - "have.nested.property", - "response.body.responseMeta.status", - 201, - ); - cy.get("#loading").should("not.exist"); - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(2000); - - homePageTS.RenameApplication(appname); - - cy.createTestGithubRepo(appname, true); - cy.connectToGitRepo(appname, false, assertConnectFailure); - cy.get(gitSyncLocators.closeGitSyncModal).click({ force: true }); - }, -); - Cypress.Commands.add("merge", (destinationBranch) => { agHelper.AssertElementExist(gitSync._bottomBarPull); @@ -342,53 +166,22 @@ Cypress.Commands.add( (repo, assertConnectFailure, failureMessage) => { const testEmail = "test@test.com"; const testUsername = "testusername"; - const owner = Cypress.env("TEST_GITHUB_USER_NAME"); - let generatedKey; - // cy.intercept( - // { - // url: "api/v1/git/connect/app/*", - // hostname: window.location.host, - // }, - // (req) => { - // req.headers["origin"] = "Cypress"; - // }, - // ); cy.intercept("GET", "api/v1/git/import/keys?keyType=ECDSA").as( `generateKey-${repo}`, ); cy.get(gitSyncLocators.gitRepoInput).type( - //`git@github.com:${owner}/${repo}.git`, - `${dataManager.GITEA_API_URL_TED}/${repo}.git`, + `${dataManager.GIT_CLONE_URL}/${repo}.git`, ); cy.get(gitSyncLocators.generateDeployKeyBtn).click(); cy.wait(`@generateKey-${repo}`).then((result) => { - 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, - // }, - // }); - + const key = result.response.body.data.publicKey.trimEnd(); cy.request({ method: "POST", - url: `${dataManager.GITEA_API_BASE_TED}:${dataManager.GITEA_API_PORT_TED}/api/v1/repos/Cypress/${repo}/keys`, - headers: { - Authorization: `token ${Cypress.env("GITEA_TOKEN")}`, - }, + url: `${dataManager.GIT_API_BASE}/api/v1/git/keys/${repo}`, body: { title: "key1", - key: generatedKey, + key, read_only: false, }, }); @@ -472,34 +265,13 @@ Cypress.Commands.add( if (generateKey) { if (protocol === "ECDSA") { cy.wait(`@generateKey-${repo}`).then((result) => { - 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, - // }, - // }); - + const key = result.response.body.data.publicKey.trimEnd(); cy.request({ method: "POST", - url: `${dataManager.GITEA_API_BASE_TED}:${dataManager.GITEA_API_PORT_TED}/api/v1/repos/Cypress/${repo}/keys`, - headers: { - Authorization: `token ${Cypress.env("GITEA_TOKEN")}`, - }, + url: `${dataManager.GIT_API_BASE}/api/v1/repos/Cypress/${repo}/keys`, body: { title: "key1", - key: generatedKey, + key, read_only: false, }, });