Files
klz-cables.com/.pnpm-store/v10/files/2e/48b1424919c00f8c99baa94ff91f76abb4cc044e7cafb1bd48fe3edb9ca22c0512b27871da3b0b06ec4df6b88c574f05dc24502de61b541686e09d4f9ae79f
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

149 lines
4.5 KiB
Plaintext

import { ReservedFieldName } from '../../errors/index.js';
import { sanitizeCollection } from '../../collections/config/sanitize.js';
import { describe, it, expect } from 'vitest';
describe('reservedFieldNames - collections -', ()=>{
const config = {
collections: [],
globals: []
};
describe('uploads -', ()=>{
const collectionWithUploads = {
slug: 'collection-with-uploads',
fields: [],
upload: true
};
it('should throw on file', async ()=>{
const fields = [
{
name: 'file',
type: 'text',
label: 'some-collection'
}
];
await expect(async ()=>{
await sanitizeCollection(// @ts-expect-error
{
...config,
collections: [
{
...collectionWithUploads,
fields
}
]
}, {
...collectionWithUploads,
fields
});
}).rejects.toThrow(ReservedFieldName);
});
it('should not throw on a custom field', async ()=>{
const fields = [
{
name: 'customField',
type: 'text',
label: 'some-collection'
}
];
await expect(async ()=>{
await sanitizeCollection(// @ts-expect-error
{
...config,
collections: [
{
...collectionWithUploads,
fields
}
]
}, {
...collectionWithUploads,
fields
});
}).not.toThrow();
});
});
describe('auth -', ()=>{
const collectionWithAuth = {
slug: 'collection-with-auth',
auth: {
loginWithUsername: true,
useAPIKey: true,
verify: true
},
fields: []
};
it('should throw on hash', async ()=>{
const fields = [
{
name: 'hash',
type: 'text',
label: 'some-collection'
}
];
await expect(async ()=>{
await sanitizeCollection(// @ts-expect-error
{
...config,
collections: [
{
...collectionWithAuth,
fields
}
]
}, {
...collectionWithAuth,
fields
});
}).rejects.toThrow(ReservedFieldName);
});
it('should throw on salt', async ()=>{
const fields = [
{
name: 'salt',
type: 'text',
label: 'some-collection'
}
];
await expect(async ()=>{
await sanitizeCollection(// @ts-expect-error
{
...config,
collections: [
{
...collectionWithAuth,
fields
}
]
}, {
...collectionWithAuth,
fields
});
}).rejects.toThrow(ReservedFieldName);
});
it('should not throw on a custom field', async ()=>{
const fields = [
{
name: 'customField',
type: 'text',
label: 'some-collection'
}
];
await expect(async ()=>{
await sanitizeCollection(// @ts-expect-error
{
...config,
collections: [
{
...collectionWithAuth,
fields
}
]
}, {
...collectionWithAuth,
fields
});
}).not.toThrow();
});
});
});
//# sourceMappingURL=reservedFieldNames.spec.js.map