mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-03-28 17:43:05 +01:00
56 lines
2.0 KiB
TypeScript
56 lines
2.0 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { createChannel, deleteChannel, getChannels } from '../helpers/api';
|
|
|
|
test.describe('Conversation deletion flow', () => {
|
|
test.beforeAll(async () => {
|
|
const channels = await getChannels();
|
|
if (!channels.some((c) => c.name === 'Public')) {
|
|
await createChannel('Public');
|
|
}
|
|
});
|
|
|
|
test('deleting active channel removes it from sidebar and clears composer', async ({ page }) => {
|
|
const channelName = `#e2edel${Date.now().toString().slice(-6)}`;
|
|
const channel = await createChannel(channelName);
|
|
|
|
await page.goto('/');
|
|
await expect(page.getByText('Connected')).toBeVisible();
|
|
|
|
await page.getByText(channelName, { exact: true }).first().click();
|
|
await expect(page.getByPlaceholder(new RegExp(`message\\s+${channelName}`, 'i'))).toBeVisible();
|
|
|
|
page.once('dialog', async (dialog) => {
|
|
await dialog.accept();
|
|
});
|
|
await page.getByTitle('Delete').click();
|
|
|
|
await expect(page.getByText('Channel deleted')).toBeVisible();
|
|
await expect(page.getByText(channelName, { exact: true })).not.toBeVisible();
|
|
await expect(page.getByPlaceholder(new RegExp(`message\\s+${channelName}`, 'i'))).not.toBeVisible();
|
|
|
|
try {
|
|
await deleteChannel(channel.key);
|
|
} catch {
|
|
// Best-effort cleanup
|
|
}
|
|
});
|
|
|
|
test('deleting active channel falls back to Public conversation', async ({ page }) => {
|
|
const channelName = `#e2edel${Date.now().toString().slice(-6)}`;
|
|
const channel = await createChannel(channelName);
|
|
|
|
await page.goto('/');
|
|
await expect(page.getByText('Connected')).toBeVisible();
|
|
|
|
await page.getByText(channelName, { exact: true }).first().click();
|
|
await expect(page.getByPlaceholder(new RegExp(`message\\s+${channelName}`, 'i'))).toBeVisible();
|
|
|
|
page.once('dialog', async (dialog) => {
|
|
await dialog.accept();
|
|
});
|
|
await page.getByTitle('Delete').click();
|
|
|
|
await expect(page.getByPlaceholder(/message\s+public/i)).toBeVisible({ timeout: 15_000 });
|
|
});
|
|
});
|