* Bugs #9069, #9201, #6975, #9922 - Scripted * Mongo DS update from Cloud to Localhost * Updating command.js * Ignoring Mongo until Localhost is fixed * S3 fixes * S3 fix * Mongo Cloud to Localhost transition * Bug #6375 scripted * Failure fix * S3 fix + testSaveDs method flow update * Refresh datasource structure script fix * Entity explorer datasource structure script fix * testSaveDs method flow update fixes * testSaveDs method flow update fixes - set 2 * S3, Mongo Skipping cases fix * Custom Chart failure fix * Button-Call-Query Validation case script fix * Confirm run action failure fix * Confirm run action script fix * Dropdown-Call-Query Validation script fix * S3 - Delete icon issue fix * S3 - Delete icon locator updated * actionContextMenuByEntityName method call update * Table widget add new menu button column - rgb fix * Commenting BG color verify - to override flakiness * Mongo skipping script fix * Commenting Cypress.runner.stop() * Removing .skip * Bind_tableApi_spec.js failure fix * Slash command failure fix * Bugs # 8595 & 10049 - Implemented * Updating AGHelper methods to explicit public * Reverting tsconfig.json * tsconfig.json reverted * Adding local tsconfig.json for Cypress tests * fixture read updating for ts tests * Updating .yml files to pick up ts files execution * Including ts files for cypress run * Running only ts test files * Inclusion of TS files for cypress run * Revert cypress.json to run all tests * Added validation for Bug #10055 & commented * Flaky fix * JSObject_To_ListWidgetSpec - Implemented in TS * Entity_Explorer_JSEditor_spec implemented in TS * Uncommenting script for Bug 10049, 10055
125 lines
4.6 KiB
TypeScript
125 lines
4.6 KiB
TypeScript
import { AggregateHelper } from "./AggregateHelper";
|
|
const agHelper = new AggregateHelper();
|
|
|
|
export class ApiPage {
|
|
|
|
private _createapi = ".t--createBlankApiCard"
|
|
private _resourceUrl = ".t--dataSourceField"
|
|
private _headerKey = (index: number) => ".t--actionConfiguration\\.headers\\[0\\]\\.key\\." + index + ""
|
|
private _headerValue = (index: number) => ".t--actionConfiguration\\.headers\\[0\\]\\.value\\." + index + ""
|
|
private _paramKey = (index: number) => ".t--actionConfiguration\\.queryParameters\\[0\\]\\.key\\." + index + ""
|
|
private _paramValue = (index: number) => ".t--actionConfiguration\\.queryParameters\\[0\\]\\.value\\." + index + ""
|
|
private _paramsTab = "//li//span[text()='Params']"
|
|
private _apiRunBtn = ".t--apiFormRunBtn"
|
|
private _queryTimeout = "//input[@name='actionConfiguration.timeoutInMillisecond']"
|
|
private _apiTab = (tabValue: string) => "span:contains('" + tabValue + "')"
|
|
_responseBody = ".CodeMirror-code span.cm-string.cm-property"
|
|
|
|
|
|
CreateAndFillApi(url: string, apiname: string = "", queryTimeout = 30000) {
|
|
agHelper.NavigateToCreateNewTabPage()
|
|
cy.get(this._createapi).click({ force: true });
|
|
cy.wait("@createNewApi").should(
|
|
"have.nested.property",
|
|
"response.body.responseMeta.status",
|
|
201,
|
|
);
|
|
// cy.get("@createNewApi").then((response: any) => {
|
|
// expect(response.response.body.responseMeta.success).to.eq(true);
|
|
// cy.get(agHelper._actionName)
|
|
// .click()
|
|
// .invoke("text")
|
|
// .then((text) => {
|
|
// const someText = text;
|
|
// expect(someText).to.equal(response.response.body.data.name);
|
|
// });
|
|
// }); // to check if Api1 = Api1 when Create Api invoked
|
|
if (apiname)
|
|
agHelper.RenameWithInPane(apiname)
|
|
cy.get(this._resourceUrl).should("be.visible");
|
|
this.EnterURL(url)
|
|
agHelper.WaitAutoSave()
|
|
// Added because api name edit takes some time to
|
|
// reflect in api sidebar after the call passes.
|
|
agHelper.Sleep(2000);
|
|
cy.get(this._apiRunBtn).should("not.be.disabled");
|
|
this.SetAPITimeout(queryTimeout)
|
|
}
|
|
|
|
EnterURL(url: string) {
|
|
cy.get(this._resourceUrl)
|
|
.first()
|
|
.click({ force: true })
|
|
.type(url, { parseSpecialCharSequences: false });
|
|
agHelper.WaitAutoSave()
|
|
}
|
|
|
|
EnterHeader(hKey: string, hValue: string) {
|
|
cy.get(this._apiTab('Header')).should('be.visible').click();
|
|
cy.get(this._headerKey(0))
|
|
.first()
|
|
.click({ force: true })
|
|
.type(hKey, { parseSpecialCharSequences: false });
|
|
cy.get(this._headerValue(0))
|
|
.first()
|
|
.click({ force: true })
|
|
.type(hValue, { parseSpecialCharSequences: false });
|
|
agHelper.WaitAutoSave()
|
|
}
|
|
|
|
EnterParams(pKey: string, pValue: string) {
|
|
cy.xpath(this._paramsTab)
|
|
.should("be.visible")
|
|
.click({ force: true });
|
|
cy.get(this._paramKey(0))
|
|
.first()
|
|
.click({ force: true })
|
|
.type(pKey, { parseSpecialCharSequences: false });
|
|
cy.get(this._paramValue(0))
|
|
.first()
|
|
.click({ force: true })
|
|
.type(pValue, { parseSpecialCharSequences: false });
|
|
agHelper.WaitAutoSave()
|
|
}
|
|
|
|
RunAPI() {
|
|
cy.get(this._apiRunBtn).click({ force: true });
|
|
cy.wait("@postExecute").should(
|
|
"have.nested.property",
|
|
"response.body.data.isExecutionSuccess",
|
|
true,
|
|
);
|
|
}
|
|
|
|
SetAPITimeout(timeout: number) {
|
|
cy.get(this._apiTab('Settings')).click();
|
|
cy.xpath(this._queryTimeout)
|
|
.clear()
|
|
.type(timeout.toString());
|
|
|
|
cy.get(this._apiTab('Header')).click();
|
|
}
|
|
|
|
ValidateQueryParams(param: { key: string; value: string; }) {
|
|
cy.xpath(this._paramsTab)
|
|
.should("be.visible")
|
|
.click({ force: true });
|
|
|
|
agHelper.ValidateCodeEditorContent(this._paramKey(0), param.key)
|
|
agHelper.ValidateCodeEditorContent(this._paramValue(0), param.value)
|
|
}
|
|
|
|
ReadApiResponsebyKey(key: string) {
|
|
let apiResp: string = "";
|
|
cy.get(this._responseBody)
|
|
.contains(key)
|
|
.siblings("span")
|
|
.invoke("text")
|
|
.then((text) => {
|
|
apiResp = `${text.match(/"(.*)"/)![0].split('"').join("") } `;
|
|
cy.log("Key value in api response is :" + apiResp);
|
|
cy.wrap(apiResp).as("apiResp")
|
|
});
|
|
}
|
|
}
|