Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

06/09 Daily Promotion #36142

Merged
merged 10 commits into from
Sep 6, 2024
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import ReconnectLocators from "../../../../locators/ReconnectLocators";
import { featureFlagIntercept } from "../../../../support/Objects/FeatureFlags";
import {
agHelper,
gitSync,
homePage,
} from "../../../../support/Objects/ObjectsCore";

let wsName: string;
let repoName: string = "TED-testrepo1";

describe(
"Git Autocommit",
{ tags: ["@tag.Git", "@tag.GitAutocommit"] },
function () {
it("Check if autocommit progress bar is visible and network requests are properly called", function () {
featureFlagIntercept({
release_git_autocommit_feature_enabled: true,
});
agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
wsName = "GitAC-" + uid;
homePage.CreateNewWorkspace(wsName, true);

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

cy.intercept(
{
method: "GET",
url: "/api/v1/git/auto-commit/progress/app/*",
},
(req) => {
req.on("response", (res) => {
res.setDelay(500);
});
},
).as("gitAutocommitProgressApi");

gitSync.ImportAppFromGit(wsName, repoName);
agHelper.GetNClick(ReconnectLocators.SkipToAppBtn);
cy.wait("@gitAutocommitTriggerApi").then((interception) => {
expect(interception?.response?.statusCode).to.equal(200);
expect(
interception?.response?.body?.data?.autoCommitResponse,
).to.equal("PUBLISHED");
agHelper.WaitUntilEleAppear(gitSync._autocommitStatusbar);
});
cy.wait("@gitAutocommitProgressApi").then((interceptions) => {
expect(interceptions?.response?.statusCode).to.equal(200);
});
});
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {

const testdata = require("../../../../fixtures/testdata.json");
const apiwidget = require("../../../../locators/apiWidgetslocator.json");
import apiLocators from "../../../../locators/ApiEditor";

import {
agHelper,
Expand All @@ -17,6 +18,7 @@ describe(
"API Panel Test Functionality",
{ tags: ["@tag.Datasource"] },
function () {
const successMsg = "Executed successfully from user request";
afterEach(function () {
agHelper.ActionContextMenuWithInPane({
action: "Delete",
Expand All @@ -39,12 +41,8 @@ describe(
agHelper.AssertAutoSave();
apiPage.RunAPI();
apiPage.ResponseStatusCheck("200 OK");
cy.validateRequest(
"Executed successfully",
testdata.baseUrl,
testdata.echoMethod,
testdata.Put,
);
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
agHelper.AssertContains(successMsg);
});
cy.ResponseCheck("updatedAt");
});
Expand All @@ -63,12 +61,8 @@ describe(
agHelper.AssertAutoSave();
apiPage.RunAPI();
apiPage.ResponseStatusCheck("200 OK");
cy.validateRequest(
"Executed successfully",
testdata.baseUrl,
testdata.echoMethod,
testdata.Post,
);
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
agHelper.AssertContains(successMsg);
});
cy.ResponseCheck("createdAt");
});
Expand All @@ -87,12 +81,8 @@ describe(
agHelper.AssertAutoSave();
apiPage.RunAPI();
apiPage.ResponseStatusCheck("200 OK");
cy.validateRequest(
"Executed successfully",
testdata.baseUrl,
testdata.echoMethod,
testdata.Patch,
);
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
agHelper.AssertContains(successMsg);
});
cy.ResponseCheck("updatedAt");
});
Expand All @@ -111,12 +101,8 @@ describe(
agHelper.AssertAutoSave();
apiPage.RunAPI();
apiPage.ResponseStatusCheck("200 OK");
cy.validateRequest(
"Executed successfully",
testdata.baseUrl,
testdata.echoMethod,
testdata.Delete,
);
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
agHelper.AssertContains(successMsg);
});
});

Expand All @@ -127,12 +113,8 @@ describe(
apiPage.RunAPI();
apiPage.ResponseStatusCheck("200 OK");
cy.ResponseCheck(testdata.responsetext);
cy.validateRequest(
"Executed successfully",
testdata.baseUrl,
testdata.methods,
testdata.Get,
);
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
agHelper.AssertContains(successMsg);

apiPage.SelectPaneTab("Pagination");
agHelper.GetNClick(apiwidget.paginationWithUrl);
Expand All @@ -144,12 +126,8 @@ describe(
cy.clickTest(apiwidget.TestNextUrl);
apiPage.ResponseStatusCheck("200 OK");
cy.ResponseCheck("Josh M Krantz");
cy.validateRequest(
"Executed successfully",
testdata.baseUrl,
testdata.next,
testdata.Get,
);
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
agHelper.AssertContains(successMsg);

apiPage.SelectPaneTab("Pagination");
cy.enterUrl(
Expand All @@ -160,12 +138,8 @@ describe(
cy.clickTest(apiwidget.TestPreUrl);
apiPage.ResponseStatusCheck("200 OK");
cy.ResponseCheck(testdata.responsetext);
cy.validateRequest(
"Executed successfully",
testdata.baseUrl,
testdata.prev,
testdata.Get,
);
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
agHelper.AssertContains(successMsg);
});

it("6. API check with query params test API feature", function () {
Expand All @@ -174,12 +148,8 @@ describe(
apiPage.RunAPI();
apiPage.ResponseStatusCheck("200 OK");
cy.ResponseCheck(testdata.responsetext3);
cy.validateRequest(
"Executed successfully",
testdata.baseUrl,
testdata.queryAndValue,
testdata.Get,
);
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
agHelper.AssertContains(successMsg);
});

it("7. API check with Invalid Header", function () {
Expand All @@ -188,13 +158,8 @@ describe(
agHelper.AssertAutoSave();
apiPage.RunAPI(false);
apiPage.ResponseStatusCheck("5000");
cy.validateRequest(
"Execution failed",
testdata.baseUrl,
testdata.methods,
testdata.Get,
true,
);
agHelper.GetNClickByContains(apiLocators.apiResponseTabsList, "Logs");
agHelper.AssertContains(successMsg);
cy.ResponseCheck("Invalid value for Content-Type");
});
},
Expand Down
1 change: 1 addition & 0 deletions app/client/cypress/locators/ApiEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ export default {
slashCommandButton: ".commands-button",
apiResponseObject: ".object-key",
apiDebuggerLink: ".debugger-entity-link",
apiResponseTabsList : ".ads-v2-tabs__list"
};
19 changes: 19 additions & 0 deletions app/client/cypress/support/Pages/AggregateHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,25 @@ export class AggregateHelper {
) as Cypress.Chainable<boolean>;
}

/**
* Checks if the specified instance of the element is present with number and visible on the page.
*
* @param {ElementType} selector - The element selector.
* @param {number} [eq=0] - The index of the element to check (default is 0).
* @returns {Cypress.Chainable<boolean>} - Returns a boolean wrapped in a Cypress Chainable indicating visibility.
*/
IsElementVisibleWithEq(selector: ElementType, eq: number = 0) {
return this.GetElement(selector)
.eq(eq)
.then(($element) => {
// Check if the element is present and visible
const isVisible =
Cypress.$($element).length > 0 && Cypress.$($element).is(":visible");
console.log(`Element visibility: ${isVisible}`);
return isVisible;
}) as Cypress.Chainable<boolean>;
}

public FailIfErrorToast(error: string) {
cy.get("body").then(($ele) => {
if ($ele.find(this.locator._toastMsg).length > 0) {
Expand Down
1 change: 1 addition & 0 deletions app/client/cypress/support/Pages/GitSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class GitSync {
"[data-testid='t--git-protected-branches-select']";
public _branchProtectionUpdateBtn =
"[data-testid='t--git-protected-branches-update-btn']";
public _autocommitStatusbar = "[data-testid='t--autocommit-statusbar']";
public _disconnectGitBtn = "[data-testid='t--git-disconnect-btn']";
public _mergeLoader = "[data-testid='t--git-merge-loader']";

Expand Down
2 changes: 1 addition & 1 deletion app/client/packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"postinstall": "yarn build",
"test:unit": "yarn g:jest"
}
}
}
6 changes: 1 addition & 5 deletions app/client/src/ce/sagas/ApplicationSagas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,7 @@ export function* fetchAppAndPagesSaga(
) {
try {
const { pages, ...payload } = action.payload;
const request = {
applicationId: payload.applicationId,
pageId: payload.pageId,
mode: payload.mode,
};
const request = { ...payload };
if (request.pageId && request.applicationId) {
delete request.applicationId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export function getWidgetSessionValues(
}

for (const key in configMap) {
if (configMap[key] === undefined) continue;
let sessionStorageKey = `${widgetType}.${key}`;

if (type === "ZONE_WIDGET") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function AutocommitStatusbar({
}
});
return (
<StatusbarWrapper>
<StatusbarWrapper data-testid="t--autocommit-statusbar">
<Statusbar
active={false}
message={createMessage(AUTOCOMMIT_IN_PROGRESS_MESSAGE)}
Expand Down
41 changes: 24 additions & 17 deletions app/client/src/pages/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ interface EditorProps {
type Props = EditorProps & RouteComponentProps<BuilderRouteParams>;

class Editor extends Component<Props> {
prevPageId: string | null = null;

componentDidMount() {
const { basePageId } = this.props.match.params || {};
urlBuilder.setCurrentBasePageId(basePageId);
Expand Down Expand Up @@ -110,7 +112,24 @@ class Editor extends Component<Props> {

componentDidUpdate(prevProps: Props) {
const { baseApplicationId, basePageId } = this.props.match.params || {};
const { basePageId: prevPageBaseId } = prevProps.match.params || {};
const { basePageId: prevBasePageId } = prevProps.match.params || {};

const pageId = this.props.pages.find(
(page) => page.basePageId === basePageId,
)?.pageId;

const prevPageId = prevProps.pages.find(
(page) => page.basePageId === prevBasePageId,
)?.pageId;
// caching value for prevPageId as it is required in future lifecycles
if (prevPageId) {
this.prevPageId = prevPageId;
}

const isPageIdUpdated = pageId !== this.prevPageId;
const isBasePageIdUpdated = basePageId !== prevBasePageId;
const isPageUpdated = isPageIdUpdated || isBasePageIdUpdated;

const isBranchUpdated = getIsBranchUpdated(
this.props.location,
prevProps.location,
Expand All @@ -125,8 +144,6 @@ class Editor extends Component<Props> {
GIT_BRANCH_QUERY_KEY,
);

const isPageIdUpdated = basePageId !== prevPageBaseId;

// to prevent re-init during connect
if (prevBranch && isBranchUpdated && basePageId) {
this.props.initEditor({
Expand All @@ -141,20 +158,10 @@ class Editor extends Component<Props> {
* If we don't check for `prevPageId`: fetch page is re triggered
* when redirected to the default page
*/
if (
prevPageBaseId &&
basePageId &&
isPageIdUpdated &&
this.props.pages.length
) {
const pageId = this.props.pages.find(
(page) => page.basePageId === basePageId,
)?.pageId;
if (pageId) {
this.props.updateCurrentPage(pageId);
this.props.setupPage(pageId);
urlBuilder.setCurrentBasePageId(basePageId);
}
if (pageId && this.prevPageId && isPageUpdated) {
this.props.updateCurrentPage(pageId);
this.props.setupPage(pageId);
urlBuilder.setCurrentBasePageId(basePageId);
}
}
}
Expand Down
Loading
Loading