Skip to content

Commit

Permalink
Merge pull request #6333 from TheThingsNetwork/fix/js-sdk-delete-query
Browse files Browse the repository at this point in the history
Send DELETE payload as search parameters for delete requests in JS SDK
  • Loading branch information
kschiffer authored Jun 27, 2023
2 parents 98e65a7 + 3238401 commit 1c42207
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ For details about compatibility between different releases, see the **Commitment

### Fixed

- Removing user invitations not working in the user management panel for administrators.
- Fix payload formatter page launching malformed requests in the Console.
- HTTP API routes for parsing QR codes for the QR Generator service. We exercise our right to break compatibility with third party HTTP clients since this is a bug.
- `/qr-code/end-devices/parse` is changed to `/qr-codes/end-devices/parse`.
Expand Down
14 changes: 9 additions & 5 deletions cypress/integration/console/devices/unclaim.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('Device un-claiming', () => {
})

it('succeeds un-claiming and deleting an end device', () => {
cy.intercept('DELETE', `/api/v3/edcs/claim/${appId}/devices/${endDeviceId}`, {}).as(
cy.intercept('DELETE', `/api/v3/edcs/claim/${appId}/devices/${endDeviceId}?*`, {}).as(
'unclaim-request',
)

Expand All @@ -86,10 +86,14 @@ describe('Device un-claiming', () => {
cy.findByRole('button', { name: /Unclaim and delete end device/ }).click()
})

cy.wait('@unclaim-request').its('request.body').should('deep.equal', {
dev_eui: ns.end_device.ids.dev_eui,
join_eui: '0000000000000000',
})
cy.wait('@unclaim-request')
.its('request.url')
.then(url => {
const params = new URLSearchParams(new URL(url).search)

expect(params.get('dev_eui')).to.equal(ns.end_device.ids.dev_eui)
expect(params.get('join_eui')).to.equal('0000000000000000')
})

cy.findByTestId('error-notification').should('not.exist')

Expand Down
2 changes: 1 addition & 1 deletion sdk/js/src/api/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Http {
url: endpoint,
}

if (method === 'get') {
if (method === 'get' || method === 'delete') {
// For GETs convert payload to query params (should usually
// be field_mask only).
config.params = this._payloadToQueryParams(payload)
Expand Down

0 comments on commit 1c42207

Please sign in to comment.