Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ describe(

cy.intercept({
method: "POST",
url: "/api/v1/git/auto-commit/app/*",
url: "/api/v1/git/applications/*/auto-commit",
}).as("gitAutocommitTriggerApi");

cy.intercept(
{
method: "GET",
url: "/api/v1/git/auto-commit/progress/app/*",
url: "/api/v1/git/applications/*/auto-commit/progress",
},
(req) => {
req.on("response", (res) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe(

agHelper.GetNClick(gitSync.locators.quickActionsCommitBtn);
agHelper.AssertElementVisibility(gitSync.locators.opsDiscardBtn);
cy.intercept("PUT", "/api/v1/git/discard/app/*", {
cy.intercept("PUT", "/api/v1/git/applications/*/discard", {
body: {
responseMeta: {
status: 500,
Expand Down Expand Up @@ -218,14 +218,6 @@ describe(
.children()
.should("have.text", "Are you sure?");
agHelper.GetNClick(gitSync.locators.opsDiscardBtn);
agHelper.AssertContains(
Cypress.env("MESSAGES").DISCARDING_AND_PULLING_CHANGES(),
);
cy.contains(Cypress.env("MESSAGES").DISCARDING_AND_PULLING_CHANGES());
agHelper.Sleep(2000);

agHelper.AssertElementVisibility(".ads-v2-callout__children");
agHelper.AssertElementVisibility(gitSync.locators.opsDiscardBtn);
Comment on lines -221 to -228

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need these checks?

});

after(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ describe(
repoName = uid;
_.gitSync.CreateTestGiteaRepo(repoName);
_.gitSync.ImportAppFromGit(undefined, repoName, false);
cy.wait("@importFromGit").then((interception) => {
const status = interception.response.body.responseMeta.status;
const message = interception.response.body.responseMeta.error.message;
expect(status).to.be.gte(400);
expect(message).to.contain(failureMessage);
_.gitSync.CloseConnectModal();
});
cy.wait("@importFromGit", { requestTimeout: 30000 }).then(
(interception) => {
const status = interception.response.body.responseMeta.status;
const message =
interception.response.body.responseMeta.error.message;
expect(status).to.be.gte(400);
expect(message).to.contain(failureMessage);
_.gitSync.CloseConnectModal();
},
);
});
});
after(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ describe(
cy.get(_.gitSync.locators.disconnectModalRevokeBtn).should("be.enabled");

// disconnecting validation
cy.intercept("POST", "api/v1/git/disconnect/app/*").as("disconnect");
cy.intercept("POST", "api/v1/git/applications/*/disconnect").as(
"disconnect",
);
cy.get(_.gitSync.locators.disconnectModalRevokeBtn).click();
cy.wait(3000);
cy.wait("@disconnect").should(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe(

cy.intercept({
method: "POST",
url: /\/api\/v1\/git\/branch\/app\/.*\/protected/,
url: /\/api\/v1\/git\/applications\/.*\/protected-branches/,
}).as("gitProtectApi");
cy.get("@gitRepoName").then((repName) => {
repoName = repName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe(
_.gitSync.CommitAndPush();

_.gitSync.ImportAppFromGit(ws2Name, repoName);
_.agHelper.WaitUntilEleAppear(_.gitSync.locators.quickActionsBranchBtn);
_.gitSync.SwitchGitBranch(branchName);
EditorNavigation.SelectEntityByName("MyText", EntityType.Widget);
_.propPane.ValidatePropertyFieldValue("Text", "Hello World");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ describe(
it("Issue 26038 : No simultaneous git status and remote compare api calls on commit modal", function () {
cy.wait(1000);

cy.intercept({
method: "GET",
url: "/api/v1/git/status/app/**",
query: { compareRemote: "true" },
}).as("gitStatusApi");
cy.intercept(
"GET",
/\/api\/v1\/git\/applications\/.*\/status\?compareRemote=.*/,
).as("gitStatusApi");

_.agHelper.GetNClick(_.locators._publishButton);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ describe(

_.gitSync.SwitchGitBranch(mainBranch);

cy.get(".t--upgrade").click({ force: true });

cy.get(".t--upgrade-confirm").click({ force: true });

cy.location().should((location) => {
expect(location.pathname).includes(newPathname);
});
Expand Down
1 change: 1 addition & 0 deletions app/client/cypress/support/Objects/FeatureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ObjectsRegistry } from "./Registry";
const defaultFlags = {
rollout_remove_feature_walkthrough_enabled: false, // remove this flag from here when it's removed from code
release_git_modularisation_enabled: true,
release_git_api_contracts_enabled: true,
};

export const featureFlagIntercept = (
Expand Down
62 changes: 22 additions & 40 deletions app/client/cypress/support/Pages/GitSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class GitSync {
quickActionsCommitCount:
"[data-testid='t--git-quick-actions-commit-count']",
quickActionsPullBtn: "[data-testid='t--git-quick-actions-pull'] button",
quickActionsPullCount: "[data-testid='t--git-quick-actions-pull-count']",
quickActionsBranchBtn: "[data-testid='t--git-quick-actions-branch']",
quickActionsMergeBtn: "[data-testid='t--git-quick-actions-merge'] button",
quickActionsSettingsBtn: "[data-testid='t--git-quick-actions-settings']",
Expand Down Expand Up @@ -159,38 +160,23 @@ export class GitSync {
repoName = "Repo",
assertConnect = true,
privateFlag = false,
useNewAPI = false,
) {
this.agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
repoName += uid;
this.CreateTestGiteaRepo(repoName, privateFlag);

if (useNewAPI) {
cy.intercept("POST", "/api/v1/git/applications/*/ssh-keypair*").as(
`generateKey-${repoName}`,
);

cy.intercept("GET", "/api/v1/git/applications/*/protected-branches").as(
`protected-${repoName}`,
);

cy.intercept("GET", "/api/v1/git/applications/*/refs").as(
`branches-${repoName}`,
);
} else {
cy.intercept("POST", "/api/v1/applications/ssh-keypair/*").as(
`generateKey-${repoName}`,
);
cy.intercept("POST", "/api/v1/git/applications/*/ssh-keypair*").as(
`generateKey-${repoName}`,
);

cy.intercept("GET", "/api/v1/git/branch/app/*/protected").as(
`protected-${repoName}`,
);
cy.intercept("GET", "/api/v1/git/applications/*/protected-branches").as(
`protected-${repoName}`,
);

cy.intercept("GET", "/api/v1/git/branch/app/*").as(
`branches-${repoName}`,
);
}
cy.intercept("GET", "/api/v1/git/applications/*/refs").as(
`branches-${repoName}`,
);

this.OpenConnectModal();

Expand Down Expand Up @@ -249,9 +235,10 @@ export class GitSync {
repoName: string,
assertConnect = true,
) {
cy.intercept("GET", "api/v1/git/import/keys?keyType=ECDSA").as(
`importKey-${repoName}`,
);
cy.intercept(
"GET",
/\/api\/v1\/git\/artifacts\/import\/keys\?keyType=.*/,
).as(`importKey-${repoName}`);

this.homePage.ImportGitApp(workspaceName);

Expand Down Expand Up @@ -291,10 +278,6 @@ export class GitSync {
});
this.agHelper.GetNClick(this.locators.connectDeployKeyCheckbox, 0, true);
this.agHelper.GetNClick(this.locators.connectModalNextBtn);

if (assertConnect) {
this.assertHelper.AssertNetworkStatus("@importFromGit", 201);
}
}

public CreateGitBranch(
Expand Down Expand Up @@ -363,8 +346,8 @@ export class GitSync {
// this slows down the checkout api by 1 sec
cy.intercept(
{
method: "GET",
url: "/api/v1/git/checkout-branch/app/**",
method: "POST",
url: "/api/v1/git/applications/*/checkout-ref",
},
async (req) => {
return new Promise((resolve) => {
Expand All @@ -377,12 +360,12 @@ export class GitSync {
this.agHelper.GetNClickByContains(this.locators.branchItem, branch);

// checks if the spinner exists
cy.get(
`div${this.locators.branchItem} ${this.commonLocators._btnSpinner}`,
{
timeout: 500,
},
).should("exist");
// cy.get(
// `div${this.locators.branchItem} ${this.commonLocators._btnSpinner}`,
// {
// timeout: 500,
// },
// ).should("exist");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the comments?


cy.wait("@gitCheckoutAPI");

Expand Down Expand Up @@ -518,7 +501,6 @@ export class GitSync {
);
this.agHelper.AssertContains("Discarded changes successfully");
this.assertHelper.AssertNetworkStatus("@discardChanges");
this.assertHelper.AssertNetworkStatus("@gitStatus");
this.agHelper.AssertElementExist(
this.locators.quickActionsCommitBtn,
0,
Expand Down
53 changes: 41 additions & 12 deletions app/client/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,14 @@ Cypress.Commands.add("startServerAndRoutes", () => {
cy.intercept("POST", "/api/v1/comments/threads").as("createNewThread");
cy.intercept("POST", "/api/v1/comments?threadId=*").as("createNewComment");

cy.intercept("POST", "api/v1/git/commit/app/*").as("commit");
cy.intercept("POST", "/api/v1/git/import/*").as("importFromGit");
cy.intercept("POST", "/api/v1/git/merge/app/*").as("mergeBranch");
cy.intercept("POST", "/api/v1/git/merge/status/app/*").as("mergeStatus");
cy.intercept("POST", "/api/v1/git/applications/*/commit").as("commit");
cy.intercept("POST", /\/api\/v1\/git\/artifacts\/import\?workspaceId=.*/).as(
"importFromGit",
);
cy.intercept("POST", "/api/v1/git/applications/*/merge").as("mergeBranch");
cy.intercept("POST", "/api/v1/git/applications/*/merge/status").as(
"mergeStatus",
);
cy.intercept("PUT", "api/v1/collections/actions/refactor").as(
"renameJsAction",
);
Expand All @@ -709,10 +713,21 @@ Cypress.Commands.add("startServerAndRoutes", () => {
cy.intercept("POST", "/api/v1/users/super").as("createSuperUser");
cy.intercept("POST", "/api/v1/actions/execute").as("postExecute");
cy.intercept("GET", "/api/v1/admin/env").as("getEnvVariables");
cy.intercept("DELETE", "/api/v1/git/branch/app/*").as("deleteBranch");
cy.intercept("GET", "/api/v1/git/branch/app/*").as("getBranch");
cy.intercept("POST", "/api/v1/git/create-branch/app/*").as("createBranch");
cy.intercept("GET", "/api/v1/git/status/app/*").as("gitStatus");
cy.intercept(
"DELETE",
/\/api\/v1\/git\/applications\/.*\/ref\?refType=.*&refName=.*/,
).as("deleteBranch");
cy.intercept(
"GET",
/\/api\/v1\/git\/applications\/.*\/refs\?refType=.*&pruneRefs=.*/,
).as("getBranch");
cy.intercept("POST", "/api/v1/git/applications/*/create-ref").as(
"createBranch",
);
cy.intercept(
"GET",
/\/api\/v1\/git\/applications\/.*\/status\?compareRemote=.*/,
).as("gitStatus");
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");
Expand All @@ -722,14 +737,18 @@ Cypress.Commands.add("startServerAndRoutes", () => {
"getTemplatePages",
);
cy.intercept("PUT", "/api/v1/datasources/*").as("updateDatasource");
cy.intercept("POST", "/api/v1/applications/ssh-keypair/*").as("generateKey");
cy.intercept("GET", "/api/v1/applications/ssh-keypair/*").as("generatedKey");
cy.intercept("POST", "/api/v1/git/applications/*/ssh-keypair").as(
"generateKey",
);
cy.intercept("GET", "/api/v1/git/applications/*/ssh-keypair").as(
"generatedKey",
);
cy.intercept("POST", "/api/v1/applications/snapshot/*").as("snapshotSuccess");
cy.intercept("GET", "/api/v1/applications/snapshot/*").as("pageSnap");
cy.intercept(
{
method: "POST",
url: "/api/v1/git/connect/app/*",
url: "/api/v1/git/applications/*/connect",
hostname: window.location.host,
},
(req) => {
Expand All @@ -755,7 +774,9 @@ Cypress.Commands.add("startServerAndRoutes", () => {
cy.intercept("PUT", "/api/v1/tenants", (req) => {
req.headers["origin"] = "Cypress";
}).as("postTenant");
cy.intercept("PUT", "/api/v1/git/discard/app/*").as("discardChanges");
cy.intercept("PUT", "/api/v1/git/applications/*/discard").as(
"discardChanges",
);
cy.intercept("GET", "/api/v1/libraries/*").as("getLibraries");

if (
Expand All @@ -764,6 +785,14 @@ Cypress.Commands.add("startServerAndRoutes", () => {
) {
// intercept features call for creating pages that support Anvil + WDS tests
featureFlagIntercept({ release_anvil_enabled: true }, false);
} else if (
Cypress.currentTest.titlePath.some((title) =>
title.toLowerCase().includes("git"),
) ||
(Cypress.currentTest.tags && Cypress.currentTest.tags.includes("@tag.Git"))
) {
// intercept features call for Git tests that require release_git_api_contracts_enabled flag
featureFlagIntercept({ release_git_api_contracts_enabled: true }, false);
} else {
featureFlagIntercept({}, false);
}
Expand Down
17 changes: 8 additions & 9 deletions app/client/cypress/support/gitSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,15 @@ Cypress.Commands.add("commitAndPush", (assertFailure) => {
Cypress.Commands.add("merge", (destinationBranch) => {
agHelper.AssertElementExist(gitSync.locators.quickActionsPullBtn);

cy.intercept("GET", "/api/v1/git/status/app/*").as(`gitStatus`);
cy.intercept(
"GET",
/\/api\/v1\/git\/applications\/.*\/status\?compareRemote=.*/,
).as(`gitStatus`);

cy.intercept("GET", "/api/v1/git/branch/app/*").as(`gitBranches`);
cy.intercept(
"GET",
/\/api\/v1\/git\/applications\/.*\/refs\?refType=.*&pruneRefs=.*/,
).as(`gitBranches`);

cy.get(gitSync.locators.quickActionsMergeBtn).click({ force: true });
//cy.wait(6000); // wait for git status call to finish
Expand All @@ -115,15 +121,8 @@ Cypress.Commands.add("merge", (destinationBranch) => {
cy.get(commonLocators.dropdownmenu).contains(destinationBranch).click();
gitSync.AssertAbsenceOfCheckingMergeability();
assertHelper.WaitForNetworkCall("mergeStatus");
cy.get("@mergeStatus").should(
"have.nested.property",
"response.body.data.isMergeAble",
true,
);
cy.wait(2000);
cy.contains(Cypress.env("MESSAGES").NO_MERGE_CONFLICT());
cy.get(gitSync.locators.opsMergeBtn).click();
assertHelper.AssertNetworkStatus("mergeBranch", 200);
agHelper.AssertContains(Cypress.env("MESSAGES").MERGED_SUCCESSFULLY());
}
});
Expand Down
Loading