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 { formatAttributes, replaceTemporaryUIDs } = require('../utils/attributes');
|
||||
const createBuilder = require('./schema-builder');
|
||||
const apiHandler = require('./api-handler');
|
||||
const { coreUids, pluginsUids } = require('./constants');
|
||||
|
||||
const isContentTypeVisible = model =>
|
||||
@ -187,6 +186,7 @@ const editContentType = async (uid, { contentType, components = [] }) => {
|
||||
});
|
||||
|
||||
if (newKind !== previousKind) {
|
||||
const apiHandler = strapi.service('plugin::content-type-builder.api-handler');
|
||||
await apiHandler.backup(uid);
|
||||
|
||||
try {
|
||||
@ -213,6 +213,7 @@ const editContentType = async (uid, { contentType, components = [] }) => {
|
||||
|
||||
const deleteContentTypes = async uids => {
|
||||
const builder = createBuilder();
|
||||
const apiHandler = strapi.service('plugin::content-type-builder.api-handler');
|
||||
|
||||
for (const uid of uids) {
|
||||
await deleteContentType(uid, builder);
|
||||
@ -237,6 +238,8 @@ const deleteContentTypes = async uids => {
|
||||
const deleteContentType = async (uid, defaultBuilder = undefined) => {
|
||||
const builder = defaultBuilder || createBuilder();
|
||||
// make a backup
|
||||
const apiHandler = strapi.service('plugin::content-type-builder.api-handler');
|
||||
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||
await apiHandler.backup(uid);
|
||||
|
||||
const contentType = builder.deleteContentType(uid);
|
||||
|
@ -78,6 +78,10 @@ class Strapi {
|
||||
return ee({ dir: this.dir, logger: this.log });
|
||||
}
|
||||
|
||||
service(uid) {
|
||||
return this.container.get('services').get(uid);
|
||||
}
|
||||
|
||||
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', []));
|
||||
}, []);
|
||||
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 path = prefix !== undefined ? `${prefix}${curr.path}` : `/${current}${curr.path}`;
|
||||
_.set(curr, 'path', path);
|
||||
|
@ -18,11 +18,11 @@ module.exports = {
|
||||
author: {
|
||||
type: 'relation',
|
||||
relation: 'manyToOne',
|
||||
target: 'plugins::users-permissions.user',
|
||||
target: 'plugin::users-permissions.user',
|
||||
targetAttribute: 'articles',
|
||||
},
|
||||
},
|
||||
uid: 'application::article.article',
|
||||
uid: 'api::article.article',
|
||||
name: 'article',
|
||||
description: '',
|
||||
collectionName: '',
|
||||
@ -35,11 +35,11 @@ module.exports = {
|
||||
articles: {
|
||||
type: 'relation',
|
||||
relation: 'manyToMany',
|
||||
target: 'application::article.article',
|
||||
target: 'api::article.article',
|
||||
targetAttribute: 'tags',
|
||||
},
|
||||
},
|
||||
uid: 'application::tag.tag',
|
||||
uid: 'api::tag.tag',
|
||||
name: 'tag',
|
||||
description: '',
|
||||
collectionName: '',
|
||||
@ -52,11 +52,11 @@ module.exports = {
|
||||
articles: {
|
||||
type: 'relation',
|
||||
relation: 'oneToMany',
|
||||
target: 'application::article.article',
|
||||
target: 'api::article.article',
|
||||
targetAttribute: 'category',
|
||||
},
|
||||
},
|
||||
uid: 'application::category.category',
|
||||
uid: 'api::category.category',
|
||||
name: 'category',
|
||||
description: '',
|
||||
collectionName: '',
|
||||
@ -69,16 +69,16 @@ module.exports = {
|
||||
article: {
|
||||
type: 'relation',
|
||||
relation: 'oneToOne',
|
||||
target: 'application::article.article',
|
||||
target: 'api::article.article',
|
||||
targetAttribute: 'reference',
|
||||
},
|
||||
tag: {
|
||||
type: 'relation',
|
||||
relation: 'oneToOne',
|
||||
target: 'application::tag.tag',
|
||||
target: 'api::tag.tag',
|
||||
},
|
||||
},
|
||||
uid: 'application::reference.reference',
|
||||
uid: 'api::reference.reference',
|
||||
name: 'reference',
|
||||
description: '',
|
||||
collectionName: 'refs',
|
||||
@ -95,7 +95,7 @@ module.exports = {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
uid: 'application::product.product',
|
||||
uid: 'api::product.product',
|
||||
name: 'product',
|
||||
description: '',
|
||||
collectionName: '',
|
||||
@ -108,10 +108,10 @@ module.exports = {
|
||||
tags: {
|
||||
type: 'relation',
|
||||
relation: 'oneToMany',
|
||||
target: 'application::tag.tag',
|
||||
target: 'api::tag.tag',
|
||||
},
|
||||
},
|
||||
uid: 'application::articlewit.articlewit',
|
||||
uid: 'api::articlewit.articlewit',
|
||||
name: 'articlewithtag',
|
||||
description: '',
|
||||
collectionName: '',
|
||||
|
@ -4,7 +4,7 @@ const { isFunction, isNil, prop } = require('lodash/fp');
|
||||
const { createStrapiInstance } = require('./strapi');
|
||||
|
||||
const toUID = name => {
|
||||
return name.includes('::') ? name : `application::${name}.${name}`;
|
||||
return name.includes('::') ? name : `api::${name}.${name}`;
|
||||
};
|
||||
|
||||
const createHelpers = async ({ strapi: strapiInstance = null, ...options } = {}) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user