From 23f82dc728d655ab663b171a97deaf159967a7ee Mon Sep 17 00:00:00 2001 From: qiqi Date: Fri, 20 Nov 2026 12:59:56 +0800 Subject: [PATCH] =?UTF-8?q?test(gallery):=20=E6=96=AD=E8=A8=80=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=A0=B7=E5=BC=8F=E7=94=9F=E6=95=88=EF=BC=88=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E6=97=A0=E6=A1=86=E6=97=A0=E5=BA=95=E8=89=B2=E3=80=81?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=BB=84=E6=A8=AA=E6=8E=92=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/plugin-gallery-recovery-test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/plugin-gallery-recovery-test.js b/tests/plugin-gallery-recovery-test.js index 2f0c1f4..71f4c9c 100644 --- a/tests/plugin-gallery-recovery-test.js +++ b/tests/plugin-gallery-recovery-test.js @@ -11,6 +11,8 @@ const vm = require('vm') const { JSDOM } = require('jsdom') const src = fs.readFileSync(path.resolve(__dirname, '..', '..', 'iwb-plugins-desktop', 'gallery', 'src', 'index.js'), 'utf8') +// 插件自带样式:图标按钮无外框、工具组横排,靠这份 CSS 保证(不依赖客户端 style.css) +const pluginCss = fs.readFileSync(path.resolve(__dirname, '..', '..', 'iwb-plugins-desktop', 'gallery', 'styles.css'), 'utf8') const wait = (ms) => new Promise((r) => setTimeout(r, ms)) @@ -43,6 +45,10 @@ async function boot ({ items, thumb, clock }) { remove: async () => ({ ok: true }), }, } + const styleTag = window.document.createElement('style') + styleTag.textContent = pluginCss + window.document.head.appendChild(styleTag) + registered[0].factory(ctx) const node = window.document.getElementById('host') mounted(node) @@ -94,6 +100,7 @@ async function boot ({ items, thumb, clock }) { // 底部「刷新」按钮:随时强制重拉 const tools = env.node.querySelector('.iwb-gal-tools') + assert.strictEqual(env.window.getComputedStyle(tools).display, 'flex', '工具组应为横排 flex(否则图标会竖排)') assert.ok(tools, '底栏应有右侧工具组') const footBtns = Array.from(tools.querySelectorAll('button')) assert.strictEqual(footBtns.length, 2, '工具组应为刷新+设置两个图标,实际 ' + footBtns.length) @@ -104,6 +111,9 @@ async function boot ({ items, thumb, clock }) { // 图标按钮:不显示文字,只有 svg assert.strictEqual(btn.textContent.trim(), '', '刷新按钮不应再显示文字(窄栏会被挤成竖排)') assert.ok(btn.querySelector('svg'), '刷新按钮应有 svg 图标') + const cs = env.window.getComputedStyle(btn) + assert.strictEqual(cs.borderTopWidth, '0px', '图标按钮不应有外框(实际 ' + cs.borderTopWidth + ')') + assert.strictEqual(cs.backgroundColor, 'rgba(0, 0, 0, 0)', '图标按钮不应有底色(实际 ' + cs.backgroundColor + ')') btn.dispatchEvent(new env.window.MouseEvent('click', { bubbles: true })) await wait(60) assert.strictEqual(env.calls.list, 3, '点「刷新」应重拉列表,实际 ' + env.calls.list)