mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-12 11:43:03 +02:00
Add a smatttering of tests and fix return-to-public after channel deletion
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
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 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user