feat: #1001 - builds a way to allow list view to search multiple fields

* make textfields searchable

* shorten namings in placeholder function

* chore: finishes listSearchableFields

Co-authored-by: Christian Reichart <christian.reichart@camperboys.com>
This commit is contained in:
James Mikrut
2022-09-12 16:38:02 -07:00
committed by GitHub
parent d5ccd45b53
commit a1083727ef
10 changed files with 101 additions and 18 deletions

View File

@@ -56,6 +56,7 @@ export default buildConfig({
{
slug,
admin: {
listSearchableFields: ['title', 'description', 'number'],
group: 'One',
},
fields: [
@@ -67,6 +68,10 @@ export default buildConfig({
name: 'description',
type: 'text',
},
{
name: 'number',
type: 'number',
},
],
},
{

View File

@@ -184,10 +184,26 @@ describe('admin', () => {
test('search by id', async () => {
const { id } = await createPost();
await page.locator('.search-filter__input').fill(id);
await wait(250);
const tableItems = page.locator(tableRowLocator);
await expect(tableItems).toHaveCount(1);
});
test('search by title or description', async () => {
await createPost({
title: 'find me',
description: 'this is fun',
});
await page.locator('.search-filter__input').fill('find me');
await wait(250);
await expect(page.locator(tableRowLocator)).toHaveCount(1);
await page.locator('.search-filter__input').fill('this is fun');
await wait(250);
await expect(page.locator(tableRowLocator)).toHaveCount(1);
});
test('toggle columns', async () => {
const columnCountLocator = 'table >> thead >> tr >> th';
await createPost();

View File

@@ -19,6 +19,11 @@ const init = async () => {
},
});
// Redirect root to Admin panel
expressApp.get('/', (_, res) => {
res.redirect('/admin');
});
const externalRouter = express.Router();
externalRouter.use(payload.authenticate);