greentext

This commit is contained in:
Moon.eth
2026-07-30 20:22:52 +09:00
parent 657d517503
commit f735de5185
20 changed files with 530 additions and 26 deletions
+54
View File
@@ -0,0 +1,54 @@
import { describe, expect, it } from 'vitest'
import { account, status } from '$test/fixtures'
import { accountForStatus, isHelenepost } from './heleneposting'
describe('Heleneposting detection', () => {
it.each([
'<p>A note<br>-Helene</p>',
'<p>A note</p><p>-- Helene</p>',
'<p>A note &mdash;<strong>Helene</strong></p>',
'<blockquote>A note</blockquote><p>— Helene&nbsp;</p>',
'<div><span class="h-card">@sun</span> that is woke —helene</div>',
])('recognizes a signed HTML note: %s', (content) => {
expect(isHelenepost(content)).toBe(true)
})
it.each([
'<p>Helene</p>',
'<p>---Helene</p>',
'<p>—Helene!</p>',
'<p>—Helene wrote this</p>',
'<p>—helen</p>',
])('rejects content that is not an exact final signature: %s', (content) => {
expect(isHelenepost(content)).toBe(false)
})
it('substitutes presentation fields without changing account identity', () => {
const original = account({
id: 'actual-id',
acct: 'actual@remote.test',
display_name: 'Actual Author',
avatar: 'https://remote.test/avatar.png',
})
const presented = accountForStatus(
status({ account: original, content: '<p>Hello —Helene</p>' }),
true,
)
expect(presented).toMatchObject({
id: 'actual-id',
acct: 'actual@remote.test',
display_name: 'Helene',
})
expect(presented.avatar).toContain('helene')
expect(presented.avatar_static).toBe(presented.avatar)
expect(original.display_name).toBe('Actual Author')
})
it('does nothing while the feature is disabled', () => {
const original = account()
expect(
accountForStatus(status({ account: original, content: '<p>—Helene</p>' }), false),
).toBe(original)
})
})