dsh-paste-code-block 0.2.5 → 0.2.6

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.
@@ -0,0 +1,71 @@
1
+ import { test } from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+
4
+ import { collectChipNodes, chipNodeOf } from '../src/chip-nodes.js'
5
+
6
+ /** Minimal stand-in for DSH's ReferenceChipNode. */
7
+ function chip(source, ref, extra = {}) {
8
+ return {
9
+ __source: source,
10
+ __ref: ref,
11
+ getSource() { return this.__source },
12
+ getReference() { return this.__ref },
13
+ remove() { this.removed = true },
14
+ ...extra,
15
+ }
16
+ }
17
+
18
+ const SOURCE = 'paste-code-block'
19
+
20
+ test('a node-map value IS a node (Lexical >= 0.21) and is recognized', () => {
21
+ const node = chip(SOURCE, 'r1')
22
+ // The v0.1.2 bug: the code read `value.node`, which is undefined for this
23
+ // exact shape, so every delete silently matched nothing.
24
+ assert.equal(node.node, undefined)
25
+ assert.equal(chipNodeOf(node), node)
26
+ })
27
+
28
+ test('a legacy NodeState wrapper still resolves to its node', () => {
29
+ const node = chip(SOURCE, 'r1')
30
+ assert.equal(chipNodeOf({ node }), node)
31
+ })
32
+
33
+ test('non-node values normalize to null', () => {
34
+ assert.equal(chipNodeOf(null), null)
35
+ assert.equal(chipNodeOf(undefined), null)
36
+ assert.equal(chipNodeOf({}), null)
37
+ assert.equal(chipNodeOf({ node: null }), null)
38
+ assert.equal(chipNodeOf({ node: { getSource: 'not a function' } }), null)
39
+ assert.equal(chipNodeOf('text'), null)
40
+ })
41
+
42
+ test('collection matches one source + ref and ignores everything else', () => {
43
+ const target = chip(SOURCE, 'r2')
44
+ const otherRef = chip(SOURCE, 'r9')
45
+ const otherSource = chip('dsh-file-upload', 'r2')
46
+ const hit = collectChipNodes([target, otherRef, otherSource], SOURCE, 'r2')
47
+ assert.deepEqual(hit, [target])
48
+ })
49
+
50
+ test('collection works on a Map.values() iterator (the real call shape)', () => {
51
+ const target = chip(SOURCE, 'r2')
52
+ const map = new Map([['k0', target], ['k1', chip(SOURCE, 'r1')], ['k2', { node: chip(SOURCE, 'r2') }]])
53
+ assert.deepEqual(collectChipNodes(map.values(), SOURCE, 'r2'), [target, map.get('k2').node])
54
+ })
55
+
56
+ test('collection is non-empty for node-valued entries (v0.1.2 silent no-op regression)', () => {
57
+ const values = [chip(SOURCE, 'r1'), chip(SOURCE, 'r2')]
58
+ assert.equal(collectChipNodes(values, SOURCE, 'r2').length, 1)
59
+ assert.equal(collectChipNodes(values, SOURCE, 'r3').length, 0)
60
+ })
61
+
62
+ test('duplicated chips for one ref are all collected', () => {
63
+ const first = chip(SOURCE, 'r5')
64
+ const second = chip(SOURCE, 'r5')
65
+ assert.deepEqual(collectChipNodes([first, second], SOURCE, 'r5'), [first, second])
66
+ })
67
+
68
+ test('a missing/empty value list collects nothing', () => {
69
+ assert.deepEqual(collectChipNodes(null, SOURCE, 'r1'), [])
70
+ assert.deepEqual(collectChipNodes([], SOURCE, 'r1'), [])
71
+ })
@@ -0,0 +1,9 @@
1
+ // GENERATED by _tools/gen-fixtures.mjs — do not edit by hand.
2
+ // Real DSH messages captured from the user's session logs:
3
+ // W a CLEAN sent message (0.2.5 serialised a prose paste as a text block)
4
+ // B the result of pasting W back into the composer (the 0.2.5 bug)
5
+ // P the original prose paste inside W, i.e. W's fence body
6
+ export const W = "```text\n\r\n更新\r\n@smalltailqwq/dsh-client-ui-skin-deep-whale-manager\r\nle. Reinstall that commit manually if needed.);请先检查该 profile,再重新启动。 / @smalltailqwq/dsh-client-ui-skin-deep-whale-manager update failed and restoration of the previous build could not be verified (更新前的 GitHub 来源使用 monorepo 子目录(提交 42ecc2a587c4276e6b65a01933505a42d7f31584),当前 DSH 命令无法表达该精确目标,因此自动回滚不可用;需要时请手工重新安装该提交。\r\n关闭此提示\r\n更新\r\naegis\r\n官方桌面客户端的这个插件操作需要在「设置 → 插件」里完成;市场无法通过命令行修改桌面端的 profile。\n```\n解决这个"
7
+ export const B = "```\n```text\r\n\r\n更新\r\n@smalltailqwq/dsh-client-ui-skin-deep-whale-manager\r\nle. Reinstall that commit manually if needed.);请先检查该 profile,再重新启动。 / @smalltailqwq/dsh-client-ui-skin-deep-whale-manager update failed and restoration of the previous build could not be verified (更新前的 GitHub 来源使用 monorepo 子目录(提交 42ecc2a587c4276e6b65a01933505a42d7f31584),当前 DSH 命令无法表达该精确目标,因此自动回滚不可用;需要时请手工重新安装该提交。\r\n关闭此提示\r\n更新\r\naegis\r\n官方桌面客户端的这个插件操作需要在「设置 → 插件」里完成;市场无法通过命令行修改桌面端的 profile。\r\n```\r\n解决这个\n```"
8
+ export const B2 = "```\n```text\n\n更新\n@smalltailqwq/dsh-client-ui-skin-deep-whale-manager\nle. Reinstall that commit manually if needed.);请先检查该 profile,再重新启动。 / @smalltailqwq/dsh-client-ui-skin-deep-whale-manager update failed and restoration of the previous build could not be verified (更新前的 GitHub 来源使用 monorepo 子目录(提交 42ecc2a587c4276e6b65a01933505a42d7f31584),当前 DSH 命令无法表达该精确目标,因此自动回滚不可用;需要时请手工重新安装该提交。\n关闭此提示\n更新\naegis\n官方桌面客户端的这个插件操作需要在「设置 → 插件」里完成;市场无法通过命令行修改桌面端的 profile。\n```\n测试,不需要执行\n```"
9
+ export const P = "\r\n更新\r\n@smalltailqwq/dsh-client-ui-skin-deep-whale-manager\r\nle. Reinstall that commit manually if needed.);请先检查该 profile,再重新启动。 / @smalltailqwq/dsh-client-ui-skin-deep-whale-manager update failed and restoration of the previous build could not be verified (更新前的 GitHub 来源使用 monorepo 子目录(提交 42ecc2a587c4276e6b65a01933505a42d7f31584),当前 DSH 命令无法表达该精确目标,因此自动回滚不可用;需要时请手工重新安装该提交。\r\n关闭此提示\r\n更新\r\naegis\r\n官方桌面客户端的这个插件操作需要在「设置 → 插件」里完成;市场无法通过命令行修改桌面端的 profile。"