2022-04-11 03:30:37 +00:00
|
|
|
/* eslint-disable cypress/no-unnecessary-waiting */
|
2022-09-03 18:27:41 +00:00
|
|
|
/* eslint-disable cypress/no-assigning-return-values */
|
2022-04-11 03:30:37 +00:00
|
|
|
|
|
|
|
|
require("cy-verify-downloads").addCustomCommand();
|
|
|
|
|
require("cypress-file-upload");
|
|
|
|
|
import ApiEditor from "../locators/ApiEditor";
|
2024-12-07 11:58:42 +00:00
|
|
|
|
2022-04-11 03:30:37 +00:00
|
|
|
const apiwidget = require("../locators/apiWidgetslocator.json");
|
|
|
|
|
const explorer = require("../locators/explorerlocators.json");
|
2023-05-19 18:37:06 +00:00
|
|
|
import { ObjectsRegistry } from "./Objects/Registry";
|
2024-12-03 03:51:43 +00:00
|
|
|
import { PluginActionForm } from "./Pages/PluginActionForm";
|
2024-12-10 07:06:57 +00:00
|
|
|
import BottomTabs from "./Pages/IDE/BottomTabs";
|
2023-05-19 18:37:06 +00:00
|
|
|
|
2023-07-27 04:46:55 +00:00
|
|
|
let agHelper = ObjectsRegistry.AggregateHelper;
|
2023-05-19 18:37:06 +00:00
|
|
|
let dataSources = ObjectsRegistry.DataSources;
|
|
|
|
|
let apiPage = ObjectsRegistry.ApiPage;
|
2024-12-03 03:51:43 +00:00
|
|
|
let locator = ObjectsRegistry.CommonLocators;
|
|
|
|
|
let pluginActionForm = new PluginActionForm();
|
2022-04-11 03:30:37 +00:00
|
|
|
|
|
|
|
|
export const initLocalstorage = () => {
|
|
|
|
|
cy.window().then((window) => {
|
|
|
|
|
window.localStorage.setItem("ShowCommentsButtonToolTip", "");
|
|
|
|
|
window.localStorage.setItem("updateDismissed", "true");
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("enterDatasourceAndPath", (datasource, path) => {
|
|
|
|
|
cy.enterDatasource(datasource + path);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("enterDatasource", (datasource) => {
|
|
|
|
|
cy.get(apiwidget.resourceUrl)
|
|
|
|
|
.first()
|
|
|
|
|
.click({ force: true })
|
2022-07-20 06:06:33 +00:00
|
|
|
.type(datasource, { parseSpecialCharSequences: false });
|
|
|
|
|
//.type("{esc}}");
|
2022-07-29 03:03:32 +00:00
|
|
|
cy.wait(2000);
|
2024-06-06 07:41:03 +00:00
|
|
|
agHelper.AssertAutoSave();
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("ResponseStatusCheck", (statusCode) => {
|
2024-12-10 07:06:57 +00:00
|
|
|
BottomTabs.response.validateResponseStatus(statusCode);
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("ResponseCheck", () => {
|
|
|
|
|
//Explicit assert
|
|
|
|
|
cy.get(apiwidget.responseText).should("be.visible");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("ResponseTextCheck", (textTocheck) => {
|
|
|
|
|
cy.ResponseCheck();
|
|
|
|
|
cy.get(apiwidget.responseText).contains(textTocheck);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("NavigateToAPI_Panel", () => {
|
2023-05-19 18:37:06 +00:00
|
|
|
dataSources.NavigateToDSCreateNew();
|
2022-04-11 03:30:37 +00:00
|
|
|
cy.get("#loading").should("not.exist");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("CreateAPI", (apiname) => {
|
2023-05-19 18:37:06 +00:00
|
|
|
apiPage.CreateApi(apiname);
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("EditApiNameFromExplorer", (apiname) => {
|
|
|
|
|
/*
|
|
|
|
|
cy.xpath(apiwidget.popover)
|
|
|
|
|
.last()
|
|
|
|
|
.click({ force: true });
|
|
|
|
|
cy.get(apiwidget.editName).click({ force: true });
|
|
|
|
|
*/
|
|
|
|
|
cy.get(explorer.editNameField)
|
|
|
|
|
.clear()
|
|
|
|
|
.type(apiname, { force: true })
|
|
|
|
|
.should("have.value", apiname)
|
2024-02-05 16:33:53 +00:00
|
|
|
.blur({ force: true });
|
2022-04-11 03:30:37 +00:00
|
|
|
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
|
|
|
cy.wait(3000);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("RunAPI", () => {
|
|
|
|
|
cy.get(ApiEditor.ApiRunBtn).click({ force: true });
|
|
|
|
|
cy.wait("@postExecute");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("SaveAndRunAPI", () => {
|
|
|
|
|
cy.WaitAutoSave();
|
|
|
|
|
cy.RunAPI();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add(
|
|
|
|
|
"validateRequest",
|
|
|
|
|
(apiName, baseurl, path, verb, error = false) => {
|
2023-05-19 18:37:06 +00:00
|
|
|
cy.get(".ads-v2-tabs__list").contains("Logs").click();
|
|
|
|
|
cy.get("[data-testid=t--debugger-search]").clear().type(apiName);
|
2023-10-20 02:15:47 +00:00
|
|
|
agHelper.PressEnter(2000);
|
2022-04-11 03:30:37 +00:00
|
|
|
if (!error) {
|
2023-08-03 18:24:36 +00:00
|
|
|
cy.get(ApiEditor.apiResponseObject).last().contains("request").click();
|
2022-04-11 03:30:37 +00:00
|
|
|
}
|
|
|
|
|
cy.get(".string-value").contains(baseurl.concat(path));
|
|
|
|
|
cy.get(".string-value").contains(verb);
|
2024-10-08 10:42:27 +00:00
|
|
|
cy.get("[data-testid=t--tab-RESPONSE_TAB]").first().click({ force: true });
|
2022-04-11 03:30:37 +00:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
2023-03-11 07:01:39 +00:00
|
|
|
Cypress.Commands.add("enterUrl", (baseUrl, url, value) => {
|
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
|
|
|
cy.get(url).first().type(baseUrl.concat(value), {
|
|
|
|
|
force: true,
|
|
|
|
|
parseSpecialCharSequences: false,
|
|
|
|
|
});
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("CreationOfUniqueAPIcheck", (apiname) => {
|
2023-05-19 18:37:06 +00:00
|
|
|
dataSources.NavigateToDSCreateNew();
|
2024-03-15 05:43:14 +00:00
|
|
|
agHelper.GetNClick(apiwidget.createapi);
|
2022-04-11 03:30:37 +00:00
|
|
|
cy.wait("@createNewApi");
|
|
|
|
|
// cy.wait("@getUser");
|
|
|
|
|
cy.get(apiwidget.resourceUrl).should("be.visible");
|
2024-12-07 11:58:42 +00:00
|
|
|
agHelper.RenameQuery(
|
|
|
|
|
apiname,
|
|
|
|
|
apiname.concat(" is already being used or is a restricted keyword."),
|
|
|
|
|
);
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("RenameEntity", (value, selectFirst) => {
|
|
|
|
|
if (selectFirst) {
|
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
|
|
|
cy.xpath(apiwidget.popover).first().click({ force: true });
|
2022-04-11 03:30:37 +00:00
|
|
|
} else {
|
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
|
|
|
cy.xpath(apiwidget.popover).last().click({ force: true });
|
2022-04-11 03:30:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cy.get(apiwidget.renameEntity).click({ force: true });
|
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
|
|
|
cy.get(explorer.editEntity).last().type(value, { force: true });
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("CreateApiAndValidateUniqueEntityName", (apiname) => {
|
2023-11-15 02:31:12 +00:00
|
|
|
dataSources.NavigateToDSCreateNew();
|
2024-03-15 05:43:14 +00:00
|
|
|
agHelper.GetNClick(apiwidget.createapi);
|
2022-04-11 03:30:37 +00:00
|
|
|
cy.wait("@createNewApi");
|
|
|
|
|
cy.get(apiwidget.resourceUrl).should("be.visible");
|
2024-12-07 11:58:42 +00:00
|
|
|
agHelper.RenameQuery(
|
|
|
|
|
apiname,
|
|
|
|
|
apiname.concat(" is already being used or is a restricted keyword."),
|
|
|
|
|
);
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("validateMessage", (value) => {
|
2023-05-19 18:37:06 +00:00
|
|
|
cy.get(".rc-tooltip-inner").should(($x) => {
|
2025-03-14 12:10:02 +00:00
|
|
|
expect($x).contain(
|
|
|
|
|
value.concat(" is already being used or is a restricted keyword."),
|
|
|
|
|
);
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("DeleteWidgetFromSideBar", () => {
|
2025-03-14 12:10:02 +00:00
|
|
|
cy.get(apiwidget.popover).last().click({ force: true });
|
2022-04-11 03:30:37 +00:00
|
|
|
cy.get(apiwidget.delete).click({ force: true });
|
|
|
|
|
cy.wait("@updateLayout").should(
|
|
|
|
|
"have.nested.property",
|
|
|
|
|
"response.body.responseMeta.status",
|
|
|
|
|
200,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("DeleteAPI", () => {
|
|
|
|
|
cy.get(ApiEditor.ApiActionMenu).click({ multiple: true });
|
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
|
|
|
cy.get(apiwidget.deleteAPI).first().click({ force: true });
|
|
|
|
|
cy.get(apiwidget.deleteAPI).first().click({ force: true });
|
2023-06-15 13:21:11 +00:00
|
|
|
|
|
|
|
|
cy.wait("@deleteAction")
|
|
|
|
|
.its("response.body.responseMeta.status")
|
|
|
|
|
.should("eq", 200);
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("testCreateApiButton", () => {
|
2024-03-15 05:43:14 +00:00
|
|
|
agHelper.GetNClick(ApiEditor.createBlankApiCard);
|
2023-06-15 13:21:11 +00:00
|
|
|
cy.wait("@createNewApi");
|
|
|
|
|
cy.get("@createNewApi")
|
|
|
|
|
.its("response.body.responseMeta.status")
|
|
|
|
|
.should("eq", 201);
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("createAndFillApi", (url, parameters) => {
|
2023-05-19 18:37:06 +00:00
|
|
|
dataSources.NavigateToDSCreateNew();
|
2022-04-11 03:30:37 +00:00
|
|
|
cy.testCreateApiButton();
|
|
|
|
|
cy.get("@createNewApi").then((response) => {
|
2025-02-06 08:33:54 +00:00
|
|
|
cy.get(locator._activeEntityTab).should("be.visible");
|
2022-04-11 03:30:37 +00:00
|
|
|
expect(response.response.body.responseMeta.success).to.eq(true);
|
2025-02-06 08:33:54 +00:00
|
|
|
cy.get(locator._activeEntityTab)
|
2022-04-11 03:30:37 +00:00
|
|
|
.invoke("text")
|
|
|
|
|
.then((text) => {
|
|
|
|
|
const someText = text;
|
|
|
|
|
expect(someText).to.equal(response.response.body.data.name);
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-05-11 05:26:03 +00:00
|
|
|
|
|
|
|
|
cy.EnableAllCodeEditors();
|
2024-12-03 03:51:43 +00:00
|
|
|
cy.updateCodeInput(ApiEditor.dataSourceField, url + parameters);
|
2022-04-11 03:30:37 +00:00
|
|
|
cy.WaitAutoSave();
|
2024-12-03 03:51:43 +00:00
|
|
|
cy.get(pluginActionForm.locators.actionRunButton).should("not.be.disabled");
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
2023-04-06 16:49:12 +00:00
|
|
|
// Cypress.Commands.add("callApi", (apiname) => {
|
|
|
|
|
// cy.get(commonlocators.callApi).first().click({ force: true });
|
|
|
|
|
// cy.get(commonlocators.singleSelectMenuItem)
|
|
|
|
|
// .contains("Execute a query")
|
|
|
|
|
// .click({ force: true });
|
|
|
|
|
// cy.get(commonlocators.selectMenuItem)
|
|
|
|
|
// .contains(apiname)
|
|
|
|
|
// .click({ force: true });
|
|
|
|
|
// });
|