Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -41,6 +41,10 @@ describe(
assertHelper.AssertNetworkStatus("@getDatasourceStructure"); //Making sure table dropdown is populated
agHelper.GetNClick(dataSources._selectTableDropdown, 0, true);
agHelper.GetNClickByContains(dataSources._dropdownOption, "pokemon");

agHelper.GetNClick(dataSources._selectTableDropdown, 1, true);
agHelper.GetNClickByContains(dataSources._dropdownOption, "img");

GenerateCRUDNValidateDeployPage(
"http://www.serebii.net/pokemongo/pokemon/150.png",
"150",
Expand Down Expand Up @@ -103,30 +107,68 @@ describe(
assertHelper.AssertNetworkStatus("@postExecute", 200);
agHelper.ClickButton("Got it");
assertHelper.AssertNetworkStatus("@updateLayout", 200);

deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.TABLE));

//Validating loaded table
agHelper.AssertElementExist(dataSources._selectedRow);
table.ReadTableRowColumnData(0, 0, "v2", 2000).then(($cellData) => {
expect($cellData).to.eq(col1Text);
});
table.ReadTableRowColumnData(0, 3, "v2", 200).then(($cellData) => {
expect($cellData).to.eq(col2Text);
});
table.ReadTableRowColumnData(0, 6, "v2", 200).then(($cellData) => {
expect($cellData).to.eq(col3Text);
});

//Validating loaded JSON form
cy.xpath(locators._buttonByText("Update")).then((selector) => {
cy.wrap(selector)
.invoke("attr", "class")
.then((classes) => {
//cy.log("classes are:" + classes);
expect(classes).not.contain("bp3-disabled");
findTheDataRow(col1Text).then((rowIndex: number) => {
cy.log(`This is the rowIndex of ${col1Text} : ${rowIndex}`);
table
.ReadTableRowColumnData(rowIndex, 0, "v2", 2000)
.then(($cellData) => {
expect($cellData).to.eq(col1Text);
});
table
.ReadTableRowColumnData(rowIndex, 3, "v2", 200)
.then(($cellData) => {
expect($cellData).to.eq(col2Text);
});
table
.ReadTableRowColumnData(rowIndex, 6, "v2", 200)
.then(($cellData) => {
expect($cellData).to.eq(col3Text);
});

//Validating loaded JSON form
cy.xpath(locators._buttonByText("Update")).then((selector) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@sagar-qa007 @AmanAgarwal041 Is using an xpath a best practice in Cypress? Or do we have no other alternatives that could have been used here?

I'm asking this because the package cypress-xpath has been deprecated a year ago. Additionally, Cypress recommends using more specific ids to select elements rather than xpath.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mohanarpit Yeah we should ideally remove that and go for the css selectors. It was already there, but we can definitely update this.
cc @sagar-qa007

@sagar-qa007 sagar-qa007 Sep 10, 2024

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.

Yes agree and noted. @mohanarpit

@AmanAgarwal041 It has present multiple places, can we update on that specs too? It will be good optimisation.

cy.xpath(locators._buttonByText("Update")).then((selector)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@AmanAgarwal041 Is there a CSS selector already available for this validation today? If yes, can we change it right now? If not, then we'll leave it for the time being.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mohanarpit I am not really sure we have something like that, because we have a repetitive block in around 8 files. @sagar-qa007 Can we add a task to update this block at every place ?
List of files :

  1. app/client/cypress/e2e/Regression/ServerSide/GenerateCRUD/Mongo_Spec.ts
  2. app/client/cypress/e2e/Regression/ServerSide/GenerateCRUD/MongoURI_Spec.ts
  3. app/client/cypress/e2e/Regression/ServerSide/GenerateCRUD/MySQL1_Spec.ts
  4. app/client/cypress/e2e/Regression/ServerSide/GenerateCRUD/MySQL2_Spec.ts
  5. app/client/cypress/e2e/Regression/ServerSide/GenerateCRUD/Postgres1_Spec.ts
  6. app/client/cypress/e2e/Regression/ServerSide/GenerateCRUD/Postgres2_Spec.ts
  7. app/client/cypress/e2e/Regression/ServerSide/QueryPane/Mongo1_spec.ts
  8. app/client/cypress/e2e/Sanity/Datasources/MsSQL_Basic_Spec.ts

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.

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.

#36230

created task.

cy.wrap(selector)
.invoke("attr", "class")
.then((classes) => {
//cy.log("classes are:" + classes);
expect(classes).not.contain("bp3-disabled");
});
});
dataSources.AssertJSONFormHeader(0, idIndex, "Id", "", true);
});
dataSources.AssertJSONFormHeader(0, idIndex, "Id", "", true);
}

function findTheDataRow(col1Text: string) {
if (col1Text.length === 0) {
return cy.wrap(0);
}

return agHelper
.GetElement(table._tableColumnDataWithText(0, col1Text, "v2"))
.closest(".tr")
.then(($p1) => {
return cy
.wrap($p1)
.parent()
.children()
.then(($children) => {
let index = 0;
$children.each((i, el) => {
// Iterate through the children
if (Cypress.$(el).is($p1)) {
// Check if the current child is p1
index = i; // Assign the index when found
}
});
return index;
});
});
}
},
);
9 changes: 9 additions & 0 deletions app/client/cypress/support/Pages/Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ export class Table {
_tableRow = (rowNum: number, colNum: number, version: "v1" | "v2") =>
this._tableWidgetVersion(version) +
` .tbody .td[data-rowindex=${rowNum}][data-colindex=${colNum}]`;
_tableColumnDataWithText = (
colNum: number,
columnText: string,
version: "v1" | "v2",
) =>
this._tableWidgetVersion(version) +
` .tbody .td[data-colindex=${colNum}]` +
this._tableRowColumnDataVersion(version) +
` div:contains("${columnText}")`;
_editCellIconDiv = ".t--editable-cell-icon";
_editCellEditor = ".t--inlined-cell-editor";
_editCellEditorInput = this._editCellEditor + " input";
Expand Down