-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Remove error for window fetch API (#33339)
## Description Fix linting error for `fetch` window API Fixes #33268 ## Automation /ok-to-test tags="@tag.JS" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9023762582> > Commit: f235c91 > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9023762582&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No
- Loading branch information
1 parent
5701ae1
commit abbf326
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
app/client/src/plugins/Linting/tests/getLintingErrors.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { getScriptType } from "workers/Evaluation/evaluate"; | ||
import getLintingErrors from "../utils/getLintingErrors"; | ||
|
||
describe("getLintingErrors", () => { | ||
describe("1. Verify lint errors are not shown for supported window APIs", () => { | ||
const data = {}; | ||
|
||
it("1. For fetch API", () => { | ||
const originalBinding = "{{fetch()}}"; | ||
const script = "fetch()"; | ||
|
||
const scriptType = getScriptType(false, true); | ||
|
||
const lintErrors = getLintingErrors({ | ||
data, | ||
originalBinding, | ||
script, | ||
scriptType, | ||
}); | ||
|
||
expect(Array.isArray(lintErrors)).toBe(true); | ||
expect(lintErrors.length).toEqual(0); | ||
}); | ||
it("2. For setTimeout", () => { | ||
const originalBinding = "{{setTimeout()}}"; | ||
const script = "setTimeout()"; | ||
|
||
const scriptType = getScriptType(false, true); | ||
|
||
const lintErrors = getLintingErrors({ | ||
data, | ||
originalBinding, | ||
script, | ||
scriptType, | ||
}); | ||
|
||
expect(Array.isArray(lintErrors)).toBe(true); | ||
expect(lintErrors.length).toEqual(0); | ||
}); | ||
it("3. For console", () => { | ||
const originalBinding = "{{console.log()}}"; | ||
const script = "console.log()"; | ||
|
||
const scriptType = getScriptType(false, true); | ||
|
||
const lintErrors = getLintingErrors({ | ||
data, | ||
originalBinding, | ||
script, | ||
scriptType, | ||
}); | ||
|
||
expect(lintErrors.length).toEqual(0); | ||
}); | ||
}); | ||
|
||
describe("2. Verify lint errors are shown for unsupported window APIs", () => { | ||
const data = {}; | ||
it("1. For window", () => { | ||
const originalBinding = "{{window}}"; | ||
const script = "window"; | ||
|
||
const scriptType = getScriptType(false, true); | ||
|
||
const lintErrors = getLintingErrors({ | ||
data, | ||
originalBinding, | ||
script, | ||
scriptType, | ||
}); | ||
|
||
expect(lintErrors.length).toEqual(1); | ||
}); | ||
it("2. For document", () => { | ||
const originalBinding = "{{document}}"; | ||
const script = "document"; | ||
|
||
const scriptType = getScriptType(false, true); | ||
|
||
const lintErrors = getLintingErrors({ | ||
data, | ||
originalBinding, | ||
script, | ||
scriptType, | ||
}); | ||
|
||
expect(lintErrors.length).toEqual(1); | ||
}); | ||
it("3. For dom", () => { | ||
const originalBinding = "{{dom}}"; | ||
const script = "dom"; | ||
|
||
const scriptType = getScriptType(false, true); | ||
|
||
const lintErrors = getLintingErrors({ | ||
data, | ||
originalBinding, | ||
script, | ||
scriptType, | ||
}); | ||
|
||
expect(lintErrors.length).toEqual(1); | ||
}); | ||
}); | ||
}); |