mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-28 19:03:15 +01:00
feat: version number in collection schema
This commit is contained in:
parent
7078d5cec2
commit
fe900b90c9
@ -237,6 +237,9 @@ export const transformCollectionToSaveToIdb = (collection, options = {}) => {
|
|||||||
const collectionToSave = {};
|
const collectionToSave = {};
|
||||||
collectionToSave.name = collection.name;
|
collectionToSave.name = collection.name;
|
||||||
collectionToSave.uid = collection.uid;
|
collectionToSave.uid = collection.uid;
|
||||||
|
|
||||||
|
// todo: move this to the place where collection gets created
|
||||||
|
collectionToSave.version = '1';
|
||||||
collectionToSave.items = [];
|
collectionToSave.items = [];
|
||||||
collectionToSave.activeEnvironmentUid = collection.activeEnvironmentUid;
|
collectionToSave.activeEnvironmentUid = collection.activeEnvironmentUid;
|
||||||
collectionToSave.environments = collection.environments || [];
|
collectionToSave.environments = collection.environments || [];
|
||||||
|
@ -64,6 +64,7 @@ const itemSchema = Yup.object({
|
|||||||
}).noUnknown(true).strict();
|
}).noUnknown(true).strict();
|
||||||
|
|
||||||
const collectionSchema = Yup.object({
|
const collectionSchema = Yup.object({
|
||||||
|
version: Yup.string().oneOf(['1']).required('version is required'),
|
||||||
uid: uidSchema,
|
uid: uidSchema,
|
||||||
name: Yup.string()
|
name: Yup.string()
|
||||||
.min(1, 'name must be atleast 1 characters')
|
.min(1, 'name must be atleast 1 characters')
|
||||||
|
@ -5,6 +5,7 @@ const { collectionSchema } = require("./index");
|
|||||||
describe('Collection Schema Validation', () => {
|
describe('Collection Schema Validation', () => {
|
||||||
it('collection schema must validate successfully - simple collection, no items', async () => {
|
it('collection schema must validate successfully - simple collection, no items', async () => {
|
||||||
const collection = {
|
const collection = {
|
||||||
|
version: '1',
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
name: 'My Collection'
|
name: 'My Collection'
|
||||||
};
|
};
|
||||||
@ -15,6 +16,7 @@ describe('Collection Schema Validation', () => {
|
|||||||
|
|
||||||
it('collection schema must validate successfully - simple collection, empty items', async () => {
|
it('collection schema must validate successfully - simple collection, empty items', async () => {
|
||||||
const collection = {
|
const collection = {
|
||||||
|
version: '1',
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
name: 'My Collection',
|
name: 'My Collection',
|
||||||
items: []
|
items: []
|
||||||
@ -26,6 +28,7 @@ describe('Collection Schema Validation', () => {
|
|||||||
|
|
||||||
it('collection schema must validate successfully - simple collection, just a folder item', async () => {
|
it('collection schema must validate successfully - simple collection, just a folder item', async () => {
|
||||||
const collection = {
|
const collection = {
|
||||||
|
version: '1',
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
name: 'My Collection',
|
name: 'My Collection',
|
||||||
items: [{
|
items: [{
|
||||||
@ -41,6 +44,7 @@ describe('Collection Schema Validation', () => {
|
|||||||
|
|
||||||
it('collection schema must validate successfully - simple collection, just a request item', async () => {
|
it('collection schema must validate successfully - simple collection, just a request item', async () => {
|
||||||
const collection = {
|
const collection = {
|
||||||
|
version: '1',
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
name: 'My Collection',
|
name: 'My Collection',
|
||||||
items: [{
|
items: [{
|
||||||
@ -65,6 +69,7 @@ describe('Collection Schema Validation', () => {
|
|||||||
|
|
||||||
it('collection schema must validate successfully - simple collection, folder inside folder', async () => {
|
it('collection schema must validate successfully - simple collection, folder inside folder', async () => {
|
||||||
const collection = {
|
const collection = {
|
||||||
|
version: '1',
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
name: 'My Collection',
|
name: 'My Collection',
|
||||||
items: [{
|
items: [{
|
||||||
@ -85,6 +90,7 @@ describe('Collection Schema Validation', () => {
|
|||||||
|
|
||||||
it('collection schema must validate successfully - simple collection, [folder] [request + folder]', async () => {
|
it('collection schema must validate successfully - simple collection, [folder] [request + folder]', async () => {
|
||||||
const collection = {
|
const collection = {
|
||||||
|
version: '1',
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
name: 'My Collection',
|
name: 'My Collection',
|
||||||
items: [{
|
items: [{
|
||||||
|
@ -35,50 +35,4 @@ describe('Request Schema Validation', () => {
|
|||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('request schema must throw an error of header name is missing', async () => {
|
|
||||||
const request = {
|
|
||||||
url: 'https://restcountries.com/v2/alpha/in',
|
|
||||||
method: 'GET',
|
|
||||||
headers: [{
|
|
||||||
uid: uuid(),
|
|
||||||
value: 'Check',
|
|
||||||
description: '',
|
|
||||||
enabled: true
|
|
||||||
}],
|
|
||||||
params: [],
|
|
||||||
body: {
|
|
||||||
mode: 'none'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return Promise.all([
|
|
||||||
expect(requestSchema.validate(request)).rejects.toEqual(
|
|
||||||
validationErrorWithMessages('headers[0].name must be defined')
|
|
||||||
)
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('request schema must throw an error of param value is missing', async () => {
|
|
||||||
const request = {
|
|
||||||
url: 'https://restcountries.com/v2/alpha/in',
|
|
||||||
method: 'GET',
|
|
||||||
headers: [],
|
|
||||||
params: [{
|
|
||||||
uid: uuid(),
|
|
||||||
name: 'customerId',
|
|
||||||
description: '',
|
|
||||||
enabled: true
|
|
||||||
}],
|
|
||||||
body: {
|
|
||||||
mode: 'none'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return Promise.all([
|
|
||||||
expect(requestSchema.validate(request)).rejects.toEqual(
|
|
||||||
validationErrorWithMessages('params[0].value must be defined')
|
|
||||||
)
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user