2021-08-12 15:04:37 +02:00
|
|
|
import supertest from 'supertest';
|
|
|
|
import { createTestConfig } from '../../../test/config/test-config';
|
2019-03-12 10:46:08 +01:00
|
|
|
|
2021-08-12 15:04:37 +02:00
|
|
|
import createStores from '../../../test/fixtures/store';
|
|
|
|
import getApp from '../../app';
|
|
|
|
import { createServices } from '../../services';
|
2022-06-02 10:44:45 +02:00
|
|
|
import {
|
|
|
|
DEFAULT_SEGMENT_VALUES_LIMIT,
|
|
|
|
DEFAULT_STRATEGY_SEGMENTS_LIMIT,
|
|
|
|
} from '../../util/segments';
|
2019-03-12 10:46:08 +01:00
|
|
|
|
|
|
|
const uiConfig = {
|
|
|
|
headerBackground: 'red',
|
|
|
|
slogan: 'hello',
|
|
|
|
};
|
|
|
|
|
2022-01-06 10:31:00 +01:00
|
|
|
async function getSetup() {
|
2019-03-12 10:46:08 +01:00
|
|
|
const base = `/random${Math.round(Math.random() * 1000)}`;
|
2021-04-22 10:07:10 +02:00
|
|
|
const config = createTestConfig({
|
|
|
|
server: { baseUriPath: base },
|
|
|
|
ui: uiConfig,
|
|
|
|
});
|
2021-08-12 15:04:37 +02:00
|
|
|
const stores = createStores();
|
2021-05-28 11:10:24 +02:00
|
|
|
const services = createServices(stores, config);
|
|
|
|
|
2022-01-06 10:31:00 +01:00
|
|
|
const app = await getApp(config, stores, services);
|
2019-03-12 10:46:08 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
base,
|
|
|
|
request: supertest(app),
|
2021-05-28 11:10:24 +02:00
|
|
|
destroy: () => {
|
|
|
|
services.versionService.destroy();
|
2021-12-09 21:25:06 +01:00
|
|
|
services.clientInstanceService.destroy();
|
2021-05-28 11:10:24 +02:00
|
|
|
services.apiTokenService.destroy();
|
|
|
|
},
|
2019-03-12 10:46:08 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
let request;
|
|
|
|
let base;
|
|
|
|
let destroy;
|
|
|
|
|
2022-01-06 10:31:00 +01:00
|
|
|
beforeEach(async () => {
|
|
|
|
const setup = await getSetup();
|
2021-05-28 11:10:24 +02:00
|
|
|
request = setup.request;
|
|
|
|
base = setup.base;
|
|
|
|
destroy = setup.destroy;
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
destroy();
|
|
|
|
});
|
2022-06-02 10:44:45 +02:00
|
|
|
|
|
|
|
test('should get ui config', async () => {
|
|
|
|
const { body } = await request
|
2019-03-12 10:46:08 +01:00
|
|
|
.get(`${base}/api/admin/ui-config`)
|
|
|
|
.expect('Content-Type', /json/)
|
2022-06-02 10:44:45 +02:00
|
|
|
.expect(200);
|
|
|
|
|
|
|
|
expect(body.slogan).toEqual('hello');
|
|
|
|
expect(body.headerBackground).toEqual('red');
|
|
|
|
expect(body.segmentValuesLimit).toEqual(DEFAULT_SEGMENT_VALUES_LIMIT);
|
|
|
|
expect(body.strategySegmentsLimit).toEqual(DEFAULT_STRATEGY_SEGMENTS_LIMIT);
|
2019-03-12 10:46:08 +01:00
|
|
|
});
|