Skip to content

Commit

Permalink
Merge pull request #36024 from appsmithorg/cypress/cheryy-pick-flaky-…
Browse files Browse the repository at this point in the history
…fixes-ce
  • Loading branch information
nidhi-nair committed Sep 2, 2024
2 parents 9ebecbe + ffdcaed commit 5c293ea
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ describe(
it("3. handleSelectAllChange: unchecked", function () {
const selectAllSelector = formWidgetsPage.selectAllCheckboxControl;
const uncheckedOptionInputs = `${formWidgetsPage.checkboxGroupOptionInputs} input:not(:checked)`;
// Deselect all
cy.get(selectAllSelector).click();
// Should get 2 unchecked option inputs
cy.get(uncheckedOptionInputs).should("have.length", 2);
//handleSelectAllChange: checked", function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
agHelper,
apiPage,
assertHelper,
dataManager,
deployMode,
entityItems,
jsEditor,
Expand Down Expand Up @@ -128,8 +129,8 @@ describe(
agHelper.AddDsl("multiPartFormDataDsl");

apiPage.CreateAndFillApi(
"https://api.cloudinary.com/v1_1/appsmithautomationcloud/image/upload?upload_preset=fbbhg4xu",
"CloudinaryUploadApi",
dataManager.dsValues[dataManager.defaultEnviorment].multipartAPI,
"MultipartAPI",
30000,
"POST",
);
Expand All @@ -145,7 +146,7 @@ describe(
myVar1: [],
myVar2: {},
upload: async () => {
await CloudinaryUploadApi.run().then(()=> showAlert('Image uploaded to Cloudinary successfully', 'success')).catch(err => showAlert(err.message, 'error'));
await MultipartAPI.run().then(()=> showAlert('Image uploaded to multipart successfully', 'success')).catch(err => showAlert(err.message, 'error'));
await resetWidget('FilePicker1', true);
}
}`,
Expand All @@ -161,25 +162,17 @@ describe(
propPane.EnterJSContext("onFilesSelected", `{{JSObject1.upload()}}`);

EditorNavigation.SelectEntityByName("Image1", EntityType.Widget);
propPane.UpdatePropertyFieldValue(
"Image",
"{{CloudinaryUploadApi.data.url}}",
);
propPane.UpdatePropertyFieldValue("Image", "{{MultipartAPI.data.url}}");

EditorNavigation.SelectEntityByName(
"CloudinaryUploadApi",
EntityType.Api,
);
EditorNavigation.SelectEntityByName("MultipartAPI", EntityType.Api);

apiPage.ToggleOnPageLoadRun(false); //Bug 12476
EditorNavigation.SelectEntityByName("Page1", EntityType.Page);
deployMode.DeployApp(locators._buttonByText("Select Files"));
agHelper.ClickButton("Select Files");
agHelper.UploadFile(imageNameToUpload);
assertHelper.AssertNetworkExecutionSuccess("@postExecute"); //validating Cloudinary api call
agHelper.ValidateToastMessage(
"Image uploaded to Cloudinary successfully",
);
agHelper.ValidateToastMessage("Image uploaded to multipart successfully");
agHelper.Sleep();
cy.xpath(apiPage._imageSrc)
.find("img")
Expand All @@ -192,31 +185,5 @@ describe(
agHelper.AssertElementVisibility(locators._buttonByText("Select Files")); //verifying if reset!
deployMode.NavigateBacktoEditor();
});

it("8. Checks MultiPart form data for a Array Type upload results in API error", () => {
const imageNameToUpload = "AAAFlowerVase.jpeg";
EditorNavigation.SelectEntityByName(
"CloudinaryUploadApi",
EntityType.Api,
);
apiPage.EnterBodyFormData(
"MULTIPART_FORM_DATA",
"file",
"{{FilePicker1.files[0]}}",
"Array",
true,
);
EditorNavigation.SelectEntityByName("FilePicker1", EntityType.Widget);
agHelper.ClickButton("Select Files");
agHelper.UploadFile(imageNameToUpload);
assertHelper.AssertNetworkExecutionSuccess("@postExecute", false);

deployMode.DeployApp(locators._buttonByText("Select Files"));
agHelper.ClickButton("Select Files");
agHelper.UploadFile(imageNameToUpload);
assertHelper.AssertNetworkExecutionSuccess("@postExecute", false);
agHelper.ValidateToastMessage("CloudinaryUploadApi failed to execute");
agHelper.AssertElementVisibility(locators._buttonByText("Select Files")); //verifying if reset in case of failure!
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ describe(
dataSources.RunQueryNVerifyResponseViews(10);
dataSources.AssertQueryTableResponse(5, "2112");
dataSources.AssertQueryTableResponse(6, "Mike's Liquors");
agHelper.ActionContextMenuWithInPane({
action: "Delete",
entityType: entityItems.Query,
});
// Commenting this deletion of query to make the generate crud work on the new page instead of the current page
// agHelper.ActionContextMenuWithInPane({
// action: "Delete",
// entityType: entityItems.Query,
// });
});

it("3. Verify Generate CRUD for the new table & Verify Deploy mode for table - Stores", () => {
Expand Down Expand Up @@ -129,13 +130,13 @@ describe(
updateNVerify(6, 4, newStoreSecret as string);
});

table.SelectTableRow(17, 0, true, "v2");
dataSources.AssertJSONFormHeader(17, 0, "store_id");
generateStoresSecretInfo(17);
table.SelectTableRow(12, 0, true, "v2");
dataSources.AssertJSONFormHeader(12, 0, "store_id");
generateStoresSecretInfo(12);
cy.get("@secretInfo").then(($secretInfo) => {
newStoreSecret = $secretInfo;
cy.log("newStoreSecret is : " + newStoreSecret);
updateNVerify(17, 4, newStoreSecret as string);
updateNVerify(12, 4, newStoreSecret as string);
});

//Hidden field bug - to add here aft secret codes are updated for some fields!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
locators,
table,
} from "../../../../support/Objects/ObjectsCore";
import { featureFlagIntercept } from "../../../../support/Objects/FeatureFlags";
import EditorNavigation, {
AppSidebar,
AppSidebarButton,
Expand Down Expand Up @@ -76,38 +75,7 @@ describe("Binary Datatype tests", { tags: ["@tag.Datasource"] }, function () {
table.WaitForTableEmpty(); //asserting table is empty before inserting!
});

//Timing out a lot in CI, hence skipped, Insert verified also in next case
// it.skip("3. Inserting record - binarytype", () => {
// imageNameToUpload = "Datatypes/Bridge.jpg";
// // entityExplorer.SelectEntityByName("Page1");
// // deployMode.DeployApp();
// // table.WaitForTableEmpty(); //asserting table is empty before inserting!
// agHelper.ClickButton("Run InsertQuery");
// agHelper.AssertElementVisibility(locators._modal);

// agHelper.ClickButton("Select New Image");
// agHelper.UploadFile(imageNameToUpload);

// agHelper.ClickButton("Insert");
// agHelper.AssertElementAbsence(locators._toastMsg); //Assert that Insert did not fail
// agHelper.AssertElementVisibility(locators._buttonByText("Run InsertQuery"));
// agHelper.AssertElementAbsence(locators._btnSpinner, 10000); //for the update row to appear at last
// table.WaitUntilTableLoad();
// agHelper.Sleep(3000); //some more time for all rows with images to be populated
// table.ReadTableRowColumnData(0, 0).then(($cellData) => {
// expect($cellData).to.eq("1"); //asserting serial column is inserting fine in sequence
// });
// table.ReadTableRowColumnData(0, 1, "v1", 200).then(($cellData) => {
// expect($cellData).to.eq("Bridge.jpg");
// });
// table.AssertTableRowImageColumnIsLoaded(0, 2).then(($oldimage) => {
// table.AssertTableRowImageColumnIsLoaded(0, 3).then(($newimage) => {
// expect($oldimage).to.eq($newimage);
// });
// });
// });

it("4. Inserting another record - binarytype", () => {
it("3. Inserting another record - binarytype", () => {
imageNameToUpload = "Datatypes/Georgia.jpeg";

agHelper.ClickButton("Run InsertQuery");
Expand All @@ -121,21 +89,21 @@ describe("Binary Datatype tests", { tags: ["@tag.Datasource"] }, function () {
agHelper.AssertElementVisibility(locators._buttonByText("Run InsertQuery"));
agHelper.AssertElementAbsence(locators._btnSpinner, 20000); //for the update row to appear at last
table.WaitUntilTableLoad();
agHelper.Sleep(2000); //some more time for all rows with images to be populated
table.ReadTableRowColumnData(1, 0).then(($cellData) => {
expect($cellData).to.eq("2"); //asserting serial column is inserting fine in sequence
const rowIndex = 0;
table.ReadTableRowColumnData(rowIndex, 0).then(($cellData) => {
expect($cellData).to.eq("1"); //asserting serial column is inserting fine in sequence
});
table.ReadTableRowColumnData(1, 1, "v1", 200).then(($cellData) => {
table.ReadTableRowColumnData(rowIndex, 1, "v1", 200).then(($cellData) => {
expect($cellData).to.eq("Georgia.jpeg");
});
table.AssertTableRowImageColumnIsLoaded(1, 2).then(($oldimage) => {
table.AssertTableRowImageColumnIsLoaded(1, 3).then(($newimage) => {
table.AssertTableRowImageColumnIsLoaded(rowIndex, 2).then(($oldimage) => {
table.AssertTableRowImageColumnIsLoaded(rowIndex, 3).then(($newimage) => {
expect($oldimage).to.eq($newimage);
});
});
});

it("5. Inserting another record - binarytype", () => {
it("4. Inserting another record - binarytype", () => {
imageNameToUpload = "Datatypes/Maine.jpeg";

agHelper.ClickButton("Run InsertQuery");
Expand All @@ -149,21 +117,21 @@ describe("Binary Datatype tests", { tags: ["@tag.Datasource"] }, function () {
agHelper.AssertElementVisibility(locators._buttonByText("Run InsertQuery"));
agHelper.AssertElementAbsence(locators._btnSpinner, 20000); //for the update row to appear at last
table.WaitUntilTableLoad();
agHelper.Sleep(2000); //some more time for all rows with images to be populated
table.ReadTableRowColumnData(2, 0).then(($cellData) => {
expect($cellData).to.eq("3"); //asserting serial column is inserting fine in sequence
const rowIndex = 1;
table.ReadTableRowColumnData(rowIndex, 0).then(($cellData) => {
expect($cellData).to.eq("2"); //asserting serial column is inserting fine in sequence
});
table.ReadTableRowColumnData(2, 1, "v1", 200).then(($cellData) => {
table.ReadTableRowColumnData(rowIndex, 1, "v1", 200).then(($cellData) => {
expect($cellData).to.eq("Maine.jpeg");
});
table.AssertTableRowImageColumnIsLoaded(2, 2).then(($oldimage) => {
table.AssertTableRowImageColumnIsLoaded(2, 3).then(($newimage) => {
table.AssertTableRowImageColumnIsLoaded(rowIndex, 2).then(($oldimage) => {
table.AssertTableRowImageColumnIsLoaded(rowIndex, 3).then(($newimage) => {
expect($oldimage).to.eq($newimage);
});
});
});

it("6. Updating record - binarytype", () => {
it("5. Updating record - binarytype", () => {
imageNameToUpload = "Datatypes/NewJersey.jpeg";

table.SelectTableRow(1);
Expand All @@ -178,45 +146,38 @@ describe("Binary Datatype tests", { tags: ["@tag.Datasource"] }, function () {
agHelper.AssertElementVisibility(locators._buttonByText("Run UpdateQuery"));
agHelper.AssertElementAbsence(locators._btnSpinner, 20000); //for the update row to appear at last
table.WaitUntilTableLoad();
agHelper.Sleep(14000); //some more time for rows to rearrange!
table.ReadTableRowColumnData(2, 0, "v1", 2000).then(($cellData) => {
const rowIndex = 1;
table.ReadTableRowColumnData(rowIndex, 0, "v1", 2000).then(($cellData) => {
expect($cellData).to.eq("2"); //asserting serial column is inserting fine in sequence
});
table.ReadTableRowColumnData(2, 1, "v1", 200).then(($cellData) => {
table.ReadTableRowColumnData(rowIndex, 1, "v1", 200).then(($cellData) => {
expect($cellData).to.eq("NewJersey.jpeg");
});
table.AssertTableRowImageColumnIsLoaded(2, 2).then(($oldimage) => {
table.AssertTableRowImageColumnIsLoaded(2, 3).then(($newimage) => {
table.AssertTableRowImageColumnIsLoaded(rowIndex, 2).then(($oldimage) => {
table.AssertTableRowImageColumnIsLoaded(rowIndex, 3).then(($newimage) => {
expect($oldimage).to.not.eq($newimage);
});
});
});

it("7. Deleting records - binarytype", () => {
//entityExplorer.SelectEntityByName("Page1");//commenting 2 lines since case 6th is skipped!
//deployMode.DeployApp();
it("6. Deleting records - binarytype", () => {
table.WaitUntilTableLoad();
table.SelectTableRow(1);
agHelper.ClickButton("DeleteQuery", 1);
assertHelper.AssertNetworkStatus("@postExecute", 200);
assertHelper.AssertNetworkStatus("@postExecute", 200);
agHelper.AssertElementAbsence(locators._btnSpinner, 20000); //Allowing time for delete to be success
agHelper.Sleep(6000); //Allwowing time for delete to be success
table.ReadTableRowColumnData(1, 0).then(($cellData) => {
expect($cellData).not.to.eq("3"); //asserting 2nd record is deleted
});
table.ReadTableRowColumnData(1, 0, "v1", 200).then(($cellData) => {
expect($cellData).to.eq("2");
agHelper.WaitUntilEleDisappear(locators._btnSpinner); //Allowing time for delete to be success
table.ReadTableRowColumnData(0, 0).then(($cellData) => {
expect($cellData).to.eq("1");
});

//Deleting all records from .table
agHelper.GetNClick(locators._deleteIcon);
agHelper.AssertElementVisibility(locators._buttonByText("Run InsertQuery"));
agHelper.Sleep(2000);
table.WaitForTableEmpty();
});

it("8. Inserting another record (to check serial column) - binarytype", () => {
it("7. Inserting another record (to check serial column) - binarytype", () => {
imageNameToUpload = "Datatypes/Massachusetts.jpeg";

agHelper.ClickButton("Run InsertQuery");
Expand All @@ -230,9 +191,8 @@ describe("Binary Datatype tests", { tags: ["@tag.Datasource"] }, function () {
agHelper.AssertElementAbsence(locators._toastMsg); //Assert that Insert did not fail
agHelper.AssertElementVisibility(locators._buttonByText("Run InsertQuery"));
table.WaitUntilTableLoad();
agHelper.Sleep(2000); //for all rows with images to be populated
table.ReadTableRowColumnData(0, 0, "v1", 2000).then(($cellData) => {
expect($cellData).to.eq("4"); //asserting serial column is inserting fine in sequence
expect($cellData).to.eq("3"); //asserting serial column is inserting fine in sequence
});
table.ReadTableRowColumnData(0, 1, "v1", 200).then(($cellData) => {
expect($cellData).to.eq("Massachusetts.jpeg");
Expand All @@ -244,7 +204,7 @@ describe("Binary Datatype tests", { tags: ["@tag.Datasource"] }, function () {
});
});

it("9. Validating Binary (bytea) - escape, hex, base64 functions", () => {
it("8. Validating Binary (bytea) - escape, hex, base64 functions", () => {
deployMode.NavigateBacktoEditor();
table.WaitUntilTableLoad();
PageLeftPane.switchSegment(PagePaneSegment.Queries);
Expand Down Expand Up @@ -291,7 +251,7 @@ describe("Binary Datatype tests", { tags: ["@tag.Datasource"] }, function () {
});
});

it("10. Validating Binary (bytea) - escape, hex, base64 functions, conts", () => {
it("9. Validating Binary (bytea) - escape, hex, base64 functions, conts", () => {
//Validating backslash
query = `select encode('\\\\'::bytea, 'escape') as "backslash Escape1", encode('\\134'::bytea, 'escape') as "backslash Escape2", encode('\\\\'::bytea, 'hex') as "backslash Hex1", encode('\\134'::bytea, 'hex') as "backslash Hex2", encode('\\\\'::bytea, 'base64') as "backslash Base64";`;
dataSources.EnterQuery(query);
Expand Down Expand Up @@ -375,8 +335,6 @@ describe("Binary Datatype tests", { tags: ["@tag.Datasource"] }, function () {
});
AppSidebar.navigate(AppSidebarButton.Editor);
});

//Since query delete & Postgress DS delete is covered in other specs, commenting below code
// after(
// "Validate Drop of the Newly Created - binarytype - Table & Verify Deletion of all created queries",
// () => {
Expand Down
4 changes: 4 additions & 0 deletions app/client/cypress/support/Objects/DataManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export class DataManager {
"http://host.docker.internal:5001/v1/mock-api-object?records=10",
echoApiUrl: "http://host.docker.internal:5001/v1/mock-api/echo",
randomCatfactUrl: "http://host.docker.internal:5001/v1/catfact/random",
multipartAPI:
"http://host.docker.internal:5001/v1/mock-api/echo-multipart",
randomTrumpApi:
"http://host.docker.internal:5001/v1/whatdoestrumpthink/random",
mockHttpCodeUrl: "http://host.docker.internal:5001/v1/mock-http-codes/",
Expand Down Expand Up @@ -179,6 +181,8 @@ export class DataManager {
mockApiUrl: "http://host.docker.internal:5001/v1/mock-api?records=10",
echoApiUrl: "http://host.docker.internal:5001/v1/mock-api/echo",
randomCatfactUrl: "http://host.docker.internal:5001/v1/catfact/random",
multipartAPI:
"http://host.docker.internal:5001/v1/mock-api/echo-multipart",
mockHttpCodeUrl: "http://host.docker.internal:5001/v1/mock-http-codes/",
AirtableBaseForME: "appubHrVbovcudwN6",
AirtableTableForME: "tblsFCQSskVFf7xNd",
Expand Down
2 changes: 1 addition & 1 deletion app/client/cypress/support/Pages/ApiPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export class ApiPage {
| "RAW",
) {
this.agHelper.GetNClick(this._bodyTypeSelect);
cy.xpath(this._bodyTypeToSelect(subTabName)).should("be.visible").click();
this.agHelper.GetNClick(this._bodyTypeToSelect(subTabName));
}

AssertRightPaneSelectedTab(tabName: RightPaneTabs) {
Expand Down

0 comments on commit 5c293ea

Please sign in to comment.