Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inject runtime config only if FastBoot dependency exists #121

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ module.exports = {
// - application has ember-cli-fastboot dependency.
this._needsFastBootSupport = this._config.enabled &&
this._config.delivery.includes('header') &&
// TODO: check if application has ember-cli-fastboot-dependency
// https://github.com/rwjblue/ember-cli-content-security-policy/issues/116
true;
new VersionChecker(this).for('ember-cli-fastboot').exists();
jelhan marked this conversation as resolved.
Show resolved Hide resolved

// Run-time configuration is only needed for FastBoot support.
if (!this._needsFastBootSupport) {
Expand Down
52 changes: 52 additions & 0 deletions node-tests/e2e/fastboot-support-app-not-using-fastboot-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const expect = require('chai').expect;
const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp;
const denodeify = require('denodeify');
const request = denodeify(require('request'));

function getRunTimeConfig(html) {
let encodedConfig = html.match(/<meta name="default\/config\/environment" content="(.*)" \/>/)[1];
return JSON.parse(decodeURIComponent(encodedConfig));
}

// ember-cli-version-checker reports wrong information if used together with ember-cli-addon-tests.
describe.skip('e2e: fastboot integration if consumer does not use FastBoot', function() {
this.timeout(300000);

let app;

before(async function() {
app = new AddonTestApp();

await app.create('default', {
noFixtures: true,
skipNpm: true,
});

await app.editPackageJSON(pkg => {
delete pkg.devDependencies['ember-cli-fastboot'];
delete pkg.devDependencies['fastboot-app-server'];
});

await app.run('npm', 'install');

await app.startServer();
});

after(async function() {
await app.stopServer();
});

it('does not push run-time configuration into app if app does not use FastBoot', async function() {
let response = await request({
url: 'http://localhost:49741',
headers: {
'Accept': 'text/html'
}
});

expect(response.statusCode).to.equal(200);

let runTimeConfig = getRunTimeConfig(response.body);
expect(runTimeConfig).to.not.include.key('ember-cli-content-security-policy');
});
});