mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-10-04 03:01:42 +08:00
feat: 隐藏设置里的防撤回入口,历史开启强制收敛为 false
This commit is contained in:
@@ -499,11 +499,8 @@ test('SETTINGS-02 basic settings controls fit the default desktop window and kee
|
||||
await debugSwitch.click()
|
||||
await expect(debugSwitch).toBeChecked()
|
||||
|
||||
await fixture.page.getByRole('button', { name: '防撤回' }).click()
|
||||
const recallSwitch = fixture.page.getByRole('switch', { name: '开启防撤回' })
|
||||
await expect(recallSwitch).toBeVisible()
|
||||
await recallSwitch.click()
|
||||
await expect(recallSwitch).toBeChecked()
|
||||
// 防撤回已下线:设置导航不再暴露该入口(与「存储与导出」同一处理方式)。
|
||||
await expect(fixture.page.getByRole('button', { name: '防撤回' })).toHaveCount(0)
|
||||
|
||||
await fixture.page.getByRole('button', { name: '关于' }).click()
|
||||
await expect(fixture.page.getByRole('button', { name: '检查更新' })).toBeVisible()
|
||||
|
||||
@@ -661,36 +661,8 @@ test('SETTINGS-03 database key controls visual @visual', async () => {
|
||||
}
|
||||
})
|
||||
|
||||
for (const appearanceTheme of ['light', 'dark'] as const) {
|
||||
test(`SETTINGS-08 recall protection ${appearanceTheme} visual @visual`, async () => {
|
||||
const fixture = await launchTestApp({ now: visualNow, appearanceTheme })
|
||||
const pageErrors: Error[] = []
|
||||
fixture.page.on('pageerror', (error) => pageErrors.push(error))
|
||||
try {
|
||||
await fixture.page
|
||||
.getByRole('navigation', { name: '一级导航' })
|
||||
.getByRole('button', { name: '设置' })
|
||||
.click()
|
||||
await fixture.page.getByRole('button', { name: '防撤回' }).click()
|
||||
await expect(fixture.page.getByRole('switch', { name: '开启防撤回' })).toBeVisible()
|
||||
await expect(fixture.page.locator('html')).toHaveAttribute('data-theme', appearanceTheme)
|
||||
expect(
|
||||
await fixture.page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)
|
||||
).toBe(true)
|
||||
expect(pageErrors).toEqual([])
|
||||
await clearScreenshotFocus(fixture.page)
|
||||
await expect(fixture.page).toHaveScreenshot(
|
||||
`settings-recall-protection-${appearanceTheme}.png`,
|
||||
{
|
||||
animations: 'disabled',
|
||||
caret: 'hide'
|
||||
}
|
||||
)
|
||||
} finally {
|
||||
await fixture.close()
|
||||
}
|
||||
})
|
||||
}
|
||||
// SETTINGS-08(防撤回页 light/dark 视觉)已移除:该设置入口已下线,
|
||||
// 页面不再可达,对应的 settings-recall-protection-{light,dark}.png 基线同步删除。
|
||||
|
||||
for (const appearanceTheme of ['light', 'dark'] as const) {
|
||||
test(`SETTINGS-04 image decryption controls ${appearanceTheme} visual @visual`, async () => {
|
||||
|
||||
@@ -22,4 +22,11 @@ describe('settings navigation', () => {
|
||||
)
|
||||
expect(SETTINGS_CATEGORY_LABELS['storage-export']).toBe('存储与导出')
|
||||
})
|
||||
|
||||
it('hides recall protection from visible navigation', () => {
|
||||
expect(SETTINGS_NAVIGATION.flatMap((group) => group.items)).not.toEqual(
|
||||
expect.arrayContaining([{ id: 'recall-protection', label: '防撤回' }])
|
||||
)
|
||||
expect(SETTINGS_CATEGORY_LABELS['recall-protection']).toBe('防撤回')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import { mkdtempSync, readFileSync, writeFileSync } from 'fs'
|
||||
import { tmpdir } from 'os'
|
||||
import { join } from 'path'
|
||||
import { afterAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('electron', () => ({ app: { getPath: () => '/tmp/tracememo-settings-test-user-data' } }))
|
||||
|
||||
/**
|
||||
* settings-store 在模块加载时确定 settings.json 路径并缓存设置对象,
|
||||
* 所以每个用例都要用独立的目录 + 重新加载模块。
|
||||
*/
|
||||
async function importStore(directory: string): Promise<
|
||||
typeof import('../../src/main/services/settings-store')
|
||||
> {
|
||||
process.env.WE_SETTINGS_DIR = directory
|
||||
vi.resetModules()
|
||||
return import('../../src/main/services/settings-store')
|
||||
}
|
||||
|
||||
function readSettingsFile(directory: string): Record<string, unknown> {
|
||||
return JSON.parse(readFileSync(join(directory, 'settings.json'), 'utf8')) as Record<
|
||||
string,
|
||||
unknown
|
||||
>
|
||||
}
|
||||
|
||||
function createDirectory(): string {
|
||||
return mkdtempSync(join(tmpdir(), 'tracememo-settings-recall-'))
|
||||
}
|
||||
|
||||
describe('recall protection retirement migration', () => {
|
||||
afterAll(() => {
|
||||
delete process.env.WE_SETTINGS_DIR
|
||||
})
|
||||
|
||||
it('forces a previously enabled recall protection back to false on disk', async () => {
|
||||
const directory = createDirectory()
|
||||
writeFileSync(
|
||||
join(directory, 'settings.json'),
|
||||
JSON.stringify({ recallProtectionEnabled: true }),
|
||||
'utf8'
|
||||
)
|
||||
|
||||
const store = await importStore(directory)
|
||||
|
||||
expect(store.loadSettings().recallProtectionEnabled).toBe(false)
|
||||
expect(readSettingsFile(directory).recallProtectionEnabled).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps recall protection off for every write path', async () => {
|
||||
const directory = createDirectory()
|
||||
const store = await importStore(directory)
|
||||
|
||||
expect(store.updateSettings({ recallProtectionEnabled: true }).recallProtectionEnabled).toBe(
|
||||
false
|
||||
)
|
||||
expect(store.loadSettings().recallProtectionEnabled).toBe(false)
|
||||
|
||||
expect(
|
||||
store.saveSettings({ ...store.loadSettings(), recallProtectionEnabled: true })
|
||||
.recallProtectionEnabled
|
||||
).toBe(false)
|
||||
expect(readSettingsFile(directory).recallProtectionEnabled).toBe(false)
|
||||
})
|
||||
|
||||
it('defaults recall protection to false without a settings file', async () => {
|
||||
const store = await importStore(createDirectory())
|
||||
|
||||
expect(store.loadSettings().recallProtectionEnabled).toBe(false)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user