Skip to content
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

fix: missing statusCode when updating meta over WebSocket with put message #1511

Merged
merged 2 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ function putPath(app, contextParam, path, body, req, requestId, updateCb) {
if (reply.state === 'PENDING') {
// backwards compatibility
reply.action = { href: reply.href }
reply.statusCode = 202
}
resolve(reply)
})
Expand Down
1 change: 1 addition & 0 deletions src/requestResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function createRequest(app, type, clientRequest, user, clientIp, updateCb) {
ip: clientIp || undefined,
date: new Date(),
state: 'PENDING',
statusCode: 202,
updateCb: updateCb,
user: user || undefined
}
Expand Down
19 changes: 10 additions & 9 deletions test/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Put Requests', () => {
result.status.should.equal(405)
})

it('HTTP successfull put', async function () {
it('HTTP successful PUT', async function () {
let result = await fetch(
`${url}/signalk/v1/api/vessels/self/electrical/switches/switch2.state`,
{
Expand All @@ -95,20 +95,21 @@ describe('Put Requests', () => {

result.status.should.equal(202)

let json = await result.json()
json.should.have.property('state')
json.state.should.equal('PENDING')
json.should.have.property('href')
let response = await result.json()
response.should.have.property('state')
response.state.should.equal('PENDING')
response.statusCode.should.equal(202)
response.should.have.property('href')

await sleep(200)

result = await fetch(`${url}${json.href}`)
result = await fetch(`${url}${response.href}`)

result.status.should.equal(200)

json = await result.json()
json.should.have.property('state')
json.state.should.equal('COMPLETED')
response = await result.json()
response.should.have.property('state')
response.state.should.equal('COMPLETED')
})

it('HTTP successfull meta put', async function () {
Expand Down