mirror of
https://github.com/strapi/strapi.git
synced 2025-11-10 23:29:33 +00:00
* fix: content-api route extension for i18n and users-permissions * refactor: simplify tests to catch breaking change * test: cli for openapi plugin routes * refactor: implement createcontentapiroutesfactory for content-api routes across multiple packages * fix: more accurate message * chore: formatting * chore: cleanup backward compatibility tests --------- Co-authored-by: Ziyi Yuan <daydreamnation@live.com>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import path from 'path';
|
|
import fs from 'node:fs/promises';
|
|
|
|
import { createStrapiInstance } from 'api-tests/strapi';
|
|
|
|
const writeFileSafe = async (filePath, contents) => {
|
|
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
await fs.writeFile(filePath, contents);
|
|
};
|
|
|
|
const pluginExtensionSource = `
|
|
module.exports = (plugin) => {
|
|
plugin.routes["content-api"].routes = plugin.routes["content-api"].routes.map((route) => {
|
|
return route;
|
|
});
|
|
|
|
return plugin;
|
|
};
|
|
`;
|
|
|
|
describe('Plugin route extension backward compatibility', () => {
|
|
let strapi;
|
|
|
|
beforeAll(async () => {
|
|
const appRoot = path.resolve(__dirname, '../../../../test-apps/api');
|
|
|
|
const upExtPath = path.join(appRoot, 'src/extensions/users-permissions/strapi-server.js');
|
|
const i18nExtPath = path.join(appRoot, 'src/extensions/i18n/strapi-server.js');
|
|
|
|
await Promise.all([
|
|
writeFileSafe(upExtPath, pluginExtensionSource),
|
|
writeFileSafe(i18nExtPath, pluginExtensionSource),
|
|
]);
|
|
|
|
strapi = await createStrapiInstance();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await strapi.destroy();
|
|
});
|
|
|
|
test('server starts when plugins mutate content-api routes', async () => {
|
|
expect(strapi.server).toBeDefined();
|
|
expect(strapi.server.httpServer.listening).toBe(true);
|
|
});
|
|
});
|