-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX release] Enable
store.createRecord
in FastBoot (#6568)
* Add FastBoot test for store.createRecord Fails at the moment. * Enable store.createRecord in FastBoot Changes the V4 UUID generation to leverage `FastBoot.require` when possible. This currently requires that the host application add the following to their `package.json`: ``` "fastbootDependencies": [ "crypto" ] ``` * fix types
- Loading branch information
Showing
7 changed files
with
138 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import EmberRouter from '@ember/routing/router'; | ||
import config from './config/environment'; | ||
|
||
const Router = EmberRouter.extend({ | ||
location: config.locationType, | ||
rootURL: config.rootURL, | ||
}); | ||
|
||
Router.map(function() { | ||
this.route('person', function() { | ||
this.route('new'); | ||
}); | ||
}); | ||
|
||
export default Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default Route.extend({ | ||
store: service(), | ||
|
||
model() { | ||
return this.store.createRecord('person'); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<form> | ||
<label> | ||
Name | ||
{{input class="person-name" value=this.model.name}} | ||
</label> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"name": "fastboot-test-app", | ||
"version": "3.15.0-alpha.1", | ||
"private": true, | ||
"description": "Small description for fastboot-test-app goes here", | ||
"repository": "", | ||
"license": "MIT", | ||
"author": "", | ||
"directories": { | ||
"doc": "doc", | ||
"test": "tests" | ||
}, | ||
"scripts": { | ||
"build": "ember build", | ||
"lint:hbs": "ember-template-lint .", | ||
"lint:js": "eslint --config ../../.eslintrc.js --ignore-path ../../.eslintignore .", | ||
"start": "ember serve", | ||
"test": "ember test --test-port=0" | ||
}, | ||
"dependencies": { | ||
"ember-data": "3.15.0-alpha.1", | ||
"ember-inflector": "^3.0.1" | ||
}, | ||
"devDependencies": { | ||
"@ember/optional-features": "^1.1.0", | ||
"@types/ember": "^3.1.1", | ||
"@types/ember-qunit": "^3.4.7", | ||
"@types/ember__test-helpers": "~0.7.9", | ||
"@types/qunit": "^2.5.3", | ||
"@types/rsvp": "^4.0.3", | ||
"broccoli-asset-rev": "^3.0.0", | ||
"ember-cli": "~3.13.1", | ||
"ember-cli-app-version": "^3.2.0", | ||
"ember-cli-babel": "^7.12.0", | ||
"ember-cli-dependency-checker": "^3.2.0", | ||
"ember-cli-fastboot": "^2.2.1", | ||
"ember-cli-fastboot-testing": "^0.2.3", | ||
"ember-cli-htmlbars": "^4.0.8", | ||
"ember-cli-inject-live-reload": "^2.0.2", | ||
"ember-cli-template-lint": "^1.0.0-beta.1", | ||
"ember-cli-typescript": "^3.0.0", | ||
"ember-cli-typescript-blueprints": "^3.0.0", | ||
"ember-export-application-global": "^2.0.0", | ||
"ember-fetch": "^6.7.1", | ||
"ember-load-initializers": "^2.1.0", | ||
"ember-maybe-import-regenerator": "^0.1.6", | ||
"ember-qunit": "^4.5.1", | ||
"ember-resolver": "^5.3.0", | ||
"ember-simple-tree": "^0.7.1", | ||
"ember-source": "^3.13.3", | ||
"eslint": "^6.5.1", | ||
"eslint-plugin-ember": "^7.2.0", | ||
"eslint-plugin-node": "^10.0.0", | ||
"loader.js": "^4.7.0", | ||
"qunit": "^2.9.3", | ||
"qunit-dom": "^0.9.0", | ||
"typescript": "~3.6.4" | ||
}, | ||
"fastbootDependencies": [ | ||
"crypto" | ||
], | ||
"engines": { | ||
"node": "8.* || >= 10.*" | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/-fastboot-test-app/tests/fastboot/person/new-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { module, test } from 'qunit'; | ||
import { setup, visit } from 'ember-cli-fastboot-testing/test-support'; | ||
|
||
module('FastBoot | /person/new', function(hooks) { | ||
setup(hooks); | ||
|
||
test('it does not error in SSR (GH#6563)', async function(assert) { | ||
await visit('/person/new'); | ||
|
||
// from application.hbs | ||
assert.dom('h1').hasText('Ember Data'); | ||
assert.dom('a').hasAttribute('href', '/tests'); | ||
|
||
assert.dom('.person-name').exists(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
interface FastBoot { | ||
require(moduleName: string): any; | ||
} | ||
const FastBoot: undefined | FastBoot; |