import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'

const unitId = 'SHEP-5-上-Unit2'
const topicUrl = new URL('../src/views/Editor/EnglishSpeaking/data/topicDiscussionTasks.json', import.meta.url)
const articleUrl = new URL('../src/views/Editor/EnglishSpeaking/data/articleReadingTasks.json', import.meta.url)
const topics = JSON.parse(await readFile(topicUrl, 'utf8'))
const articles = JSON.parse(await readFile(articleUrl, 'utf8'))

assert.equal(topics[unitId].length, 4)
assert.ok(topics[unitId].every(task => task.taskType === 'topic-discussion'))
assert.equal(articles[unitId].length, 1)

const article = articles[unitId][0]
assert.equal(article.id, 'ar-unit2-zoo')
assert.equal(article.taskType, 'article-reading')
assert.equal(article.titleEn, 'A Day at the Zoo')
assert.equal(article.durationMinutes, 10)
// 标题只住在 titleEn 里，**不再重复进正文**（2026-07-26 起）——
// 正文第一段就是第一段朗读内容，否则学生第一次录音录的是标题。
assert.ok(!article.content.startsWith(article.titleEn), 'title must not be duplicated into content')
assert.ok(article.content.startsWith('Last Sunday'))
assert.ok(article.content.endsWith('I learned many things about animals.'))
// 首尾由上面两条断言守住；这条只兜住"中段被删"，故用宽松下限而非精确值——
// 正文允许正常修订，但不该缩水到只剩几段。（enspeak 原文实测 829 字符。）
assert.ok(article.content.length > 700, 'full demo article must not be truncated')
