import assert from 'node:assert/strict'; import { createHash } from 'node:crypto'; import { readFile } from 'node:fs/promises'; import test from 'node:test'; import { createElement } from 'react'; import { renderToStaticMarkup } from 'react-dom/server'; import { MobileTabbar } from '../src/components/layout/MobileTabbar'; const render = (requestPath?: string, favorites?: unknown[]) => renderToStaticMarkup(createElement(MobileTabbar, { data: { requestPath, favorites } })); test('mobile navigation follows the Figma page whitelist and current route', () => { for (const [path, current] of [['/', '/'], ["/dramas/", "/dramas/"], ["/dramas/all/page/2/", "/dramas/"], ['/series/', '/series/'], ['/series/anime/12/2/', '/series/']] as const) { const html = render(path, []); assert.equal((html.match(/data-navigation-key=/g) || []).length, 3, path); assert.doesNotMatch(html, /mobile_mine|我的|\/account\//, path); assert.equal((html.match(/aria-current="page"/g) || []).length, 1, path); assert.ok(html.includes(`href="${current}" aria-current="page"`), path); assert.match(html, /mobile-tabbar\/\w+-active\.svg/); } for (const path of ["/account/", "/account/favorites/", "/account/login/", "/account/register/", "/discover/search/", "/drama/1/", "/series/watch/1/", "/account/recharge/", "/account/history/", "/account/purchases/", "/account/settings/", '/about/', '/help/', '/terms/', '/privacy/', '/feedback/', "/collections/", "/rankings/", '/404/']) { assert.doesNotMatch(render(path), /