2019-12-12 07:50:53 +00:00
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
2021-11-17 10:10:57 +00:00
/// <reference types="Cypress" />
2023-05-11 18:45:06 +00:00
/// <reference types='cypress-tags' />
2021-11-18 10:22:04 +00:00
import "cypress-real-events/support" ;
2022-02-24 03:11:35 +00:00
import "cypress-wait-until" ;
2023-05-11 05:26:03 +00:00
import "cypress-network-idle" ;
2022-04-11 03:30:37 +00:00
import "cypress-xpath" ;
import * as MESSAGES from "../../../client/src/ce/constants/messages.ts" ;
import "./ApiCommands" ;
2019-12-12 07:50:53 +00:00
// Import commands.js using ES2015 syntax:
2020-03-27 09:02:11 +00:00
import "./commands" ;
2023-08-31 14:19:36 +00:00
import { initLocalstorage , addIndexedDBKey } from "./commands" ;
2022-04-11 03:30:37 +00:00
import "./dataSourceCommands" ;
import "./gitSync" ;
2022-04-03 16:43:20 +00:00
import { initLocalstorageRegistry } from "./Objects/Registry" ;
2023-05-18 10:08:38 +00:00
import RapidMode from "./RapidMode.ts" ;
2023-07-19 06:42:36 +00:00
import "cypress-mochawesome-reporter/register" ;
2023-10-05 09:12:30 +00:00
import installLogsCollector from "cypress-terminal-report/src/installLogsCollector" ;
2023-10-27 13:13:28 +00:00
import { CURRENT _REPO , REPO } from "../fixtures/REPO" ;
2023-05-18 10:08:38 +00:00
2022-06-15 15:37:41 +00:00
import "./WorkspaceCommands" ;
2022-04-11 03:30:37 +00:00
import "./queryCommands" ;
import "./widgetCommands" ;
2022-05-11 06:13:28 +00:00
import "./themeCommands" ;
2022-04-21 06:14:02 +00:00
import "./AdminSettingsCommands" ;
2023-04-28 10:02:40 +00:00
import "cypress-plugin-tab" ;
2023-10-06 10:03:27 +00:00
import {
FEATURE _WALKTHROUGH _INDEX _KEY ,
WALKTHROUGH _TEST _PAGE ,
} from "./Constants.js" ;
2022-04-11 03:30:37 +00:00
/// <reference types="cypress-xpath" />
2020-06-17 10:47:01 +00:00
2023-10-05 09:12:30 +00:00
installLogsCollector ( ) ;
2023-10-17 14:56:24 +00:00
Cypress . on ( "uncaught:exception" , ( error ) => {
//cy.log(error.message);
return false ; // returning false here prevents Cypress from failing the test
2020-06-17 10:47:01 +00:00
} ) ;
2022-04-11 03:30:37 +00:00
Cypress . on ( "fail" , ( error ) => {
2023-10-17 14:56:24 +00:00
cy . log ( error . message ) ;
2023-10-20 02:15:47 +00:00
throw error ; // throw error to have test fail
2020-07-24 04:31:39 +00:00
} ) ;
2021-11-17 15:28:23 +00:00
Cypress . env ( "MESSAGES" , MESSAGES ) ;
2023-06-15 13:21:11 +00:00
let dataSet ; // Declare a variable to hold the test data
2021-11-17 15:28:23 +00:00
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### 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
- [ ] 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
- [ ] 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:
- [ ] 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
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
before ( function ( ) {
2023-05-18 10:08:38 +00:00
if ( RapidMode . config . enabled ) {
2023-05-02 10:47:23 +00:00
cy . startServerAndRoutes ( ) ;
cy . getCookie ( "SESSION" ) . then ( ( cookie ) => {
if ( ! cookie ) {
cy . LoginFromAPI ( Cypress . env ( "USERNAME" ) , Cypress . env ( "PASSWORD" ) ) ;
}
} ) ;
2023-06-15 13:21:11 +00:00
//Cypress.Cookies.preserveOnce("SESSION", "remember_token");
2023-05-18 10:08:38 +00:00
if ( ! RapidMode . config . usesDSL ) {
cy . visit ( RapidMode . url ( ) ) ;
cy . wait ( "@getWorkspace" ) ;
}
2023-05-02 10:47:23 +00:00
}
} ) ;
before ( function ( ) {
2023-05-18 10:08:38 +00:00
if ( RapidMode . config . enabled ) {
2023-05-02 10:47:23 +00:00
return ;
}
2022-08-10 16:06:30 +00:00
//console.warn = () => {}; //to remove all warnings in cypress console
2021-07-02 06:04:36 +00:00
initLocalstorage ( ) ;
2022-04-03 16:43:20 +00:00
initLocalstorageRegistry ( ) ;
2020-05-27 11:21:11 +00:00
cy . startServerAndRoutes ( ) ;
2021-01-04 10:22:22 +00:00
// Clear indexedDB
cy . window ( ) . then ( ( window ) => {
window . indexedDB . deleteDatabase ( "Appsmith" ) ;
} ) ;
2023-06-17 10:25:37 +00:00
cy . visit ( "/setup/welcome" , { timeout : 60000 } ) ;
2022-04-03 16:43:20 +00:00
cy . wait ( "@getMe" ) ;
cy . wait ( 2000 ) ;
2023-10-25 14:03:07 +00:00
const username = Cypress . env ( "USERNAME" ) ;
const password = Cypress . env ( "PASSWORD" ) ;
2021-11-16 10:23:05 +00:00
cy . url ( ) . then ( ( url ) => {
if ( url . indexOf ( "setup/welcome" ) > - 1 ) {
cy . createSuperUser ( ) ;
cy . SignupFromAPI (
Cypress . env ( "TESTUSERNAME1" ) ,
Cypress . env ( "TESTPASSWORD1" ) ,
) ;
cy . LogOut ( ) ;
cy . SignupFromAPI (
Cypress . env ( "TESTUSERNAME2" ) ,
Cypress . env ( "TESTPASSWORD2" ) ,
) ;
cy . LogOut ( ) ;
2022-12-06 05:51:54 +00:00
cy . SignupFromAPI (
Cypress . env ( "TESTUSERNAME3" ) ,
Cypress . env ( "TESTPASSWORD3" ) ,
) ;
cy . LogOut ( ) ;
cy . SignupFromAPI (
Cypress . env ( "TESTUSERNAME4" ) ,
Cypress . env ( "TESTPASSWORD4" ) ,
) ;
cy . LogOut ( ) ;
2023-10-25 14:03:07 +00:00
cy . LoginFromAPI ( username , password ) ;
} else if ( url . indexOf ( "user/login" ) > - 1 ) {
//Cypress.Cookies.preserveOnce("SESSION", "remember_token");
cy . LoginFromAPI ( username , password ) ;
cy . wait ( 3000 ) ;
2021-11-16 10:23:05 +00:00
}
} ) ;
2021-10-29 09:10:30 +00:00
2023-10-28 21:55:06 +00:00
if ( CURRENT _REPO === REPO . EE ) {
cy . wait ( 2000 ) ;
cy . url ( ) . then ( ( url ) => {
if ( url . indexOf ( "/license" ) > - 1 ) {
cy . validateLicense ( ) ;
}
} ) ;
}
2023-08-31 14:19:36 +00:00
if ( ! Cypress . currentTest . titlePath [ 0 ] . includes ( WALKTHROUGH _TEST _PAGE ) ) {
// Adding key FEATURE_WALKTHROUGH (which is used to check if the walkthrough is already shown to the user or not) for non walkthrough cypress tests (to not show walkthrough)
2023-10-06 10:03:27 +00:00
addIndexedDBKey ( FEATURE _WALKTHROUGH _INDEX _KEY , {
2023-08-31 14:19:36 +00:00
ab _ds _binding _enabled : true ,
ab _ds _schema _enabled : true ,
binding _widget : true ,
} ) ;
}
2021-12-10 07:23:12 +00:00
//console.warn = () => {};
2023-10-25 14:03:07 +00:00
cy . CreateNewAppInNewWorkspace ( ) ; //Creating new workspace and app
2023-06-15 13:21:11 +00:00
cy . fixture ( "TestDataSet1" ) . then ( function ( data ) {
this . dataSet = data ;
2020-05-08 09:01:11 +00:00
} ) ;
2020-05-11 10:38:49 +00:00
} ) ;
2020-05-08 09:01:11 +00:00
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### 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
- [ ] 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
- [ ] 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:
- [ ] 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
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
beforeEach ( function ( ) {
2022-08-10 16:06:30 +00:00
//cy.window().then((win) => (win.onbeforeunload = undefined));
if ( ! navigator . userAgent . includes ( "Cypress" ) ) {
window . addEventListener ( "beforeunload" , this . beforeunloadFunction ) ;
}
2021-07-02 06:04:36 +00:00
initLocalstorage ( ) ;
2023-06-15 13:21:11 +00:00
//Cypress.Cookies.preserveOnce("SESSION", "remember_token");
2020-05-27 11:21:11 +00:00
cy . startServerAndRoutes ( ) ;
2022-03-11 15:47:42 +00:00
//-- Delete local storage data of entity explorer
cy . DeleteEntityStateLocalStorage ( ) ;
2023-01-09 12:40:32 +00:00
cy . intercept ( "api/v1/admin/env" , ( req ) => {
req . headers [ "origin" ] = Cypress . config ( "baseUrl" ) ;
} ) ;
2020-05-11 10:38:49 +00:00
} ) ;
2019-12-12 07:50:53 +00:00
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### 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
- [ ] 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
- [ ] 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:
- [ ] 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
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
after ( function ( ) {
2023-05-18 10:08:38 +00:00
if ( RapidMode . config . enabled ) {
2023-05-02 10:47:23 +00:00
return ;
}
2023-08-08 09:14:46 +00:00
//-- Deleting the application by Api---//
cy . DeleteAppByApi ( ) ;
2023-10-20 02:15:47 +00:00
cy . DeleteWorkspaceByApi ( ) ;
2023-08-08 09:14:46 +00:00
//-- LogOut Application---//
2023-10-25 14:03:07 +00:00
//cy.LogOut(false);
2023-02-07 10:15:23 +00:00
// Commenting until Upgrade Appsmith cases are fixed
// const tedUrl = "http://localhost:5001/v1/parent/cmd";
2022-09-12 04:18:44 +00:00
// cy.log("Start the appsmith container");
2023-02-07 10:15:23 +00:00
// cy.StartContainer(tedUrl, "appsmith"); // start the old container
2020-03-27 09:02:11 +00:00
} ) ;