-
-
Notifications
You must be signed in to change notification settings - Fork 830
Delayed events (Futures) / MSC4140 for call widget #12714
Conversation
I'll take this out of draft once the dependent js-sdk PR is merged. |
Note that the Static Analysis failure is also happening on develop. |
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.
Oh forgot how easy this is since all the work is done in the widget-api repo.
This is just the matrix part!
I am positive on this, bu Just to get you confirmation: also the capability checks are done in the widget-api right?
Yes they are, in src/ClientWidgetApi.ts |
The latest batch of commits is just a rebase on the |
stateKey?: string | null, | ||
targetRoomId?: string, | ||
stateKey: string | null = null, | ||
targetRoomId: string | null = null, |
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.
why the changes from undefined to null? I think in general intend want to move in the other direction.
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's to match the signature of WidgetApi#sendEvent
, which uses string | null = null
for these arguments.
It also struck me as dangerous to allow stateKey
to be undefined
or null
when there was only a !== null
check on it, and felt that restricting both parameters to just null
made things simpler.
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.
ok, it would probably be good to change the widget api at some point but that needn't be today
@@ -328,6 +333,93 @@ export class StopGapWidgetDriver extends WidgetDriver { | |||
return { roomId, eventId: r.event_id }; | |||
} | |||
|
|||
/** | |||
* @experimental Part of MSC4140 & MSC4157 | |||
*/ |
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.
Could this have some doc on the params please? For instance, I'm at a loss as to what parentDelayId
might be.
Also, what would it mean to pass null
to delay
here?
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.
Also, this is quite a lot of params for a function. May want to consider making it an object (although equally I guess we want it consistent with the rest of the API).
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.
This implements WidgetDriver#sendDelayedEvent
, which is present as of v1.8.0 & is where the documentation is. I'll add a @see
here to link to it.
Also, making this take an object would require updating the widget-api. It doesn't take an object for the sake of avoiding adding a new type in case the whole "parent" idea gets dropped.
await expect(driver.sendDelayedEvent(2000, null, EventType.RoomMessage, {})).resolves.toEqual({ | ||
roomId, | ||
delayId: "id", | ||
}); |
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.
Could do with an assertion that the client function is actually called in the way you think it should be called, otherwise this isn't testing what it claims to (same for the rest of these).
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.
Good catch, thanks!
|
||
beforeEach(() => { | ||
driver = mkDefaultDriver(); | ||
jest.spyOn(SdkContextClass.instance.roomViewStore, "getRoomId").mockReturnValue(roomId); |
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 remember to always call restoreAllMocks()
in an afterEach()
if you mock or spy on anything, otherwise your mocks will bleed into other tests.
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 turns out I don't need this after all, so I'll just get rid of it.
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.
looks good then!
I've rebased + squashed the commits to hide some of the churn that built up over time, and also wrote a more descriptive commit message. |
Depends on:
Signed-off-by: Andrew Ferrazzutti andrewf@element.io
Checklist
public
/exported
symbols have accurate TSDoc documentation.