-
Notifications
You must be signed in to change notification settings - Fork 395
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
Adds view_closed support #276
Changes from all commits
250fc78
36f970d
9c4a075
cf03031
6b3564d
a28c65d
51e6811
ab6909f
c89ddbb
43f0ce0
479cf3a
b99bb8d
a7cd1d7
c4114be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -432,25 +432,24 @@ describe('App', () => { | |
team: {}, | ||
view: { | ||
callback_id: 'view_callback_id', | ||
} | ||
}, | ||
}, | ||
respond: noop, | ||
ack: noop, | ||
}, | ||
{ | ||
body: { | ||
type: 'view_closed', | ||
channel: {}, | ||
user: {}, | ||
team: {}, | ||
view: { | ||
callback_id: 'view_callback_id', | ||
}, | ||
}, | ||
respond: noop, | ||
ack: noop, | ||
}, | ||
// TODO: https://github.com/slackapi/bolt/issues/263 | ||
// { | ||
// body: { | ||
// type: 'view_closed', | ||
// channel: {}, | ||
// user: {}, | ||
// team: {}, | ||
// view: { | ||
// callback_id: 'view_callback_id', | ||
// } | ||
// }, | ||
// respond: noop, | ||
// ack: noop, | ||
// }, | ||
]; | ||
} | ||
|
||
|
@@ -467,11 +466,12 @@ describe('App', () => { | |
// Act | ||
const app = new App({ receiver: fakeReceiver, authorize: sinon.fake.resolves(dummyAuthorizationResult) }); | ||
app.use((_args) => { ackFn(); }); | ||
app.action('block_action_id', ({ }) => { actionFn(); }) | ||
app.action({ callback_id: 'message_action_callback_id' }, ({ }) => { actionFn(); }) | ||
app.action({ callback_id: 'interactive_message_callback_id' }, ({ }) => { actionFn(); }) | ||
app.action({ callback_id: 'dialog_submission_callback_id' }, ({ }) => { actionFn(); }) | ||
app.view('view_callback_id', ({ }) => { viewFn(); }) | ||
app.action('block_action_id', ({ }) => { actionFn(); }); | ||
app.action({ callback_id: 'message_action_callback_id' }, ({ }) => { actionFn(); }); | ||
app.action({ callback_id: 'interactive_message_callback_id' }, ({ }) => { actionFn(); }); | ||
app.action({ callback_id: 'dialog_submission_callback_id' }, ({ }) => { actionFn(); }); | ||
app.view('view_callback_id', ({ }) => { viewFn(); }); | ||
app.view({ callback_id: 'view_callback_id', type: 'view_closed' }, ({ }) => { viewFn(); }); | ||
Comment on lines
+473
to
+474
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi, I was looking for a way to listen to view closed actions and I stumbled upon this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to write a listener to handle both the submission and the close action in the same function and I expected to write There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, both listeners are triggered here. The following assertion Thus, as long as you set only callback_id to an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the quick reply. however, that's not what I experience. I have the following listeners: this.boltApp.view(FEEDBACK_NOTE_CALLBACK_ID, ({body, ack}) => this.handleFeedbackNoteCallback(body, ack, 'first'))
this.boltApp.view({callback_id: FEEDBACK_NOTE_CALLBACK_ID, type: 'view_closed'}, ({body, ack}) => this.handleFeedbackNoteCallback(body, ack, 'second')) I'm logging the "first" and "second" strings. When closing a modal, I just tested only the second function is called. |
||
app.options('external_select_action_id', ({ }) => { optionsFn(); }); | ||
app.options({ callback_id: 'dialog_suggestion_callback_id' }, ({ }) => { optionsFn(); }); | ||
|
||
|
@@ -481,7 +481,7 @@ describe('App', () => { | |
|
||
// Assert | ||
assert.equal(actionFn.callCount, 4); | ||
assert.equal(viewFn.callCount, 1); | ||
assert.equal(viewFn.callCount, 2); | ||
assert.equal(optionsFn.callCount, 2); | ||
assert.equal(ackFn.callCount, dummyReceiverEvents.length); | ||
assert(fakeErrorHandler.notCalled); | ||
|
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.
nit: we also can verify if the condition works by having the following lines in the test suite.