mirror of
https://github.com/strapi/strapi.git
synced 2025-08-19 14:19:03 +00:00
Fix some E2E tests
This commit is contained in:
parent
f4981dd8e7
commit
9e75d59e15
@ -7,7 +7,6 @@ const generator = require('@strapi/generate');
|
|||||||
const { nameToSlug, contentTypes: contentTypesUtils } = require('@strapi/utils');
|
const { nameToSlug, contentTypes: contentTypesUtils } = require('@strapi/utils');
|
||||||
const { formatAttributes, replaceTemporaryUIDs } = require('../utils/attributes');
|
const { formatAttributes, replaceTemporaryUIDs } = require('../utils/attributes');
|
||||||
const createBuilder = require('./schema-builder');
|
const createBuilder = require('./schema-builder');
|
||||||
const apiHandler = require('./api-handler');
|
|
||||||
const { coreUids, pluginsUids } = require('./constants');
|
const { coreUids, pluginsUids } = require('./constants');
|
||||||
|
|
||||||
const isContentTypeVisible = model =>
|
const isContentTypeVisible = model =>
|
||||||
@ -187,6 +186,7 @@ const editContentType = async (uid, { contentType, components = [] }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (newKind !== previousKind) {
|
if (newKind !== previousKind) {
|
||||||
|
const apiHandler = strapi.service('plugin::content-type-builder.api-handler');
|
||||||
await apiHandler.backup(uid);
|
await apiHandler.backup(uid);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -213,6 +213,7 @@ const editContentType = async (uid, { contentType, components = [] }) => {
|
|||||||
|
|
||||||
const deleteContentTypes = async uids => {
|
const deleteContentTypes = async uids => {
|
||||||
const builder = createBuilder();
|
const builder = createBuilder();
|
||||||
|
const apiHandler = strapi.service('plugin::content-type-builder.api-handler');
|
||||||
|
|
||||||
for (const uid of uids) {
|
for (const uid of uids) {
|
||||||
await deleteContentType(uid, builder);
|
await deleteContentType(uid, builder);
|
||||||
@ -237,6 +238,8 @@ const deleteContentTypes = async uids => {
|
|||||||
const deleteContentType = async (uid, defaultBuilder = undefined) => {
|
const deleteContentType = async (uid, defaultBuilder = undefined) => {
|
||||||
const builder = defaultBuilder || createBuilder();
|
const builder = defaultBuilder || createBuilder();
|
||||||
// make a backup
|
// make a backup
|
||||||
|
const apiHandler = strapi.service('plugin::content-type-builder.api-handler');
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||||
await apiHandler.backup(uid);
|
await apiHandler.backup(uid);
|
||||||
|
|
||||||
const contentType = builder.deleteContentType(uid);
|
const contentType = builder.deleteContentType(uid);
|
||||||
|
@ -78,6 +78,10 @@ class Strapi {
|
|||||||
return ee({ dir: this.dir, logger: this.log });
|
return ee({ dir: this.dir, logger: this.log });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service(uid) {
|
||||||
|
return this.container.get('services').get(uid);
|
||||||
|
}
|
||||||
|
|
||||||
plugin(name) {
|
plugin(name) {
|
||||||
return this.container.get('modules').get(`plugin::${name}`);
|
return this.container.get('modules').get(`plugin::${name}`);
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ module.exports = ({ strapi }) => ({
|
|||||||
return acc.concat(_.get(strapi.api[current].config, 'routes', []));
|
return acc.concat(_.get(strapi.api[current].config, 'routes', []));
|
||||||
}, []);
|
}, []);
|
||||||
const pluginsRoutes = Object.keys(strapi.plugins).reduce((acc, current) => {
|
const pluginsRoutes = Object.keys(strapi.plugins).reduce((acc, current) => {
|
||||||
const routes = strapi.container.plugin(current).routes.reduce((acc, curr) => {
|
const routes = strapi.plugin(current).routes.reduce((acc, curr) => {
|
||||||
const prefix = curr.config.prefix;
|
const prefix = curr.config.prefix;
|
||||||
const path = prefix !== undefined ? `${prefix}${curr.path}` : `/${current}${curr.path}`;
|
const path = prefix !== undefined ? `${prefix}${curr.path}` : `/${current}${curr.path}`;
|
||||||
_.set(curr, 'path', path);
|
_.set(curr, 'path', path);
|
||||||
|
@ -18,11 +18,11 @@ module.exports = {
|
|||||||
author: {
|
author: {
|
||||||
type: 'relation',
|
type: 'relation',
|
||||||
relation: 'manyToOne',
|
relation: 'manyToOne',
|
||||||
target: 'plugins::users-permissions.user',
|
target: 'plugin::users-permissions.user',
|
||||||
targetAttribute: 'articles',
|
targetAttribute: 'articles',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
uid: 'application::article.article',
|
uid: 'api::article.article',
|
||||||
name: 'article',
|
name: 'article',
|
||||||
description: '',
|
description: '',
|
||||||
collectionName: '',
|
collectionName: '',
|
||||||
@ -35,11 +35,11 @@ module.exports = {
|
|||||||
articles: {
|
articles: {
|
||||||
type: 'relation',
|
type: 'relation',
|
||||||
relation: 'manyToMany',
|
relation: 'manyToMany',
|
||||||
target: 'application::article.article',
|
target: 'api::article.article',
|
||||||
targetAttribute: 'tags',
|
targetAttribute: 'tags',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
uid: 'application::tag.tag',
|
uid: 'api::tag.tag',
|
||||||
name: 'tag',
|
name: 'tag',
|
||||||
description: '',
|
description: '',
|
||||||
collectionName: '',
|
collectionName: '',
|
||||||
@ -52,11 +52,11 @@ module.exports = {
|
|||||||
articles: {
|
articles: {
|
||||||
type: 'relation',
|
type: 'relation',
|
||||||
relation: 'oneToMany',
|
relation: 'oneToMany',
|
||||||
target: 'application::article.article',
|
target: 'api::article.article',
|
||||||
targetAttribute: 'category',
|
targetAttribute: 'category',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
uid: 'application::category.category',
|
uid: 'api::category.category',
|
||||||
name: 'category',
|
name: 'category',
|
||||||
description: '',
|
description: '',
|
||||||
collectionName: '',
|
collectionName: '',
|
||||||
@ -69,16 +69,16 @@ module.exports = {
|
|||||||
article: {
|
article: {
|
||||||
type: 'relation',
|
type: 'relation',
|
||||||
relation: 'oneToOne',
|
relation: 'oneToOne',
|
||||||
target: 'application::article.article',
|
target: 'api::article.article',
|
||||||
targetAttribute: 'reference',
|
targetAttribute: 'reference',
|
||||||
},
|
},
|
||||||
tag: {
|
tag: {
|
||||||
type: 'relation',
|
type: 'relation',
|
||||||
relation: 'oneToOne',
|
relation: 'oneToOne',
|
||||||
target: 'application::tag.tag',
|
target: 'api::tag.tag',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
uid: 'application::reference.reference',
|
uid: 'api::reference.reference',
|
||||||
name: 'reference',
|
name: 'reference',
|
||||||
description: '',
|
description: '',
|
||||||
collectionName: 'refs',
|
collectionName: 'refs',
|
||||||
@ -95,7 +95,7 @@ module.exports = {
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
uid: 'application::product.product',
|
uid: 'api::product.product',
|
||||||
name: 'product',
|
name: 'product',
|
||||||
description: '',
|
description: '',
|
||||||
collectionName: '',
|
collectionName: '',
|
||||||
@ -108,10 +108,10 @@ module.exports = {
|
|||||||
tags: {
|
tags: {
|
||||||
type: 'relation',
|
type: 'relation',
|
||||||
relation: 'oneToMany',
|
relation: 'oneToMany',
|
||||||
target: 'application::tag.tag',
|
target: 'api::tag.tag',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
uid: 'application::articlewit.articlewit',
|
uid: 'api::articlewit.articlewit',
|
||||||
name: 'articlewithtag',
|
name: 'articlewithtag',
|
||||||
description: '',
|
description: '',
|
||||||
collectionName: '',
|
collectionName: '',
|
||||||
|
@ -4,7 +4,7 @@ const { isFunction, isNil, prop } = require('lodash/fp');
|
|||||||
const { createStrapiInstance } = require('./strapi');
|
const { createStrapiInstance } = require('./strapi');
|
||||||
|
|
||||||
const toUID = name => {
|
const toUID = name => {
|
||||||
return name.includes('::') ? name : `application::${name}.${name}`;
|
return name.includes('::') ? name : `api::${name}.${name}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createHelpers = async ({ strapi: strapiInstance = null, ...options } = {}) => {
|
const createHelpers = async ({ strapi: strapiInstance = null, ...options } = {}) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user