Files

56 lines
2.8 KiB
JavaScript

'use strict';
const { test } = require('node:test'),
assert = require('node:assert/strict');
const { managementFixture } = require('./management-fixture.cjs');
test(
'conversation row menus archive, restore and delete through an explicit recycle bin',
{ timeout: 120000 },
async (t) => {
const f = await managementFixture(t, { browser: true }),
{ page, open, store } = f;
const owner = f.users.users().find((u) => u.username === 'admin').id,
c = store.create(owner),
turn = store.beginTurn(c.id, owner, '待管理的测试对话');
store.updateTurn(turn.id, 'success', { reply: '历史保留' });
await open();
const row = page.locator('[data-conversation-row]').filter({ hasText: '待管理的测试对话' });
await row.getByRole('button', { name: '会话操作', exact: true }).click();
await page.getByRole('button', { name: '归档', exact: true }).click();
await page.getByLabel('会话范围', { exact: true }).selectOption('archived');
await page
.locator('[data-conversation-row]')
.filter({ hasText: '待管理的测试对话' })
.getByRole('button', { name: '会话操作', exact: true })
.click();
await page.getByRole('button', { name: '恢复会话', exact: true }).last().click();
await page.getByLabel('会话范围', { exact: true }).selectOption('active');
await page
.locator('[data-conversation-row]')
.filter({ hasText: '待管理的测试对话' })
.getByRole('button', { name: '会话操作', exact: true })
.click();
await page.getByRole('button', { name: '移至回收站', exact: true }).click();
await page.getByLabel('会话范围', { exact: true }).selectOption('deleted');
await page
.locator('[data-assistant-conversation]')
.filter({ hasText: '待管理的测试对话' })
.click();
assert.equal(await page.getByRole('button', { name: '发送', exact: true }).isDisabled(), true);
await page.getByRole('button', { name: '永久删除', exact: true }).click();
await page.getByRole('dialog', { name: '永久删除会话', exact: true }).waitFor();
await require('node:fs/promises').mkdir('output/verification/dsh-providers', {
recursive: true,
});
await page.screenshot({
path: 'output/verification/dsh-providers/trash-confirmation.png',
fullPage: true,
});
await page.getByRole('button', { name: '取消', exact: true }).click();
assert.equal(store.listConversations(owner, { scope: 'deleted' }).total, 1);
await page.getByRole('button', { name: '永久删除', exact: true }).click();
await page.getByRole('button', { name: '确认永久删除', exact: true }).click();
await page.getByText('没有匹配会话。', { exact: true }).waitFor();
assert.equal(store.usage().calls, 1);
},
);