dsh-delete-session 0.3.1 → 0.3.2
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.
- package/README.md +7 -0
- package/package.json +1 -1
- package/src/client.js +62 -8
- package/test/checkbox.dom.test.js +155 -77
package/README.md
CHANGED
|
@@ -162,6 +162,13 @@ MIT
|
|
|
162
162
|
|
|
163
163
|
## 修复记录
|
|
164
164
|
|
|
165
|
+
**(v0.3.2)** —— 语言跟随 DSH 的界面语言,而不是操作系统。
|
|
166
|
+
|
|
167
|
+
- **问题**:插件的语言只认 `navigator.language`。OS 是英文、DSH 设成中文的用户,看到的是全英文界面,而且没有任何办法改([#3](https://github.com/DDDMUC/dsh-delete-session/issues/3))。
|
|
168
|
+
- **现在跟随宿主**:先读 `locale` 服务的 `getSnapshot().active`(`dsh-client-locale` 就是这么暴露当前语言的);服务取不到就读 `document.documentElement.lang`(宿主每次切换都会把选择同步到这里);两者都没有才退回浏览器语言。
|
|
169
|
+
- **宿主语言我们没收录时的落点**:DSH 自己还认识 ja/es/fr/de/pt。这些没有对应字典,宿主对它们也只会答英文,所以插件答英文 —— 而不是像原来那样直接从浏览器猜,猜不到就掉回中文。
|
|
170
|
+
- **菜单和底栏不能再分裂**:原来会话菜单对 zh/en 一律交给宿主翻译,只有俄语才用插件字典。跟随宿主语言之后这条规则会让同一种语言出现两个来源 —— DSH 设成英文时菜单英文、底栏和弹窗中文。现在统一先查插件字典,未收录的键才交给宿主。
|
|
171
|
+
- **切换语言即时生效**:订阅 `locale.subscribe()`,宿主改语言时底栏和弹窗跟着重渲染,不需要刷新页面。
|
|
165
172
|
**(v0.3.1)** —— 批量删除也会处理产出文件了。
|
|
166
173
|
|
|
167
174
|
- **批量删除原来完全不碰产出文件**:单删会带上 `quarantine`,批量那条却调 `postDelete(id)` 什么都不传,宿主按缺省当「不动文件」。于是用户明明开着「产出文件默认全部进隔离夹」,批量删时文件**原地留着**,而且没有任何提示——看起来像做了,其实没做。现在两条路径共用 `quarantinePlan()`。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-delete-session",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Delete sessions from the DSH Web sidebar: adds a Delete action to the session row menu with a risk-consent dialog, sends the session log, workspace accounting and live session state to the system trash (or removes them outright), and, when opted in, quarantines the files the conversation produced.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/client.js
CHANGED
|
@@ -359,11 +359,52 @@ window.__ModuleLoader__.load({
|
|
|
359
359
|
let sessionsSvc = null
|
|
360
360
|
let localeSvc = null
|
|
361
361
|
|
|
362
|
+
/** Languages this plugin ships dictionaries for. */
|
|
363
|
+
const SHIPPED = ['zh', 'en', 'ru']
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* The language DSH itself is showing, or null when the host offers none.
|
|
367
|
+
*
|
|
368
|
+
* `dsh-client-locale` provides a `locale` service: `getSnapshot()` returns
|
|
369
|
+
* `{ active }` and `subscribe()` fires on every change. It also mirrors the
|
|
370
|
+
* choice onto `document.documentElement.lang`, which covers the case where the
|
|
371
|
+
* service is not reachable but the page has already been localised.
|
|
372
|
+
*/
|
|
373
|
+
function hostLang() {
|
|
374
|
+
if (localeSvc !== null && typeof localeSvc.getSnapshot === 'function') {
|
|
375
|
+
try {
|
|
376
|
+
const snapshot = localeSvc.getSnapshot()
|
|
377
|
+
const active = snapshot && typeof snapshot.active === 'string' ? snapshot.active : null
|
|
378
|
+
if (active !== null) return active
|
|
379
|
+
} catch { /* fall through to the document hint */ }
|
|
380
|
+
}
|
|
381
|
+
if (typeof document !== 'undefined' && document.documentElement) {
|
|
382
|
+
const html = document.documentElement.lang
|
|
383
|
+
if (typeof html === 'string' && html !== '') return html
|
|
384
|
+
}
|
|
385
|
+
return null
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Which of our dictionaries to read.
|
|
390
|
+
*
|
|
391
|
+
* The host is authoritative and the browser is the fallback: following
|
|
392
|
+
* `navigator.language` alone meant an English OS rendered an English plugin
|
|
393
|
+
* even with DSH switched to 中文. A host language we do not ship (DSH knows
|
|
394
|
+
* ja/es/fr/de/pt as well) falls back to Russian for ru, English for the rest,
|
|
395
|
+
* because the host would also answer in one of those two.
|
|
396
|
+
*/
|
|
362
397
|
function browserLang() {
|
|
398
|
+
const host = hostLang()
|
|
399
|
+
if (host !== null) {
|
|
400
|
+
const primary = String(host).toLowerCase().split('-')[0]
|
|
401
|
+
if (primary === 'zh' || primary === 'en' || primary === 'ru') return primary
|
|
402
|
+
return primary === 'ru' ? 'ru' : 'en'
|
|
403
|
+
}
|
|
363
404
|
if (typeof navigator === 'undefined') return 'zh'
|
|
364
405
|
for (const tag of (navigator.languages || []).concat([navigator.language])) {
|
|
365
406
|
const primary = String(tag || '').toLowerCase().split('-')[0]
|
|
366
|
-
if (primary
|
|
407
|
+
if (SHIPPED.indexOf(primary) !== -1) return primary
|
|
367
408
|
}
|
|
368
409
|
return 'zh'
|
|
369
410
|
}
|
|
@@ -444,17 +485,18 @@ window.__ModuleLoader__.load({
|
|
|
444
485
|
}
|
|
445
486
|
|
|
446
487
|
/**
|
|
447
|
-
*
|
|
488
|
+
* The translator every slot component renders through.
|
|
448
489
|
*
|
|
449
|
-
* The
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
490
|
+
* The plugin ships its own dictionaries and follows the host's language
|
|
491
|
+
* (issue #3), so its dictionary is asked first for every language it carries,
|
|
492
|
+
* not just Russian. Deferring to the injected `t` for zh/en would split one
|
|
493
|
+
* language across two authorities: with DSH set to English the menu would say
|
|
494
|
+
* "Delete session" while the bar and the dialog stayed Chinese. Keys this
|
|
495
|
+
* plugin does not ship still go to the host.
|
|
454
496
|
*/
|
|
455
497
|
function slotTranslator(injected) {
|
|
456
498
|
const raw = typeof injected === 'function' ? injected : t
|
|
457
|
-
return
|
|
499
|
+
return localizedTranslator(raw)
|
|
458
500
|
}
|
|
459
501
|
|
|
460
502
|
// --- state -----------------------------------------------------------------
|
|
@@ -2741,8 +2783,20 @@ window.__ModuleLoader__.load({
|
|
|
2741
2783
|
// printing raw keys ("multiSelect", "menu"). `ctx.effect` ties the
|
|
2742
2784
|
// registration's lifetime to the plugin, matching ui-workspace.
|
|
2743
2785
|
let localeRegistered = false
|
|
2786
|
+
let localeSubscribed = false
|
|
2744
2787
|
const adoptLocale = (svc) => {
|
|
2745
2788
|
localeSvc = svc || null
|
|
2789
|
+
// The bar, the dialog and the toasts are rendered by this plugin, so they
|
|
2790
|
+
// do not inherit the host's re-render when the language changes in the
|
|
2791
|
+
// settings. Piggy-backing on the service's own notification keeps them in
|
|
2792
|
+
// step with the menu rows, which the host and re-render itself.
|
|
2793
|
+
if (localeSvc !== null && typeof localeSvc.subscribe === 'function' && !localeSubscribed) {
|
|
2794
|
+
localeSubscribed = true
|
|
2795
|
+
try {
|
|
2796
|
+
const off = localeSvc.subscribe(() => { try { publish() } catch { /* not mounted yet */ } })
|
|
2797
|
+
if (typeof ctx.effect === 'function' && typeof off === 'function') ctx.effect(() => off, `${NS}: language changes`)
|
|
2798
|
+
} catch { /* a host without subscribe still renders on its own */ }
|
|
2799
|
+
}
|
|
2746
2800
|
if (localeRegistered || !localeSvc || typeof localeSvc.register !== 'function') return
|
|
2747
2801
|
localeRegistered = true
|
|
2748
2802
|
const register = () => localeSvc.register(NS, { zh, en, ru })
|
|
@@ -257,6 +257,8 @@ async function loadPlugin(options = {}) {
|
|
|
257
257
|
const document = {
|
|
258
258
|
body: new StubElement('body'),
|
|
259
259
|
head: new StubElement('head'),
|
|
260
|
+
// Read when the host provides no locale service at all.
|
|
261
|
+
documentElement: new StubElement('html'),
|
|
260
262
|
createElement: (tag) => new StubElement(tag),
|
|
261
263
|
addEventListener(type, handler) {
|
|
262
264
|
const list = documentListeners.get(type) ?? []
|
|
@@ -399,6 +401,11 @@ async function loadPlugin(options = {}) {
|
|
|
399
401
|
const locales = {}
|
|
400
402
|
const localeStub = {
|
|
401
403
|
register: (namespace, dictionaries) => { locales[namespace] = dictionaries },
|
|
404
|
+
// `dsh-client-locale` exposes `getSnapshot() -> { active }`. The plugin follows
|
|
405
|
+
// it instead of `navigator.language`, so an English OS with DSH in Chinese no
|
|
406
|
+
// longer renders an English plugin (issue #3).
|
|
407
|
+
getSnapshot: () => ({ active: options.activeLocale ?? 'zh', locales: [], revision: 0 }),
|
|
408
|
+
subscribe: () => () => {},
|
|
402
409
|
// Mirrors dsh-client-locale: a non-string entry is handed back untouched, and
|
|
403
410
|
// only string templates interpolate `{name}` from a params object. Returning
|
|
404
411
|
// a function as-is is exactly what makes the plugin fall back to its own
|
|
@@ -449,11 +456,14 @@ async function loadPlugin(options = {}) {
|
|
|
449
456
|
if (name === 'slots') return slotsStub
|
|
450
457
|
// `lateLocale` models a host where the locale service is only reachable
|
|
451
458
|
// through ctx.inject, which is the path that used to skip registration.
|
|
452
|
-
if (name === 'locale') return options.lateLocale ? null : localeStub
|
|
459
|
+
if (name === 'locale') return (options.lateLocale || options.noLocale) ? null : localeStub
|
|
453
460
|
return null
|
|
454
461
|
},
|
|
455
462
|
inject: (names, cb) => {
|
|
456
|
-
if (typeof cb === 'function')
|
|
463
|
+
if (typeof cb === 'function') {
|
|
464
|
+
const late = options.lateLocale && !options.noLocale
|
|
465
|
+
cb(late ? { slots: slotsStub, locale: localeStub } : { slots: slotsStub })
|
|
466
|
+
}
|
|
457
467
|
},
|
|
458
468
|
effect: (fn) => { const dispose = fn(); return () => { if (typeof dispose === 'function') dispose() } },
|
|
459
469
|
})
|
|
@@ -723,8 +733,69 @@ test('the Russian dictionary ships with every key the other dictionaries carry',
|
|
|
723
733
|
assert.deepEqual(keys(en), keys(zh), 'en still covers the zh key set')
|
|
724
734
|
})
|
|
725
735
|
|
|
726
|
-
test('
|
|
727
|
-
const harness = await loadPlugin()
|
|
736
|
+
test('an English OS with DSH in Chinese renders Chinese (issue #3)', async () => {
|
|
737
|
+
const harness = await loadPlugin({ activeLocale: 'zh' })
|
|
738
|
+
const previous = globalThis.navigator
|
|
739
|
+
Object.defineProperty(globalThis, 'navigator', {
|
|
740
|
+
value: { language: 'en-US', languages: ['en-US'] },
|
|
741
|
+
configurable: true,
|
|
742
|
+
writable: true,
|
|
743
|
+
})
|
|
744
|
+
try {
|
|
745
|
+
// The reported bug: the OS is English, the user set DSH to 中文, and the plugin
|
|
746
|
+
// still answered in English because it read `navigator.language`. The host is
|
|
747
|
+
// the authority now, so the browser language must not win.
|
|
748
|
+
assert.equal(deleteRow(harness).element.props.children, '删除会话')
|
|
749
|
+
assert.equal(selectRow(harness).element.props.children, '多选')
|
|
750
|
+
} finally {
|
|
751
|
+
Object.defineProperty(globalThis, 'navigator', {
|
|
752
|
+
value: previous,
|
|
753
|
+
configurable: true,
|
|
754
|
+
writable: true,
|
|
755
|
+
})
|
|
756
|
+
}
|
|
757
|
+
})
|
|
758
|
+
|
|
759
|
+
test('a Chinese OS with DSH in English renders English', async () => {
|
|
760
|
+
const harness = await loadPlugin({ activeLocale: 'en' })
|
|
761
|
+
const previous = globalThis.navigator
|
|
762
|
+
Object.defineProperty(globalThis, 'navigator', {
|
|
763
|
+
value: { language: 'zh-CN', languages: ['zh-CN'] },
|
|
764
|
+
configurable: true,
|
|
765
|
+
writable: true,
|
|
766
|
+
})
|
|
767
|
+
try {
|
|
768
|
+
assert.equal(deleteRow(harness).element.props.children, 'Delete session')
|
|
769
|
+
assert.equal(selectRow(harness).element.props.children, 'Select multiple')
|
|
770
|
+
} finally {
|
|
771
|
+
Object.defineProperty(globalThis, 'navigator', {
|
|
772
|
+
value: previous,
|
|
773
|
+
configurable: true,
|
|
774
|
+
writable: true,
|
|
775
|
+
})
|
|
776
|
+
}
|
|
777
|
+
})
|
|
778
|
+
|
|
779
|
+
test('a host language we do not ship falls back to English', async () => {
|
|
780
|
+
const harness = await loadPlugin({ activeLocale: 'ja' })
|
|
781
|
+
|
|
782
|
+
// DSH knows ja/es/fr/de/pt as well. Those have no dictionary here, and the host
|
|
783
|
+
// would answer in English for them, so the plugin does too instead of silently
|
|
784
|
+
// dropping to Chinese (which is what the old browser-based fallback did).
|
|
785
|
+
assert.equal(deleteRow(harness).element.props.children, 'Delete session')
|
|
786
|
+
})
|
|
787
|
+
|
|
788
|
+
test('with no locale service the document hint decides', async () => {
|
|
789
|
+
const harness = await loadPlugin({ lateLocale: true, noLocale: true })
|
|
790
|
+
harness.document.documentElement.lang = 'ru'
|
|
791
|
+
|
|
792
|
+
// `dsh-client-locale` mirrors its choice onto `<html lang>`. A host that never
|
|
793
|
+
// hands over the service still leaves that behind, so it is read next.
|
|
794
|
+
assert.equal(deleteRow(harness).element.props.children, 'Удалить сессию')
|
|
795
|
+
})
|
|
796
|
+
|
|
797
|
+
test('with neither hint the browser language is the last resort', async () => {
|
|
798
|
+
const harness = await loadPlugin({ noLocale: true })
|
|
728
799
|
const previous = globalThis.navigator
|
|
729
800
|
Object.defineProperty(globalThis, 'navigator', {
|
|
730
801
|
value: { language: 'ru-RU', languages: ['ru-RU'] },
|
|
@@ -732,10 +803,9 @@ test('a Russian browser gets Russian labels from the built-in dictionary', async
|
|
|
732
803
|
writable: true,
|
|
733
804
|
})
|
|
734
805
|
try {
|
|
735
|
-
//
|
|
736
|
-
//
|
|
806
|
+
// Pre-#3 behaviour, kept as the floor: something has to answer when the host
|
|
807
|
+
// provides nothing at all.
|
|
737
808
|
assert.equal(deleteRow(harness).element.props.children, 'Удалить сессию')
|
|
738
|
-
assert.equal(selectRow(harness).element.props.children, 'Выбрать несколько')
|
|
739
809
|
} finally {
|
|
740
810
|
Object.defineProperty(globalThis, 'navigator', {
|
|
741
811
|
value: previous,
|
|
@@ -744,6 +814,14 @@ test('a Russian browser gets Russian labels from the built-in dictionary', async
|
|
|
744
814
|
})
|
|
745
815
|
}
|
|
746
816
|
})
|
|
817
|
+
test('a Russian DSH gets Russian labels from the built-in dictionary', async () => {
|
|
818
|
+
const harness = await loadPlugin({ activeLocale: 'ru' })
|
|
819
|
+
|
|
820
|
+
// The host translator in this harness answers in zh; the rows must prefer the
|
|
821
|
+
// plugin's own Russian dictionary instead of following it.
|
|
822
|
+
assert.equal(deleteRow(harness).element.props.children, 'Удалить сессию')
|
|
823
|
+
assert.equal(selectRow(harness).element.props.children, 'Выбрать несколько')
|
|
824
|
+
})
|
|
747
825
|
|
|
748
826
|
test('the delete row asks the host for its danger styling', async () => {
|
|
749
827
|
const harness = await loadPlugin()
|
|
@@ -3591,73 +3669,73 @@ test('a workspace box never reaches into a nested workspace', async () => {
|
|
|
3591
3669
|
|
|
3592
3670
|
const box = header.querySelector('.dsdel-select-all')
|
|
3593
3671
|
assert.deepEqual(box.__dsdelIds, [SESSION_A.id], 'only the outer group\'s own session')
|
|
3594
|
-
})
|
|
3595
|
-
|
|
3596
|
-
test('multi-select delete carries the artifact switch to every request', async () => {
|
|
3597
|
-
const harness = await loadPlugin({ plan: PLAN })
|
|
3598
|
-
localStorage.setItem(OFF_KEY, '0')
|
|
3599
|
-
localStorage.setItem(AUTO_KEY, '1')
|
|
3600
|
-
localStorage.setItem(SKIP_KEY, '1')
|
|
3601
|
-
const first = mountRow(harness, SESSION_A)
|
|
3602
|
-
const second = mountRow(harness, SESSION_B)
|
|
3603
|
-
await enterMulti(harness)
|
|
3604
|
-
clickRowIn(harness, first)
|
|
3605
|
-
clickRowIn(harness, second)
|
|
3606
|
-
await flush()
|
|
3607
|
-
|
|
3608
|
-
clickBar(barDelete(harness))
|
|
3609
|
-
// The batch runs several workers and settles asynchronously; waiting only one
|
|
3610
|
-
// tick left them running into the NEXT test, whose harness swapped the document
|
|
3611
|
-
// out from under them. Drain until the bar is gone.
|
|
3612
|
-
await settle()
|
|
3613
|
-
for (let i = 0; i < 40 && bar(harness) !== null; i += 1) await flush()
|
|
3614
|
-
|
|
3615
|
-
// The single-delete path sends `quarantine`; batch used to call postDelete(id)
|
|
3616
|
-
// with nothing, so "quarantine the produced files" was silently skipped while
|
|
3617
|
-
// that same switch stayed on. Every request here has to carry it.
|
|
3618
|
-
const bodies = harness.requests
|
|
3619
|
-
.filter((call) => call.url === '/dsh-delete-session/delete')
|
|
3620
|
-
.map((call) => JSON.parse(call.init.body))
|
|
3621
|
-
assert.equal(bodies.length, 2, 'one request per selected session')
|
|
3622
|
-
for (const body of bodies) {
|
|
3623
|
-
assert.deepEqual(body.quarantine, { scope: 'created' }, 'the produced files follow the switch')
|
|
3624
|
-
}
|
|
3625
|
-
})
|
|
3626
|
-
|
|
3627
|
-
test('multi-select delete leaves the files alone when the switch is off', async () => {
|
|
3628
|
-
const harness = await loadPlugin()
|
|
3629
|
-
const first = mountRow(harness, SESSION_A)
|
|
3630
|
-
await enterMulti(harness)
|
|
3631
|
-
clickRowIn(harness, first)
|
|
3632
|
-
await flush()
|
|
3633
|
-
|
|
3634
|
-
clickBar(barDelete(harness))
|
|
3635
|
-
await settle()
|
|
3636
|
-
for (let i = 0; i < 40 && bar(harness) !== null; i += 1) await flush()
|
|
3637
|
-
|
|
3638
|
-
const bodies = harness.requests
|
|
3639
|
-
.filter((call) => call.url === '/dsh-delete-session/delete')
|
|
3640
|
-
.map((call) => JSON.parse(call.init.body))
|
|
3641
|
-
assert.equal(bodies.length, 1, 'the delete went out')
|
|
3642
|
-
assert.equal('quarantine' in bodies[0], false, 'and does not move any file')
|
|
3643
|
-
})
|
|
3644
|
-
|
|
3645
|
-
test('a batch in asking mode says the files were left alone', async () => {
|
|
3646
|
-
const harness = await loadPlugin()
|
|
3647
|
-
localStorage.setItem(OFF_KEY, '0')
|
|
3648
|
-
localStorage.setItem(AUTO_KEY, '0')
|
|
3649
|
-
const first = mountRow(harness, SESSION_A)
|
|
3650
|
-
await enterMulti(harness)
|
|
3651
|
-
clickRowIn(harness, first)
|
|
3652
|
-
await flush()
|
|
3653
|
-
|
|
3654
|
-
clickBar(barDelete(harness))
|
|
3655
|
-
await settle()
|
|
3656
|
-
for (let i = 0; i < 40 && bar(harness) !== null; i += 1) await flush()
|
|
3657
|
-
|
|
3658
|
-
// Asking means a per-file checklist, which a batch has nowhere to show. Silence
|
|
3659
|
-
// would look like the files had been handled.
|
|
3660
|
-
const said = toasts(harness).join(' | ')
|
|
3661
|
-
assert.equal(said.includes('产出文件没有处理'), true, 'the user is told: ' + said)
|
|
3662
|
-
assert.equal('quarantine' in deleteBody(harness), false, 'and nothing was moved')
|
|
3663
|
-
})
|
|
3672
|
+
})
|
|
3673
|
+
|
|
3674
|
+
test('multi-select delete carries the artifact switch to every request', async () => {
|
|
3675
|
+
const harness = await loadPlugin({ plan: PLAN })
|
|
3676
|
+
localStorage.setItem(OFF_KEY, '0')
|
|
3677
|
+
localStorage.setItem(AUTO_KEY, '1')
|
|
3678
|
+
localStorage.setItem(SKIP_KEY, '1')
|
|
3679
|
+
const first = mountRow(harness, SESSION_A)
|
|
3680
|
+
const second = mountRow(harness, SESSION_B)
|
|
3681
|
+
await enterMulti(harness)
|
|
3682
|
+
clickRowIn(harness, first)
|
|
3683
|
+
clickRowIn(harness, second)
|
|
3684
|
+
await flush()
|
|
3685
|
+
|
|
3686
|
+
clickBar(barDelete(harness))
|
|
3687
|
+
// The batch runs several workers and settles asynchronously; waiting only one
|
|
3688
|
+
// tick left them running into the NEXT test, whose harness swapped the document
|
|
3689
|
+
// out from under them. Drain until the bar is gone.
|
|
3690
|
+
await settle()
|
|
3691
|
+
for (let i = 0; i < 40 && bar(harness) !== null; i += 1) await flush()
|
|
3692
|
+
|
|
3693
|
+
// The single-delete path sends `quarantine`; batch used to call postDelete(id)
|
|
3694
|
+
// with nothing, so "quarantine the produced files" was silently skipped while
|
|
3695
|
+
// that same switch stayed on. Every request here has to carry it.
|
|
3696
|
+
const bodies = harness.requests
|
|
3697
|
+
.filter((call) => call.url === '/dsh-delete-session/delete')
|
|
3698
|
+
.map((call) => JSON.parse(call.init.body))
|
|
3699
|
+
assert.equal(bodies.length, 2, 'one request per selected session')
|
|
3700
|
+
for (const body of bodies) {
|
|
3701
|
+
assert.deepEqual(body.quarantine, { scope: 'created' }, 'the produced files follow the switch')
|
|
3702
|
+
}
|
|
3703
|
+
})
|
|
3704
|
+
|
|
3705
|
+
test('multi-select delete leaves the files alone when the switch is off', async () => {
|
|
3706
|
+
const harness = await loadPlugin()
|
|
3707
|
+
const first = mountRow(harness, SESSION_A)
|
|
3708
|
+
await enterMulti(harness)
|
|
3709
|
+
clickRowIn(harness, first)
|
|
3710
|
+
await flush()
|
|
3711
|
+
|
|
3712
|
+
clickBar(barDelete(harness))
|
|
3713
|
+
await settle()
|
|
3714
|
+
for (let i = 0; i < 40 && bar(harness) !== null; i += 1) await flush()
|
|
3715
|
+
|
|
3716
|
+
const bodies = harness.requests
|
|
3717
|
+
.filter((call) => call.url === '/dsh-delete-session/delete')
|
|
3718
|
+
.map((call) => JSON.parse(call.init.body))
|
|
3719
|
+
assert.equal(bodies.length, 1, 'the delete went out')
|
|
3720
|
+
assert.equal('quarantine' in bodies[0], false, 'and does not move any file')
|
|
3721
|
+
})
|
|
3722
|
+
|
|
3723
|
+
test('a batch in asking mode says the files were left alone', async () => {
|
|
3724
|
+
const harness = await loadPlugin()
|
|
3725
|
+
localStorage.setItem(OFF_KEY, '0')
|
|
3726
|
+
localStorage.setItem(AUTO_KEY, '0')
|
|
3727
|
+
const first = mountRow(harness, SESSION_A)
|
|
3728
|
+
await enterMulti(harness)
|
|
3729
|
+
clickRowIn(harness, first)
|
|
3730
|
+
await flush()
|
|
3731
|
+
|
|
3732
|
+
clickBar(barDelete(harness))
|
|
3733
|
+
await settle()
|
|
3734
|
+
for (let i = 0; i < 40 && bar(harness) !== null; i += 1) await flush()
|
|
3735
|
+
|
|
3736
|
+
// Asking means a per-file checklist, which a batch has nowhere to show. Silence
|
|
3737
|
+
// would look like the files had been handled.
|
|
3738
|
+
const said = toasts(harness).join(' | ')
|
|
3739
|
+
assert.equal(said.includes('产出文件没有处理'), true, 'the user is told: ' + said)
|
|
3740
|
+
assert.equal('quarantine' in deleteBody(harness), false, 'and nothing was moved')
|
|
3741
|
+
})
|