Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1,801 changes: 1,727 additions & 74 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions test-packages/classic-app-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"broccoli-asset-rev": "^3.0.0",
"ember-auto-import": "^2.13.1",
"ember-cli": "~3.28.5",
"ember-cli-app-version": "^5.0.0",
"ember-cli-babel": "^7.26.10",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-fastboot": "workspace:*",
Expand All @@ -40,8 +39,6 @@
"ember-cli-sri": "^2.1.1",
"ember-cli-terser": "^4.0.2",
"ember-data": "~3.28.6",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.1.1",
"ember-load-initializers": "^2.1.2",
"ember-page-title": "^6.2.2",
"ember-qunit": "^5.1.5",
Expand Down
44 changes: 9 additions & 35 deletions test-packages/test-scenarios/custom-fastboot-app-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,7 @@ import { appScenarios } from './scenarios.mjs';
import path from 'node:path';
import fs from 'fs-extra';

qunit.assert.includes = function (haystack, needle) {
if (!Array.isArray(haystack)) {
this.pushResult({
result: false,
message: 'you must pass an array to assert.includes',
});
return;
}

this.pushResult({
result: haystack.includes(needle),
expected: needle,
actual: haystack,
message: `[${needle}] is missing from the array`,
});
};
import './helpers/qunit-assertions.mjs';

const { module: Qmodule, test } = qunit;

Expand Down Expand Up @@ -109,22 +94,11 @@ module.exports = function(environment) {
`,
},
});

project.removeDependency('ember-fetch');
})
.forEachScenario((scenario) => {
Qmodule(scenario.name, function (hooks) {
let app; // PreparedApp

qunit.assert.file = function (filePath) {
this.pushResult({
result: fs.existsSync(path.join(app.dir, 'dist', filePath)),
expected: filePath,
actual: fs.readdirSync(path.join(app.dir, 'dist')),
message: 'File does not exist',
});
};

hooks.before(async () => {
app = await scenario.prepare();
const result = await app.execute(`pnpm build`);
Expand All @@ -134,28 +108,28 @@ module.exports = function(environment) {
});

test('builds a package.json', function (assert) {
assert.file('totally-customized-asset-map.json');
assert.file('package.json');
assert.distFile(app, 'totally-customized-asset-map.json');
assert.distFile(app, 'package.json');
});

test('respects a custom asset map path and prepended URLs', function (assert) {
assert.file('totally-customized-asset-map.json');
assert.distFile(app, 'totally-customized-asset-map.json');
let pkg = fs.readJSONSync(path.join(app.dir, 'dist/package.json'));
let manifest = pkg.fastboot.manifest;

manifest.appFiles.forEach((file) => {
assert.file(file);
assert.distFile(app, file);
});

assert.file(manifest.htmlFile);
assert.distFile(app, manifest.htmlFile);

manifest.vendorFiles.forEach((file) => {
assert.file(file);
assert.distFile(app, file);
});
});

test('respects individual files being excluded from fingerprinting', function (assert) {
assert.file('totally-customized-asset-map.json');
assert.distFile(app, 'totally-customized-asset-map.json');

let pkg = fs.readJSONSync(path.join(app.dir, 'dist/package.json'));
let manifest = pkg.fastboot.manifest;
Expand All @@ -171,7 +145,7 @@ module.exports = function(environment) {
let manifest = pkg.fastboot.manifest;

assert.equal(manifest.htmlFile, 'custom-index.html');
assert.file(manifest.htmlFile);
assert.distFile(app, manifest.htmlFile);
});
});
});
103 changes: 79 additions & 24 deletions test-packages/test-scenarios/custom-output-paths-test.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import qunit from 'qunit';
import { merge } from 'lodash-es';

import { appScenarios } from './scenarios.mjs';
import path from 'node:path';
import fs from 'fs-extra';

const { module: Qmodule, test } = qunit;

import './helpers/qunit-assertions.mjs';

appScenarios
.map('custom-output-paths', (project) => {
merge(project.files, {
project.mergeFiles({
'ember-cli-build.js': `var EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
Expand All @@ -35,22 +36,79 @@ appScenarios

return app.toTree();
};`,
});
app: {
'index.html': `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

{{content-for "head"}}

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/classic-app-template.css">

{{content-for "head-footer"}}
</head>
<body>
{{content-for "body"}}

<script src="{{rootURL}}assets/vendor.js"></script>
<auto-import-script entrypoint="app"></auto-import-script>
<script src="{{rootURL}}assets/classic-app-template.js"></script>

{{content-for "body-footer"}}
</body>
</html>
`,
},
tests: {
'index.html': `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

{{content-for "head"}}
{{content-for "test-head"}}

project.files.app['index.html'].replace(
'<script src="{{rootURL}}assets/classic-app-template.js"></script>',
`<auto-import-script entrypoint="app"></auto-import-script>
<script src="{{rootURL}}assets/classic-app-template.js"></script>`
);
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/classic-app-template.css">
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css">

project.files.tests['index.html'].replace(
'<script src="{{rootURL}}assets/test-support.js"></script>',
`<auto-import-script entrypoint="app"></auto-import-script>
{{content-for "head-footer"}}
{{content-for "test-head-footer"}}
</head>
<body>
{{content-for "body"}}
{{content-for "test-body"}}

<div id="qunit"></div>
<div id="qunit-fixture">
<div id="ember-testing-container">
<div id="ember-testing"></div>
</div>
</div>

<script src="/testem.js" integrity="" data-embroider-ignore></script>
<script src="{{rootURL}}assets/vendor.js"></script>
<auto-import-script entrypoint="app"></auto-import-script>
<script src="{{rootURL}}assets/test-support.js"></script>
<auto-import-script entrypoint="tests"></auto-import-script>`
);
<auto-import-script entrypoint="tests"></auto-import-script>
<script src="{{rootURL}}assets/classic-app-template.js"></script>
<script src="{{rootURL}}assets/tests.js"></script>

project.removeDependency('ember-fetch');
{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
</body>
</html>
`,
},
});
})
.forEachScenario((scenario) => {
Qmodule(scenario.name, function (hooks) {
Expand All @@ -65,22 +123,19 @@ appScenarios
});

test('respects custom output paths and maps to them in the manifest', function (assert) {
function assertFile(filePath) {
assert.ok(fs.existsSync(path.join(app.dir, 'dist', filePath)));

const stat = fs.statSync(path.join(app.dir, 'dist', filePath));
assert.ok(stat.isFile);
}

let pkg = fs.readJsonSync(path.join(app.dir, 'dist/package.json'));
let manifest = pkg.fastboot.manifest;

assert.ok(manifest.appFiles.includes('some-assets/path/app-file.js'));
manifest.appFiles.forEach(assertFile);
assertFile(manifest.htmlFile);
manifest.appFiles.forEach((file) => {
assert.distFile(app, file);
});
assert.distFile(app, manifest.htmlFile);

assert.ok(manifest.vendorFiles.includes('some-assets/path/lib.js'));
manifest.vendorFiles.forEach(assertFile);
manifest.vendorFiles.forEach((file) => {
assert.distFile(app, file);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ appScenarios
`,
},
});

project.removeDependency('ember-fetch');
})
.forEachScenario((scenario) => {
Qmodule(scenario.name, function (hooks) {
Expand Down
2 changes: 0 additions & 2 deletions test-packages/test-scenarios/fastboot-location-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const { module: Qmodule, test } = qunit;
appScenarios
.map('fastboot-location', (project) => {
merge(project.files, loadFromFixtureData('fastboot-location'));

project.removeDependency('ember-fetch');
})
.forEachScenario((scenario) => {
Qmodule(scenario.name, function (hooks) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FastBoot compatible vendor file: {{model.importStatus}}
FastBoot compatible vendor file: {{this.model.importStatus}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FastBoot compatible vendor file: {{model.importStatus}}
FastBoot compatible vendor file: {{this.model.importStatus}}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint-disable ember/new-module-imports, prettier/prettier */
import Ember from 'ember';
import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = Ember.Router.extend({
location: config.locationType,
rootURL: config.rootURL
});
export default class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
}

Router.map(function() {
this.route('noop-transition-to');
Expand All @@ -15,5 +14,3 @@ Router.map(function() {
this.route('redirect-on-replace-with');
this.route('test-passed');
});

export default Router;
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable ember/new-module-imports, prettier/prettier */
import Ember from 'ember';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class extends Route {
@service router;

export default Ember.Route.extend({
beforeModel() {
this.replaceWith('noop-replace-with');
this.router.replaceWith('noop-replace-with');
}
});
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable ember/new-module-imports, prettier/prettier */
import Ember from 'ember';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class extends Route {
@service router;

export default Ember.Route.extend({
beforeModel() {
this.replaceWith('noop-transition-to');
this.router.replaceWith('noop-transition-to');
}
});
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable ember/new-module-imports, prettier/prettier */
import Ember from 'ember';
import Route from '@ember/routing/route';

export default Ember.Route.extend({
export default class extends Route {
beforeModel() {
this.intermediateTransitionTo('test-passed');
}
});
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable ember/new-module-imports, prettier/prettier */
import Ember from 'ember';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class extends Route {
@service router;

export default Ember.Route.extend({
beforeModel() {
this.replaceWith('test-passed');
this.router.replaceWith('test-passed');
}
});
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable ember/new-module-imports, prettier/prettier */
import Ember from 'ember';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class extends Route {
@service router;

export default Ember.Route.extend({
beforeModel() {
this.transitionTo('test-passed');
this.router.transitionTo('test-passed');
}
});
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable ember/new-module-imports */
import Ember from 'ember';
import Route from '@ember/routing/route';

export default Ember.Route.extend({});
export default class extends Route {}
Loading
Loading