mirror of
https://github.com/strapi/strapi.git
synced 2025-10-04 21:02:43 +00:00
Handle uids in ctm explorer routes
This commit is contained in:
parent
49e270a7f6
commit
3e8816161a
@ -13,6 +13,7 @@ class DatabaseManager {
|
||||
this.initialized = false;
|
||||
this.queries = new Map();
|
||||
this.connectors = new Map();
|
||||
this.models = new Map();
|
||||
}
|
||||
|
||||
async initialize() {
|
||||
@ -38,9 +39,30 @@ class DatabaseManager {
|
||||
await connector.initialize();
|
||||
}
|
||||
|
||||
this.initializeModelsMap();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
initializeModelsMap() {
|
||||
Object.keys(this.strapi.models).forEach(modelKey => {
|
||||
const model = this.strapi.models[modelKey];
|
||||
this.models.set(model.uid, model);
|
||||
});
|
||||
|
||||
Object.keys(this.strapi.admin.models).forEach(modelKey => {
|
||||
const model = this.strapi.admin.models[modelKey];
|
||||
this.models.set(model.uid, model);
|
||||
});
|
||||
|
||||
Object.keys(this.strapi.plugins).forEach(pluginKey => {
|
||||
Object.keys(this.strapi.plugins[pluginKey].models).forEach(modelKey => {
|
||||
const model = this.strapi.plugins[pluginKey].models[modelKey];
|
||||
this.models.set(model.uid, model);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
query(entity, plugin) {
|
||||
if (!entity) {
|
||||
throw new Error(`argument entity is required`);
|
||||
@ -48,7 +70,10 @@ class DatabaseManager {
|
||||
|
||||
const normalizedName = entity.toLowerCase();
|
||||
|
||||
const model = this.getModel(normalizedName, plugin);
|
||||
// get by uid or name / plugin
|
||||
const model = this.models.has(entity)
|
||||
? this.models.get(entity)
|
||||
: this.getModel(normalizedName, plugin);
|
||||
|
||||
if (!model) {
|
||||
throw new Error(`The model ${entity} can't be found.`);
|
||||
@ -70,6 +95,8 @@ class DatabaseManager {
|
||||
getModel(name, plugin) {
|
||||
const key = _.toLower(name);
|
||||
|
||||
if (this.models.has(key)) return this.models.get(key);
|
||||
|
||||
if (plugin === 'admin') {
|
||||
return _.get(strapi.admin, ['models', key]);
|
||||
}
|
||||
|
@ -4,35 +4,25 @@ const parseMultipartBody = require('../../utils/parse-multipart');
|
||||
const uploadFiles = require('../../utils/upload-files');
|
||||
|
||||
module.exports = async (ctx, next) => {
|
||||
const { source } = ctx.request.query;
|
||||
const { model } = ctx.params;
|
||||
|
||||
const target = source === 'admin' ? strapi.admin : strapi.plugins[source];
|
||||
const ct = strapi.contentTypes[model];
|
||||
|
||||
if (
|
||||
source &&
|
||||
_.get(target, [
|
||||
'config',
|
||||
'layout',
|
||||
model,
|
||||
'actions',
|
||||
ctx.request.route.action,
|
||||
])
|
||||
) {
|
||||
const [controller, action] = _.get(
|
||||
target,
|
||||
[
|
||||
'config',
|
||||
'layout',
|
||||
ctx.params.model,
|
||||
'actions',
|
||||
ctx.request.route.action,
|
||||
],
|
||||
[]
|
||||
).split('.');
|
||||
const target =
|
||||
ct.plugin === 'admin' ? strapi.admin : strapi.plugins[ct.plugin];
|
||||
|
||||
const actionPath = [
|
||||
'config',
|
||||
'layout',
|
||||
ct.modelName,
|
||||
'actions',
|
||||
ctx.request.route.action,
|
||||
];
|
||||
|
||||
if (_.has(target, actionPath)) {
|
||||
const [controller, action] = _.get(target, actionPath, []).split('.');
|
||||
|
||||
if (controller && action) {
|
||||
// TODO: handle in the targeted controller directly
|
||||
if (ctx.is('multipart')) {
|
||||
const { data, files } = parseMultipartBody(ctx);
|
||||
ctx.request.body = data;
|
||||
@ -43,7 +33,10 @@ module.exports = async (ctx, next) => {
|
||||
|
||||
if (ctx.status >= 300) return;
|
||||
|
||||
await uploadFiles(resBody, files, { model, source });
|
||||
await uploadFiles(resBody, files, {
|
||||
model: ct.modelName,
|
||||
source: ct.plugin,
|
||||
});
|
||||
|
||||
return ctx.send(resBody);
|
||||
}
|
||||
|
@ -2,15 +2,13 @@
|
||||
|
||||
const _ = require('lodash');
|
||||
const parseMultipartBody = require('../utils/parse-multipart');
|
||||
const contentManagerService = require('../services/ContentManager');
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Returns a list of entities of a content-type matching the query parameters
|
||||
*/
|
||||
async find(ctx) {
|
||||
const contentManagerService =
|
||||
strapi.plugins['content-manager'].services['contentmanager'];
|
||||
|
||||
let entities = [];
|
||||
if (_.has(ctx.request.query, '_q')) {
|
||||
entities = await contentManagerService.search(
|
||||
@ -30,11 +28,7 @@ module.exports = {
|
||||
* Returns an entity of a content type by id
|
||||
*/
|
||||
async findOne(ctx) {
|
||||
const { source } = ctx.request.query;
|
||||
const contentManagerService =
|
||||
strapi.plugins['content-manager'].services['contentmanager'];
|
||||
|
||||
const entry = await contentManagerService.fetch(ctx.params, source);
|
||||
const entry = await contentManagerService.fetch(ctx.params);
|
||||
|
||||
// Entry not found
|
||||
if (!entry) {
|
||||
@ -48,9 +42,6 @@ module.exports = {
|
||||
* Returns a count of entities of a content type matching query parameters
|
||||
*/
|
||||
async count(ctx) {
|
||||
const contentManagerService =
|
||||
strapi.plugins['content-manager'].services['contentmanager'];
|
||||
|
||||
let count;
|
||||
if (_.has(ctx.request.query, '_q')) {
|
||||
count = await contentManagerService.countSearch(
|
||||
@ -71,10 +62,6 @@ module.exports = {
|
||||
*/
|
||||
async create(ctx) {
|
||||
const { model } = ctx.params;
|
||||
const { source } = ctx.request.query;
|
||||
|
||||
const contentManagerService =
|
||||
strapi.plugins['content-manager'].services['contentmanager'];
|
||||
|
||||
try {
|
||||
if (ctx.is('multipart')) {
|
||||
@ -82,17 +69,15 @@ module.exports = {
|
||||
ctx.body = await contentManagerService.create(data, {
|
||||
files,
|
||||
model,
|
||||
source,
|
||||
});
|
||||
} else {
|
||||
// Create an entry using `queries` system
|
||||
ctx.body = await contentManagerService.create(ctx.request.body, {
|
||||
source,
|
||||
model,
|
||||
});
|
||||
}
|
||||
|
||||
strapi.emit('didCreateFirstContentTypeEntry', ctx.params, source);
|
||||
strapi.emit('didCreateFirstContentTypeEntry', ctx.params);
|
||||
} catch (error) {
|
||||
strapi.log.error(error);
|
||||
ctx.badRequest(null, [
|
||||
@ -110,9 +95,6 @@ module.exports = {
|
||||
*/
|
||||
async update(ctx) {
|
||||
const { model } = ctx.params;
|
||||
const { source } = ctx.request.query;
|
||||
const contentManagerService =
|
||||
strapi.plugins['content-manager'].services['contentmanager'];
|
||||
|
||||
try {
|
||||
if (ctx.is('multipart')) {
|
||||
@ -120,14 +102,13 @@ module.exports = {
|
||||
ctx.body = await contentManagerService.edit(ctx.params, data, {
|
||||
files,
|
||||
model,
|
||||
source,
|
||||
});
|
||||
} else {
|
||||
// Return the last one which is the current model.
|
||||
ctx.body = await contentManagerService.edit(
|
||||
ctx.params,
|
||||
ctx.request.body,
|
||||
{ source, model }
|
||||
{ model }
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
@ -146,22 +127,13 @@ module.exports = {
|
||||
* Deletes one entity of a content type matching a query
|
||||
*/
|
||||
async delete(ctx) {
|
||||
const contentManagerService =
|
||||
strapi.plugins['content-manager'].services['contentmanager'];
|
||||
|
||||
ctx.body = await contentManagerService.delete(
|
||||
ctx.params,
|
||||
ctx.request.query
|
||||
);
|
||||
ctx.body = await contentManagerService.delete(ctx.params);
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes multiple entities of a content type matching a query
|
||||
*/
|
||||
async deleteMany(ctx) {
|
||||
const contentManagerService =
|
||||
strapi.plugins['content-manager'].services['contentmanager'];
|
||||
|
||||
ctx.body = await contentManagerService.deleteMany(
|
||||
ctx.params,
|
||||
ctx.request.query
|
||||
|
@ -7,8 +7,6 @@ const storeUtils = require('./utils/store');
|
||||
const uidToStoreKey = uid => `components::${uid}`;
|
||||
|
||||
module.exports = {
|
||||
uidToStoreKey,
|
||||
|
||||
async getComponentInformations(uid) {
|
||||
const ctService = strapi.plugins['content-manager'].services.contenttypes;
|
||||
|
||||
|
@ -6,14 +6,12 @@ const uploadFiles = require('../utils/upload-files');
|
||||
* A set of functions called "actions" for `ContentManager`
|
||||
*/
|
||||
module.exports = {
|
||||
fetch(params, source, populate) {
|
||||
return strapi
|
||||
.query(params.model, source)
|
||||
.findOne({ id: params.id }, populate);
|
||||
fetch(params) {
|
||||
return strapi.query(params.model).findOne({ id: params.id });
|
||||
},
|
||||
|
||||
fetchAll(params, query) {
|
||||
const { query: request, source, populate, ...filters } = query;
|
||||
const { query: request, populate, ...filters } = query;
|
||||
|
||||
const queryFilter = !_.isEmpty(request)
|
||||
? {
|
||||
@ -23,63 +21,59 @@ module.exports = {
|
||||
: filters;
|
||||
|
||||
// Find entries using `queries` system
|
||||
return strapi.query(params.model, source).find(queryFilter, populate);
|
||||
return strapi.query(params.model).find(queryFilter, populate);
|
||||
},
|
||||
|
||||
count(params, query) {
|
||||
const { source, ...filters } = query;
|
||||
return strapi.query(params.model, source).count(filters);
|
||||
const { ...filters } = query;
|
||||
return strapi.query(params.model).count(filters);
|
||||
},
|
||||
|
||||
async create(data, { files, model, source } = {}) {
|
||||
const entry = await strapi.query(model, source).create(data);
|
||||
async create(data, { files, model } = {}) {
|
||||
const entry = await strapi.query(model).create(data);
|
||||
|
||||
if (files) {
|
||||
await uploadFiles(entry, files, { model, source });
|
||||
return strapi.query(model, source).findOne({ id: entry.id });
|
||||
await uploadFiles(entry, files, { model });
|
||||
return strapi.query(model).findOne({ id: entry.id });
|
||||
}
|
||||
|
||||
return entry;
|
||||
},
|
||||
|
||||
async edit(params, data, { model, source, files } = {}) {
|
||||
const entry = await strapi
|
||||
.query(model, source)
|
||||
.update({ id: params.id }, data);
|
||||
async edit(params, data, { model, files } = {}) {
|
||||
const entry = await strapi.query(model).update({ id: params.id }, data);
|
||||
|
||||
if (files) {
|
||||
await uploadFiles(entry, files, { model, source });
|
||||
return strapi.query(model, source).findOne({ id: entry.id });
|
||||
await uploadFiles(entry, files, { model });
|
||||
return strapi.query(model).findOne({ id: entry.id });
|
||||
}
|
||||
|
||||
return entry;
|
||||
},
|
||||
|
||||
delete(params, { source }) {
|
||||
return strapi.query(params.model, source).delete({ id: params.id });
|
||||
delete(params) {
|
||||
return strapi.query(params.model).delete({ id: params.id });
|
||||
},
|
||||
|
||||
deleteMany(params, query) {
|
||||
const { source } = query;
|
||||
const { model } = params;
|
||||
|
||||
const toRemove = Object.values(_.omit(query, 'source'));
|
||||
const { primaryKey } = strapi.query(model, source);
|
||||
const { primaryKey } = strapi.query(model);
|
||||
const filter = { [`${primaryKey}_in`]: toRemove, _limit: 100 };
|
||||
|
||||
return strapi.query(model, source).delete(filter);
|
||||
return strapi.query(model).delete(filter);
|
||||
},
|
||||
|
||||
search(params, query) {
|
||||
const { model } = params;
|
||||
const { source } = query;
|
||||
|
||||
return strapi.query(model, source).search(query);
|
||||
return strapi.query(model).search(query);
|
||||
},
|
||||
|
||||
countSearch(params, query) {
|
||||
const { model } = params;
|
||||
const { source, _q } = query;
|
||||
return strapi.query(model, source).countSearch({ _q });
|
||||
const { _q } = query;
|
||||
return strapi.query(model).countSearch({ _q });
|
||||
},
|
||||
};
|
||||
|
@ -10,6 +10,11 @@ const uidToStoreKey = uid => {
|
||||
return `content_types::${uid}`;
|
||||
};
|
||||
|
||||
const toUID = (name, plugin) => {
|
||||
const model = strapi.getModel(name, plugin);
|
||||
return model.uid;
|
||||
};
|
||||
|
||||
const formatContentTypeLabel = label => _.upperFirst(pluralize(label));
|
||||
|
||||
const HIDDEN_CONTENT_TYPES = [
|
||||
@ -19,89 +24,88 @@ const HIDDEN_CONTENT_TYPES = [
|
||||
'plugins::users-permissions.role',
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
uidToStoreKey,
|
||||
|
||||
getConfiguration(uid) {
|
||||
const storeKey = uidToStoreKey(uid);
|
||||
return storeUtils.getModelConfiguration(storeKey);
|
||||
},
|
||||
|
||||
setConfiguration(uid, input) {
|
||||
const { settings, metadatas, layouts } = input;
|
||||
|
||||
const storeKey = uidToStoreKey(uid);
|
||||
return storeUtils.setModelConfiguration(storeKey, {
|
||||
uid,
|
||||
settings,
|
||||
metadatas,
|
||||
layouts,
|
||||
});
|
||||
},
|
||||
|
||||
deleteConfiguration(uid) {
|
||||
const storeKey = uidToStoreKey(uid);
|
||||
return storeUtils.deleteKey(storeKey);
|
||||
},
|
||||
|
||||
formatContentType(contentType) {
|
||||
return {
|
||||
uid: contentType.uid,
|
||||
name: _.get(contentType, ['info', 'name']),
|
||||
label: formatContentTypeLabel(
|
||||
_.get(contentType, ['info', 'name'], contentType.modelName)
|
||||
),
|
||||
isDisplayed: HIDDEN_CONTENT_TYPES.includes(contentType.uid)
|
||||
? false
|
||||
: true,
|
||||
schema: this.formatContentTypeSchema(contentType),
|
||||
};
|
||||
},
|
||||
|
||||
formatContentTypeSchema(contentType) {
|
||||
const { associations, attributes } = contentType;
|
||||
return {
|
||||
...pickSchemaFields(contentType),
|
||||
attributes: {
|
||||
id: {
|
||||
type: contentType.primaryKeyType,
|
||||
},
|
||||
...Object.keys(attributes).reduce((acc, key) => {
|
||||
const attribute = attributes[key];
|
||||
const assoc = associations.find(assoc => assoc.alias === key);
|
||||
|
||||
if (assoc) {
|
||||
const { plugin } = attribute;
|
||||
let targetEntity = attribute.model || attribute.collection;
|
||||
|
||||
if (plugin === 'upload' && targetEntity === 'file') {
|
||||
acc[key] = {
|
||||
type: 'media',
|
||||
multiple: attribute.collection ? true : false,
|
||||
required: attribute.required ? true : false,
|
||||
};
|
||||
} else {
|
||||
acc[key] = {
|
||||
...attribute,
|
||||
type: 'relation',
|
||||
targetModel: targetEntity,
|
||||
relationType: assoc.nature,
|
||||
};
|
||||
}
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
acc[key] = attribute;
|
||||
return acc;
|
||||
}, {}),
|
||||
...addTimestamps(contentType),
|
||||
},
|
||||
};
|
||||
},
|
||||
const getConfiguration = uid => {
|
||||
const storeKey = uidToStoreKey(uid);
|
||||
return storeUtils.getModelConfiguration(storeKey);
|
||||
};
|
||||
|
||||
function addTimestamps(contentType) {
|
||||
const setConfiguration = (uid, input) => {
|
||||
const { settings, metadatas, layouts } = input;
|
||||
|
||||
const storeKey = uidToStoreKey(uid);
|
||||
return storeUtils.setModelConfiguration(storeKey, {
|
||||
uid,
|
||||
settings,
|
||||
metadatas,
|
||||
layouts,
|
||||
});
|
||||
};
|
||||
|
||||
const deleteConfiguration = uid => {
|
||||
const storeKey = uidToStoreKey(uid);
|
||||
return storeUtils.deleteKey(storeKey);
|
||||
};
|
||||
|
||||
const formatContentType = contentType => {
|
||||
return {
|
||||
uid: contentType.uid,
|
||||
name: _.get(contentType, ['info', 'name']),
|
||||
label: formatContentTypeLabel(
|
||||
_.get(contentType, ['info', 'name'], contentType.modelName)
|
||||
),
|
||||
isDisplayed: HIDDEN_CONTENT_TYPES.includes(contentType.uid) ? false : true,
|
||||
schema: formatContentTypeSchema(contentType),
|
||||
};
|
||||
};
|
||||
|
||||
const formatAttributes = model => {
|
||||
return Object.keys(model.attributes).reduce((acc, key) => {
|
||||
acc[key] = formatAttribute(key, model.attributes[key], { model });
|
||||
return acc;
|
||||
}, {});
|
||||
};
|
||||
|
||||
const formatAttribute = (key, attribute, { model }) => {
|
||||
if (_.has(attribute, 'type')) return attribute;
|
||||
|
||||
// format relations
|
||||
const relation = (model.associations || []).find(
|
||||
assoc => assoc.alias === key
|
||||
);
|
||||
|
||||
const { plugin } = attribute;
|
||||
let targetEntity = attribute.model || attribute.collection;
|
||||
|
||||
if (plugin === 'upload' && targetEntity === 'file') {
|
||||
return {
|
||||
type: 'media',
|
||||
multiple: attribute.collection ? true : false,
|
||||
required: attribute.required ? true : false,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
...attribute,
|
||||
type: 'relation',
|
||||
targetModel: targetEntity === '*' ? '*' : toUID(targetEntity, plugin),
|
||||
relationType: relation.nature,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const formatContentTypeSchema = contentType => {
|
||||
return {
|
||||
...pickSchemaFields(contentType),
|
||||
attributes: {
|
||||
id: {
|
||||
type: contentType.primaryKeyType,
|
||||
},
|
||||
...formatAttributes(contentType),
|
||||
...createTimestampsSchema(contentType),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const createTimestampsSchema = contentType => {
|
||||
if (_.get(contentType, 'options.timestamps', false) === false) {
|
||||
return {};
|
||||
}
|
||||
@ -119,4 +123,12 @@ function addTimestamps(contentType) {
|
||||
type: 'timestamp',
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getConfiguration,
|
||||
setConfiguration,
|
||||
deleteConfiguration,
|
||||
formatContentType,
|
||||
formatContentTypeSchema,
|
||||
};
|
||||
|
@ -6,7 +6,10 @@ let modelsUtils;
|
||||
let rq;
|
||||
|
||||
describe.each([
|
||||
['CONTENT MANAGER', '/content-manager/explorer/withcomponent'],
|
||||
[
|
||||
'CONTENT MANAGER',
|
||||
'/content-manager/explorer/application::withcomponent.withcomponent',
|
||||
],
|
||||
['GENERATED API', '/withcomponents'],
|
||||
])('[%s] => Non repeatable and Not required component', (_, path) => {
|
||||
beforeAll(async () => {
|
||||
|
@ -6,7 +6,10 @@ let modelsUtils;
|
||||
let rq;
|
||||
|
||||
describe.each([
|
||||
['CONTENT MANAGER', '/content-manager/explorer/withcomponent'],
|
||||
[
|
||||
'CONTENT MANAGER',
|
||||
'/content-manager/explorer/application::withcomponent.withcomponent',
|
||||
],
|
||||
['GENERATED API', '/withcomponents'],
|
||||
])('[%s] => Non repeatable and Not required component', (_, path) => {
|
||||
beforeAll(async () => {
|
||||
|
@ -6,7 +6,10 @@ let modelsUtils;
|
||||
let rq;
|
||||
|
||||
describe.each([
|
||||
['CONTENT MANAGER', '/content-manager/explorer/withcomponent'],
|
||||
[
|
||||
'CONTENT MANAGER',
|
||||
'/content-manager/explorer/application::withcomponent.withcomponent',
|
||||
],
|
||||
['GENERATED API', '/withcomponents'],
|
||||
])('[%s] => Non repeatable and Not required component', (_, path) => {
|
||||
beforeAll(async () => {
|
||||
|
@ -6,7 +6,10 @@ let modelsUtils;
|
||||
let rq;
|
||||
|
||||
describe.each([
|
||||
['CONTENT MANAGER', '/content-manager/explorer/withcomponent'],
|
||||
[
|
||||
'CONTENT MANAGER',
|
||||
'/content-manager/explorer/application::withcomponent.withcomponent',
|
||||
],
|
||||
['GENERATED API', '/withcomponents'],
|
||||
])('[%s] => Non repeatable and Not required component', (_, path) => {
|
||||
beforeAll(async () => {
|
||||
|
@ -6,7 +6,10 @@ let modelsUtils;
|
||||
let rq;
|
||||
|
||||
describe.each([
|
||||
['CONTENT MANAGER', '/content-manager/explorer/withcomponent'],
|
||||
[
|
||||
'CONTENT MANAGER',
|
||||
'/content-manager/explorer/application::withcomponent.withcomponent',
|
||||
],
|
||||
['GENERATED API', '/withcomponents'],
|
||||
])('[%s] => Non repeatable and Not required component', (_, path) => {
|
||||
beforeAll(async () => {
|
||||
|
@ -6,7 +6,10 @@ let modelsUtils;
|
||||
let rq;
|
||||
|
||||
describe.each([
|
||||
['CONTENT MANAGER', '/content-manager/explorer/withcomponent'],
|
||||
[
|
||||
'CONTENT MANAGER',
|
||||
'/content-manager/explorer/application::withcomponent.withcomponent',
|
||||
],
|
||||
['GENERATED API', '/withcomponents'],
|
||||
])('[%s] => Non repeatable and required component', (_, path) => {
|
||||
beforeAll(async () => {
|
||||
|
@ -55,7 +55,8 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Create tag1', async () => {
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/tag/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::tag.tag/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'tag1',
|
||||
@ -71,7 +72,8 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Create tag2', async () => {
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/tag/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::tag.tag/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'tag2',
|
||||
@ -87,7 +89,8 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Create tag3', async () => {
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/tag/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::tag.tag/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'tag3',
|
||||
@ -109,7 +112,8 @@ describe('Content Manager End to End', () => {
|
||||
};
|
||||
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/article/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::article.article/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: entry,
|
||||
});
|
||||
@ -131,7 +135,8 @@ describe('Content Manager End to End', () => {
|
||||
};
|
||||
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/article/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::article.article/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: entry,
|
||||
});
|
||||
@ -154,7 +159,7 @@ describe('Content Manager End to End', () => {
|
||||
cleanDate(entry);
|
||||
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/article/${entry.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::article.article/${entry.id}?source=content-manager`,
|
||||
method: 'PUT',
|
||||
body: entry,
|
||||
});
|
||||
@ -177,7 +182,7 @@ describe('Content Manager End to End', () => {
|
||||
cleanDate(entry);
|
||||
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/article/${entry.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::article.article/${entry.id}?source=content-manager`,
|
||||
method: 'PUT',
|
||||
body: entry,
|
||||
});
|
||||
@ -198,7 +203,7 @@ describe('Content Manager End to End', () => {
|
||||
cleanDate(entry);
|
||||
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/article/${entry.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::article.article/${entry.id}?source=content-manager`,
|
||||
method: 'PUT',
|
||||
body: entry,
|
||||
});
|
||||
@ -220,7 +225,7 @@ describe('Content Manager End to End', () => {
|
||||
cleanDate(entry);
|
||||
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/article/${entry.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::article.article/${entry.id}?source=content-manager`,
|
||||
method: 'PUT',
|
||||
body: entry,
|
||||
});
|
||||
@ -236,7 +241,8 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Delete all articles should remove the association in each tags related to them', async () => {
|
||||
const { body: createdTag } = await rq({
|
||||
url: '/content-manager/explorer/tag/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::tag.tag/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'tag11',
|
||||
@ -244,7 +250,8 @@ describe('Content Manager End to End', () => {
|
||||
});
|
||||
|
||||
const { body: article12 } = await rq({
|
||||
url: '/content-manager/explorer/article/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::article.article/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
title: 'article12',
|
||||
@ -254,12 +261,13 @@ describe('Content Manager End to End', () => {
|
||||
});
|
||||
|
||||
const { body: updatedTag } = await rq({
|
||||
url: `/content-manager/explorer/tag/${createdTag.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::tag.tag/${createdTag.id}?source=content-manager`,
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
const { body: article13 } = await rq({
|
||||
url: '/content-manager/explorer/article/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::article.article/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
title: 'article13',
|
||||
@ -276,7 +284,7 @@ describe('Content Manager End to End', () => {
|
||||
expect(articles[1].tags.length).toBe(1);
|
||||
|
||||
let { body: tagToGet } = await rq({
|
||||
url: `/content-manager/explorer/tag/${createdTag.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::tag.tag/${createdTag.id}?source=content-manager`,
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
@ -284,14 +292,14 @@ describe('Content Manager End to End', () => {
|
||||
expect(tagToGet.articles.length).toBe(2);
|
||||
|
||||
await rq({
|
||||
url: `/content-manager/explorer/deleteAll/article/?source=content-manager&${articles
|
||||
url: `/content-manager/explorer/deleteAll/application::article.article/?source=content-manager&${articles
|
||||
.map((article, index) => `${index}=${article.id}`)
|
||||
.join('&')}`,
|
||||
method: 'DELETE',
|
||||
});
|
||||
|
||||
let { body: tagToGet2 } = await rq({
|
||||
url: `/content-manager/explorer/tag/${createdTag.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::tag.tag/${createdTag.id}?source=content-manager`,
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
@ -307,7 +315,8 @@ describe('Content Manager End to End', () => {
|
||||
};
|
||||
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/articlewithtag/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::articlewithtag.articlewithtag/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: entry,
|
||||
});
|
||||
@ -329,7 +338,8 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Create cat1', async () => {
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/category/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::category.category/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'cat1',
|
||||
@ -345,7 +355,8 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Create cat2', async () => {
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/category/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::category.category/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'cat2',
|
||||
@ -367,7 +378,8 @@ describe('Content Manager End to End', () => {
|
||||
};
|
||||
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/article/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::article.article/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: entry,
|
||||
});
|
||||
@ -389,7 +401,7 @@ describe('Content Manager End to End', () => {
|
||||
cleanDate(entry);
|
||||
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/article/${entry.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::article.article/${entry.id}?source=content-manager`,
|
||||
method: 'PUT',
|
||||
body: entry,
|
||||
});
|
||||
@ -410,7 +422,8 @@ describe('Content Manager End to End', () => {
|
||||
};
|
||||
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/article?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::article.article?source=content-manager',
|
||||
method: 'POST',
|
||||
body: entry,
|
||||
});
|
||||
@ -431,7 +444,7 @@ describe('Content Manager End to End', () => {
|
||||
cleanDate(entry);
|
||||
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/article/${entry.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::article.article/${entry.id}?source=content-manager`,
|
||||
method: 'PUT',
|
||||
body: entry,
|
||||
});
|
||||
@ -452,7 +465,7 @@ describe('Content Manager End to End', () => {
|
||||
cleanDate(entry);
|
||||
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/category/${entry.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::category.category/${entry.id}?source=content-manager`,
|
||||
method: 'PUT',
|
||||
body: entry,
|
||||
});
|
||||
@ -472,7 +485,8 @@ describe('Content Manager End to End', () => {
|
||||
};
|
||||
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/category/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::category.category/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: entry,
|
||||
});
|
||||
@ -487,7 +501,7 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Get article1 with cat3', async () => {
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/article/${data.articles[0].id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::article.article/${data.articles[0].id}?source=content-manager`,
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
@ -497,7 +511,7 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Get article2 with cat2', async () => {
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/article/${data.articles[1].id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::article.article/${data.articles[1].id}?source=content-manager`,
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
@ -507,7 +521,7 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Get cat1 without relations', async () => {
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/category/${data.categories[0].id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::category.category/${data.categories[0].id}?source=content-manager`,
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
@ -517,7 +531,7 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Get cat2 with article2', async () => {
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/category/${data.categories[1].id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::category.category/${data.categories[1].id}?source=content-manager`,
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
@ -528,7 +542,7 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Get cat3 with article1', async () => {
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/category/${data.categories[2].id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::category.category/${data.categories[2].id}?source=content-manager`,
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
@ -548,7 +562,8 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Create ref1', async () => {
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/reference/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::reference.reference/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'ref1',
|
||||
@ -568,7 +583,8 @@ describe('Content Manager End to End', () => {
|
||||
};
|
||||
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/article?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::article.article?source=content-manager',
|
||||
method: 'POST',
|
||||
body: entry,
|
||||
});
|
||||
@ -588,7 +604,7 @@ describe('Content Manager End to End', () => {
|
||||
cleanDate(entry);
|
||||
|
||||
let { body } = await rq({
|
||||
url: `/content-manager/explorer/article/${entry.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::article.article/${entry.id}?source=content-manager`,
|
||||
method: 'PUT',
|
||||
body: entry,
|
||||
});
|
||||
@ -609,7 +625,8 @@ describe('Content Manager End to End', () => {
|
||||
};
|
||||
|
||||
let { body } = await rq({
|
||||
url: '/content-manager/explorer/article?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::article.article?source=content-manager',
|
||||
method: 'POST',
|
||||
body: entry,
|
||||
});
|
||||
@ -626,7 +643,8 @@ describe('Content Manager End to End', () => {
|
||||
describe('Test oneWay relation (reference - tag) with Content Manager', () => {
|
||||
test('Attach Tag to a Reference', async () => {
|
||||
const { body: tagToCreate } = await rq({
|
||||
url: '/content-manager/explorer/tag/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::tag.tag/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'tag111',
|
||||
@ -634,7 +652,8 @@ describe('Content Manager End to End', () => {
|
||||
});
|
||||
|
||||
const { body: referenceToCreate } = await rq({
|
||||
url: '/content-manager/explorer/reference/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::reference.reference/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'cat111',
|
||||
@ -647,7 +666,8 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Detach Tag to a Reference', async () => {
|
||||
const { body: tagToCreate } = await rq({
|
||||
url: '/content-manager/explorer/tag/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::tag.tag/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'tag111',
|
||||
@ -655,7 +675,8 @@ describe('Content Manager End to End', () => {
|
||||
});
|
||||
|
||||
const { body: referenceToCreate } = await rq({
|
||||
url: '/content-manager/explorer/reference/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::reference.reference/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'cat111',
|
||||
@ -666,7 +687,7 @@ describe('Content Manager End to End', () => {
|
||||
expect(referenceToCreate.tag.id).toBe(tagToCreate.id);
|
||||
|
||||
const { body: referenceToUpdate } = await rq({
|
||||
url: `/content-manager/explorer/reference/${referenceToCreate.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::reference.reference/${referenceToCreate.id}?source=content-manager`,
|
||||
method: 'PUT',
|
||||
body: {
|
||||
tag: null,
|
||||
@ -678,7 +699,8 @@ describe('Content Manager End to End', () => {
|
||||
|
||||
test('Delete Tag so the relation in the Reference side should be removed', async () => {
|
||||
const { body: tagToCreate } = await rq({
|
||||
url: '/content-manager/explorer/tag/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::tag.tag/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'tag111',
|
||||
@ -686,7 +708,8 @@ describe('Content Manager End to End', () => {
|
||||
});
|
||||
|
||||
const { body: referenceToCreate } = await rq({
|
||||
url: '/content-manager/explorer/reference/?source=content-manager',
|
||||
url:
|
||||
'/content-manager/explorer/application::reference.reference/?source=content-manager',
|
||||
method: 'POST',
|
||||
body: {
|
||||
name: 'cat111',
|
||||
@ -695,12 +718,12 @@ describe('Content Manager End to End', () => {
|
||||
});
|
||||
|
||||
await rq({
|
||||
url: `/content-manager/explorer/tag/${tagToCreate.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::tag.tag/${tagToCreate.id}?source=content-manager`,
|
||||
method: 'DELETE',
|
||||
});
|
||||
|
||||
const { body: referenceToGet } = await rq({
|
||||
url: `/content-manager/explorer/reference/${referenceToCreate.id}?source=content-manager`,
|
||||
url: `/content-manager/explorer/application::reference.reference/${referenceToCreate.id}?source=content-manager`,
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
|
@ -21,11 +21,14 @@ describe('Test type biginteger', () => {
|
||||
|
||||
test('Create entry with value input JSON', async () => {
|
||||
const inputValue = '1223372036854775';
|
||||
const res = await rq.post('/content-manager/explorer/withbiginteger', {
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withbiginteger.withbiginteger',
|
||||
{
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -35,11 +38,14 @@ describe('Test type biginteger', () => {
|
||||
|
||||
test('Create entry with value input Formdata', async () => {
|
||||
const inputValue = '1223372036854775';
|
||||
const res = await rq.post('/content-manager/explorer/withbiginteger', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: inputValue }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withbiginteger.withbiginteger',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: inputValue }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -49,11 +55,14 @@ describe('Test type biginteger', () => {
|
||||
|
||||
test('Create entry with integer should return a string', async () => {
|
||||
const inputValue = 1821;
|
||||
const res = await rq.post('/content-manager/explorer/withbiginteger', {
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withbiginteger.withbiginteger',
|
||||
{
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -62,7 +71,9 @@ describe('Test type biginteger', () => {
|
||||
});
|
||||
|
||||
test('Reading entry, returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withbiginteger');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withbiginteger.withbiginteger'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -73,15 +84,18 @@ describe('Test type biginteger', () => {
|
||||
|
||||
test('Updating entry sets the right value and format', async () => {
|
||||
const inputValue = '1223372036854775';
|
||||
const res = await rq.post('/content-manager/explorer/withbiginteger', {
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withbiginteger.withbiginteger',
|
||||
{
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const newVal = '9882823782712112';
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withbiginteger/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withbiginteger.withbiginteger/${res.body.id}`,
|
||||
{
|
||||
body: {
|
||||
field: newVal,
|
||||
|
@ -20,11 +20,14 @@ describe('Test type boolean', () => {
|
||||
}, 60000);
|
||||
|
||||
test('Create entry with value input JSON', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withboolean', {
|
||||
body: {
|
||||
field: true,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withboolean.withboolean',
|
||||
{
|
||||
body: {
|
||||
field: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -33,11 +36,14 @@ describe('Test type boolean', () => {
|
||||
});
|
||||
|
||||
test('Create entry with value input FromData', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withboolean', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: true }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withboolean.withboolean',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: true }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -48,18 +54,24 @@ describe('Test type boolean', () => {
|
||||
test.todo('Throws on invalid boolean value');
|
||||
|
||||
test('Convert integer to boolean value', async () => {
|
||||
let res = await rq.post('/content-manager/explorer/withboolean', {
|
||||
body: { field: 1 },
|
||||
});
|
||||
let res = await rq.post(
|
||||
'/content-manager/explorer/application::withboolean.withboolean',
|
||||
{
|
||||
body: { field: 1 },
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
field: true,
|
||||
});
|
||||
|
||||
res = await rq.post('/content-manager/explorer/withboolean', {
|
||||
body: { field: 0 },
|
||||
});
|
||||
res = await rq.post(
|
||||
'/content-manager/explorer/application::withboolean.withboolean',
|
||||
{
|
||||
body: { field: 0 },
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -68,7 +80,9 @@ describe('Test type boolean', () => {
|
||||
});
|
||||
|
||||
test('Reading entry, returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withboolean');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withboolean.withboolean'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -82,14 +96,17 @@ describe('Test type boolean', () => {
|
||||
});
|
||||
|
||||
test('Updating entry sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withboolean', {
|
||||
body: {
|
||||
field: true,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withboolean.withboolean',
|
||||
{
|
||||
body: {
|
||||
field: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withboolean/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withboolean.withboolean/${res.body.id}`,
|
||||
{
|
||||
body: {
|
||||
field: false,
|
||||
|
@ -20,11 +20,14 @@ describe('Test type date', () => {
|
||||
}, 60000);
|
||||
|
||||
test('Create entry with valid value JSON', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withdate', {
|
||||
body: {
|
||||
field: '2019-08-08T10:10:57.000Z',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withdate.withdate',
|
||||
{
|
||||
body: {
|
||||
field: '2019-08-08T10:10:57.000Z',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -35,11 +38,14 @@ describe('Test type date', () => {
|
||||
test('Create entry with valid value FormData', async () => {
|
||||
const now = new Date(2019, 0, 12);
|
||||
|
||||
const res = await rq.post('/content-manager/explorer/withdate', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: now }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withdate.withdate',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: now }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -50,11 +56,14 @@ describe('Test type date', () => {
|
||||
test('Create entry with timestamp value should be converted to ISO', async () => {
|
||||
const now = new Date(2016, 4, 8);
|
||||
|
||||
const res = await rq.post('/content-manager/explorer/withdate', {
|
||||
body: {
|
||||
field: now.getTime(),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withdate.withdate',
|
||||
{
|
||||
body: {
|
||||
field: now.getTime(),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -65,11 +74,14 @@ describe('Test type date', () => {
|
||||
test('Accepts string timestamp', async () => {
|
||||
const now = new Date(2000, 0, 1);
|
||||
|
||||
const res = await rq.post('/content-manager/explorer/withdate', {
|
||||
body: {
|
||||
field: `${now.getTime()}`,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withdate.withdate',
|
||||
{
|
||||
body: {
|
||||
field: `${now.getTime()}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -78,17 +90,22 @@ describe('Test type date', () => {
|
||||
});
|
||||
|
||||
test('Throws on invalid date format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withdate', {
|
||||
body: {
|
||||
field: 'azdazindoaizdnoainzd',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withdate.withdate',
|
||||
{
|
||||
body: {
|
||||
field: 'azdazindoaizdnoainzd',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(400);
|
||||
});
|
||||
|
||||
test('Reading entry, returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withdate');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withdate.withdate'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -100,15 +117,18 @@ describe('Test type date', () => {
|
||||
test('Updating entry sets the right value and format JSON', async () => {
|
||||
const now = new Date(2018, 7, 5);
|
||||
|
||||
const res = await rq.post('/content-manager/explorer/withdate', {
|
||||
body: {
|
||||
field: now.getTime(),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withdate.withdate',
|
||||
{
|
||||
body: {
|
||||
field: now.getTime(),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const newDate = new Date(2017, 10, 23);
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withdate/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withdate.withdate/${res.body.id}`,
|
||||
{
|
||||
body: {
|
||||
field: newDate,
|
||||
|
@ -21,11 +21,14 @@ describe('Test type decimal', () => {
|
||||
|
||||
test('Create entry with value input JSON', async () => {
|
||||
const inputValue = 12.31;
|
||||
const res = await rq.post('/content-manager/explorer/withdecimal', {
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withdecimal.withdecimal',
|
||||
{
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -35,11 +38,14 @@ describe('Test type decimal', () => {
|
||||
|
||||
test('Create entry with value input Formdata', async () => {
|
||||
const inputValue = 23.1;
|
||||
const res = await rq.post('/content-manager/explorer/withdecimal', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: inputValue }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withdecimal.withdecimal',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: inputValue }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -49,11 +55,14 @@ describe('Test type decimal', () => {
|
||||
|
||||
test('Create entry with integer should convert to decimal', async () => {
|
||||
const inputValue = 1821;
|
||||
const res = await rq.post('/content-manager/explorer/withdecimal', {
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withdecimal.withdecimal',
|
||||
{
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -62,7 +71,9 @@ describe('Test type decimal', () => {
|
||||
});
|
||||
|
||||
test('Reading entry, returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withdecimal');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withdecimal.withdecimal'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -72,14 +83,17 @@ describe('Test type decimal', () => {
|
||||
});
|
||||
|
||||
test('Updating entry sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withdecimal', {
|
||||
body: {
|
||||
field: 11.2,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withdecimal.withdecimal',
|
||||
{
|
||||
body: {
|
||||
field: 11.2,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withdecimal/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withdecimal.withdecimal/${res.body.id}`,
|
||||
{
|
||||
body: {
|
||||
field: 14,
|
||||
|
@ -20,11 +20,14 @@ describe('Test type email', () => {
|
||||
}, 60000);
|
||||
|
||||
test('Create entry with value input JSON', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withemail', {
|
||||
body: {
|
||||
field: 'someemail',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withemail.withemail',
|
||||
{
|
||||
body: {
|
||||
field: 'someemail',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -35,11 +38,14 @@ describe('Test type email', () => {
|
||||
test.todo('Should Throw on invalid email');
|
||||
|
||||
test('Create entry with value input Formdata', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withemail', {
|
||||
body: {
|
||||
field: 1234567,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withemail.withemail',
|
||||
{
|
||||
body: {
|
||||
field: 1234567,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -48,7 +54,9 @@ describe('Test type email', () => {
|
||||
});
|
||||
|
||||
test('Reading entry returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withemail');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withemail.withemail'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -62,14 +70,17 @@ describe('Test type email', () => {
|
||||
});
|
||||
|
||||
test('Updating entry sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withemail', {
|
||||
body: {
|
||||
field: 'someemail',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withemail.withemail',
|
||||
{
|
||||
body: {
|
||||
field: 'someemail',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withemail/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withemail.withemail/${res.body.id}`,
|
||||
{
|
||||
body: {
|
||||
field: 'otherPwd',
|
||||
|
@ -22,11 +22,14 @@ describe('Test type enumeration', () => {
|
||||
}, 60000);
|
||||
|
||||
test('Create entry value enumeration input JSON', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withenumeration', {
|
||||
body: {
|
||||
field: 'one',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withenumeration.withenumeration',
|
||||
{
|
||||
body: {
|
||||
field: 'one',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200); // should return 201
|
||||
expect(res.body).toMatchObject({
|
||||
@ -35,11 +38,14 @@ describe('Test type enumeration', () => {
|
||||
});
|
||||
|
||||
test('Create entry value enumeration input Formdata', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withenumeration', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 'two' }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withenumeration.withenumeration',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 'two' }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200); // should return 201
|
||||
expect(res.body).toMatchObject({
|
||||
@ -48,7 +54,9 @@ describe('Test type enumeration', () => {
|
||||
});
|
||||
|
||||
test('Reading entry, returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withenumeration');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withenumeration.withenumeration'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -58,14 +66,17 @@ describe('Test type enumeration', () => {
|
||||
});
|
||||
|
||||
test('Updating entry sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withenumeration', {
|
||||
body: {
|
||||
field: 'two',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withenumeration.withenumeration',
|
||||
{
|
||||
body: {
|
||||
field: 'two',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withenumeration/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withenumeration.withenumeration/${res.body.id}`,
|
||||
{
|
||||
body: {
|
||||
field: 'one',
|
||||
|
@ -21,11 +21,14 @@ describe('Test type float', () => {
|
||||
|
||||
test('Create entry with value input JSON', async () => {
|
||||
const inputValue = 12.31;
|
||||
const res = await rq.post('/content-manager/explorer/withfloat', {
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withfloat.withfloat',
|
||||
{
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -35,11 +38,14 @@ describe('Test type float', () => {
|
||||
|
||||
test('Create entry with value input Formdata', async () => {
|
||||
const inputValue = 23.1;
|
||||
const res = await rq.post('/content-manager/explorer/withfloat', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: inputValue }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withfloat.withfloat',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: inputValue }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -49,11 +55,14 @@ describe('Test type float', () => {
|
||||
|
||||
test('Create entry with integer should convert to float', async () => {
|
||||
const inputValue = 1821;
|
||||
const res = await rq.post('/content-manager/explorer/withfloat', {
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withfloat.withfloat',
|
||||
{
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -62,7 +71,9 @@ describe('Test type float', () => {
|
||||
});
|
||||
|
||||
test('Reading entry, returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withfloat');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withfloat.withfloat'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -72,14 +83,17 @@ describe('Test type float', () => {
|
||||
});
|
||||
|
||||
test('Updating entry sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withfloat', {
|
||||
body: {
|
||||
field: 11.2,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withfloat.withfloat',
|
||||
{
|
||||
body: {
|
||||
field: 11.2,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withfloat/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withfloat.withfloat/${res.body.id}`,
|
||||
{
|
||||
body: {
|
||||
field: 14,
|
||||
|
@ -20,11 +20,14 @@ describe('Test type integer', () => {
|
||||
}, 60000);
|
||||
|
||||
test('Create entry with value input JSON', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withinteger', {
|
||||
body: {
|
||||
field: 123456,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withinteger.withinteger',
|
||||
{
|
||||
body: {
|
||||
field: 123456,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -33,11 +36,14 @@ describe('Test type integer', () => {
|
||||
});
|
||||
|
||||
test('Create entry with value input Fromdata', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withinteger', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 123456 }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withinteger.withinteger',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 123456 }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -47,11 +53,14 @@ describe('Test type integer', () => {
|
||||
|
||||
// I don't think it will work everywhere ...
|
||||
test('Create entry with a string should cast the value', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withinteger', {
|
||||
body: {
|
||||
field: '123456',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withinteger.withinteger',
|
||||
{
|
||||
body: {
|
||||
field: '123456',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -60,7 +69,9 @@ describe('Test type integer', () => {
|
||||
});
|
||||
|
||||
test('Reading entry, returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withinteger');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withinteger.withinteger'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -70,14 +81,17 @@ describe('Test type integer', () => {
|
||||
});
|
||||
|
||||
test('Updating entry sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withinteger', {
|
||||
body: {
|
||||
field: 123,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withinteger.withinteger',
|
||||
{
|
||||
body: {
|
||||
field: 123,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const updatedRes = await rq.put(
|
||||
`/content-manager/explorer/withinteger/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withinteger.withinteger/${res.body.id}`,
|
||||
{
|
||||
body: {
|
||||
field: 543,
|
||||
|
@ -23,11 +23,14 @@ describe('Test type json', () => {
|
||||
const inputValue = {
|
||||
key: 'value',
|
||||
};
|
||||
const res = await rq.post('/content-manager/explorer/withjson', {
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withjson.withjson',
|
||||
{
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -44,11 +47,14 @@ describe('Test type json', () => {
|
||||
key: 'value',
|
||||
},
|
||||
];
|
||||
const res = await rq.post('/content-manager/explorer/withjson', {
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withjson.withjson',
|
||||
{
|
||||
body: {
|
||||
field: inputValue,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -60,11 +66,14 @@ describe('Test type json', () => {
|
||||
const inputValue = {
|
||||
number: '12',
|
||||
};
|
||||
const res = await rq.post('/content-manager/explorer/withjson', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: inputValue }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withjson.withjson',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: inputValue }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -73,7 +82,9 @@ describe('Test type json', () => {
|
||||
});
|
||||
|
||||
test('Reading entry, returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withjson');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withjson.withjson'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -87,16 +98,19 @@ describe('Test type json', () => {
|
||||
test.todo('Throw when input is not a nested object');
|
||||
|
||||
test('Updating entry sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withjson', {
|
||||
body: {
|
||||
field: {
|
||||
key: 'value',
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withjson.withjson',
|
||||
{
|
||||
body: {
|
||||
field: {
|
||||
key: 'value',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withjson/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withjson.withjson/${res.body.id}`,
|
||||
{
|
||||
body: {
|
||||
field: {
|
||||
|
@ -20,11 +20,14 @@ describe('Test type password', () => {
|
||||
}, 60000);
|
||||
|
||||
test('Create entry with value input JSON', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withpassword', {
|
||||
body: {
|
||||
field: 'somePassword',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withpassword.withpassword',
|
||||
{
|
||||
body: {
|
||||
field: 'somePassword',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -35,11 +38,14 @@ describe('Test type password', () => {
|
||||
test.todo('Should be private by default');
|
||||
|
||||
test('Create entry with value input Formdata', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withpassword', {
|
||||
body: {
|
||||
field: 1234567,
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withpassword.withpassword',
|
||||
{
|
||||
body: {
|
||||
field: 1234567,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -48,7 +54,9 @@ describe('Test type password', () => {
|
||||
});
|
||||
|
||||
test('Reading entry returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withpassword');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withpassword.withpassword'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -62,14 +70,17 @@ describe('Test type password', () => {
|
||||
});
|
||||
|
||||
test('Updating entry sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withpassword', {
|
||||
body: {
|
||||
field: 'somePassword',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withpassword.withpassword',
|
||||
{
|
||||
body: {
|
||||
field: 'somePassword',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withpassword/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withpassword.withpassword/${res.body.id}`,
|
||||
{
|
||||
body: {
|
||||
field: 'otherPwd',
|
||||
|
@ -20,11 +20,14 @@ describe('Test type richtext', () => {
|
||||
}, 60000);
|
||||
|
||||
test('Creates an entry with JSON', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withrichtext', {
|
||||
body: {
|
||||
field: 'Some\ntext',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withrichtext.withrichtext',
|
||||
{
|
||||
body: {
|
||||
field: 'Some\ntext',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -33,11 +36,14 @@ describe('Test type richtext', () => {
|
||||
});
|
||||
|
||||
test('Creates an entry with formData', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withrichtext', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: '"Some \ntext"' }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withrichtext.withrichtext',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: '"Some \ntext"' }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -46,7 +52,9 @@ describe('Test type richtext', () => {
|
||||
});
|
||||
|
||||
test('Reading entry, returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withrichtext');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withrichtext.withrichtext'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -60,12 +68,15 @@ describe('Test type richtext', () => {
|
||||
});
|
||||
|
||||
test('Updating entry with JSON sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withrichtext', {
|
||||
body: { field: 'Some \ntext' },
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withrichtext.withrichtext',
|
||||
{
|
||||
body: { field: 'Some \ntext' },
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withrichtext/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withrichtext.withrichtext/${res.body.id}`,
|
||||
{
|
||||
body: { field: 'Updated \nstring' },
|
||||
}
|
||||
@ -78,14 +89,17 @@ describe('Test type richtext', () => {
|
||||
});
|
||||
|
||||
test('Updating entry with Formdata sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withrichtext', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 'Some string' }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withrichtext.withrichtext',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 'Some string' }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withrichtext/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withrichtext.withrichtext/${res.body.id}`,
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 'Updated \nstring' }),
|
||||
|
@ -20,11 +20,14 @@ describe('Test type string', () => {
|
||||
}, 60000);
|
||||
|
||||
test('Creates an entry with JSON', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withstring', {
|
||||
body: {
|
||||
field: 'Some string',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withstring.withstring',
|
||||
{
|
||||
body: {
|
||||
field: 'Some string',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -33,11 +36,14 @@ describe('Test type string', () => {
|
||||
});
|
||||
|
||||
test('Creates an entry with formData', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withstring', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: '"Some string"' }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withstring.withstring',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: '"Some string"' }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -46,7 +52,9 @@ describe('Test type string', () => {
|
||||
});
|
||||
|
||||
test('Reading entry, returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withstring');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withstring.withstring'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -60,12 +68,15 @@ describe('Test type string', () => {
|
||||
});
|
||||
|
||||
test('Updating entry with JSON sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withstring', {
|
||||
body: { field: 'Some string' },
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withstring.withstring',
|
||||
{
|
||||
body: { field: 'Some string' },
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withstring/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withstring.withstring/${res.body.id}`,
|
||||
{
|
||||
body: { field: 'Updated string' },
|
||||
}
|
||||
@ -78,14 +89,17 @@ describe('Test type string', () => {
|
||||
});
|
||||
|
||||
test('Updating entry with Formdata sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withstring', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 'Some string' }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withstring.withstring',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 'Some string' }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withstring/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withstring.withstring/${res.body.id}`,
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 'Updated string' }),
|
||||
|
@ -20,11 +20,14 @@ describe('Test type text', () => {
|
||||
}, 60000);
|
||||
|
||||
test('Creates an entry with JSON', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withtext', {
|
||||
body: {
|
||||
field: 'Some\ntext',
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withtext.withtext',
|
||||
{
|
||||
body: {
|
||||
field: 'Some\ntext',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -33,11 +36,14 @@ describe('Test type text', () => {
|
||||
});
|
||||
|
||||
test('Creates an entry with formData', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withtext', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: '"Some \ntext"' }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withtext.withtext',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: '"Some \ntext"' }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
@ -46,7 +52,9 @@ describe('Test type text', () => {
|
||||
});
|
||||
|
||||
test('Reading entry, returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withtext');
|
||||
const res = await rq.get(
|
||||
'/content-manager/explorer/application::withtext.withtext'
|
||||
);
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
@ -60,12 +68,15 @@ describe('Test type text', () => {
|
||||
});
|
||||
|
||||
test('Updating entry with JSON sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withtext', {
|
||||
body: { field: 'Some \ntext' },
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withtext.withtext',
|
||||
{
|
||||
body: { field: 'Some \ntext' },
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withtext/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withtext.withtext/${res.body.id}`,
|
||||
{
|
||||
body: { field: 'Updated \nstring' },
|
||||
}
|
||||
@ -78,14 +89,17 @@ describe('Test type text', () => {
|
||||
});
|
||||
|
||||
test('Updating entry with Formdata sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withtext', {
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 'Some string' }),
|
||||
},
|
||||
});
|
||||
const res = await rq.post(
|
||||
'/content-manager/explorer/application::withtext.withtext',
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 'Some string' }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withtext/${res.body.id}`,
|
||||
`/content-manager/explorer/application::withtext.withtext/${res.body.id}`,
|
||||
{
|
||||
formData: {
|
||||
data: JSON.stringify({ field: 'Updated \nstring' }),
|
||||
|
@ -64,7 +64,7 @@ const formatAttribute = (key, attribute, { model }) => {
|
||||
} else {
|
||||
return {
|
||||
nature: relation.nature,
|
||||
target: toUID(targetEntity, plugin),
|
||||
target: targetEntity === '*' ? targetEntity : toUID(targetEntity, plugin),
|
||||
plugin: plugin || undefined,
|
||||
dominant: attribute.dominant ? true : false,
|
||||
targetAttribute: attribute.via || undefined,
|
||||
|
1
packages/strapi/lib/core/bootstrap.js
vendored
1
packages/strapi/lib/core/bootstrap.js
vendored
@ -158,6 +158,7 @@ module.exports = function(strapi) {
|
||||
__schema__: pickSchema(model),
|
||||
modelType: 'contentType',
|
||||
uid: `strapi::${key}`,
|
||||
plugin: 'admin',
|
||||
modelName: key,
|
||||
identity: model.identity || _.upperFirst(key),
|
||||
globalId: model.globalId || _.upperFirst(_.camelCase(`admin-${key}`)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user