mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-11 11:13:04 +02:00
Add better search management and operators + contact search quick link
This commit is contained in:
@@ -1,21 +1,29 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { createChannel, deleteChannel, getChannels } from '../helpers/api';
|
||||
import { createChannel, createContact, deleteChannel, deleteContact } from '../helpers/api';
|
||||
|
||||
test.describe('Sidebar search/filter', () => {
|
||||
const suffix = Date.now().toString().slice(-6);
|
||||
const nameA = `#alpha${suffix}`;
|
||||
const nameB = `#bravo${suffix}`;
|
||||
const contactName = `Search Contact ${suffix}`;
|
||||
const contactKey = `feed${suffix.padStart(8, '0')}${'ab'.repeat(26)}`;
|
||||
let keyA = '';
|
||||
let keyB = '';
|
||||
|
||||
test.beforeAll(async () => {
|
||||
const chA = await createChannel(nameA);
|
||||
const chB = await createChannel(nameB);
|
||||
await createContact(contactKey, contactName);
|
||||
keyA = chA.key;
|
||||
keyB = chB.key;
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
try {
|
||||
await deleteContact(contactKey);
|
||||
} catch {
|
||||
// Best-effort cleanup
|
||||
}
|
||||
for (const key of [keyA, keyB]) {
|
||||
try {
|
||||
await deleteChannel(key);
|
||||
@@ -25,27 +33,40 @@ test.describe('Sidebar search/filter', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('search filters conversations by name', async ({ page }) => {
|
||||
test('search filters channel and contact conversations by name and key prefix', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('/');
|
||||
await expect(page.getByRole('status', { name: 'Radio OK' })).toBeVisible();
|
||||
|
||||
// Both channels should be visible
|
||||
// Seeded conversations should be visible.
|
||||
await expect(page.getByText(nameA, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText(nameB, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText(contactName, { exact: true })).toBeVisible();
|
||||
|
||||
// Type partial name to filter
|
||||
const searchInput = page.getByLabel('Search conversations');
|
||||
await searchInput.fill(`alpha${suffix}`);
|
||||
|
||||
// Only nameA should be visible
|
||||
// Channel name query should filter to the matching channel only.
|
||||
await searchInput.fill(`alpha${suffix}`);
|
||||
await expect(page.getByText(nameA, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText(nameB, { exact: true })).not.toBeVisible();
|
||||
await expect(page.getByText(contactName, { exact: true })).not.toBeVisible();
|
||||
|
||||
// Clear search
|
||||
// Contact name query should filter to the matching contact.
|
||||
await searchInput.fill(`contact ${suffix}`);
|
||||
await expect(page.getByText(contactName, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText(nameA, { exact: true })).not.toBeVisible();
|
||||
await expect(page.getByText(nameB, { exact: true })).not.toBeVisible();
|
||||
|
||||
// Contact key prefix query should also match that contact.
|
||||
await searchInput.fill(contactKey.slice(0, 12));
|
||||
await expect(page.getByText(contactName, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText(nameA, { exact: true })).not.toBeVisible();
|
||||
|
||||
// Clear search should restore the full conversation list.
|
||||
await page.getByTitle('Clear search').click();
|
||||
|
||||
// Both should return
|
||||
await expect(page.getByText(nameA, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText(nameB, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText(contactName, { exact: true })).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user