mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00

There seems to be some integration tests that sometimes fail on tests where the order is reversed. Hopefully this resolves the problem.
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import fetch from 'cross-fetch';
|
|
import { outputJson } from 'fs-extra';
|
|
import type { App } from '../../src/init/App';
|
|
import { joinFilePath, joinUrl } from '../../src/util/PathUtil';
|
|
import { getPort } from '../util/Util';
|
|
import { getDefaultVariables, getTestConfigPath, getTestFolder, instantiateFromConfig, removeFolder } from './Config';
|
|
|
|
const port = getPort('SeedingPods');
|
|
const baseUrl = `http://localhost:${port}/`;
|
|
|
|
const rootFilePath = getTestFolder('seeding-pods');
|
|
|
|
describe('A server with seeded pods', (): void => {
|
|
const seedingJson = joinFilePath(rootFilePath, 'pods.json');
|
|
let app: App;
|
|
|
|
beforeAll(async(): Promise<void> => {
|
|
// Create seeding config
|
|
await outputJson(seedingJson, [
|
|
{
|
|
podName: 'alice',
|
|
email: 'alice@example.com',
|
|
password: 'alice-password',
|
|
},
|
|
{
|
|
podName: 'bob',
|
|
email: 'bob@example.com',
|
|
password: 'bob-password',
|
|
register: false,
|
|
},
|
|
]);
|
|
|
|
const variables = {
|
|
...getDefaultVariables(port, baseUrl),
|
|
'urn:solid-server:default:variable:seededPodConfigJson': seedingJson,
|
|
};
|
|
|
|
const instances = await instantiateFromConfig(
|
|
'urn:solid-server:test:Instances',
|
|
getTestConfigPath('server-memory.json'),
|
|
variables,
|
|
) as Record<string, any>;
|
|
({ app } = instances);
|
|
await app.start();
|
|
});
|
|
|
|
afterAll(async(): Promise<void> => {
|
|
await removeFolder(rootFilePath);
|
|
await app.stop();
|
|
});
|
|
|
|
it('has created the requested pods.', async(): Promise<void> => {
|
|
let response = await fetch(joinUrl(baseUrl, 'alice/profile/card#me'));
|
|
expect(response.status).toBe(200);
|
|
response = await fetch(joinUrl(baseUrl, 'bob/profile/card#me'));
|
|
expect(response.status).toBe(200);
|
|
});
|
|
});
|