test(e2e): gracefully handle SESSION_PASSWORD_NEEDED (again)
This commit is contained in:
parent
8b80a3ddbe
commit
80ddf85083
2 changed files with 18 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { assertEquals } from 'https://deno.land/std@0.223.0/assert/mod.ts'
|
import { assertEquals } from 'https://deno.land/std@0.223.0/assert/mod.ts'
|
||||||
|
|
||||||
import { MtcuteError } from '@mtcute/core'
|
import { MtcuteError, tl } from '@mtcute/core'
|
||||||
import { BaseTelegramClient, TelegramClient } from '@mtcute/core/client.js'
|
import { BaseTelegramClient, TelegramClient } from '@mtcute/core/client.js'
|
||||||
|
|
||||||
import { getApiParams } from '../utils.ts'
|
import { getApiParams } from '../utils.ts'
|
||||||
|
@ -29,7 +29,10 @@ Deno.test('1. authorization', { sanitizeResources: false }, async (t) => {
|
||||||
code: () => '22222',
|
code: () => '22222',
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) {
|
if (
|
||||||
|
(e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) ||
|
||||||
|
tl.RpcError.is(e, 'SESSION_PASSWORD_NEEDED')
|
||||||
|
) {
|
||||||
// retry with another number
|
// retry with another number
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,7 +67,10 @@ Deno.test('1. authorization', { sanitizeResources: false }, async (t) => {
|
||||||
code: () => '11111',
|
code: () => '11111',
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) {
|
if (
|
||||||
|
(e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) ||
|
||||||
|
tl.RpcError.is(e, 'SESSION_PASSWORD_NEEDED')
|
||||||
|
) {
|
||||||
// retry with another number
|
// retry with another number
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { describe, it } from 'mocha'
|
import { describe, it } from 'mocha'
|
||||||
|
|
||||||
import { MtcuteError } from '@mtcute/core'
|
import { MtcuteError, tl } 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,7 +32,10 @@ describe('1. authorization', function () {
|
||||||
code: () => '22222',
|
code: () => '22222',
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) {
|
if (
|
||||||
|
(e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) ||
|
||||||
|
tl.RpcError.is(e, 'SESSION_PASSWORD_NEEDED')
|
||||||
|
) {
|
||||||
// retry with another number
|
// retry with another number
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
@ -67,7 +70,10 @@ describe('1. authorization', function () {
|
||||||
code: () => '11111',
|
code: () => '11111',
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) {
|
if (
|
||||||
|
(e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) ||
|
||||||
|
tl.RpcError.is(e, 'SESSION_PASSWORD_NEEDED')
|
||||||
|
) {
|
||||||
// retry with another number
|
// retry with another number
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue