-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: Abstraction of Bottom View in Cypress #37410
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import EditorNavigation, { | |
| EntityType, | ||
| } from "../../../../support/Pages/EditorNavigation"; | ||
| import PageList from "../../../../support/Pages/PageList"; | ||
| import BottomPane from "../../../../support/Pages/IDE/BottomPane"; | ||
|
|
||
| let dsName: any; | ||
|
|
||
|
|
@@ -429,8 +430,12 @@ describe( | |
| parseInt(JSON.stringify(resObj.response.body.data.body.n)), | ||
| ).to.eq(3); | ||
| }); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("JSON")); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("RAW")); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("JSON"), | ||
| ); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("RAW"), | ||
| ); | ||
|
Comment on lines
+433
to
+438
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider extracting repeated assertions into a helper function The same response type selector assertions are repeated across multiple test cases. This violates the DRY principle and makes maintenance harder. Consider creating a helper function in the test utilities: // In support/Objects/ObjectsCore.ts
export const assertResponseTypeSelectors = () => {
agHelper.AssertElementVisibility(
BottomPane.response.getResponseTypeSelector("JSON")
);
agHelper.AssertElementVisibility(
BottomPane.response.getResponseTypeSelector("RAW")
);
};
// In the test file
assertResponseTypeSelectors();Also applies to: 470-475, 517-522, 559-564, 590-595, 623-628, 660-665, 685-690, 722-727 |
||
| agHelper.ActionContextMenuWithInPane({ | ||
| action: "Delete", | ||
| entityType: entityItems.Query, | ||
|
|
@@ -462,8 +467,12 @@ describe( | |
| parseInt(JSON.stringify(resObj.response.body.data.body.nModified)), | ||
| ).to.eq(0); | ||
| }); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("JSON")); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("RAW")); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("JSON"), | ||
| ); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("RAW"), | ||
| ); | ||
| agHelper.ActionContextMenuWithInPane({ | ||
| action: "Delete", | ||
| entityType: entityItems.Query, | ||
|
|
@@ -505,8 +514,12 @@ describe( | |
| parseInt(JSON.stringify(resObj.response.body.data.body.nModified)), | ||
| ).to.eq(2); | ||
| }); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("JSON")); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("RAW")); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("JSON"), | ||
| ); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("RAW"), | ||
| ); | ||
| agHelper.ActionContextMenuWithInPane({ | ||
| action: "Delete", | ||
| entityType: entityItems.Query, | ||
|
|
@@ -543,8 +556,12 @@ describe( | |
| parseInt(JSON.stringify(resObj.response.body.data.body.nModified)), | ||
| ).to.eq(1); | ||
| }); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("JSON")); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("RAW")); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("JSON"), | ||
| ); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("RAW"), | ||
| ); | ||
| agHelper.ActionContextMenuWithInPane({ | ||
| action: "Delete", | ||
| entityType: entityItems.Query, | ||
|
|
@@ -570,8 +587,12 @@ describe( | |
| parseInt(JSON.stringify(resObj.response.body.data.body.n)), | ||
| ).to.eq(0); | ||
| }); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("JSON")); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("RAW")); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("JSON"), | ||
| ); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("RAW"), | ||
| ); | ||
| agHelper.ActionContextMenuWithInPane({ | ||
| action: "Delete", | ||
| entityType: entityItems.Query, | ||
|
|
@@ -599,8 +620,12 @@ describe( | |
| parseInt(JSON.stringify(resObj.response.body.data.body.n)), | ||
| ).to.eq(1); | ||
| }); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("JSON")); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("RAW")); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("JSON"), | ||
| ); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("RAW"), | ||
| ); | ||
| agHelper.ActionContextMenuWithInPane({ | ||
| action: "Delete", | ||
| entityType: entityItems.Query, | ||
|
|
@@ -632,8 +657,12 @@ describe( | |
| 2, | ||
| ); | ||
| }); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("JSON")); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("RAW")); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("JSON"), | ||
| ); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("RAW"), | ||
| ); | ||
| agHelper.ActionContextMenuWithInPane({ | ||
| action: "Delete", | ||
| entityType: entityItems.Query, | ||
|
|
@@ -653,8 +682,12 @@ describe( | |
| 7, | ||
| ); | ||
| }); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("JSON")); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("RAW")); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("JSON"), | ||
| ); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("RAW"), | ||
| ); | ||
| agHelper.ActionContextMenuWithInPane({ | ||
| action: "Delete", | ||
| entityType: entityItems.Query, | ||
|
|
@@ -686,8 +719,12 @@ describe( | |
| JSON.parse(JSON.stringify(resObj.response.body.data.body.values[1])), | ||
| ).to.eql("51e062189c6ae665454e301d"); | ||
| }); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("JSON")); | ||
| agHelper.AssertElementVisibility(dataSources._queryResponse("RAW")); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("JSON"), | ||
| ); | ||
| agHelper.AssertElementVisibility( | ||
| BottomPane.response.getResponseTypeSelector("RAW"), | ||
| ); | ||
| agHelper.ActionContextMenuWithInPane({ | ||
| action: "Delete", | ||
| entityType: entityItems.Query, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||||||
| class Response { | ||||||||||
| private ResponseTab = "//button[@data-testid='t--tab-RESPONSE_TAB']"; | ||||||||||
|
Comment on lines
+1
to
+2
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace XPath selector with data- attribute selector* The XPath selector usage violates our coding guidelines. Use data-* attributes for more maintainable selectors. class Response {
- private ResponseTab = "//button[@data-testid='t--tab-RESPONSE_TAB']";
+ private ResponseTab = "[data-testid='t--tab-RESPONSE_TAB']";📝 Committable suggestion
Suggested change
|
||||||||||
|
|
||||||||||
| public switchToResponseTab(): void { | ||||||||||
| cy.xpath(this.ResponseTab).click({ force: true }); | ||||||||||
| } | ||||||||||
|
Comment on lines
+4
to
+6
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid force clicks and XPath in Cypress commands Force clicks can make tests brittle and mask underlying issues. Consider adding proper wait conditions or element visibility checks. public switchToResponseTab(): void {
- cy.xpath(this.ResponseTab).click({ force: true });
+ cy.get(this.ResponseTab)
+ .should('be.visible')
+ .click();
}
|
||||||||||
|
|
||||||||||
| public getResponseTypeSelector(type: string): string { | ||||||||||
| return `//div[@data-testid='t--response-tab-segmented-control']//span[text()='${type}']`; | ||||||||||
| } | ||||||||||
|
Comment on lines
+8
to
+10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use data attributes for response type selection String interpolation in selectors is fragile. Consider using data attributes with specific values for each type. public getResponseTypeSelector(type: string): string {
- return `//div[@data-testid='t--response-tab-segmented-control']//span[text()='${type}']`;
+ return `[data-testid='t--response-type-${type.toLowerCase()}']`;
}
|
||||||||||
|
|
||||||||||
| public switchResponseType(type: string): void { | ||||||||||
| this.switchToResponseTab(); | ||||||||||
| cy.xpath(this.getResponseTypeSelector(type)).click({ force: true }); | ||||||||||
| } | ||||||||||
|
Comment on lines
+12
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve response type switching reliability Similar to the tab switching, avoid force clicks and use proper wait conditions. public switchResponseType(type: string): void {
this.switchToResponseTab();
- cy.xpath(this.getResponseTypeSelector(type)).click({ force: true });
+ cy.get(this.getResponseTypeSelector(type))
+ .should('be.visible')
+ .click();
}
|
||||||||||
|
|
||||||||||
| // TODO: Implement this method when response UI is ready | ||||||||||
| public validateRecordCount(count: number): void {} | ||||||||||
| } | ||||||||||
|
|
||||||||||
| export { Response }; | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { Response } from "./Response"; | ||
|
|
||
| class BottomPane { | ||
| public readonly response: Response; | ||
|
|
||
| constructor() { | ||
| this.response = new Response(); | ||
| } | ||
| } | ||
|
|
||
| export default new BottomPane(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
agHelper.Sleep(1000)Replace the sleep with proper Cypress wait commands or assertions to ensure the page has loaded.
Apply this change: