Skip to content

Commit 19f6f16

Browse files
committed
move root-url test to scenario-tester
1 parent 5abf0a6 commit 19f6f16

File tree

5 files changed

+100
-127
lines changed

5 files changed

+100
-127
lines changed

packages/ember-cli-fastboot/test/fixtures/root-url/app/templates/application.hbs

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/ember-cli-fastboot/test/fixtures/root-url/config/environment.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/ember-cli-fastboot/test/fixtures/root-url/config/targets.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/ember-cli-fastboot/test/root-url-test.js

Lines changed: 0 additions & 98 deletions
This file was deleted.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import qunit from 'qunit';
2+
import { merge } from 'lodash-es';
3+
4+
import { appScenarios } from './scenarios.mjs';
5+
import emberServe from './helpers/ember-serve.mjs';
6+
import fetch from 'node-fetch';
7+
8+
const { module: Qmodule, test } = qunit;
9+
10+
appScenarios
11+
.map('root-url', (project) => {
12+
merge(project.files, {
13+
app: {
14+
templates: {
15+
'application.hbs': `<h2 id="title">Welcome to Ember.js</h2>`,
16+
},
17+
},
18+
config: {
19+
'environment.js': `'use strict';
20+
21+
module.exports = function(environment) {
22+
var ENV = {
23+
rootURL: '/my-root/',
24+
environment: environment,
25+
modulePrefix: 'classic-app-template',
26+
locationType: 'auto'
27+
};
28+
29+
return ENV;
30+
};
31+
`,
32+
},
33+
});
34+
35+
project.pkg.fastbootDependencies = ['crypto'];
36+
project.removeDependency('ember-fetch');
37+
})
38+
.forEachScenario((scenario) => {
39+
Qmodule(scenario.name, function (hooks) {
40+
let app; // PreparedApp
41+
let process;
42+
43+
hooks.before(async () => {
44+
app = await scenario.prepare();
45+
process = await emberServe(app);
46+
});
47+
48+
hooks.after(() => {
49+
return process.stop();
50+
});
51+
52+
test('/ HTML contents', async function (assert) {
53+
const response = await fetch(`http://localhost:${process.port}/my-root/`, {
54+
headers: {
55+
Accept: 'text/html',
56+
},
57+
});
58+
assert.equal(response.status, 200);
59+
assert.equal(response.headers.get('content-type'), 'text/html; charset=utf-8');
60+
if (response.status === 500) throw new Error(await response.text());
61+
const body = await response.text();
62+
assert.ok(body.includes('Welcome to Ember.js'));
63+
});
64+
65+
test('Out of scope requests', async function (assert) {
66+
const response = await fetch(`http://localhost:${process.port}/foo-bar/`, {
67+
headers: {
68+
Accept: 'text/html',
69+
},
70+
});
71+
assert.equal(response.status, 404);
72+
});
73+
74+
test('with fastboot query parameter turned on', async function (assert) {
75+
const response = await fetch(`http://localhost:${process.port}/my-root/?fastboot=true`, {
76+
headers: {
77+
Accept: 'text/html',
78+
},
79+
});
80+
assert.equal(response.status, 200);
81+
assert.equal(response.headers.get('content-type'), 'text/html; charset=utf-8');
82+
if (response.status === 500) throw new Error(await response.text());
83+
const body = await response.text();
84+
assert.ok(body.includes('Welcome to Ember.js'));
85+
});
86+
87+
test('with fastboot query parameter turned off', async function (assert) {
88+
const response = await fetch(`http://localhost:${process.port}/my-root/?fastboot=false`, {
89+
headers: {
90+
Accept: 'text/html',
91+
},
92+
});
93+
assert.equal(response.status, 200);
94+
assert.equal(response.headers.get('content-type'), 'text/html; charset=utf-8');
95+
if (response.status === 500) throw new Error(await response.text());
96+
const body = await response.text();
97+
assert.ok(body.includes('<!-- EMBER_CLI_FASTBOOT_BODY -->'));
98+
});
99+
});
100+
});

0 commit comments

Comments
 (0)