PromucFlow_constructor/app/client/cypress/support/Pages/Onboarding.ts
Hetu Nandu 5ab58504a8
feat: Create Query asks for Page (#29253)
## Description

Shows a list of pages to select when creating a query. It will only show
when there are multiple pages in an app. If not, clicking the button
directly creates the query in the only page.


#### PR fixes following issue(s)
Fixes #27961

#### Media


![Page](https://github-production-user-asset-6210df.s3.amazonaws.com/20532920/285431639-91758301-7b9e-4ee8-a209-afc563b0d96b.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A/20231204/us-east-1/s3/aws4_request&X-Amz-Date=20231204T093109Z&X-Amz-Expires=300&X-Amz-Signature=bfff9c87288f9ca913c14bc3284e9974ad805130462a375adb271936777eec26&X-Amz-SignedHeaders=host&actor_id=12022471&key_id=0&repo_id=275993885)


#### Type of change

- New feature (non-breaking change which adds functionality)

## Testing
>
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [x] Manual
- [ ] JUnit
- [ ] Jest
- [x] Cypress
>
>
#### Test Plan
> Add Testsmith test cases links that relate to this PR
>
>
#### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
>
>
>
## Checklist:
#### Dev activity
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [ ] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Streamlined the process for creating queries from the datasource
editor across various test suites.
- Enhanced the control flow and logic for handling data sources and
queries in test scenarios.

- **Bug Fixes**
- Standardized the method of creating new queries after saving a
datasource to improve test reliability.
- Removed deprecated code and updated test cases to use the new
`CreateQueryForDS` function.

- **Tests**
- Updated test scripts to reflect changes in datasource interaction and
query creation.
- Added new assertions and modified existing ones to accommodate the
updated test flows.

- **Chores**
- Cleaned up import statements and removed unused code across multiple
test files.
- Commented out unused properties and methods to improve code
maintainability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2023-12-05 11:20:36 +05:30

141 lines
5.2 KiB
TypeScript

import { ObjectsRegistry } from "../Objects/Registry";
import localForage from "localforage";
const OnboardingLocator = require("../../locators/FirstTimeUserOnboarding.json");
let datasourceName;
export class Onboarding {
private _aggregateHelper = ObjectsRegistry.AggregateHelper;
private _datasources = ObjectsRegistry.DataSources;
private _debuggerHelper = ObjectsRegistry.DebuggerHelper;
public readonly locators = {
back_to_canvas: "#back-to-canvas",
deploy: "#application-publish-btn",
table_widget_card: "#widget-card-draggable-tablewidgetv2",
create_query: "#create-query",
explorer_widget_tab: `#explorer-tab-options [data-value*="widgets"]`,
add_datasources: "#add_datasources",
connect_data_overlay: "#table-overlay-connectdata",
};
completeSignposting() {
cy.get(OnboardingLocator.checklistStatus).should("be.visible");
cy.get(OnboardingLocator.checklistStatus).should("contain", "0 of 5");
this._aggregateHelper
.GetElement(OnboardingLocator.checklistConnectionBtn)
.realHover()
.should("have.css", "cursor", "not-allowed");
this._aggregateHelper.GetHoverNClick(
OnboardingLocator.checklistDatasourceBtn,
0,
true,
);
this._aggregateHelper.AssertElementVisibility(
this._datasources._newDatasourceContainer,
);
this.closeIntroModal();
this._aggregateHelper.AssertElementAbsence(
OnboardingLocator.introModal,
10000,
);
if (Cypress.env("AIRGAPPED")) {
this._datasources.CreateDataSource("Mongo");
cy.get("@dsName").then(($dsName) => {
datasourceName = $dsName;
});
} else {
cy.get(OnboardingLocator.datasourceMock).first().click();
}
cy.wait(1000);
this._aggregateHelper.GetNClick(this._debuggerHelper.locators._helpButton);
cy.get(OnboardingLocator.checklistStatus).should("contain", "1 of 5");
this._aggregateHelper
.GetElement(OnboardingLocator.checklistConnectionBtn)
.realHover()
.should("have.css", "cursor", "not-allowed");
cy.get(OnboardingLocator.checklistActionBtn).should("be.visible");
cy.get(OnboardingLocator.checklistActionBtn).click();
this._datasources.CreateQueryForDS("Movies");
cy.wait(1000);
this._aggregateHelper.GetNClick(this._debuggerHelper.locators._helpButton);
cy.get(OnboardingLocator.checklistStatus).should("contain", "2 of 5");
this._aggregateHelper
.GetElement(OnboardingLocator.checklistActionBtn)
.realHover()
.should("have.css", "cursor", "auto");
cy.get(OnboardingLocator.checklistWidgetBtn).should("be.visible");
cy.get(OnboardingLocator.checklistWidgetBtn).click();
cy.get(OnboardingLocator.widgetSidebar).should("be.visible");
(cy as any).dragAndDropToCanvas("textwidget", { x: 400, y: 400 });
this._aggregateHelper.GetNClick(this._debuggerHelper.locators._helpButton);
cy.get(OnboardingLocator.checklistStatus).should("contain", "3 of 5");
this._aggregateHelper
.GetElement(OnboardingLocator.checklistWidgetBtn)
.realHover()
.should("have.css", "cursor", "auto");
cy.get(OnboardingLocator.checklistConnectionBtn).should("be.visible");
cy.get(OnboardingLocator.checklistConnectionBtn).click();
cy.get(OnboardingLocator.snipingBanner).should("be.visible");
cy.get(OnboardingLocator.snipingTextWidget)
.first()
.trigger("mouseover", { force: true })
.wait(500);
cy.get(OnboardingLocator.widgetName).should("be.visible");
cy.get(OnboardingLocator.widgetName).click();
this._aggregateHelper.GetNClick(this._debuggerHelper.locators._helpButton);
cy.get(OnboardingLocator.checklistStatus).should("contain", "4 of 5");
this._aggregateHelper
.GetElement(OnboardingLocator.checklistConnectionBtn)
.realHover()
.should("have.css", "cursor", "auto");
let open: any;
cy.window().then((window: any) => {
open = window.open;
window.open = Cypress._.noop;
});
cy.get(OnboardingLocator.checklistDeployBtn).should("be.visible");
cy.get(OnboardingLocator.checklistDeployBtn).click();
this._aggregateHelper.AssertElementAbsence(OnboardingLocator.introModal);
this._aggregateHelper.Sleep();
this._aggregateHelper.GetNClick(this._debuggerHelper.locators._helpButton);
this._aggregateHelper.AssertElementExist(
OnboardingLocator.checklistCompletionBanner,
);
cy.window().then((window) => {
window.open = open;
});
}
closeIntroModal() {
cy.get("body").then(($body) => {
if ($body.find(OnboardingLocator.introModalCloseBtn).length) {
this._aggregateHelper.GetNClick(OnboardingLocator.introModalCloseBtn);
}
});
}
skipSignposting() {
cy.get("body").then(($body) => {
if ($body.find(OnboardingLocator.introModalCloseBtn).length) {
cy.wrap(null).then(async () => {
localForage.config({
name: "Appsmith",
});
// return a promise to cy.then() that
// is awaited until it resolves
return localForage.setItem("ENABLE_START_SIGNPOSTING", false);
});
//this._aggregateHelper.RefreshPage();//this is causing CI flakiness, so using below
cy.window().then((win) => {
win.location.reload();
});
}
});
}
}