dsh-progress-union 0.5.13 → 0.6.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ const end = src.indexOf('*/', endMark) + 2 // 含收尾注释,避免残留未
15
15
  const block = src.slice(begin, end)
16
16
  const GEN = (block.match(/var STAR_GEN = "([^"]*)";/) || [])[1]
17
17
  const NS = (block.match(/var STAR_NS = "([^"]*)";/) || [])[1]
18
- assert.ok(['v1', 'v2', 'v3'].includes(GEN), 'STAR_GEN 合法: ' + GEN)
18
+ assert.ok(['v1', 'v2', 'v3', 'v4'].includes(GEN), 'STAR_GEN 合法: ' + GEN)
19
19
  assert.equal(NS, 'progress-union', 'STAR_NS 固定为 im-union')
20
20
 
21
21
  // ── 最小 DOM ──
@@ -75,6 +75,7 @@ function find(el, pred, out = []) {
75
75
  const K1 = 'dsh.star.progress-union.dismissed'
76
76
  const K2 = 'dsh.star.progress-union.v2.dismissed'
77
77
  const K3 = 'dsh.star.progress-union.v3.supported'
78
+ const K4 = 'dsh.star.progress-union.v4.supported'
78
79
 
79
80
  test('star 面板:渲染出 GitHub 仓库链接(各代通用)', () => {
80
81
  const { mount } = runPanel('zh')
@@ -149,3 +150,32 @@ if (GEN === 'v3') {
149
150
  })
150
151
  }
151
152
 
153
+ if (GEN === 'v4') {
154
+ test('v4:三动作统一描边胶囊 dsh-star-btn;⭐/💬 只跳转不收敛,只有「我已支持」写 v4.supported', () => {
155
+ const { mount, env } = runPanel('zh')
156
+ assert.equal(mount.className, 'dsh-star-foot', 'v4 页脚')
157
+ const isBtn = (e) => (e.className || '').split(' ').includes('dsh-star-btn')
158
+ const caps = find(mount, isBtn)
159
+ assert.equal(caps.length, 3, 'v4 三个动作都是胶囊:⭐ / 我已支持 / 💬')
160
+ const sup = find(mount, (e) => e.className === 'dsh-star-btn dsh-star-support')
161
+ assert.equal(sup.length, 1, 'v4 一个「我已支持」胶囊按钮')
162
+ const star = find(mount, (e) => e.tagName === 'a' && (e.textContent || '').includes('⭐'))[0]
163
+ assert.ok(isBtn(star), '⭐ 是胶囊链接')
164
+ star.click()
165
+ assert.equal(env.localStorage.getItem(K4), null, '点 ⭐ 不写 supported')
166
+ sup[0].dispatch('click')
167
+ assert.equal(env.localStorage.getItem(K4), '1', '按「我已支持」写 v4.supported')
168
+ })
169
+ test('v4:加载即清 v3/v2/v1 三旧键、不迁值', () => {
170
+ const { env } = runPanel('zh', { [K1]: '1', [K2]: '1', [K3]: '1' })
171
+ assert.equal(env.localStorage.getItem(K1), null, 'v1 键清')
172
+ assert.equal(env.localStorage.getItem(K2), null, 'v2 键清')
173
+ assert.equal(env.localStorage.getItem(K3), null, 'v3 键清')
174
+ })
175
+ test('v4:已 supported → 收敛态(仓库地址 + 💬),无「我已支持」按钮', () => {
176
+ const { mount } = runPanel('zh', { [K4]: '1' })
177
+ assert.equal(mount.className, 'dsh-star-foot-collapsed', 'v4 收敛态')
178
+ assert.equal(find(mount, (e) => e.className === 'dsh-star-btn dsh-star-support').length, 0, '收敛后无按钮')
179
+ })
180
+ }
181
+