PromucFlow_constructor/app/client/cypress/support/Pages/Onboarding.ts
Sangeeth Sivan bc5a23e8cd
feat: ci changes & cypress tests with cypress tags (#22989)
## Description

This includes

> Building a new image for airgapped instances
> Running ci-tests on airgapped image
> Running cypress tests selectively ignoring non supported features for
airgap like Templates, Custom JS lib and also alternating test
behaviours for some tests like tests using mock db, since it doesn't
work on airgap we have to create a ds. So this selective testing was
done using cypress-tags
> Having a new client build for airgapped images which bundles all the
assets.
> And changes in the workflow files to account for all the above. 

With airgap, we can ignore certain tests and also need to account for
tests using mock datasources and such by creating new datasources
instead of mock datasources. Since those are blocked. So to perform a
selective testing we are using a plugin called `cypress-tags` and to
perform conditional testing when required we use the `AIRGAPPED` cypress
env. This PR introduces both and also modified the codebase to support
this new way of running cypress.

Since we can't trigger `/ok-to-test` on this because ci-test needs the
CYPRESS_EXCLUDE_TAGS and slash command doesn't dispatch from current
branch,

I manually triggered the `TBP` workflow to run ci-test on this branch. 
And the new `TBP airgap` workflow to run ci-test on airgapped docker
image on this branch.

Here is the link to the run 
https://github.com/appsmithorg/appsmith/actions/runs/4882041416

Fixes #22007 
Fixes #22814 


## Type of change

> Please delete options that are not relevant.

- New feature (non-breaking change which adds functionality)
- Chore (housekeeping or task changes that don't impact user perception)


## How Has This Been Tested?

- Manual
- 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
- [x] My code follows the style guidelines of this project
- [x] 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
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
2023-05-12 00:15:06 +05:30

93 lines
3.8 KiB
TypeScript

import { ObjectsRegistry } from "../Objects/Registry";
const OnboardingLocator = require("../../locators/FirstTimeUserOnboarding.json");
let datasourceName;
export class Onboarding {
private _aggregateHelper = ObjectsRegistry.AggregateHelper;
private _datasources = ObjectsRegistry.DataSources;
completeSignposting() {
cy.get(OnboardingLocator.introModalBuild).click();
cy.get(OnboardingLocator.statusbar).click();
cy.get(OnboardingLocator.checklistStatus).should("be.visible");
cy.get(OnboardingLocator.checklistStatus).should("contain", "0 of 5");
cy.get(OnboardingLocator.checklistBack).click();
cy.get(OnboardingLocator.statusbar).click();
cy.get(OnboardingLocator.checklistDatasourceBtn).should("not.be.disabled");
cy.get(OnboardingLocator.checklistDatasourceBtn).click();
cy.get(OnboardingLocator.datasourcePage).should("be.visible");
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);
cy.get(OnboardingLocator.statusbar).click();
cy.get(OnboardingLocator.checklistStatus).should("contain", "1 of 5");
cy.get(OnboardingLocator.checklistDatasourceBtn).should("not.exist");
cy.get(OnboardingLocator.checklistActionBtn).should("be.visible");
cy.get(OnboardingLocator.checklistActionBtn).click();
cy.get(OnboardingLocator.createQuery).should("be.visible");
cy.get(OnboardingLocator.createQuery).click();
cy.wait(1000);
cy.get(OnboardingLocator.statusbar).click();
cy.get(OnboardingLocator.checklistStatus).should("contain", "2 of 5");
cy.get(OnboardingLocator.checklistActionBtn).should("not.exist");
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 });
cy.get(OnboardingLocator.statusbar).click();
cy.get(OnboardingLocator.checklistStatus).should("contain", "3 of 5");
cy.get(OnboardingLocator.checklistWidgetBtn).should("not.exist");
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();
cy.get(OnboardingLocator.statusbar).click();
cy.get(OnboardingLocator.checklistStatus).should("contain", "4 of 5");
cy.get(OnboardingLocator.checklistConnectionBtn).should("not.exist");
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();
cy.get(OnboardingLocator.checklistStatus).should("contain", "5 of 5");
cy.get(OnboardingLocator.checklistDeployBtn).should("not.exist");
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.statusbarClose).length) {
this._aggregateHelper.GetNClick(OnboardingLocator.statusbarClose);
}
});
}
}