From 9126927af7783b47780c387a12247b2459cc7391 Mon Sep 17 00:00:00 2001 From: Aishwarya-U-R <91450662+Aishwarya-U-R@users.noreply.github.com> Date: Mon, 4 Sep 2023 19:00:21 +0530 Subject: [PATCH] test: Cypress | CI Stabilize (#26934) ## Description - This PR unskips JSOnload1_spec.ts & try in CI - Improves the GraphQL methods to be more modular #### Type of change - Script update (non-breaking change which fixes an issue) ## Testing #### How Has This Been Tested? - [X] Cypress CI runs ## Checklist: #### QA activity: - [X] Added `Test Plan Approved` label after Cypress tests were reviewed --- .../ServerSide/OnLoadTests/JSOnLoad1_Spec.ts | 2 +- .../e2e/Sanity/Datasources/GraphQL_spec.ts | 2 + .../cypress/support/Pages/DataSources.ts | 40 ++++++++++++++----- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ServerSide/OnLoadTests/JSOnLoad1_Spec.ts b/app/client/cypress/e2e/Regression/ServerSide/OnLoadTests/JSOnLoad1_Spec.ts index 8979e3a414..3678175de5 100644 --- a/app/client/cypress/e2e/Regression/ServerSide/OnLoadTests/JSOnLoad1_Spec.ts +++ b/app/client/cypress/e2e/Regression/ServerSide/OnLoadTests/JSOnLoad1_Spec.ts @@ -112,7 +112,7 @@ describe("JSObjects OnLoad Actions tests", function () { }); //Skipping due to - "tableData":"ERROR: invalid input syntax for type smallint: "{}"" - it.skip("4. Tc 53 - Verify OnPage Load - Enabled & Disabling - Before Function calling for JSOBject", function () { + it("4. Tc 53 - Verify OnPage Load - Enabled & Disabling - Before Function calling for JSOBject", function () { entityExplorer.SelectEntityByName(jsName as string, "Queries/JS"); jsEditor.EnableDisableAsyncFuncSettings("getEmployee", true, false); //jsEditor.RunJSObj(); //Even running JS functin before delpoying does not help diff --git a/app/client/cypress/e2e/Sanity/Datasources/GraphQL_spec.ts b/app/client/cypress/e2e/Sanity/Datasources/GraphQL_spec.ts index 7bafec3f70..c4340129ce 100644 --- a/app/client/cypress/e2e/Sanity/Datasources/GraphQL_spec.ts +++ b/app/client/cypress/e2e/Sanity/Datasources/GraphQL_spec.ts @@ -230,6 +230,8 @@ describe("GraphQL Datasource Implementation", function () { }); //Create Auth GraphQL to verify Delete operation + dataSources.NavigateToDSCreateNew(); + dataSources.CreatePlugIn("Authenticated GraphQL API"); dataSources.CreateNFillAuthenticatedGraphQLDSForm( datasourceName, "Authorization", diff --git a/app/client/cypress/support/Pages/DataSources.ts b/app/client/cypress/support/Pages/DataSources.ts index dcbc8a86c4..2730b50423 100644 --- a/app/client/cypress/support/Pages/DataSources.ts +++ b/app/client/cypress/support/Pages/DataSources.ts @@ -7,6 +7,7 @@ export const DataSourceKVP = { Mongo: "MongoDB", MySql: "MySQL", UnAuthenticatedGraphQL: "GraphQL API", + AuthenticatedGraph: "Authenticated GraphQL API", MsSql: "Microsoft SQL Server", Airtable: "Airtable", ArangoDB: "ArangoDB", @@ -269,6 +270,9 @@ export class DataSources { _s3MaxFileSizeAlert = "//p[@role='alert']"; _entityExplorerID = (dsName: string) => "[data-testid='t--entity-item-" + dsName + "']"; + _stagingTab = "[data-testid='t--ds-data-filter-Staging']"; + _graphQlDsFromRightPane = (dsName: string) => + "//div/span[text() ='" + dsName + "']"; public AssertDSEditViewMode(mode: "Edit" | "View") { if (mode == "Edit") this.agHelper.AssertElementAbsence(this._editButton); @@ -683,31 +687,41 @@ export class DataSources { public FillUnAuthenticatedGraphQLDSForm( environment = this.dataManager.defaultEnviorment, + enterOrSelectUrl: "enter" | "select" = "enter", + dsNameToSelect = "", ) { this.agHelper.GetNClick(this._createBlankGraphQL); cy.get("@guid").then((uid) => { this.agHelper.RenameWithInPane("GraphQL_API" + "_" + uid, true); - this.apiPage.EnterURL( - this.dataManager.dsValues[environment].GraphqlApiUrl_TED, - ); + if (enterOrSelectUrl == "enter") + this.apiPage.EnterURL( + this.dataManager.dsValues[environment].GraphqlApiUrl_TED, + ); + else if (enterOrSelectUrl == "select") + this.agHelper.GetNClick(this._graphQlDsFromRightPane(dsNameToSelect)); + this.assertHelper.AssertNetworkStatus("@createNewApi", 201); cy.wrap("GraphQL_API" + "_" + uid).as("dsName"); }); } + public FillAuthenticatedGrapgQLURL( + environment = this.dataManager.defaultEnviorment, + ) { + this.agHelper.TypeText( + this.locator._inputFieldByName("URL") + "//" + this.locator._inputField, + this.dataManager.dsValues[environment].GraphqlApiUrl_TED, + ); + } + public CreateNFillAuthenticatedGraphQLDSForm( dataSourceName: string, hKey: string, hValue: string, environment = this.dataManager.defaultEnviorment, ) { - this.NavigateToDSCreateNew(); - this.CreatePlugIn("Authenticated GraphQL API"); - this.agHelper.TypeText( - this.locator._inputFieldByName("URL") + "//" + this.locator._inputField, - this.dataManager.dsValues[environment].GraphqlApiUrl_TED, - ); + this.FillAuthenticatedGrapgQLURL(environment); this.agHelper.UpdateInputValue(this._graphQLHeaderKey, hKey); this.agHelper.UpdateInputValue(this._graphQLHeaderValue, hValue); @@ -741,7 +755,7 @@ export class DataSources { ); } - public fillTwilioDSForm(environment = this.dataManager.defaultEnviorment) { + public FillTwilioDSForm(environment = this.dataManager.defaultEnviorment) { this.ValidateNSelectDropdown("Authentication type", "", "Basic auth"); this.agHelper.UpdateInputValue( this._username, @@ -774,6 +788,7 @@ export class DataSources { this.assertHelper.AssertNetworkStatus("@saveDatasource", 201); if (!isSavingEnvInOldDS) this.agHelper.AssertContains("datasource created"); + else this.agHelper.AssertContains("datasource updated successfully"); } else { this.assertHelper.AssertNetworkStatus("@updateDatasource", 200); } @@ -1215,6 +1230,7 @@ export class DataSources { | "Mongo" | "MySql" | "UnAuthenticatedGraphQL" + | "AuthenticatedGraph" | "MsSql" | "Airtable" | "ArangoDB" @@ -1272,7 +1288,9 @@ export class DataSources { else if (DataSourceKVP[dsType] == "Redis") this.FillRedisDSForm(environment); else if (DataSourceKVP[dsType] == "S3") this.FillS3DSForm(); - else if (DataSourceKVP[dsType] == "Twilio") this.fillTwilioDSForm(); + else if (DataSourceKVP[dsType] == "Twilio") this.FillTwilioDSForm(); + else if (DataSourceKVP[dsType] == "Authenticated GraphQL API") + this.FillAuthenticatedGrapgQLURL(); if (testNSave) { this.TestSaveDatasource();