test: Cypress | Flaky fixes (#25691)

## Description
- This PR fixes below specs:
              -    BugTests/DatasourceSchema_spec.ts
              -  /Dropdown/Dropdown_onOptionChange_spec.js
              - Improved homePage.CreateNewWorkspace()

#### Type of change
- Script fix (non-breaking change which fixes an issue)

## Testing
>
#### How Has This Been Tested?
- [X] Cypress

## Checklist:
#### QA activity:
- [X] Added `Test Plan Approved` label after Cypress tests were reviewed
This commit is contained in:
Aishwarya-U-R 2023-07-25 17:57:16 +05:30 committed by GitHub
parent b17c4ab083
commit 722f84b26b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 42 additions and 35 deletions

View File

@ -10,10 +10,9 @@ import {
describe("Content Management System App", function () {
before(() => {
homePage.NavigateToHome();
agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
homePage.CreateNewWorkspace("EchoApiCMS" + uid);
homePage.CreateNewWorkspace("EchoApiCMS" + uid, true);
homePage.CreateAppInWorkspace("EchoApiCMS" + uid, "EchoApiCMSApp");
agHelper.AddDsl("CMSdsl");
});

View File

@ -12,10 +12,9 @@ describe("Shopping cart App", function () {
let datasourceName: string, repoName: any;
before(() => {
homePage.NavigateToHome();
agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
homePage.CreateNewWorkspace("MongoDBShop" + uid);
homePage.CreateNewWorkspace("MongoDBShop" + uid, true);
homePage.CreateAppInWorkspace("MongoDBShop" + uid, "MongoDBShopApp");
agHelper.AddDsl("mongoAppdsl");
});

View File

@ -1,19 +1,26 @@
import { featureFlagIntercept } from "../../../../support/Objects/FeatureFlags";
import { ObjectsRegistry } from "../../../../support/Objects/Registry";
const agHelper = ObjectsRegistry.AggregateHelper,
dataSources = ObjectsRegistry.DataSources,
ee = ObjectsRegistry.EntityExplorer;
import {
agHelper,
entityItems,
dataSources,
entityExplorer,
homePage,
} from "../../../../support/Objects/ObjectsCore";
let guid;
let dataSourceName: string;
describe("Datasource form related tests", function () {
before(() => {
homePage.CreateNewWorkspace("FetchSchemaOnce", true);
homePage.CreateAppInWorkspace("FetchSchemaOnce");
});
it("1. Bug - 17238 Verify datasource structure refresh on save - invalid datasource", () => {
agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
guid = uid;
dataSourceName = "Postgres " + guid;
ee.ExpandCollapseEntity("Datasources");
entityExplorer.ExpandCollapseEntity("Datasources");
dataSources.NavigateToDSCreateNew();
dataSources.CreatePlugIn("PostgreSQL");
agHelper.RenameWithInPane(dataSourceName, false);
@ -36,14 +43,16 @@ describe("Datasource form related tests", function () {
it("2. Verify if schema was fetched once #18448", () => {
agHelper.RefreshPage();
ee.ExpandCollapseEntity("Datasources");
ee.ExpandCollapseEntity(dataSourceName, false);
cy.intercept("GET", dataSources._getStructureReq).as("getDSStructure");
ee.ExpandCollapseEntity("Datasources");
ee.ExpandCollapseEntity(dataSourceName);
entityExplorer.ExpandCollapseEntity("Datasources");
entityExplorer.ExpandCollapseEntity(dataSourceName, false);
entityExplorer.ExpandCollapseEntity("Datasources");
entityExplorer.ExpandCollapseEntity(dataSourceName);
agHelper.Sleep(1500);
agHelper.VerifyCallCount(`@getDatasourceStructure`, 1);
dataSources.DeleteQuery("Query1");
agHelper.ActionContextMenuWithInPane({
action: "Delete",
entityType: entityItems.Query,
});
dataSources.DeleteDatasouceFromWinthinDS(dataSourceName);
});
@ -61,7 +70,7 @@ describe("Datasource form related tests", function () {
dataSources.CreateMockDB("Users");
dataSources.CreateQueryAfterDSSaved();
dataSources.VerifyTableSchemaOnQueryEditor("public.users");
ee.ExpandCollapseEntity("public.users");
entityExplorer.ExpandCollapseEntity("public.users");
dataSources.VerifyColumnSchemaOnQueryEditor("id");
dataSources.FilterAndVerifyDatasourceSchemaBySearch(
"gender",

View File

@ -9,10 +9,9 @@ let tempBranch3: any;
describe("Git Bugs", function () {
before(() => {
_.homePage.NavigateToHome();
_.agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
_.homePage.CreateNewWorkspace("GitBugs" + uid);
_.homePage.CreateNewWorkspace("GitBugs" + uid, true);
_.homePage.CreateAppInWorkspace("GitBugs" + uid);
});
});

View File

@ -11,8 +11,7 @@ let ee = ObjectsRegistry.EntityExplorer,
describe("Entity explorer API pane related testcases", function () {
it("1. Empty Message validation for Widgets/API/Queries", function () {
homePage.NavigateToHome();
homePage.CreateNewWorkspace("EmptyMsgCheck");
homePage.CreateNewWorkspace("EmptyMsgCheck", true);
homePage.CreateAppInWorkspace("EmptyMsgCheck");
ee.ExpandCollapseEntity("Widgets");
agHelper.AssertElementVisible(

View File

@ -32,11 +32,10 @@ describe("Fork application with multiple datasources", function () {
it("1. Bug Id: 24708 - fork and test the forked application", function () {
// Create a new workspace and fork application
const appname: string = localStorage.getItem("AppName") || "randomApp";
homePage.NavigateToHome();
agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
workspaceId = "forkApp" + uid;
homePage.CreateNewWorkspace(workspaceId);
homePage.CreateNewWorkspace(workspaceId, true);
agHelper.PressEscape();
cy.log("------------------" + workspaceId);
homePage.ForkApplication(appname, workspaceId);

View File

@ -8,13 +8,12 @@ let currentWorkspace: string, currentAppName: string, forkWorkspaceName: string;
describe("Fork application across workspaces", function () {
it("Bug 24702: Signed user should be able to fork a public forkable app & Check if the forked application has the same dsl as the original", function () {
homePage.NavigateToHome();
// Create new workspace to create App in
agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
currentWorkspace = "CurrentWorkspace " + uid;
currentAppName = "MongoQueryApp " + uid;
homePage.CreateNewWorkspace(currentWorkspace);
homePage.CreateNewWorkspace(currentWorkspace, true);
homePage.CreateAppInWorkspace(currentWorkspace, currentAppName);
// Create datasource and query
@ -23,12 +22,11 @@ describe("Fork application across workspaces", function () {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
homePage.NavigateToHome();
agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
forkWorkspaceName = "ForkApplication" + uid;
homePage.CreateNewWorkspace(forkWorkspaceName);
homePage.CreateNewWorkspace(forkWorkspaceName, true);
homePage.FilterApplication(currentAppName);
agHelper.Sleep(500);

View File

@ -19,11 +19,10 @@ describe("Import and validate older app (app created in older versions of Appsmi
keyId: any,
workspaceName: any;
before(() => {
homePage.NavigateToHome();
agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
workspaceName = "GitImport_" + uid;
homePage.CreateNewWorkspace(workspaceName);
homePage.CreateNewWorkspace(workspaceName, true);
});
//Import App From Gitea
gitSync.ImportAppFromGit(workspaceName, appRepoName, true);

View File

@ -19,7 +19,7 @@ describe("Dropdown Widget", function () {
entityExplorer.ExpandCollapseEntity("Container3", "Widgets");
entityExplorer.SelectEntityByName("Dropdown1", "Widgets");
propPane.UpdatePropertyFieldValue(
"Options",
"Source Data",
JSON.stringify(this.dataSet.input),
);
//creating the Modal and verify Modal name //to fix below

View File

@ -3,3 +3,5 @@
# To run only limited tests - give the spec names in below format:
cypress/e2e/Regression/ClientSide/Widgets/Dropdown/Dropdown_onOptionChange_spec.js
cypress/e2e/Regression/ClientSide/Widgets/Button/Button_onClickAction_spec.js
cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts

View File

@ -180,7 +180,6 @@ export class DataSources {
_gsScopeOptions = ".ads-v2-select__dropdown .rc-select-item-option";
private _queryTimeout =
"//input[@name='actionConfiguration.timeoutInMillisecond']";
_getStructureReq = "/api/v1/datasources/*/structure?ignoreCache=true";
_editDatasourceFromActiveTab = (dsName: string) =>
".t--datasource-name:contains('" + dsName + "')";
private _suggestedWidget = (widgetType: string) =>
@ -1265,7 +1264,6 @@ export class DataSources {
schema: string,
isUpdate = false,
) {
cy.intercept("GET", this._getStructureReq).as("getDSStructure");
if (isUpdate) {
this.UpdateDatasource();
} else {
@ -1275,7 +1273,7 @@ export class DataSources {
entityNameinLeftSidebar: dataSourceName,
action: "Refresh",
});
cy.wait("@getDSStructure").then(() => {
cy.wait("@getDatasourceStructure").then(() => {
cy.get(".bp3-collapse-body").contains(schema);
});
}

View File

@ -124,7 +124,11 @@ export class HomePage {
this.agHelper.GetNClick(this._homeTab);
}
public CreateNewWorkspace(workspaceNewName: string) {
public CreateNewWorkspace(
workspaceNewName: string,
toNavigateToHome = false,
) {
if (toNavigateToHome) this.NavigateToHome();
let oldName = "";
this.agHelper.GetNClick(this._newWorkSpaceLink);
this.assertHelper.AssertNetworkStatus("createWorkspace", 201);
@ -255,6 +259,7 @@ export class HomePage {
//Maps to CreateAppForWorkspace in command.js
public CreateAppInWorkspace(workspaceName: string, appname = "") {
cy.xpath(this._existingWorkspaceCreateNewApp(workspaceName))
.last()
.scrollIntoView()
.should("be.visible")
.click({ force: true });

View File

@ -864,7 +864,8 @@ Cypress.Commands.add(
(forSuccess, forFailure, actionType, actionValue, idx = 0) => {
propPane.SelectActionByTitleAndValue(actionType, actionValue);
agHelper.GetNClick(propPane._actionCallbacks);
agHelper.Sleep();
agHelper.GetNClick(propPane._actionCallbacks, 0, true);
// add a success callback
cy.get(propPane._actionAddCallback("success")).click().wait(500);