mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 06:48:18 +08:00
DEV: Add optional theme test step to the smoke:test
rake task (#13418)
The purpose of this is to allow us to catch regressions for a feature we've built recently that allows theme tests to run in production. We recently had a regression that we didn't notice for days, so to prevent that from happening again we'll use this in our internal CI pipelines.
This commit is contained in:
@ -76,9 +76,15 @@ async function runAllTests() {
|
||||
}
|
||||
|
||||
const { Inspector, Page, Runtime, Log } = protocol;
|
||||
// eslint-disable-next-line
|
||||
await Promise.all([
|
||||
Inspector.enable(),
|
||||
Page.enable(),
|
||||
Runtime.enable(),
|
||||
Log.enable(),
|
||||
]);
|
||||
|
||||
// Documentation https://chromedevtools.github.io/devtools-protocol/tot/Log/#type-LogEntry
|
||||
Log.enable();
|
||||
Log.entryAdded(({ entry }) => {
|
||||
let message = `${new Date(entry.timestamp).toISOString()} - (type: ${
|
||||
entry.source
|
||||
@ -89,9 +95,6 @@ async function runAllTests() {
|
||||
console.log(message);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line
|
||||
await Promise.all([Inspector.enable(), Page.enable(), Runtime.enable()]);
|
||||
|
||||
Inspector.targetCrashed((entry) => {
|
||||
console.log("Chrome target crashed:");
|
||||
console.log(entry);
|
||||
@ -119,6 +122,31 @@ async function runAllTests() {
|
||||
});
|
||||
|
||||
let url = args[0] + "&qunit_disable_auto_start=1";
|
||||
|
||||
const apiKey = process.env.ADMIN_API_KEY;
|
||||
const apiUsername = process.env.ADMIN_API_USERNAME;
|
||||
if (apiKey && apiUsername) {
|
||||
const { Fetch } = protocol;
|
||||
await Fetch.enable();
|
||||
const urlObj = new URL(url);
|
||||
Fetch.requestPaused((data) => {
|
||||
const requestURL = new URL(data.request.url);
|
||||
if (requestURL.hostname != urlObj.hostname) {
|
||||
Fetch.continueRequest({
|
||||
requestId: data.requestId,
|
||||
});
|
||||
return;
|
||||
}
|
||||
Fetch.continueRequest({
|
||||
requestId: data.requestId,
|
||||
headers: [
|
||||
{ name: "Api-Key", value: apiKey },
|
||||
{ name: "Api-Username", value: apiUsername },
|
||||
],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
console.log("navigate to ", url);
|
||||
Page.navigate({ url });
|
||||
|
||||
|
Reference in New Issue
Block a user