mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-02-14 04:42:56 +00:00
feat: migrate backend to cosmiconfig
This commit is contained in:
@@ -23,19 +23,24 @@ import {
|
||||
SCValidationErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import nock from 'nock';
|
||||
import {configFile, plugins} from '../../src/common.js';
|
||||
import {plugins} from '../../src/common.js';
|
||||
import {pluginRegisterHandler} from '../../src/routes/plugin-register-route.js';
|
||||
import {expect, use} from 'chai';
|
||||
import chaiAsPromised from 'chai-as-promised';
|
||||
import {instance as registerRequest} from '@openstapps/core/test/resources/PluginRegisterRequest.1.json';
|
||||
import {DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||
import {testApp} from '../tests-setup.js';
|
||||
import {backendConfig} from '../../src/config.js';
|
||||
import {readFile} from 'fs/promises';
|
||||
|
||||
// for using promises in expectations (to.eventually.be...)
|
||||
use(chaiAsPromised);
|
||||
|
||||
const registerRequest = JSON.parse(
|
||||
await readFile('node_modules/@openstapps/core/test/resources/PluginRegisterRequest.1.json', 'utf8'),
|
||||
);
|
||||
|
||||
// cast it because of "TS2322: Type 'string' is not assignable to type '"add"'"
|
||||
export const registerAddRequest: SCPluginAdd = registerRequest as SCPluginAdd;
|
||||
export const registerAddRequest: SCPluginAdd = registerRequest.instance as SCPluginAdd;
|
||||
|
||||
export const registerRemoveRequest: SCPluginRemove = {
|
||||
action: 'remove',
|
||||
@@ -48,7 +53,7 @@ describe('Plugin registration', async function () {
|
||||
after(function () {
|
||||
// remove plugins
|
||||
plugins.clear();
|
||||
configFile.app.features = {};
|
||||
backendConfig.app.features = {};
|
||||
});
|
||||
|
||||
it('should register a plugin', async function () {
|
||||
@@ -57,7 +62,7 @@ describe('Plugin registration', async function () {
|
||||
|
||||
expect(response).to.deep.equal(bodySuccess) &&
|
||||
expect(plugins.size).to.equal(1) &&
|
||||
expect(configFile.app.features.plugins!['Foo Plugin']).to.not.be.empty;
|
||||
expect(backendConfig.app.features.plugins!['Foo Plugin']).to.not.be.empty;
|
||||
});
|
||||
|
||||
it('should allow re-registering the same plugin', async function () {
|
||||
@@ -70,7 +75,7 @@ describe('Plugin registration', async function () {
|
||||
return (
|
||||
expect(response).to.deep.equal(bodySuccess) &&
|
||||
expect(plugins.size).to.equal(1) &&
|
||||
expect(configFile.app.features.plugins!['Foo Plugin']).to.not.be.empty
|
||||
expect(backendConfig.app.features.plugins!['Foo Plugin']).to.not.be.empty
|
||||
);
|
||||
});
|
||||
|
||||
@@ -102,7 +107,7 @@ describe('Plugin registration', async function () {
|
||||
|
||||
expect(response).to.deep.equal(bodySuccess) &&
|
||||
expect(plugins.size).to.equal(0) &&
|
||||
expect(configFile.app.features.plugins).to.be.empty;
|
||||
expect(backendConfig.app.features.plugins).to.be.empty;
|
||||
});
|
||||
|
||||
it('should throw a "not found" error when removing a plugin whose registered route does not exist', async function () {
|
||||
|
||||
Reference in New Issue
Block a user