2022-05-18 10:39:42 +00:00
|
|
|
import { ObjectsRegistry } from "../Objects/Registry";
|
2022-11-25 03:47:00 +00:00
|
|
|
|
|
|
|
|
type RightPaneTabs = "datasources" | "connections";
|
|
|
|
|
|
2022-01-06 15:06:17 +00:00
|
|
|
export class ApiPage {
|
2022-05-18 10:39:42 +00:00
|
|
|
public agHelper = ObjectsRegistry.AggregateHelper;
|
|
|
|
|
public locator = ObjectsRegistry.CommonLocators;
|
2023-06-18 04:55:16 +00:00
|
|
|
private assertHelper = ObjectsRegistry.AssertHelper;
|
2022-05-18 10:39:42 +00:00
|
|
|
|
|
|
|
|
private _createapi = ".t--createBlankApiCard";
|
2023-03-10 11:39:06 +00:00
|
|
|
_resourceUrl = ".t--dataSourceField";
|
2022-05-18 10:39:42 +00:00
|
|
|
private _headerKey = (index: number) =>
|
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
|
|
|
".t--actionConfiguration\\.headers\\[" +
|
|
|
|
|
index +
|
|
|
|
|
"\\]\\.key\\." +
|
|
|
|
|
index +
|
|
|
|
|
"";
|
2022-05-18 10:39:42 +00:00
|
|
|
private _headerValue = (index: number) =>
|
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
|
|
|
".t--actionConfiguration\\.headers\\[" +
|
|
|
|
|
index +
|
|
|
|
|
"\\]\\.value\\." +
|
|
|
|
|
index +
|
|
|
|
|
"";
|
2022-05-18 10:39:42 +00:00
|
|
|
private _paramKey = (index: number) =>
|
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
|
|
|
".t--actionConfiguration\\.queryParameters\\[" +
|
|
|
|
|
index +
|
|
|
|
|
"\\]\\.key\\." +
|
|
|
|
|
index +
|
|
|
|
|
"";
|
2023-05-03 07:08:39 +00:00
|
|
|
public _paramValue = (index: number) =>
|
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
|
|
|
".t--actionConfiguration\\.queryParameters\\[" +
|
|
|
|
|
index +
|
|
|
|
|
"\\]\\.value\\." +
|
|
|
|
|
index +
|
|
|
|
|
"";
|
2023-02-24 12:18:48 +00:00
|
|
|
private _importedKey = (index: number, keyValueName: string) =>
|
|
|
|
|
`.t--${keyValueName}-key-${index}`;
|
|
|
|
|
private _importedValue = (index: number, keyValueName: string) =>
|
|
|
|
|
`.t--${keyValueName}-value-${index}`;
|
2022-05-18 10:39:42 +00:00
|
|
|
_bodyKey = (index: number) =>
|
|
|
|
|
".t--actionConfiguration\\.bodyFormData\\[0\\]\\.key\\." + index + "";
|
|
|
|
|
_bodyValue = (index: number) =>
|
|
|
|
|
".t--actionConfiguration\\.bodyFormData\\[0\\]\\.value\\." + index + "";
|
|
|
|
|
_bodyTypeDropdown =
|
2023-05-19 18:37:06 +00:00
|
|
|
"//span[text()='Type'][@class='rc-select-selection-placeholder']/ancestor::div";
|
2023-03-10 11:39:06 +00:00
|
|
|
_apiRunBtn = ".t--apiFormRunBtn";
|
2022-05-18 10:39:42 +00:00
|
|
|
private _queryTimeout =
|
|
|
|
|
"//input[@name='actionConfiguration.timeoutInMillisecond']";
|
|
|
|
|
_responseBody = ".CodeMirror-code span.cm-string.cm-property";
|
2023-05-19 18:37:06 +00:00
|
|
|
private _blankAPI = "span:contains('New blank API')";
|
|
|
|
|
private _apiVerbDropdown = ".t--apiFormHttpMethod div";
|
2022-05-18 10:39:42 +00:00
|
|
|
private _verbToSelect = (verb: string) =>
|
2023-05-19 18:37:06 +00:00
|
|
|
"//div[contains(@class, 'rc-select-item-option')]//div[contains(text(),'" +
|
2022-05-18 10:39:42 +00:00
|
|
|
verb +
|
|
|
|
|
"')]";
|
2023-05-19 18:37:06 +00:00
|
|
|
private _bodySubTab = (subTab: string) =>
|
|
|
|
|
`//div[@data-testid="t--api-body-tab-switch"]//span[text()='${subTab}']`;
|
|
|
|
|
private _rightPaneTab = (tab: string) =>
|
|
|
|
|
"//span[contains(text(), '" + tab + "')]/parent::button";
|
2022-05-18 10:39:42 +00:00
|
|
|
_visibleTextSpan = (spanText: string) => "//span[text()='" + spanText + "']";
|
|
|
|
|
_visibleTextDiv = (divText: string) => "//div[text()='" + divText + "']";
|
|
|
|
|
_noBodyMessageDiv = "#NoBodyMessageDiv";
|
|
|
|
|
_noBodyMessage = "This request does not have a body";
|
|
|
|
|
_imageSrc = "//img/parent::div";
|
2023-05-19 18:37:06 +00:00
|
|
|
private _trashDelete = "[data-testid=t--trash-icon]";
|
2022-05-18 10:39:42 +00:00
|
|
|
private _onPageLoad = "input[name='executeOnLoad'][type='checkbox']";
|
|
|
|
|
private _confirmBeforeRunningAPI =
|
|
|
|
|
"input[name='confirmBeforeExecute'][type='checkbox']";
|
2022-09-09 15:59:47 +00:00
|
|
|
private _paginationTypeLabels = ".t--apiFormPaginationType label";
|
2022-08-04 04:48:15 +00:00
|
|
|
_saveAsDS = ".t--store-as-datasource";
|
2022-09-13 05:02:59 +00:00
|
|
|
_responseStatus = ".t--response-status-code";
|
2023-05-19 18:37:06 +00:00
|
|
|
private _blankGraphqlAPI = "span:contains('New blank GraphQL API')";
|
2023-02-24 12:18:48 +00:00
|
|
|
private _importedDataButton = ".t--show-imported-datas";
|
2023-05-19 18:37:06 +00:00
|
|
|
public _responseTabHeader = "[data-testid=t--tab-headers]";
|
2023-02-24 12:18:48 +00:00
|
|
|
public _autoGeneratedHeaderInfoIcon = (key: string) =>
|
|
|
|
|
`.t--auto-generated-${key}-info`;
|
2023-03-10 11:39:06 +00:00
|
|
|
private _createQuery = ".t--create-query";
|
2022-05-18 10:39:42 +00:00
|
|
|
|
|
|
|
|
CreateApi(
|
2022-08-22 05:47:24 +00:00
|
|
|
apiName = "",
|
2022-05-18 10:39:42 +00:00
|
|
|
apiVerb: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" = "GET",
|
2023-03-10 11:39:06 +00:00
|
|
|
aftDSSaved = false,
|
2022-05-18 10:39:42 +00:00
|
|
|
) {
|
2023-03-10 11:39:06 +00:00
|
|
|
if (aftDSSaved) this.agHelper.GetNClick(this._createQuery);
|
|
|
|
|
else {
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.RemoveEvaluatedPopUp();
|
|
|
|
|
this.agHelper.GetHoverNClick(this.locator._createNew);
|
|
|
|
|
this.agHelper.GetNClick(this._blankAPI, 0, true);
|
|
|
|
|
this.agHelper.RemoveTooltip("Add a new query/JS Object");
|
2023-03-10 11:39:06 +00:00
|
|
|
}
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@createNewApi", 201);
|
2022-05-18 10:39:42 +00:00
|
|
|
|
|
|
|
|
// cy.get("@createNewApi").then((response: any) => {
|
|
|
|
|
// expect(response.response.body.responseMeta.success).to.eq(true);
|
|
|
|
|
// cy.get(this.agHelper._actionName)
|
|
|
|
|
// .click()
|
|
|
|
|
// .invoke("text")
|
|
|
|
|
// .then((text) => {
|
|
|
|
|
// const someText = text;
|
|
|
|
|
// expect(someText).to.equal(response.response.body.data.name);
|
|
|
|
|
// });
|
|
|
|
|
// }); // to check if Api1 = Api1 when Create Api invoked
|
|
|
|
|
|
|
|
|
|
if (apiName) this.agHelper.RenameWithInPane(apiName);
|
|
|
|
|
cy.get(this._resourceUrl).should("be.visible");
|
|
|
|
|
if (apiVerb != "GET") this.SelectAPIVerb(apiVerb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CreateAndFillApi(
|
|
|
|
|
url: string,
|
2022-08-22 05:47:24 +00:00
|
|
|
apiName = "",
|
2022-08-24 14:23:41 +00:00
|
|
|
queryTimeout = 10000,
|
2022-05-18 10:39:42 +00:00
|
|
|
apiVerb: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" = "GET",
|
2023-03-10 11:39:06 +00:00
|
|
|
aftDSSaved = false,
|
2022-05-18 10:39:42 +00:00
|
|
|
) {
|
2023-03-10 11:39:06 +00:00
|
|
|
this.CreateApi(apiName, apiVerb, aftDSSaved);
|
2022-05-18 10:39:42 +00:00
|
|
|
this.EnterURL(url);
|
|
|
|
|
//this.agHelper.Sleep(2000);// Added because api name edit takes some time to reflect in api sidebar after the call passes.
|
2023-06-08 09:09:19 +00:00
|
|
|
this.AssertRunButtonDisability();
|
2022-08-24 14:23:41 +00:00
|
|
|
if (queryTimeout != 10000) this.SetAPITimeout(queryTimeout);
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-08 09:09:19 +00:00
|
|
|
AssertRunButtonDisability(disabled = false) {
|
|
|
|
|
let query = "";
|
|
|
|
|
if (disabled) {
|
|
|
|
|
query = "be.disabled";
|
|
|
|
|
} else {
|
|
|
|
|
query = "not.be.disabled";
|
|
|
|
|
}
|
|
|
|
|
cy.get(this._apiRunBtn).should(query);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 09:04:53 +00:00
|
|
|
EnterURL(url: string, validateEvaluatedValue = false, evaluatedValue = "") {
|
2022-06-06 05:59:15 +00:00
|
|
|
this.agHelper.EnterValue(url, {
|
|
|
|
|
propFieldName: this._resourceUrl,
|
|
|
|
|
directInput: true,
|
|
|
|
|
inputFieldName: "",
|
|
|
|
|
});
|
2022-05-18 10:39:42 +00:00
|
|
|
this.agHelper.AssertAutoSave();
|
2023-06-16 09:04:53 +00:00
|
|
|
|
|
|
|
|
if (validateEvaluatedValue) {
|
|
|
|
|
this.agHelper.VerifyEvaluatedValue(evaluatedValue);
|
|
|
|
|
}
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-15 05:03:34 +00:00
|
|
|
EnterHeader(hKey: string, hValue: string, index = 0) {
|
2022-05-18 10:39:42 +00:00
|
|
|
this.SelectPaneTab("Headers");
|
2022-06-06 05:59:15 +00:00
|
|
|
this.agHelper.EnterValue(hKey, {
|
2023-03-15 05:03:34 +00:00
|
|
|
propFieldName: this._headerKey(index),
|
2022-06-06 05:59:15 +00:00
|
|
|
directInput: true,
|
|
|
|
|
inputFieldName: "",
|
|
|
|
|
});
|
2022-08-27 12:40:11 +00:00
|
|
|
this.agHelper.PressEscape();
|
2022-06-06 05:59:15 +00:00
|
|
|
this.agHelper.EnterValue(hValue, {
|
2023-03-15 05:03:34 +00:00
|
|
|
propFieldName: this._headerValue(index),
|
2022-06-06 05:59:15 +00:00
|
|
|
directInput: true,
|
|
|
|
|
inputFieldName: "",
|
|
|
|
|
});
|
2022-08-27 12:40:11 +00:00
|
|
|
this.agHelper.PressEscape();
|
2022-05-18 10:39:42 +00:00
|
|
|
this.agHelper.AssertAutoSave();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-03 07:08:39 +00:00
|
|
|
EnterParams(pKey: string, pValue: string, index = 0, escape = true) {
|
2022-05-18 10:39:42 +00:00
|
|
|
this.SelectPaneTab("Params");
|
2022-06-06 05:59:15 +00:00
|
|
|
this.agHelper.EnterValue(pKey, {
|
2023-03-15 05:03:34 +00:00
|
|
|
propFieldName: this._paramKey(index),
|
2022-06-06 05:59:15 +00:00
|
|
|
directInput: true,
|
|
|
|
|
inputFieldName: "",
|
|
|
|
|
});
|
2022-08-27 12:40:11 +00:00
|
|
|
this.agHelper.PressEscape();
|
2022-06-06 05:59:15 +00:00
|
|
|
this.agHelper.EnterValue(pValue, {
|
2023-03-15 05:03:34 +00:00
|
|
|
propFieldName: this._paramValue(index),
|
2022-06-06 05:59:15 +00:00
|
|
|
directInput: true,
|
|
|
|
|
inputFieldName: "",
|
|
|
|
|
});
|
2023-05-03 07:08:39 +00:00
|
|
|
if (escape) {
|
|
|
|
|
this.agHelper.PressEscape();
|
|
|
|
|
}
|
2022-05-18 10:39:42 +00:00
|
|
|
this.agHelper.AssertAutoSave();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EnterBodyFormData(
|
|
|
|
|
subTab: "FORM_URLENCODED" | "MULTIPART_FORM_DATA",
|
|
|
|
|
bKey: string,
|
|
|
|
|
bValue: string,
|
|
|
|
|
type = "",
|
|
|
|
|
toTrash = false,
|
|
|
|
|
) {
|
|
|
|
|
this.SelectPaneTab("Body");
|
|
|
|
|
this.SelectSubTab(subTab);
|
|
|
|
|
if (toTrash) {
|
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(this._trashDelete).first().click();
|
2022-05-18 10:39:42 +00:00
|
|
|
cy.xpath(this._visibleTextSpan("Add more")).click();
|
2022-03-31 11:51:08 +00:00
|
|
|
}
|
2022-06-06 05:59:15 +00:00
|
|
|
this.agHelper.EnterValue(bKey, {
|
|
|
|
|
propFieldName: this._bodyKey(0),
|
|
|
|
|
directInput: true,
|
|
|
|
|
inputFieldName: "",
|
|
|
|
|
});
|
2022-08-27 12:40:11 +00:00
|
|
|
this.agHelper.PressEscape();
|
2022-05-18 10:39:42 +00:00
|
|
|
|
|
|
|
|
if (type) {
|
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(this._bodyTypeDropdown).eq(0).click();
|
2022-05-18 10:39:42 +00:00
|
|
|
cy.xpath(this._visibleTextDiv(type)).click();
|
2022-03-31 11:51:08 +00:00
|
|
|
}
|
2022-06-06 05:59:15 +00:00
|
|
|
this.agHelper.EnterValue(bValue, {
|
|
|
|
|
propFieldName: this._bodyValue(0),
|
|
|
|
|
directInput: true,
|
|
|
|
|
inputFieldName: "",
|
|
|
|
|
});
|
2022-08-27 12:40:11 +00:00
|
|
|
this.agHelper.PressEscape();
|
2022-05-18 10:39:42 +00:00
|
|
|
this.agHelper.AssertAutoSave();
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-09 15:59:47 +00:00
|
|
|
RunAPI(
|
|
|
|
|
toValidateResponse = true,
|
|
|
|
|
waitTimeInterval = 20,
|
|
|
|
|
validateNetworkAssertOptions?: { expectedPath: string; expectedRes: any },
|
|
|
|
|
) {
|
2022-08-24 14:23:41 +00:00
|
|
|
this.agHelper.GetNClick(this._apiRunBtn, 0, true, waitTimeInterval);
|
|
|
|
|
toValidateResponse &&
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.AssertNetworkExecutionSuccess("@postExecute");
|
2022-09-09 15:59:47 +00:00
|
|
|
|
|
|
|
|
// Asserting Network result
|
|
|
|
|
validateNetworkAssertOptions?.expectedPath &&
|
|
|
|
|
validateNetworkAssertOptions?.expectedRes &&
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.AssertNetworkDataNestedProperty(
|
2022-09-09 15:59:47 +00:00
|
|
|
"@postExecute",
|
|
|
|
|
validateNetworkAssertOptions.expectedPath,
|
|
|
|
|
validateNetworkAssertOptions.expectedRes,
|
|
|
|
|
);
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetAPITimeout(timeout: number) {
|
|
|
|
|
this.SelectPaneTab("Settings");
|
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(this._queryTimeout).clear().type(timeout.toString(), { delay: 0 }); //Delay 0 to work like paste!
|
2022-05-18 10:39:42 +00:00
|
|
|
this.agHelper.AssertAutoSave();
|
|
|
|
|
this.SelectPaneTab("Headers");
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-17 06:12:18 +00:00
|
|
|
ToggleOnPageLoadRun(enable = true || false) {
|
2022-05-18 10:39:42 +00:00
|
|
|
this.SelectPaneTab("Settings");
|
2023-01-09 12:16:52 +00:00
|
|
|
if (enable) this.agHelper.CheckUncheck(this._onPageLoad, true);
|
|
|
|
|
else this.agHelper.CheckUncheck(this._onPageLoad, false);
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
2022-06-17 06:12:18 +00:00
|
|
|
ToggleConfirmBeforeRunningApi(enable = true || false) {
|
2022-05-18 10:39:42 +00:00
|
|
|
this.SelectPaneTab("Settings");
|
2022-12-09 05:06:52 +00:00
|
|
|
if (enable) this.agHelper.CheckUncheck(this._confirmBeforeRunningAPI, true);
|
|
|
|
|
else this.agHelper.CheckUncheck(this._confirmBeforeRunningAPI, false);
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectPaneTab(
|
|
|
|
|
tabName:
|
|
|
|
|
| "Headers"
|
|
|
|
|
| "Params"
|
|
|
|
|
| "Body"
|
|
|
|
|
| "Pagination"
|
|
|
|
|
| "Authentication"
|
2022-09-12 04:18:44 +00:00
|
|
|
| "Settings"
|
|
|
|
|
| "Response"
|
|
|
|
|
| "Errors"
|
|
|
|
|
| "Logs"
|
2022-10-08 02:17:07 +00:00
|
|
|
| "Inspect entity",
|
2022-05-18 10:39:42 +00:00
|
|
|
) {
|
2022-08-27 12:40:11 +00:00
|
|
|
this.agHelper.PressEscape();
|
2022-09-07 18:25:55 +00:00
|
|
|
this.agHelper.GetNClick(this._visibleTextSpan(tabName), 0, true);
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectSubTab(
|
|
|
|
|
subTabName:
|
|
|
|
|
| "NONE"
|
|
|
|
|
| "JSON"
|
|
|
|
|
| "FORM_URLENCODED"
|
|
|
|
|
| "MULTIPART_FORM_DATA"
|
|
|
|
|
| "RAW",
|
|
|
|
|
) {
|
2022-08-24 14:23:41 +00:00
|
|
|
this.agHelper.GetNClick(this._bodySubTab(subTabName));
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-25 03:47:00 +00:00
|
|
|
AssertRightPaneSelectedTab(tabName: RightPaneTabs) {
|
2023-05-19 18:37:06 +00:00
|
|
|
cy.xpath(this._rightPaneTab(tabName)).should(
|
|
|
|
|
"have.attr",
|
|
|
|
|
"aria-selected",
|
|
|
|
|
"true",
|
2022-11-25 03:47:00 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectRightPaneTab(tabName: RightPaneTabs) {
|
|
|
|
|
this.agHelper.GetNClick(this._rightPaneTab(tabName));
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-18 10:39:42 +00:00
|
|
|
ValidateQueryParams(param: { key: string; value: string }) {
|
|
|
|
|
this.SelectPaneTab("Params");
|
|
|
|
|
this.agHelper.ValidateCodeEditorContent(this._paramKey(0), param.key);
|
|
|
|
|
this.agHelper.ValidateCodeEditorContent(this._paramValue(0), param.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValidateHeaderParams(header: { key: string; value: string }) {
|
|
|
|
|
this.SelectPaneTab("Headers");
|
|
|
|
|
this.agHelper.ValidateCodeEditorContent(this._headerKey(0), header.key);
|
|
|
|
|
this.agHelper.ValidateCodeEditorContent(this._headerValue(0), header.value);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-24 12:18:48 +00:00
|
|
|
ValidateImportedHeaderParams(
|
|
|
|
|
isAutoGeneratedHeader = false,
|
|
|
|
|
header: { key: string; value: string },
|
|
|
|
|
index = 0,
|
|
|
|
|
) {
|
|
|
|
|
let keyValueName = "Header";
|
|
|
|
|
if (isAutoGeneratedHeader) {
|
|
|
|
|
keyValueName = "autoGeneratedHeader";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.SelectPaneTab("Headers");
|
|
|
|
|
this.ValidateImportedKeyValueContent(
|
|
|
|
|
this._importedKey(index, keyValueName),
|
|
|
|
|
header.key,
|
|
|
|
|
);
|
|
|
|
|
this.ValidateImportedKeyValueContent(
|
|
|
|
|
this._importedValue(index, keyValueName),
|
|
|
|
|
header.value,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ValidateImportedKeyValueContent(
|
|
|
|
|
selector: string,
|
|
|
|
|
contentToValidate: any,
|
|
|
|
|
) {
|
|
|
|
|
this.agHelper.GetNAssertElementText(
|
|
|
|
|
selector,
|
|
|
|
|
contentToValidate,
|
|
|
|
|
"have.text",
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ValidateImportedKeyValueOverride(index: number, isOverriden = true) {
|
|
|
|
|
let assertion = "";
|
|
|
|
|
|
|
|
|
|
if (isOverriden) {
|
|
|
|
|
assertion = "have.css";
|
|
|
|
|
} else {
|
|
|
|
|
assertion = "not.have.css";
|
|
|
|
|
}
|
|
|
|
|
cy.get(this._importedKey(index, "autoGeneratedHeader")).should(
|
|
|
|
|
assertion,
|
|
|
|
|
"text-decoration",
|
2023-05-19 18:37:06 +00:00
|
|
|
"line-through solid rgb(76, 86, 100)",
|
2023-02-24 12:18:48 +00:00
|
|
|
);
|
|
|
|
|
cy.get(this._importedValue(index, "autoGeneratedHeader")).should(
|
|
|
|
|
assertion,
|
|
|
|
|
"text-decoration",
|
2023-05-19 18:37:06 +00:00
|
|
|
"line-through solid rgb(76, 86, 100)",
|
2023-02-24 12:18:48 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValidateImportedHeaderParamsAbsence(
|
|
|
|
|
isAutoGeneratedHeader = false,
|
|
|
|
|
index = 0,
|
|
|
|
|
) {
|
|
|
|
|
let keyValueName = "Header";
|
|
|
|
|
if (isAutoGeneratedHeader) {
|
|
|
|
|
keyValueName = "autoGeneratedHeader";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.SelectPaneTab("Headers");
|
|
|
|
|
this.ValidateImportedKeyValueAbsence(
|
|
|
|
|
this._importedKey(index, keyValueName),
|
|
|
|
|
);
|
|
|
|
|
this.ValidateImportedKeyValueAbsence(
|
|
|
|
|
this._importedValue(index, keyValueName),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ValidateImportedKeyValueAbsence(selector: string) {
|
|
|
|
|
this.agHelper.AssertElementAbsence(selector);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-18 10:39:42 +00:00
|
|
|
ReadApiResponsebyKey(key: string) {
|
2022-09-13 05:02:59 +00:00
|
|
|
let apiResp = "";
|
2022-05-18 10:39:42 +00:00
|
|
|
cy.get(this._responseBody)
|
|
|
|
|
.contains(key)
|
|
|
|
|
.siblings("span")
|
|
|
|
|
.invoke("text")
|
|
|
|
|
.then((text) => {
|
|
|
|
|
apiResp = `${text
|
2023-03-23 11:32:18 +00:00
|
|
|
.match(/"(.*)"/)?.[0]
|
2022-05-18 10:39:42 +00:00
|
|
|
.split('"')
|
|
|
|
|
.join("")} `;
|
|
|
|
|
cy.log("Key value in api response is :" + apiResp);
|
|
|
|
|
cy.wrap(apiResp).as("apiResp");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-19 13:59:15 +00:00
|
|
|
SwitchToResponseTab(tabIdentifier: string) {
|
|
|
|
|
cy.get(tabIdentifier).click();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-18 10:39:42 +00:00
|
|
|
public SelectAPIVerb(verb: "GET" | "POST" | "PUT" | "DELETE" | "PATCH") {
|
|
|
|
|
cy.get(this._apiVerbDropdown).click();
|
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(this._verbToSelect(verb)).should("be.visible").click();
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
2022-09-09 15:59:47 +00:00
|
|
|
|
2023-06-09 08:18:59 +00:00
|
|
|
public AssertAPIVerb(verb: "GET" | "POST" | "PUT" | "DELETE" | "PATCH") {
|
|
|
|
|
this.agHelper.AssertText(this._apiVerbDropdown, "text", verb);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 05:02:59 +00:00
|
|
|
ResponseStatusCheck(statusCode: string) {
|
|
|
|
|
this.agHelper.AssertElementVisible(this._responseStatus);
|
2023-03-10 11:39:06 +00:00
|
|
|
this.agHelper.GetNAssertContains(this._responseStatus, statusCode);
|
2022-09-13 05:02:59 +00:00
|
|
|
}
|
2022-09-09 15:59:47 +00:00
|
|
|
public SelectPaginationTypeViaIndex(index: number) {
|
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(this._paginationTypeLabels).eq(index).click({ force: true });
|
2022-09-09 15:59:47 +00:00
|
|
|
}
|
2022-10-08 02:17:07 +00:00
|
|
|
|
2022-11-19 13:59:15 +00:00
|
|
|
CreateAndFillGraphqlApi(url: string, apiName = "", queryTimeout = 10000) {
|
2022-10-08 02:17:07 +00:00
|
|
|
this.CreateGraphqlApi(apiName);
|
|
|
|
|
this.EnterURL(url);
|
|
|
|
|
this.agHelper.AssertAutoSave();
|
|
|
|
|
//this.agHelper.Sleep(2000);// Added because api name edit takes some time to reflect in api sidebar after the call passes.
|
2023-06-08 09:09:19 +00:00
|
|
|
this.AssertRunButtonDisability();
|
2022-10-08 02:17:07 +00:00
|
|
|
if (queryTimeout != 10000) this.SetAPITimeout(queryTimeout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CreateGraphqlApi(apiName = "") {
|
|
|
|
|
cy.get(this.locator._createNew).click({ force: true });
|
|
|
|
|
cy.get(this._blankGraphqlAPI).click({ force: true });
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@createNewApi", 201);
|
2022-10-08 02:17:07 +00:00
|
|
|
|
|
|
|
|
if (apiName) this.agHelper.RenameWithInPane(apiName);
|
|
|
|
|
cy.get(this._resourceUrl).should("be.visible");
|
|
|
|
|
}
|
2023-06-05 09:33:51 +00:00
|
|
|
|
|
|
|
|
AssertEmptyHeaderKeyValuePairsPresent(index: number) {
|
|
|
|
|
this.agHelper.AssertElementVisible(this._headerKey(index));
|
|
|
|
|
this.agHelper.AssertElementVisible(this._headerValue(index));
|
|
|
|
|
}
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|