diff --git a/public/plugins/tests/chat.test.js b/public/plugins/tests/chat.test.js index 367a799..fa44953 100644 --- a/public/plugins/tests/chat.test.js +++ b/public/plugins/tests/chat.test.js @@ -1,4 +1,4 @@ -import { describe, it, expect, click, $, sleep, waitFor } from './runner.js?v=4'; +import { describe, it, expect, click, $, sleep, waitFor, csrf } from './runner.js?v=4'; // Chat plugin tests — UI-focused. No send/receive here: that would // require a real relay, and the user's "no mocks" rule means we don't @@ -120,19 +120,15 @@ describe('Chat: API', () => { it('/api/chat/thread-settings round-trips disposable flag', async () => { const peer = '__test_disposable_flip__'; - // Default: 0 const initial = await fetch('api/chat/thread-settings?peer=' + encodeURIComponent(peer)) .then(r => r.json()); expect(initial.disposable).toBe(0); - // Set to 1 - const csrf = document.querySelector('meta[name="csrf"]')?.content || ''; const set = await fetch('api/chat/thread-settings', { method: 'POST', - headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf }, + headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() }, body: JSON.stringify({ peer, disposable: true }), }).then(r => r.json()); expect(set.disposable).toBe(1); - // Verify const after = await fetch('api/chat/thread-settings?peer=' + encodeURIComponent(peer)) .then(r => r.json()); expect(after.disposable).toBe(1);