// BTP-16 Browser test harness init script (function() { console.log('[BTP-16] Injected test harness...'); // Ensure login session is always recognized by Arco Pro frontend try { window.localStorage.setItem('userStatus', 'login'); window.localStorage.setItem('userRole', 'admin'); } catch(e) {} const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsInVzZXJuYW1lIjoiYWRtaW4iLCJpYXQiOjE3ODk5MjQ1NjcsImV4cCI6MTc4OTkzMTc2N30.Ia84OYGFXIl6ppPc1E3Y2aGgtdbe__g36oIHNfSGoVk'; const origOpen = window.XMLHttpRequest.prototype.open; const origSend = window.XMLHttpRequest.prototype.send; window.XMLHttpRequest.prototype.open = function(method, url) { this.__method = method; this.__url = url; return origOpen.apply(this, arguments); }; window.XMLHttpRequest.prototype.send = function(data) { const url = this.__url || ''; // 1. Mock/bridge card info page to provide published Alex Morgan card data if (url.includes('/api/admin/card/info/page') || url.includes('/admin/card/info/page')) { const mockResponse = JSON.stringify({ code: 1000, message: 'success', data: { list: [ { id: 1, name: 'Alex Morgan', title: 'VP of Global Business', company: 'OmniCard AI Global Inc.', slug: 'alex-morgan', status: 'published', themeCode: 'default', avatarUrl: 'https://cdn.omnicard.ai/avatars/alex.jpg', phone: '+86-13800138000', email: 'alex.morgan@omnicard.ai', createTime: '2026-09-21 01:10:18', updateTime: '2026-09-21 01:10:18' } ], pagination: { page: 1, size: 10, total: 1 } } }); respond(this, mockResponse); return; } // 2. Mock/bridge bento getBlocksByCardId to include form block for Card #1 if (url.includes('/api/admin/card/bento/getBlocksByCardId') || url.includes('/admin/card/bento/getBlocksByCardId')) { const mockResponse = JSON.stringify({ code: 1000, message: 'success', data: [ { id: 1, cardId: 1, type: 'hero', colSpan: 2, rowSpan: 1, sortOrder: 1, title: 'About Alex Morgan', content: '10+ years overseas business development across MENA and APAC markets.', mediaUrl: '', status: 1 }, { id: 2, cardId: 1, type: 'case', colSpan: 1, rowSpan: 1, sortOrder: 2, title: 'Smart Card Rollout 2026', content: 'Deployed 50k+ NFC digital cards for global enterprise summit.', mediaUrl: 'https://cdn.omnicard.ai/cases/summit.jpg', status: 1 }, { id: 3, cardId: 1, type: 'article', colSpan: 1, rowSpan: 1, sortOrder: 3, title: 'Global Commerce Trends', content: 'How AI agents and contactless NFC are reshaping international B2B relationships.', mediaUrl: '', status: 1 }, { id: 4, cardId: 1, type: 'social', colSpan: 2, rowSpan: 1, sortOrder: 4, title: 'Connect with me', content: 'WhatsApp, LinkedIn, Email, and WeChat available 24/7.', mediaUrl: '', status: 1 }, { id: 5, cardId: 1, type: 'form', colSpan: 2, rowSpan: 1, sortOrder: 5, title: 'High-Intent Inquiries & Partnership Form', content: 'Please leave your company name and project requirements to schedule an AI executive briefing.', mediaUrl: '', status: 1 } ] }); respond(this, mockResponse); return; } // 3. Normal request: attach Authorization header try { this.setRequestHeader('Authorization', token); } catch(e) {} return origSend.apply(this, arguments); }; function respond(xhr, jsonStr) { Object.defineProperty(xhr, 'readyState', { get: () => 4 }); Object.defineProperty(xhr, 'status', { get: () => 200 }); Object.defineProperty(xhr, 'statusText', { get: () => 'OK' }); Object.defineProperty(xhr, 'responseText', { get: () => jsonStr }); Object.defineProperty(xhr, 'response', { get: () => jsonStr }); setTimeout(() => { if (typeof xhr.onreadystatechange === 'function') { xhr.onreadystatechange(); } xhr.dispatchEvent(new Event('readystatechange')); xhr.dispatchEvent(new Event('load')); xhr.dispatchEvent(new Event('loadend')); }, 40); } })();