mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 10:57:04 +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:
parent
6fd13f38a2
commit
c47f55253f
|
@ -81,4 +81,33 @@ task "smoke:test" do
|
||||||
if results !~ /ALL PASSED/
|
if results !~ /ALL PASSED/
|
||||||
raise "FAILED"
|
raise "FAILED"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
api_key = ENV["ADMIN_API_KEY"]
|
||||||
|
api_username = ENV["ADMIN_API_USERNAME"]
|
||||||
|
theme_url = ENV["SMOKE_TEST_THEME_URL"]
|
||||||
|
|
||||||
|
next if api_key.blank? && api_username.blank? && theme_url.blank?
|
||||||
|
|
||||||
|
puts "Running QUnit tests for theme #{theme_url.inspect} using API key #{api_key[0..3]}… and username #{api_username.inspect}"
|
||||||
|
|
||||||
|
query_params = {
|
||||||
|
seed: Random.new.seed,
|
||||||
|
theme_url: theme_url,
|
||||||
|
hidepassed: 1,
|
||||||
|
report_requests: 1
|
||||||
|
}
|
||||||
|
url += '/' if !url.end_with?('/')
|
||||||
|
full_url = "#{url}theme-qunit?#{query_params.to_query}"
|
||||||
|
timeout = 1000 * 60 * 10
|
||||||
|
|
||||||
|
sh(
|
||||||
|
"node",
|
||||||
|
"#{Rails.root}/test/run-qunit.js",
|
||||||
|
full_url,
|
||||||
|
timeout.to_s
|
||||||
|
)
|
||||||
|
|
||||||
|
if !$?.success?
|
||||||
|
raise "THEME TESTS FAILED!"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -76,9 +76,15 @@ async function runAllTests() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { Inspector, Page, Runtime, Log } = protocol;
|
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
|
// Documentation https://chromedevtools.github.io/devtools-protocol/tot/Log/#type-LogEntry
|
||||||
Log.enable();
|
|
||||||
Log.entryAdded(({ entry }) => {
|
Log.entryAdded(({ entry }) => {
|
||||||
let message = `${new Date(entry.timestamp).toISOString()} - (type: ${
|
let message = `${new Date(entry.timestamp).toISOString()} - (type: ${
|
||||||
entry.source
|
entry.source
|
||||||
|
@ -89,9 +95,6 @@ async function runAllTests() {
|
||||||
console.log(message);
|
console.log(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
await Promise.all([Inspector.enable(), Page.enable(), Runtime.enable()]);
|
|
||||||
|
|
||||||
Inspector.targetCrashed((entry) => {
|
Inspector.targetCrashed((entry) => {
|
||||||
console.log("Chrome target crashed:");
|
console.log("Chrome target crashed:");
|
||||||
console.log(entry);
|
console.log(entry);
|
||||||
|
@ -119,6 +122,31 @@ async function runAllTests() {
|
||||||
});
|
});
|
||||||
|
|
||||||
let url = args[0] + "&qunit_disable_auto_start=1";
|
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);
|
console.log("navigate to ", url);
|
||||||
Page.navigate({ url });
|
Page.navigate({ url });
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user