* Flaky fixes * S3 CRUD intercept fix * S3 CRUD script change revert * S3 revert! * .its(store) not present fix * TS failure fixes * ChartDataopoint js removed * JSObject ts flaky fix * Bugs 9789, 10150 scripted * Bug 10284 & 9782 scripted * Updated dsl file names * Table_Widget case #7 flaky fix * Bug 10150 scripting improved * DocumentViewer spec flaky fix * Input widget locator corrected * MemberRoles cases script started in TS * UpdateUserRoleInOrg() fix * Skip JSObject_To_ListWidgetSpec.ts until #10284 * Add validation * JSObject_To_ListWidgetSpec.ts timeout increase * Skipping tests until bug 10284 is fixed * Increased wait time * UpdateUserRoleInOrg() updated * MemberRoles_Spec.ts fixed * JSObjToInput - updated * Postgres flaky fix * Member Roles aka CreateOrg test flaky fix * JSObToListWidget_Spec.ts - commenting until bugfix * COmmenting JSobjToInput spec * Commonlocators added back * Entity explorer name fix * Locators fix * Locator corrected * Cypress.json removed files from ignoring list * S3 & Postgress failures fix * Postgress failure locator fix * S3 upload script skipping until bug fix * Params Bug 10784 script started * Fixing Promises Spec * Increased wait time! * MigrationSpec - Image column,Cardformat,Pagestyles * S3, Postgres, Promise - failures fix * Canvas renamed * Bug 11415 - Added Validations * InputWidgets_navigateTo - flaky fix * MigrationSpec - import change * Locators files - Json to Js conversion * DS plugnis name change * Locators - Json to JS conversion * Locators - Json to JS updations * Select_Widget_Value flaky fix * Adding timeout for execute calls to finish * Migration spec - diff syntax+List.js flaky fix * List & MIgration flaky fix
124 lines
4.7 KiB
TypeScript
124 lines
4.7 KiB
TypeScript
import { AggregateHelper } from "./AggregateHelper";
|
|
import explorer from "../../locators/explorerlocators.json";
|
|
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) {
|
|
cy.get(explorer.createNew).click({ force: true });
|
|
cy.get(explorer.blankAPI).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()
|
|
agHelper.Sleep(2000);// Added because api name edit takes some time to reflect in api sidebar after the call passes.
|
|
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('Headers')).eq(0).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('Headers')).eq(0).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")
|
|
});
|
|
}
|
|
}
|