mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
49 lines
1.9 KiB
TypeScript
49 lines
1.9 KiB
TypeScript
/*
|
|
* Copyright (C) 2019-2022 Open StApps
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
* Software Foundation, version 3.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with
|
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
import {Logger} from '@openstapps/logger';
|
|
import {HttpClientInterface} from '@openstapps/api';
|
|
import junit from 'junit-report-builder';
|
|
import {indexSamples} from './index-samples.js';
|
|
import {retrieveItems} from './retreive-items.js';
|
|
import {compareItems} from './compare-items.js';
|
|
import {E2EOptions, TestState} from './test-state.js';
|
|
|
|
/**
|
|
* Function that can be used for integration tests.
|
|
* Adds all the SCThings that getItemsFromSamples() returns to the backend.
|
|
* Afterward, retrieves the items from backend and checks for differences with original ones.
|
|
*/
|
|
export async function endToEndRun(client: HttpClientInterface, options: E2EOptions): Promise<string[]> {
|
|
const state = new TestState(client, options);
|
|
const builder = junit.newBuilder();
|
|
|
|
await indexSamples(state, builder.testSuite().name('e2e index'));
|
|
Logger.info(`All samples have been indexed via the backend`);
|
|
|
|
await retrieveItems(state, builder.testSuite().name('e2e retrieve'));
|
|
Logger.info(`All samples have been retrieved from the backend`);
|
|
|
|
await compareItems(state, builder.testSuite().name('e2e compare'));
|
|
|
|
if (options.reportLocation) {
|
|
builder.writeTo(options.reportLocation);
|
|
}
|
|
await (state.errors.length > 0
|
|
? Logger.error(`\n${state.errors.length} failed test cases`)
|
|
: Logger.ok('All tests passed.'));
|
|
|
|
return state.errors;
|
|
}
|