mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Replace runtime config regression selftest with simpler unit test
This commit is contained in:
@@ -316,8 +316,11 @@ var getBoilerplate = function (request, arch) {
|
||||
return memoizedBoilerplate[memHash];
|
||||
};
|
||||
|
||||
var generateBoilerplateInstance = function (arch, manifest, additionalOptions) {
|
||||
WebAppInternals.generateBoilerplateInstance = function (arch,
|
||||
manifest,
|
||||
additionalOptions) {
|
||||
additionalOptions = additionalOptions || {};
|
||||
|
||||
var runtimeConfig = _.extend(
|
||||
_.clone(__meteor_runtime_config__),
|
||||
additionalOptions.runtimeConfigOverrides || {}
|
||||
@@ -575,8 +578,9 @@ var runWebAppServer = function () {
|
||||
syncQueue.runTask(function() {
|
||||
_.each(WebApp.clientPrograms, function (program, archName) {
|
||||
boilerplateByArch[archName] =
|
||||
generateBoilerplateInstance(archName, program.manifest,
|
||||
defaultOptionsForArch[archName]);
|
||||
WebAppInternals.generateBoilerplateInstance(
|
||||
archName, program.manifest,
|
||||
defaultOptionsForArch[archName]);
|
||||
});
|
||||
|
||||
// Clear the memoized boilerplate cache.
|
||||
|
||||
@@ -144,3 +144,25 @@ Tinytest.add("webapp - valid pid check", function (test) {
|
||||
test.isFalse(WebAppInternals.validPid("foobar"));
|
||||
test.isFalse(WebAppInternals.validPid("123foo"));
|
||||
});
|
||||
|
||||
// Regression test: `generateBoilerplateInstance` should not change
|
||||
// `__meteor_runtime_config__`.
|
||||
Tinytest.add("webapp - generating boilerplate should not change runtime config", function (test) {
|
||||
// Set a dummy key in the runtime config served in the
|
||||
// boilerplate. Test that the dummy key appears in the boilerplate,
|
||||
// but not in __meteor_runtime_config__ after generating the
|
||||
// boilerplate.
|
||||
|
||||
test.isFalse(__meteor_runtime_config__.WEBAPP_TEST_KEY);
|
||||
|
||||
var boilerplate = WebAppInternals.generateBoilerplateInstance(
|
||||
"web.browser",
|
||||
{}, // empty manifest
|
||||
{ runtimeConfigOverrides: { WEBAPP_TEST_KEY: true } }
|
||||
);
|
||||
|
||||
var boilerplateHtml = boilerplate.toHTML();
|
||||
test.isFalse(boilerplateHtml.indexOf("WEBAPP_TEST_KEY") === -1);
|
||||
|
||||
test.isFalse(__meteor_runtime_config__.WEBAPP_TEST_KEY);
|
||||
});
|
||||
|
||||
@@ -409,51 +409,3 @@ selftest.define("'meteor run --port' requires a port", function () {
|
||||
run.matchErr("--port must include a port");
|
||||
run.expectExit(1);
|
||||
});
|
||||
|
||||
// Regression test: previously, if ROOT_URL was set, then the process of
|
||||
// generating the cordova boilerplate would change
|
||||
// __meteor_runtime_config__, resulting in an incorrect browser
|
||||
// boilerplate being generated the next time boilerplate generation
|
||||
// occurs.
|
||||
selftest.define("generating boilerplate does not change runtime config", function () {
|
||||
var s = new Sandbox();
|
||||
var run;
|
||||
|
||||
s.createApp("myapp", "standard-app");
|
||||
s.cd("myapp");
|
||||
|
||||
// Add 'android' to the .meteor/platforms file, just so that the
|
||||
// Cordova boilerplate will be generated and served, without having
|
||||
// to download the whole Android sdk.
|
||||
var platforms = s.read(".meteor/platforms");
|
||||
s.write(".meteor/platforms", platforms + "\nandroid\n");
|
||||
|
||||
s.set("ROOT_URL", "http://127.0.0.1:3000");
|
||||
run = s.run();
|
||||
run.waitSecs(30);
|
||||
run.match("Started your app");
|
||||
|
||||
var body = httpHelpers.getUrl("http://localhost:3000");
|
||||
var rootUrlRegExp = /"ROOT_URL":"http:\/\/127.0.0.1:3000"/;
|
||||
if (! body.match(rootUrlRegExp)) {
|
||||
selftest.fail("Incorrect ROOT_URL");
|
||||
}
|
||||
|
||||
s.mkdir("client");
|
||||
s.cd("client");
|
||||
s.write("foo.js", "console.log(1);\n");
|
||||
|
||||
run.waitSecs(30);
|
||||
// We don't expect the server to restart; we're testing that
|
||||
// __meteor_runtime_config__ does not get modified over the life of
|
||||
// a single server process.
|
||||
run.forbidAll("restarted");
|
||||
run.match("Client modified");
|
||||
|
||||
body = httpHelpers.getUrl("http://localhost:3000");
|
||||
if (! body.match(rootUrlRegExp)) {
|
||||
selftest.fail("Incorrect ROOT_URL after modifying client");
|
||||
}
|
||||
|
||||
run.stop();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user