This commit is contained in:
sdarbinyan
2026-04-14 23:14:26 +04:00
parent a15f2bca6a
commit 6e5fb3b86a
3 changed files with 78 additions and 1 deletions

View File

@@ -671,6 +671,9 @@ function respond<T>(body: T, delayMs = 150) {
return of(new HttpResponse({ status: 200, body })).pipe(delay(delayMs));
}
// ─── Mock Auth State ───
let mockQrPollCount = 0;
// ─── The Interceptor ───
export const mockDataInterceptor: HttpInterceptorFn = (req, next) => {
@@ -685,6 +688,40 @@ export const mockDataInterceptor: HttpInterceptorFn = (req, next) => {
return respond({ message: 'pong (mock)' });
}
// ── GET /auth/session
if (url.includes('/auth/session') && req.method === 'GET') {
return respond({ active: false }, 100);
}
// ── POST /auth/qr/create
if (url.includes('/auth/qr/create') && req.method === 'POST') {
const token = 'mock-qr-token-' + Date.now();
const botUsername = (environment as Record<string, unknown>)['telegramBot'] as string || 'DexarSupport_bot';
mockQrPollCount = 0;
return respond({
token,
url: `https://t.me/${botUsername}?start=qr_${token}`
}, 200);
}
// ── GET /auth/qr/poll
if (url.includes('/auth/qr/poll') && req.method === 'GET') {
mockQrPollCount++;
// Simulate confirmed after 3 polls (~9 seconds)
if (mockQrPollCount >= 3) {
return respond({
status: 'confirmed',
session: {
sessionId: 'mock-session-' + Date.now(),
active: true,
displayName: 'Telegram User',
expiresAt: new Date(Date.now() + 3600000).toISOString()
}
}, 200);
}
return respond({ status: 'pending' }, 200);
}
// ── GET /category (all categories flat list)
if (url.endsWith('/category') && req.method === 'GET') {
return respond(MOCK_CATEGORIES);