api: Fix so we can handle scripting in the API (#3840)

* handle multi in api

* fix page summary URL
This commit is contained in:
Peter Hedenskog 2023-05-10 21:07:59 +02:00 committed by GitHub
parent b923d4a2b4
commit 97c9a7ff5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

View File

@ -30,6 +30,14 @@ async function api(options) {
// a forever loop
delete apiOptions.api.hostname;
// Add support for running multi tests
if (options.multi) {
const scripting = await readFileSync(
new URL(resolve(process.cwd(), options._[0]), import.meta.url)
);
apiOptions.api.scripting = scripting.toString();
}
if (apiOptions.mobile) {
apiOptions.api.testType = 'emulatedMobile';
} else if (apiOptions.android) {
@ -40,15 +48,6 @@ async function api(options) {
apiOptions.api.testType = 'desktop';
}
/*
// Add support for running multi tests
if (options.multi) {
const scripting = await readFileSync(
new URL(resolve(process.cwd(), options._[0]), import.meta.url)
);
}
*/
if (options.config) {
const config = JSON.parse(
await readFileSync(

View File

@ -161,16 +161,20 @@ export async function run(options) {
console.log(options.summary.out); // eslint-disable-line no-console
}
let pageSummaryUrl = '';
if (resultUrls.hasBaseUrl() && options.multi) {
pageSummaryUrl = resultUrls.reportSummaryUrl() + '/index.html';
} else if (resultUrls.hasBaseUrl() && url) {
pageSummaryUrl = resultUrls.absoluteSummaryPageUrl(url) + 'index.html';
}
return {
errors,
budgetResult,
resultUrl: resultUrls.hasBaseUrl()
? resultUrls.reportSummaryUrl() + '/index.html'
: '',
pageSummaryUrl:
url && resultUrls.hasBaseUrl() && !options.multi
? resultUrls.absoluteSummaryPageUrl(url) + 'index.html'
: '',
pageSummaryUrl,
localPath: storageManager.getBaseDir()
};
} catch (error) {