test(e2e): gracefully handle SESSION_PASSWORD_NEEDED (again)

This commit is contained in:
alina 🌸 2024-05-03 05:43:51 +03:00
parent 8b80a3ddbe
commit 80ddf85083
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
2 changed files with 18 additions and 6 deletions

View file

@ -1,6 +1,6 @@
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 { getApiParams } from '../utils.ts'
@ -29,7 +29,10 @@ Deno.test('1. authorization', { sanitizeResources: false }, async (t) => {
code: () => '22222',
})
} 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
continue
} else {
@ -64,7 +67,10 @@ Deno.test('1. authorization', { sanitizeResources: false }, async (t) => {
code: () => '11111',
})
} 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
continue
} else {

View file

@ -1,7 +1,7 @@
import { expect } from 'chai'
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 { getApiParams } from '../utils.js'
@ -32,7 +32,10 @@ describe('1. authorization', function () {
code: () => '22222',
})
} 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
continue
} else {
@ -67,7 +70,10 @@ describe('1. authorization', function () {
code: () => '11111',
})
} 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
continue
} else {