feat(admin): implement P4 management console
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { api, setCsrf } from '../src/api.js'
|
||||
|
||||
test('mutation sends the session CSRF token and credentials', async () => {
|
||||
let request
|
||||
globalThis.fetch = async (url, options) => {
|
||||
request = { url, options }
|
||||
return new Response(null, { status: 204 })
|
||||
}
|
||||
setCsrf('csrf-test')
|
||||
|
||||
await api('/tools/1/status', { method: 'PATCH', body: '{"status":0}' })
|
||||
|
||||
assert.equal(request.url, '/api/admin/tools/1/status')
|
||||
assert.equal(request.options.credentials, 'same-origin')
|
||||
assert.equal(request.options.headers['X-CSRF-Token'], 'csrf-test')
|
||||
assert.equal(request.options.headers['Content-Type'], 'application/json')
|
||||
})
|
||||
Reference in New Issue
Block a user