Skip to content

Commit

Permalink
[TEST] deprecation infra (#6881)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Thoburn <runspired@gmail.com>
  • Loading branch information
Gaurav0 and runspired committed Dec 11, 2019
1 parent b05623b commit af4ad46
Show file tree
Hide file tree
Showing 21 changed files with 363 additions and 65 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,38 @@ jobs:
- name: Check for TypeScript problems
run: yarn problems

test-infra:
timeout-minutes: 4
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Yarn install
run: yarn --frozen-lockfile
- name: Yarn test infra compatWith 3.0
env:
COMPAT_WITH: '3.0'
run: yarn test:infra
- name: Yarn test infra compatWith 3.8
env:
COMPAT_WITH: '3.8'
run: yarn test:infra
- name: Yarn test infra compatWith 3.12
env:
COMPAT_WITH: '3.12'
run: yarn test:infra
- name: Yarn test infra compatWith 3.16
env:
COMPAT_WITH: '3.16'
run: yarn test:infra
- name: Yarn test infra compatWith 99.0
env:
COMPAT_WITH: '99.0'
run: yarn test:infra


basic-tests:
timeout-minutes: 15
strategy:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"test:docs": "yarn workspace ember-data test:docs",
"test:encapsulation": "lerna run --scope='*-encapsulation-test-app' test",
"test:fastboot": "yarn workspace fastboot-test-app test:try-one",
"test:infra": "yarn workspace @ember-data/unpublished-test-infra test",
"test-external:ember-m3": "./bin/test-external-partner-project.js ember-m3 https://github.com/hjdivad/ember-m3.git",
"test-external:ember-data-change-tracker": "./bin/test-external-partner-project.js ember-data-change-tracker https://github.com/danielspaniel/ember-data-change-tracker.git",
"test-external:model-fragments": "./bin/test-external-partner-project.js model-fragments https://github.com/lytics/ember-data-model-fragments.git",
Expand Down
26 changes: 26 additions & 0 deletions packages/unpublished-test-infra/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint node/no-unpublished-require: 'off' */

'use strict';

const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

const isProd = true;
const compatWith = process.env.COMPAT_WITH || '0.0.0';

module.exports = function(defaults) {
let app = new EmberAddon(defaults, {
emberData: {
compatWith,
},
babel: {
// this ensures that the same build-time code stripping that is done
// for library packages is also done for our tests and dummy app
plugins: [...require('@ember-data/private-build-infra/src/debug-macros')(null, isProd, compatWith)],
},
'ember-cli-babel': {
throwUnlessParallelizable: true,
},
});

return app.toTree();
};
36 changes: 29 additions & 7 deletions packages/unpublished-test-infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,42 @@
"doc": "doc",
"test": "tests"
},
"scripts": {},
"scripts": {
"test": "ember test"
},
"dependencies": {
"@ember-data/private-build-infra": "3.16.0-alpha.2",
"@ember/edition-utils": "^1.1.1",
"ember-cli-babel": "^7.12.0",
"ember-cli-blueprint-test-helpers": "^0.19.1",
"ember-cli-babel": "^7.13.0",
"ember-cli-typescript": "^3.1.1",
"ember-get-config": "^0.2.4",
"ember-cli-blueprint-test-helpers": "^0.19.2",
"@ember/edition-utils": "^1.1.1",
"testem": "^3.0.2"
},
"devDependencies": {
"@ember/optional-features": "^1.1.0",
"ember-cli": "~3.14.0",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-htmlbars": "^4.0.9",
"ember-cli-inject-live-reload": "^2.0.2",
"ember-cli-shims": "^1.2.0",
"ember-cli-test-loader": "^2.2.0",
"ember-cli-test-info": "^1.0.0",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-export-application-global": "^2.0.1",
"ember-load-initializers": "^2.1.1",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.6.0",
"ember-resolver": "^6.0.0",
"ember-source": "^3.15.0",
"loader.js": "^4.7.0",
"qunit": "^2.9.3",
"rsvp": "^4.8.5",
"testem": "^3.0.2"
"rsvp": "^4.8.5"
},
"engines": {
"node": ">= 8.0.0"
"node": "8.* || >= 10.*"
},
"ember-addon": {
"configPath": "tests/dummy/config"
}
}
21 changes: 21 additions & 0 deletions packages/unpublished-test-infra/testem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: ['Chrome'],
launch_in_dev: ['Chrome'],
browser_start_timeout: 120,
browser_args: {
Chrome: {
ci: [
// --no-sandbox is needed when running Chrome inside a container
process.env.CI ? '--no-sandbox' : null,
'--headless',
'--disable-dev-shm-usage',
'--disable-software-rasterizer',
'--mute-audio',
'--remote-debugging-port=0',
'--window-size=1440,900',
].filter(Boolean),
},
},
};
12 changes: 12 additions & 0 deletions packages/unpublished-test-infra/tests/dummy/app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Application from '@ember/application';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

export default class App extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
}

loadInitializers(App, config.modulePrefix);
25 changes: 25 additions & 0 deletions packages/unpublished-test-infra/tests/dummy/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Dummy</title>
<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/dummy.css">

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

<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>

{{content-for "body-footer"}}
</body>
</html>
3 changes: 3 additions & 0 deletions packages/unpublished-test-infra/tests/dummy/app/resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Resolver from 'ember-resolver';

export default Resolver;
9 changes: 9 additions & 0 deletions packages/unpublished-test-infra/tests/dummy/app/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import EmberRouter from '@ember/routing/router';
import config from './config/environment';

export default class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
}

Router.map(function() {});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ul>
<li>
<a href='/tests?hidepassed'>Tests</a>
</li>
</ul>
{{outlet}}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{outlet}}
52 changes: 52 additions & 0 deletions packages/unpublished-test-infra/tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use strict';

module.exports = function(environment) {
let ENV = {
modulePrefix: 'dummy',
environment,
rootURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false,
},
},

APP: {
// Here you can pass flags/options to your application instance
// when it is created
},
compatWith: process.env.COMPAT_WITH,
};

if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
}

if (environment === 'test') {
// Testem prefers this...
ENV.locationType = 'none';

// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;

ENV.APP.rootElement = '#ember-testing';
ENV.APP.autoboot = false;
}

if (environment === 'production') {
// here you can enable a production-specific feature
}

return ENV;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"jquery-integration": false
}
14 changes: 14 additions & 0 deletions packages/unpublished-test-infra/tests/dummy/config/targets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const browsers = ['last 1 Chrome versions', 'last 1 Firefox versions', 'last 1 Safari versions'];

const isCI = !!process.env.CI;
const isProduction = process.env.EMBER_ENV === 'production';

if (isCI || isProduction) {
browsers.push('ie 11');
}

module.exports = {
browsers,
};
Empty file.
33 changes: 33 additions & 0 deletions packages/unpublished-test-infra/tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Dummy Tests</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

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

<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css">

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

<script src="/testem.js" integrity=""></script>
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/test-support.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
<script src="{{rootURL}}assets/tests.js"></script>

{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
</body>
</html>
8 changes: 8 additions & 0 deletions packages/unpublished-test-infra/tests/test-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';

setApplication(Application.create(config.APP));

start();
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { module, test } from 'ember-qunit';
import config from 'dummy/config/environment';
import { DEPRECATE_EVENTED_API_USAGE } from '@ember-data/private-build-infra/deprecations';

const { compatWith } = config;

module('test compatWith', function() {
test('deprecation strips', function(assert) {
let deprecation_stripped = true;

if (DEPRECATE_EVENTED_API_USAGE) {
deprecation_stripped = false;
}

if (compatWith === '3.0' || compatWith === '3.8') {
assert.equal(deprecation_stripped, false, 'deprecation code was not stripped');
} else if (compatWith === '3.12' || compatWith === '3.16' || compatWith === '99.0') {
assert.equal(deprecation_stripped, true, 'deprecation code was stripped');
} else {
// do nothing
}
});
});
Loading

0 comments on commit af4ad46

Please sign in to comment.