test(e2e): handle 2fa gracefully
This commit is contained in:
parent
7ad3ddbc0c
commit
38ad5b90e8
1 changed files with 11 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { describe, it } from 'mocha'
|
import { describe, it } from 'mocha'
|
||||||
|
|
||||||
import { MtUnsupportedError } from '@mtcute/core'
|
import { MtcuteError } from '@mtcute/core'
|
||||||
import { BaseTelegramClient, TelegramClient } from '@mtcute/core/client.js'
|
import { BaseTelegramClient, TelegramClient } from '@mtcute/core/client.js'
|
||||||
|
|
||||||
import { getApiParams } from '../utils.js'
|
import { getApiParams } from '../utils.js'
|
||||||
|
@ -32,10 +32,13 @@ describe('1. authorization', function () {
|
||||||
code: () => '22222',
|
code: () => '22222',
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof MtUnsupportedError && e.message.includes('Signup is no longer supported')) {
|
if (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) {
|
||||||
// retry with another number
|
// retry with another number
|
||||||
continue
|
continue
|
||||||
} else throw e
|
} else {
|
||||||
|
await tg.close()
|
||||||
|
throw e
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await tg.close()
|
await tg.close()
|
||||||
|
@ -64,10 +67,13 @@ describe('1. authorization', function () {
|
||||||
code: () => '11111',
|
code: () => '11111',
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof MtUnsupportedError && e.message.includes('Signup is no longer supported')) {
|
if (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) {
|
||||||
// retry with another number
|
// retry with another number
|
||||||
continue
|
continue
|
||||||
} else throw e
|
} else {
|
||||||
|
await tg.close()
|
||||||
|
throw e
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await tg.close()
|
await tg.close()
|
||||||
|
|
Loading…
Reference in a new issue