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

Convert engines-host-app to new test structure #854

Merged
merged 8 commits into from
Jun 16, 2021
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 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/packages/test-setup/**/*.d.ts
/packages/addon-shim/**/*.js
/packages/addon-shim/**/*.d.ts
/tests/fixtures/

# unconventional js
/blueprints/*/files/
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
],
"additionalManifests": {
"dependencyUpdates": [
"test-packages/*/package.json"
"test-packages/*/package.json",
"tests/**/package.json"
]
}
}
Expand Down
7 changes: 4 additions & 3 deletions tests/app-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.2.5",
"@embroider/compat": "0.40.0",
"@embroider/core": "0.40.0",
"@embroider/webpack": "0.40.0",
"@embroider/compat": "0.42.0",
"@embroider/core": "0.42.0",
"@embroider/webpack": "0.42.0",
"@embroider/router": "0.42.0",
"@glimmer/component": "^1.0.4",
"@glimmer/tracking": "^1.0.4",
"babel-eslint": "^10.1.0",
Expand Down
14 changes: 14 additions & 0 deletions tests/fixtures/eager-engine/addon/engine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Engine from 'ember-engines/engine';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

const { modulePrefix } = config;
const Eng = Engine.extend({
modulePrefix,
Resolver,
});

loadInitializers(Eng, modulePrefix);

export default Eng;
6 changes: 6 additions & 0 deletions tests/fixtures/eager-engine/addon/styles/addon.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.shared-style-target {
border-left-width: 2px;
border-left-style: solid;
border-left-color: blue;
content: 'eager-engine/addon/styles/addon.css';
}
9 changes: 9 additions & 0 deletions tests/fixtures/eager-engine/addon/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div data-test-eager-engine-main>
<h1>Eager engine</h1>
{{#if (gt 2 1)}}
<div data-test-truth-helpers-ok>ok</div>
{{/if}}
<div data-test-duplicated-helper>
{{duplicated-helper needAnArgumentHere="to force ember to consider this a helper"}}
</div>
</div>
10 changes: 10 additions & 0 deletions tests/fixtures/eager-engine/config/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

module.exports = function (environment) {
const ENV = {
modulePrefix: 'eager-engine',
environment: environment,
};

return ENV;
};
11 changes: 11 additions & 0 deletions tests/fixtures/eager-engine/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

const EngineAddon = require('ember-engines/lib/engine-addon');

module.exports = EngineAddon.extend({
name: require('./package').name,
// eslint-disable-next-line ember/avoid-leaking-state-in-ember-objects
lazyLoading: {
enabled: false,
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { helper } from '@ember/component/helper';

export function duplicatedHelper() {
return 'from-eager-engine-helper';
}

export default helper(duplicatedHelper);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default, duplicatedHelper } from 'eager-engine-helper/helpers/duplicated-helper';
9 changes: 9 additions & 0 deletions tests/fixtures/eager-engine/lib/eager-engine-helper/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

module.exports = {
name: require('./package').name,

isDevelopingAddon() {
return true;
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "eager-engine-helper",
"keywords": [
"ember-addon"
],
"dependencies": {
"ember-cli-babel": "^7.20.5"
}
}
8 changes: 8 additions & 0 deletions tests/fixtures/engines-host-app/.template-lintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

module.exports = {
extends: 'octane',
rules: {
'no-curly-component-invocation': { allow: ['duplicated-helper'] },
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { helper } from '@ember/component/helper';

export function duplicatedHelper() {
return 'from-engines-host-app';
}

export default helper(duplicatedHelper);
16 changes: 16 additions & 0 deletions tests/fixtures/engines-host-app/app/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import EmberRouter from '@embroider/router';
import config from './config/environment';

const Router = EmberRouter.extend({
location: config.locationType,
rootURL: config.rootURL,
});

Router.map(function() {
this.route('use-eager-engine');
this.mount('lazy-engine', { path: '/use-lazy-engine', as: 'use-lazy-engine' });
this.route('style-check');
this.mount('lazy-in-repo-engine', { path: '/use-lazy-in-repo-engine', as: 'use-lazy-in-repo-engine' });
});

export default Router;
6 changes: 6 additions & 0 deletions tests/fixtures/engines-host-app/app/styles/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.shared-style-target {
width: 100px;
height: 100px;
background-color: gray;
content: 'engines-host-app/app/styles/app.css';
}
7 changes: 7 additions & 0 deletions tests/fixtures/engines-host-app/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<nav>
<LinkTo @route="use-eager-engine">Eager</LinkTo>
<LinkTo @route="use-lazy-engine">Lazy</LinkTo>
<LinkTo @route="style-check">Style Check</LinkTo>
</nav>

{{outlet}}
3 changes: 3 additions & 0 deletions tests/fixtures/engines-host-app/app/templates/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div data-test-duplicated-helper>
{{duplicated-helper needAnArgumentHere="to force ember to consider this a helper"}}
</div>
2 changes: 2 additions & 0 deletions tests/fixtures/engines-host-app/app/templates/style-check.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div class="shared-style-target">
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{mount "eager-engine"}}
31 changes: 31 additions & 0 deletions tests/fixtures/engines-host-app/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function (defaults) {
let app = new EmberApp(defaults, {
// Add options here
});

// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.

app.import('vendor/styles.css');

if (process.env.CLASSIC) {
return app.toTree();
}

const Webpack = require('@embroider/webpack').Webpack;
return require('@embroider/compat').compatBuild(app, Webpack);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Engine from 'ember-engines/engine';
import loadInitializers from 'ember-load-initializers';
import Resolver from './resolver';
import config from './config/environment';

const { modulePrefix } = config;

const Eng = Engine.extend({
modulePrefix,
Resolver
});

loadInitializers(Eng, modulePrefix);

export default Eng;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { helper } from '@ember/component/helper';

export function duplicatedHelper() {
return 'from-lazy-in-repo-engine';
}

export default helper(duplicatedHelper);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Resolver from 'ember-resolver';

export default Resolver;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import buildRoutes from 'ember-engines/routes';

export default buildRoutes(function () {});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.shared-style-target {
border-bottom-width: 2px;
border-bottom-style: solid;
border-bottom-color: blue;
content: 'lazy-in-repo-engine/addon/styles/addon.css';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div data-test-lazy-in-repo-engine-main>
<h1>Lazy In-Repo Engine</h1>
<div data-test-duplicated-helper>
{{duplicated-helper needAnArgumentHere="to force ember to consider this a helper"}}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-env node */
'use strict';

module.exports = function(environment) {
let ENV = {
modulePrefix: 'lazy-in-repo-engine',
environment
};

return ENV;
};
12 changes: 12 additions & 0 deletions tests/fixtures/engines-host-app/lib/lazy-in-repo-engine/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-env node */
'use strict';

const EngineAddon = require('ember-engines/lib/engine-addon');

module.exports = EngineAddon.extend({
name: 'lazy-in-repo-engine',

lazyLoading: Object.freeze({
enabled: true,
}),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "lazy-in-repo-engine",
"keywords": [
"ember-addon",
"ember-engine"
],
"dependencies": {
"ember-cli-htmlbars": "*",
"ember-cli-babel": "*"
},
"devDependencies": {
"ember-engines": "*"
},
"volta": {
"extends": "../../package.json"
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/engines-host-app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<nav>
<LinkTo @route="use-eager-engine">Eager</LinkTo>
<LinkTo @route="use-lazy-engine">Lazy</LinkTo>
<LinkTo @route="style-check">Style Check</LinkTo>
</nav>

{{outlet}}
3 changes: 3 additions & 0 deletions tests/fixtures/engines-host-app/templates/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div data-test-duplicated-helper>
{{duplicated-helper needAnArgumentHere="to force ember to consider this a helper"}}
</div>
2 changes: 2 additions & 0 deletions tests/fixtures/engines-host-app/templates/style-check.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div class="shared-style-target">
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{mount "eager-engine"}}
Loading