fix: reload default page on discard (#14964)
This commit is contained in:
parent
23c449ac27
commit
6eaabc3a7b
|
|
@ -9,6 +9,7 @@ describe("Git discard changes:", function() {
|
||||||
const query1 = "get_users";
|
const query1 = "get_users";
|
||||||
const query2 = "get_allusers";
|
const query2 = "get_allusers";
|
||||||
const jsObject = "JSObject1";
|
const jsObject = "JSObject1";
|
||||||
|
const jsObject2 = "JSObject2";
|
||||||
const page2 = "Page_2";
|
const page2 = "Page_2";
|
||||||
const page3 = "Page_3";
|
const page3 = "Page_3";
|
||||||
|
|
||||||
|
|
@ -133,6 +134,7 @@ describe("Git discard changes:", function() {
|
||||||
cy.wait("@getPage");
|
cy.wait("@getPage");
|
||||||
// discard changes
|
// discard changes
|
||||||
cy.gitDiscardChanges();
|
cy.gitDiscardChanges();
|
||||||
|
cy.wait(5000);
|
||||||
cy.CheckAndUnfoldEntityItem("QUERIES/JS");
|
cy.CheckAndUnfoldEntityItem("QUERIES/JS");
|
||||||
// verify query2 is not present
|
// verify query2 is not present
|
||||||
cy.get(`.t--entity-name:contains(${query2})`).should("not.exist");
|
cy.get(`.t--entity-name:contains(${query2})`).should("not.exist");
|
||||||
|
|
@ -144,6 +146,7 @@ describe("Git discard changes:", function() {
|
||||||
// verify jsObject is not duplicated
|
// verify jsObject is not duplicated
|
||||||
cy.get(`.t--entity-name:contains(${jsObject})`).should("have.length", 1);
|
cy.get(`.t--entity-name:contains(${jsObject})`).should("have.length", 1);
|
||||||
cy.gitDiscardChanges();
|
cy.gitDiscardChanges();
|
||||||
|
cy.wait(5000);
|
||||||
cy.CheckAndUnfoldEntityItem("QUERIES/JS");
|
cy.CheckAndUnfoldEntityItem("QUERIES/JS");
|
||||||
// verify jsObject2 is deleted after discarding changes
|
// verify jsObject2 is deleted after discarding changes
|
||||||
cy.get(`.t--entity-name:contains(${jsObject})`).should("not.exist");
|
cy.get(`.t--entity-name:contains(${jsObject})`).should("not.exist");
|
||||||
|
|
@ -156,6 +159,7 @@ describe("Git discard changes:", function() {
|
||||||
cy.get(`.t--entity-name:contains(${page2})`).should("not.exist");
|
cy.get(`.t--entity-name:contains(${page2})`).should("not.exist");
|
||||||
cy.wait(2000);
|
cy.wait(2000);
|
||||||
cy.gitDiscardChanges();
|
cy.gitDiscardChanges();
|
||||||
|
cy.wait(5000);
|
||||||
// verify page2 is recovered back
|
// verify page2 is recovered back
|
||||||
cy.get(`.t--entity-name:contains(${page2})`).should("be.visible");
|
cy.get(`.t--entity-name:contains(${page2})`).should("be.visible");
|
||||||
cy.get(`.t--entity-item:contains(${page2})`)
|
cy.get(`.t--entity-item:contains(${page2})`)
|
||||||
|
|
@ -179,6 +183,7 @@ describe("Git discard changes:", function() {
|
||||||
cy.get(`.t--entity-name:contains(${query1})`).should("not.exist");
|
cy.get(`.t--entity-name:contains(${query1})`).should("not.exist");
|
||||||
// discard changes
|
// discard changes
|
||||||
cy.gitDiscardChanges();
|
cy.gitDiscardChanges();
|
||||||
|
cy.wait(5000);
|
||||||
//verify query1 is recovered
|
//verify query1 is recovered
|
||||||
cy.get(`.t--entity-name:contains(${query1})`).should("be.visible");
|
cy.get(`.t--entity-name:contains(${query1})`).should("be.visible");
|
||||||
|
|
||||||
|
|
@ -192,6 +197,9 @@ describe("Git discard changes:", function() {
|
||||||
.first()
|
.first()
|
||||||
.click();
|
.click();
|
||||||
cy.wait("@getPage");
|
cy.wait("@getPage");
|
||||||
|
cy.wait(3000);
|
||||||
|
/* create and save jsObject */
|
||||||
|
// cy.createJSObject('return "Success";');
|
||||||
// delete jsObject1
|
// delete jsObject1
|
||||||
cy.CheckAndUnfoldEntityItem("QUERIES/JS");
|
cy.CheckAndUnfoldEntityItem("QUERIES/JS");
|
||||||
cy.get(`.t--entity-item:contains(${jsObject})`).within(() => {
|
cy.get(`.t--entity-item:contains(${jsObject})`).within(() => {
|
||||||
|
|
@ -202,8 +210,15 @@ describe("Git discard changes:", function() {
|
||||||
cy.get(`.t--entity-name:contains(${jsObject})`).should("not.exist");
|
cy.get(`.t--entity-name:contains(${jsObject})`).should("not.exist");
|
||||||
// discard changes
|
// discard changes
|
||||||
cy.gitDiscardChanges();
|
cy.gitDiscardChanges();
|
||||||
|
cy.wait(5000);
|
||||||
|
cy.CheckAndUnfoldEntityItem("PAGES");
|
||||||
|
cy.get(`.t--entity-item:contains(${page2})`)
|
||||||
|
.first()
|
||||||
|
.click();
|
||||||
|
cy.wait("@getPage");
|
||||||
|
cy.wait(3000);
|
||||||
//verify JSObject is recovered
|
//verify JSObject is recovered
|
||||||
cy.get(`.t--entity-name:contains(${jsObject})`).should("be.visible");
|
cy.get(`.t--entity-name:contains(${jsObject})`).should("exist");
|
||||||
cy.get(".bp3-input").should("have.value", "Success");
|
cy.get(".bp3-input").should("have.value", "Success");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -215,15 +230,16 @@ describe("Git discard changes:", function() {
|
||||||
.click();
|
.click();
|
||||||
// discard changes
|
// discard changes
|
||||||
cy.gitDiscardChanges();
|
cy.gitDiscardChanges();
|
||||||
|
cy.wait(5000);
|
||||||
// verify page3 is removed
|
// verify page3 is removed
|
||||||
cy.CheckAndUnfoldEntityItem("PAGES");
|
cy.CheckAndUnfoldEntityItem("PAGES");
|
||||||
cy.get(`.t--entity-name:contains("${page3}")`).should("not.exist");
|
cy.get(`.t--entity-name:contains("${page3}")`).should("not.exist");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("8. Add new page i.e page3, discard changes should give error resource not found", () => {
|
it(`8. Add new page i.e page3, discard changes should not throw error: "resource not found"`, () => {
|
||||||
cy.Createpage(page3);
|
cy.Createpage(page3);
|
||||||
cy.gitDiscardChanges(false);
|
cy.gitDiscardChanges();
|
||||||
cy.go("back");
|
cy.wait(5000);
|
||||||
cy.reload();
|
cy.get(`.t--entity-name:contains("${page3}")`).should("not.exist");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ describe("Modal Widget Functionality", function() {
|
||||||
cy.get('.bp3-collapse-body > [step="0"]')
|
cy.get('.bp3-collapse-body > [step="0"]')
|
||||||
.eq(1)
|
.eq(1)
|
||||||
.children()
|
.children()
|
||||||
.should("have.length", 2);
|
.should("have.length", 3);
|
||||||
//make sure modalis open on paste
|
//make sure modalis open on paste
|
||||||
cy.get(".t--modal-widget").should("have.length", 1);
|
cy.get(".t--modal-widget").should("have.length", 1);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ require("cy-verify-downloads").addCustomCommand();
|
||||||
require("cypress-file-upload");
|
require("cypress-file-upload");
|
||||||
import gitSyncLocators from "../locators/gitSyncLocators";
|
import gitSyncLocators from "../locators/gitSyncLocators";
|
||||||
import homePage from "../locators/HomePage";
|
import homePage from "../locators/HomePage";
|
||||||
|
|
||||||
const commonLocators = require("../locators/commonlocators.json");
|
const commonLocators = require("../locators/commonlocators.json");
|
||||||
const GITHUB_API_BASE = "https://api.github.com";
|
const GITHUB_API_BASE = "https://api.github.com";
|
||||||
|
|
||||||
|
|
@ -99,23 +100,23 @@ Cypress.Commands.add(
|
||||||
|
|
||||||
// click commit button
|
// click commit button
|
||||||
/* if (shouldCommit) {
|
/* if (shouldCommit) {
|
||||||
cy.get(gitSyncLocators.commitCommentInput).type("Initial Commit");
|
cy.get(gitSyncLocators.commitCommentInput).type("Initial Commit");
|
||||||
cy.get(gitSyncLocators.commitButton).click();
|
cy.get(gitSyncLocators.commitButton).click();
|
||||||
// check for commit success
|
// check for commit success
|
||||||
cy.wait("@commit").should(
|
cy.wait("@commit").should(
|
||||||
"have.nested.property",
|
"have.nested.property",
|
||||||
"response.body.responseMeta.status",
|
"response.body.responseMeta.status",
|
||||||
201,
|
201,
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.get(gitSyncLocators.closeGitSyncModal).click();
|
cy.get(gitSyncLocators.closeGitSyncModal).click();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cy.wait("@connectGitRepo").then((interception) => {
|
cy.wait("@connectGitRepo").then((interception) => {
|
||||||
const status = interception.response.body.responseMeta.status;
|
const status = interception.response.body.responseMeta.status;
|
||||||
expect(status).to.be.gte(400);
|
expect(status).to.be.gte(400);
|
||||||
});
|
});
|
||||||
} */
|
} */
|
||||||
cy.get(gitSyncLocators.closeGitSyncModal).click();
|
cy.get(gitSyncLocators.closeGitSyncModal).click();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -372,14 +373,9 @@ Cypress.Commands.add(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Cypress.Commands.add("gitDiscardChanges", (assertResourceFound = true) => {
|
Cypress.Commands.add("gitDiscardChanges", () => {
|
||||||
cy.get(gitSyncLocators.bottomBarCommitButton).click();
|
cy.get(gitSyncLocators.bottomBarCommitButton).click();
|
||||||
//cy.intercept("GET", "/api/v1/git/status/*").as("gitStatus");
|
cy.wait(6000);
|
||||||
// cy.wait("@gitStatus").should(
|
|
||||||
// "have.nested.property",
|
|
||||||
// "response.body.responseMeta.status",
|
|
||||||
// 200,
|
|
||||||
// );
|
|
||||||
cy.get(gitSyncLocators.discardChanges)
|
cy.get(gitSyncLocators.discardChanges)
|
||||||
.children()
|
.children()
|
||||||
.should("have.text", "Discard changes");
|
.should("have.text", "Discard changes");
|
||||||
|
|
@ -392,18 +388,8 @@ Cypress.Commands.add("gitDiscardChanges", (assertResourceFound = true) => {
|
||||||
.should("have.text", "Are you sure?");
|
.should("have.text", "Are you sure?");
|
||||||
cy.get(gitSyncLocators.discardChanges).click();
|
cy.get(gitSyncLocators.discardChanges).click();
|
||||||
cy.contains(Cypress.env("MESSAGES").DISCARDING_AND_PULLING_CHANGES());
|
cy.contains(Cypress.env("MESSAGES").DISCARDING_AND_PULLING_CHANGES());
|
||||||
if (assertResourceFound) {
|
cy.wait(2000);
|
||||||
cy.wait("@applications").should(
|
cy.validateToastMessage("Discarded changes successfully.");
|
||||||
"have.nested.property",
|
|
||||||
"response.body.responseMeta.status",
|
|
||||||
200,
|
|
||||||
);
|
|
||||||
cy.validateToastMessage("Discarded changes successfully.");
|
|
||||||
} else {
|
|
||||||
cy.get(".bold-text").should(($x) => {
|
|
||||||
expect($x).contain("Page not found");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add("regenerateSSHKey", (repo, generateKey = true) => {
|
Cypress.Commands.add("regenerateSSHKey", (repo, generateKey = true) => {
|
||||||
|
|
|
||||||
|
|
@ -468,6 +468,14 @@ const gitSyncReducer = createReducer(initialState, {
|
||||||
...state,
|
...state,
|
||||||
deletingBranch: action.payload,
|
deletingBranch: action.payload,
|
||||||
}),
|
}),
|
||||||
|
[ReduxActionTypes.GIT_DISCARD_CHANGES_SUCCESS]: (
|
||||||
|
state: GitSyncReducerState,
|
||||||
|
action: ReduxAction<any>,
|
||||||
|
) => ({
|
||||||
|
...state,
|
||||||
|
isDiscarding: false,
|
||||||
|
discard: action.payload,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type GitStatusData = {
|
export type GitStatusData = {
|
||||||
|
|
@ -505,6 +513,46 @@ export type GitBranchDeleteState = {
|
||||||
deletingBranch?: boolean;
|
deletingBranch?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type GitDiscardResponse = {
|
||||||
|
id: string;
|
||||||
|
modifiedBy: string;
|
||||||
|
userPermissions: string[];
|
||||||
|
name: string;
|
||||||
|
workspaceId: string;
|
||||||
|
isPublic: boolean;
|
||||||
|
pages: {
|
||||||
|
id: string;
|
||||||
|
isDefault: boolean;
|
||||||
|
defaultPageId: string;
|
||||||
|
default: boolean;
|
||||||
|
}[];
|
||||||
|
appIsExample: boolean;
|
||||||
|
unreadCommentThreads: number;
|
||||||
|
color: string;
|
||||||
|
icon: string;
|
||||||
|
slug: string;
|
||||||
|
gitApplicationMetadata: {
|
||||||
|
branchName: string;
|
||||||
|
defaultBranchName: string;
|
||||||
|
remoteUrl: string;
|
||||||
|
browserSupportedRemoteUrl: string;
|
||||||
|
isRepoPrivate: boolean;
|
||||||
|
repoName: string;
|
||||||
|
defaultApplicationId: string;
|
||||||
|
lastCommittedAt: string;
|
||||||
|
};
|
||||||
|
lastDeployedAt: string;
|
||||||
|
evaluationVersion: number;
|
||||||
|
applicationVersion: number;
|
||||||
|
isManualUpdate: boolean;
|
||||||
|
isAutoUpdate: boolean;
|
||||||
|
appLayout: {
|
||||||
|
type: string;
|
||||||
|
};
|
||||||
|
new: boolean;
|
||||||
|
modifiedAt: string;
|
||||||
|
};
|
||||||
|
|
||||||
export type GitSyncReducerState = GitBranchDeleteState & {
|
export type GitSyncReducerState = GitBranchDeleteState & {
|
||||||
isGitSyncModalOpen: boolean;
|
isGitSyncModalOpen: boolean;
|
||||||
isCommitting?: boolean;
|
isCommitting?: boolean;
|
||||||
|
|
@ -552,6 +600,7 @@ export type GitSyncReducerState = GitBranchDeleteState & {
|
||||||
gitImportError?: any;
|
gitImportError?: any;
|
||||||
|
|
||||||
isDiscarding?: boolean;
|
isDiscarding?: boolean;
|
||||||
|
discard?: GitDiscardResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default gitSyncReducer;
|
export default gitSyncReducer;
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ import { log } from "loglevel";
|
||||||
import GIT_ERROR_CODES from "constants/GitErrorCodes";
|
import GIT_ERROR_CODES from "constants/GitErrorCodes";
|
||||||
import { builderURL } from "RouteBuilder";
|
import { builderURL } from "RouteBuilder";
|
||||||
import { APP_MODE } from "../entities/App";
|
import { APP_MODE } from "../entities/App";
|
||||||
|
import { GitDiscardResponse } from "../reducers/uiReducers/gitSyncReducer";
|
||||||
|
|
||||||
export function* handleRepoLimitReachedError(response?: ApiResponse) {
|
export function* handleRepoLimitReachedError(response?: ApiResponse) {
|
||||||
const { responseMeta } = response || {};
|
const { responseMeta } = response || {};
|
||||||
|
|
@ -704,9 +705,8 @@ function* importAppFromGitSaga(action: ConnectToGitReduxAction) {
|
||||||
showReconnectDatasourceModal({
|
showReconnectDatasourceModal({
|
||||||
// @ts-expect-error: Type mismatch
|
// @ts-expect-error: Type mismatch
|
||||||
application: response?.data?.application,
|
application: response?.data?.application,
|
||||||
unConfiguredDatasourceList:
|
unConfiguredDatasourceList: (response as any)?.data
|
||||||
// @ts-expect-error: Type mismatch
|
.unConfiguredDatasourceList,
|
||||||
response?.data.unConfiguredDatasourceList,
|
|
||||||
workspaceId: workspaceIdForImport,
|
workspaceId: workspaceIdForImport,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -847,7 +847,7 @@ export function* deleteBranch({ payload }: ReduxAction<any>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function* discardChanges() {
|
function* discardChanges() {
|
||||||
let response: ApiResponse | undefined;
|
let response: ApiResponse<GitDiscardResponse>;
|
||||||
try {
|
try {
|
||||||
const appId: string = yield select(getCurrentApplicationId);
|
const appId: string = yield select(getCurrentApplicationId);
|
||||||
const doPull = true;
|
const doPull = true;
|
||||||
|
|
@ -858,9 +858,14 @@ function* discardChanges() {
|
||||||
getLogToSentryFromResponse(response),
|
getLogToSentryFromResponse(response),
|
||||||
);
|
);
|
||||||
if (isValidResponse) {
|
if (isValidResponse) {
|
||||||
yield put(discardChangesSuccess(response?.data));
|
yield put(discardChangesSuccess(response.data));
|
||||||
|
// const applicationId: string = response.data.id;
|
||||||
|
const pageId: string = response.data.pages.filter(
|
||||||
|
(page: any) => page.isDefault,
|
||||||
|
)[0].id;
|
||||||
localStorage.setItem("GIT_DISCARD_CHANGES", "success");
|
localStorage.setItem("GIT_DISCARD_CHANGES", "success");
|
||||||
location.reload();
|
const branch = response.data.gitApplicationMetadata.branchName;
|
||||||
|
window.open(builderURL({ pageId, branch }), "_self");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
yield put(discardChangesFailure({ error }));
|
yield put(discardChangesFailure({ error }));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user