-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix for REST query string URL encoding #7795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,37 @@ | ||
import { breakQueryString, buildQueryString } from "../data/utils" | ||
|
||
describe("check query string utils", () => { | ||
const obj1 = { | ||
key1: "123", | ||
key2: " ", | ||
key3: "333", | ||
} | ||
|
||
const obj2 = { | ||
key1: "{{ binding.awd }}", | ||
key2: "{{ binding.sed }} ", | ||
} | ||
|
||
it("should build a basic query string", () => { | ||
const queryString = buildQueryString(obj1) | ||
expect(queryString).toBe("key1=123&key2=%20%20%20&key3=333") | ||
}) | ||
|
||
it("should be able to break a basic query string", () => { | ||
const broken = breakQueryString("key1=123&key2=%20%20%20&key3=333") | ||
expect(broken.key1).toBe(obj1.key1) | ||
expect(broken.key2).toBe(obj1.key2) | ||
expect(broken.key3).toBe(obj1.key3) | ||
}) | ||
|
||
it("should be able to build with a binding", () => { | ||
const queryString = buildQueryString(obj2) | ||
expect(queryString).toBe("key1={{ binding.awd }}&key2={{ binding.sed }}%20%20") | ||
}) | ||
|
||
it("should be able to break with a binding", () => { | ||
const broken = breakQueryString("key1={{ binding.awd }}&key2={{ binding.sed }}%20%20") | ||
expect(broken.key1).toBe(obj2.key1) | ||
expect(broken.key2).toBe(obj2.key2) | ||
}) | ||
}) |
This file contains hidden or 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 |
---|---|---|
|
@@ -708,6 +708,7 @@ | |
.url-block { | ||
display: flex; | ||
gap: var(--spacing-s); | ||
z-index: 200; | ||
} | ||
.verb { | ||
flex: 1; | ||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
28 changes: 14 additions & 14 deletions
28
.../src/stores/backend/tests/queries.spec.js → ...es/backend/tests/queries.spec.js.disabled
This file contains hidden or 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 |
---|---|---|
@@ -1,46 +1,46 @@ | ||
import { get } from 'svelte/store' | ||
import api from 'builderStore/api' | ||
import { get } from "svelte/store" | ||
import { API } from "api" | ||
|
||
jest.mock('builderStore/api'); | ||
jest.mock("api") | ||
|
||
import { SOME_QUERY, SAVE_QUERY_RESPONSE } from './fixtures/queries' | ||
import { SOME_QUERY, SAVE_QUERY_RESPONSE } from "./fixtures/queries" | ||
|
||
import { createQueriesStore } from "../queries" | ||
|
||
describe("Queries Store", () => { | ||
let store = createQueriesStore() | ||
|
||
beforeEach(async () => { | ||
api.get.mockReturnValue({ json: () => [SOME_QUERY]}) | ||
API.getQueries.mockReturnValue({ json: () => [SOME_QUERY]}) | ||
await store.init() | ||
}) | ||
|
||
it("Initialises correctly", async () => { | ||
api.get.mockReturnValue({ json: () => [SOME_QUERY]}) | ||
API.getQueries.mockReturnValue({ json: () => [SOME_QUERY]}) | ||
|
||
await store.init() | ||
expect(get(store)).toEqual({ list: [SOME_QUERY], selected: null}) | ||
}) | ||
|
||
it("fetches all the queries", async () => { | ||
api.get.mockReturnValue({ json: () => [SOME_QUERY]}) | ||
API.getQueries.mockReturnValue({ json: () => [SOME_QUERY]}) | ||
|
||
await store.fetch() | ||
expect(get(store)).toEqual({ list: [SOME_QUERY], selected: null}) | ||
expect(get(store)).toEqual({ list: [SOME_QUERY], selected: null}) | ||
}) | ||
|
||
it("saves the query, updates the store and returns status message", async () => { | ||
api.post.mockReturnValue({ json: () => SAVE_QUERY_RESPONSE}) | ||
API.saveQuery.mockReturnValue({ json: () => SAVE_QUERY_RESPONSE}) | ||
|
||
await store.select(SOME_QUERY.datasourceId, SOME_QUERY) | ||
|
||
expect(get(store).list).toEqual(expect.arrayContaining([SOME_QUERY])) | ||
}) | ||
it("deletes a query, updates the store and returns status message", async () => { | ||
api.delete.mockReturnValue({status: 200, message: `Query deleted.`}) | ||
|
||
API.deleteQuery.mockReturnValue({status: 200, message: `Query deleted.`}) | ||
|
||
await store.delete(SOME_QUERY) | ||
expect(get(store)).toEqual({ list: [], selected: null}) | ||
expect(get(store)).toEqual({ list: [], selected: null}) | ||
}) | ||
}) |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be really good to have a test for this, if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did my best to get jest tests working in the builder, had to remove some of the old (disabled) jest tests as they just don't work anymore and probably need re-thought.
This is probably something we need to extend out further - cypress is great but jest tests are nice for little unit test type things. I've made the (limited) builder tests part of CI so that they hopefully offer some value from here forward.