Skip to content

Commit

Permalink
Merge branch 'wechaty-main' into feat/channel-message-wechaty
Browse files Browse the repository at this point in the history
  • Loading branch information
hcfw007 committed Jun 25, 2023
2 parents 90349b2 + c70a9b4 commit c631eeb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechaty-puppet",
"version": "1.21.2",
"version": "1.21.3",
"description": "Abstract Puppet for Wechaty",
"type": "module",
"exports": {
Expand Down
4 changes: 4 additions & 0 deletions src/mixins/login-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ const loginMixin = <MixinBase extends typeof PuppetSkeleton>(mixinBase: MixinBas
contactId: this.currentUserId,
data: 'puppet stop()',
})
await new Promise<void>(resolve => setImmediate(() => {
this.__currentUserId = undefined
resolve()
}))
}

await super.stop()
Expand Down
1 change: 1 addition & 0 deletions src/schemas/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum MessageType {
Video = 15, // Video(4), Video(43)
Post = 16, // Moment, Channel, Tweet, etc
Channel = 17, // Channel
System = 18, // System Message
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/schemas/sayable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type SayablePayloadUnsupportedType =
| 'RedEnvelope'
| 'Transfer'
| 'Unknown'
| 'System'

export {
sayablePayloads,
Expand Down
25 changes: 25 additions & 0 deletions tests/login.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env -S node --no-warnings --loader ts-node/esm
// @ts-check

import { test } from 'tstest'

import { PuppetTest } from './fixtures/puppet-test/puppet-test.js'

test('login testing', async t => {

const puppet = new PuppetTest()

const USER_ID = 'test-user'
let userFromEvent = null
const future = new Promise<void>(resolve => puppet.on('login', user => {
userFromEvent = user.contactId
resolve()
}))
await puppet.start()
puppet.login(USER_ID)
await future

t.same(userFromEvent, USER_ID, `should get login event with ${USER_ID}`)
await puppet.stop()
t.notOk(puppet.isLoggedIn, 'puppet should not be logged in after stop')
})

0 comments on commit c631eeb

Please sign in to comment.