-
Notifications
You must be signed in to change notification settings - Fork 76
Fix date payload type in ui-button
#2019
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
Conversation
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
Steve-Mcl
requested changes
Jan 19, 2026
Contributor
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.
Please also add tests. Here are some I prepared ealier...
test/nodes/widgets/ui_button.spec.js
near the top (in scope)
/** utility to wait for an event and return a promise */
function on (emitter, event) {
return new Promise((resolve) => {
emitter.on(event, resolve)
})
}towards the end of the test file
it('should receive an iso date in payload', async function () {
const copyOfFlow = JSON.parse(JSON.stringify(flow))
const buttonDefinition = copyOfFlow.find(n => n.id === 'node-ui-button')
buttonDefinition.payload = 'iso'
buttonDefinition.payloadType = 'date'
await helper.load(nodeImports, copyOfFlow)
verifyFlowLoaded(helper, copyOfFlow)
const base = helper.getNode('config-ui-base')
// setup a fake connection so that button has somewhere to emit to and we can spy on it
const socket = {
id: 'fake-conn-id',
emit: sinon.spy()
}
base.uiShared.connections['fake-conn-id'] = socket // fake connection so that button has somewhere to emit
// send a message to the button node
const button = helper.getNode('node-ui-button')
const hNode = helper.getNode('helper-node')
const inputPromise = on(hNode, 'input')
button.receive({})
const msg = await inputPromise
// tests
socket.emit.calledOnce.should.be.true()
const [eventName, message] = socket.emit.args[0] // [0][0] is the event name, [0][1] is the payload
eventName.should.equal('msg-input:' + button.id)
message.should.equal(msg)
msg.should.have.property('payload').and.be.a.String()
new Date(msg.payload).getTime().should.be.approximately(Date.now(), 500) // within 0.5 second
})
it('should receive a date object in payload', async function () {
const copyOfFlow = JSON.parse(JSON.stringify(flow))
const buttonDefinition = copyOfFlow.find(n => n.id === 'node-ui-button')
buttonDefinition.payload = 'object'
buttonDefinition.payloadType = 'date'
await helper.load(nodeImports, copyOfFlow)
verifyFlowLoaded(helper, copyOfFlow)
const base = helper.getNode('config-ui-base')
// setup a fake connection so that button has somewhere to emit to and we can spy on it
const socket = {
id: 'fake-conn-id',
emit: sinon.spy()
}
base.uiShared.connections['fake-conn-id'] = socket // fake connection so that button has somewhere to emit
// send a message to the button node
const button = helper.getNode('node-ui-button')
const hNode = helper.getNode('helper-node')
const inputPromise = on(hNode, 'input')
button.receive({})
const msg = await inputPromise
// tests
socket.emit.calledOnce.should.be.true()
const [eventName, message] = socket.emit.args[0] // [0][0] is the event name, [0][1] is the payload
eventName.should.equal('msg-input:' + button.id)
message.should.equal(msg)
msg.should.have.property('payload').and.be.an.instanceOf(Date)
msg.payload.getTime().should.be.approximately(Date.now(), 500) // within 0.5 second
})
it('should receive an epoch time value in payload', async function () {
const copyOfFlow = JSON.parse(JSON.stringify(flow))
const buttonDefinition = copyOfFlow.find(n => n.id === 'node-ui-button')
buttonDefinition.payload = '' // should be blank for epoch time
buttonDefinition.payloadType = 'date'
await helper.load(nodeImports, copyOfFlow)
verifyFlowLoaded(helper, copyOfFlow)
const base = helper.getNode('config-ui-base')
// setup a fake connection so that button has somewhere to emit to and we can spy on it
const socket = {
id: 'fake-conn-id',
emit: sinon.spy()
}
base.uiShared.connections['fake-conn-id'] = socket // fake connection so that button has somewhere to emit
// send a message to the button node
const button = helper.getNode('node-ui-button')
const hNode = helper.getNode('helper-node')
const inputPromise = on(hNode, 'input')
button.receive({})
const msg = await inputPromise
// tests
socket.emit.calledOnce.should.be.true()
const [eventName, message] = socket.emit.args[0] // [0][0] is the event name, [0][1] is the payload
eventName.should.equal('msg-input:' + button.id)
message.should.equal(msg)
msg.should.have.property('payload').and.be.a.Number()
msg.payload.should.be.approximately(Date.now(), 500) // within 0.5 second
})…evaluation to use the evaluateNodeProperty method
Steve-Mcl
approved these changes
Jan 21, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fix
ui-buttonpayload date format type selectionRelated Issue(s)
closes #2018
Checklist
flowforge.yml?FlowFuse/helmto update ConfigMap TemplateFlowFuse/CloudProjectto update values for Staging/ProductionLabels
area:migrationlabel