-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move fastboot-location-config to scenario-tester
- Loading branch information
Showing
10 changed files
with
126 additions
and
136 deletions.
There are no files selected for viewing
73 changes: 0 additions & 73 deletions
73
packages/ember-cli-fastboot/test/fastboot-location-config-test.js
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/ember-cli-fastboot/test/fixtures/fastboot-location-config/app/router.js
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...i-fastboot/test/fixtures/fastboot-location-config/app/routes/redirect-on-transition-to.js
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
packages/ember-cli-fastboot/test/fixtures/fastboot-location-config/app/routes/test-passed.js
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...s/ember-cli-fastboot/test/fixtures/fastboot-location-config/app/templates/application.hbs
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...s/ember-cli-fastboot/test/fixtures/fastboot-location-config/app/templates/test-passed.hbs
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
packages/ember-cli-fastboot/test/fixtures/fastboot-location-config/config/environment.js
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
packages/ember-cli-fastboot/test/fixtures/fastboot-location-config/config/targets.js
This file was deleted.
Oops, something went wrong.
122 changes: 122 additions & 0 deletions
122
test-packages/test-scenarios/fastboot-location-config-test.mjs
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,122 @@ | ||
import qunit from 'qunit'; | ||
import { merge } from 'lodash-es'; | ||
|
||
import { appScenarios } from './scenarios.mjs'; | ||
import emberServe from './helpers/ember-serve.mjs'; | ||
import fetch from 'node-fetch'; | ||
|
||
const { module: Qmodule, test } = qunit; | ||
|
||
appScenarios | ||
.map('fastboot-location-config', (project) => { | ||
merge(project.files, { | ||
app: { | ||
routes: { | ||
'redirect-on-transition-to.js': ` | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from '@ember/service'; | ||
export default class MyRoute extends Route { | ||
@service | ||
router; | ||
beforeModel() { | ||
this.router.transitionTo('test-passed'); | ||
} | ||
} | ||
`, | ||
'test-passed.js': ` | ||
import Ember from 'ember'; | ||
export default Ember.Route.extend({}); | ||
`, | ||
}, | ||
templates: { | ||
'test-passed.hbs': `<h1>The Test Passed!</h1> | ||
<p>All redirection tests should be set up to redirect here.</p>`, | ||
}, | ||
'router.js': ` | ||
import Ember from 'ember'; | ||
let Router = Ember.Router; | ||
Router.map(function() { | ||
this.route('redirect-on-transition-to'); | ||
this.route('test-passed'); | ||
}); | ||
export default Router; | ||
`, | ||
}, | ||
config: { | ||
'environment.js': ` | ||
'use strict'; | ||
module.exports = function(environment) { | ||
var ENV = { | ||
rootURL: '/', | ||
locationType: 'auto', | ||
environment: environment, | ||
modulePrefix: 'classic-app-template', | ||
fastboot: { | ||
fastbootHeaders: false, | ||
hostWhitelist: [/localhost:\\d+/], | ||
redirectCode: 302, | ||
} | ||
}; | ||
return ENV; | ||
}; | ||
`, | ||
}, | ||
}); | ||
|
||
project.removeDependency('ember-fetch'); | ||
}) | ||
.forEachScenario((scenario) => { | ||
Qmodule(scenario.name, function (hooks) { | ||
let app; // PreparedApp | ||
let process; | ||
|
||
hooks.before(async () => { | ||
app = await scenario.prepare(); | ||
process = await emberServe(app); | ||
}); | ||
|
||
hooks.after(() => { | ||
return process.stop(); | ||
}); | ||
|
||
test('use the redirect code provided by the EmberApp', async function (assert) { | ||
const response = await fetch(`http://localhost:${process.port}/redirect-on-transition-to`, { | ||
headers: { | ||
Accept: 'text/html', | ||
}, | ||
redirect: 'manual', | ||
}); | ||
if (response.status === 500) throw new Error(await response.body.text()); | ||
assert.equal(response.status, 302); | ||
assert.equal( | ||
response.headers.get('location'), | ||
`http://localhost:${process.port}/test-passed` | ||
); | ||
}); | ||
|
||
Qmodule('when fastboot.fastbootHeaders is false', function () { | ||
test('should not send the "x-fastboot-path" header on a redirect', async function (assert) { | ||
const response = await fetch( | ||
`http://localhost:${process.port}/redirect-on-transition-to`, | ||
{ | ||
redirect: 'manual', | ||
headers: { | ||
Accept: 'text/html', | ||
}, | ||
} | ||
); | ||
if (response.status === 500) throw new Error(await response.body.text()); | ||
assert.notOk(response.headers.has('x-fastboot-path')); | ||
}); | ||
}); | ||
}); | ||
}); |
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