Skip to content

Commit e64a527

Browse files
committed
fix: fix mobile-specific feature test
1 parent 8ea2e72 commit e64a527

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

addon/ng2/models/webpack-build-mobile.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import * as webpack from 'webpack';
22
import * as path from 'path';
33
import * as OfflinePlugin from 'offline-plugin';
4-
import { PrerenderWebpackPlugin } from '../utilities/prerender-webpack-plugin.ts'
4+
import * as CopyWebpackPlugin from 'copy-webpack-plugin';
5+
import { PrerenderWebpackPlugin } from '../utilities/prerender-webpack-plugin.ts';
56

67
export const getWebpackMobileConfigPartial = function (projectRoot: string) {
78
return {
89
plugins: [
10+
new CopyWebpackPlugin([
11+
{from: path.resolve(projectRoot, './src/icons'), to: path.resolve(projectRoot, './dist/icons')},
12+
{from: path.resolve(projectRoot, './src/manifest.webapp'), to: path.resolve(projectRoot, './dist')}
13+
]),
914
new PrerenderWebpackPlugin({
1015
templatePath: 'index.html',
1116
configPath: path.resolve(projectRoot, './src/main-app-shell.ts'),

addon/ng2/models/webpack-config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class NgCliWebpackConfig {
3030
if (CliConfig.fromProject().apps[0].mobile){
3131
this.webpackMobileConfigPartial = getWebpackMobileConfigPartial(this.ngCliProject.root);
3232
this.webpackMobileProdConfigPartial = getWebpackMobileProdConfigPartial(this.ngCliProject.root);
33-
this.webpackDevConfigPartial = webpackMerge(this.webpackDevConfigPartial, this.webpackMobileConfigPartial);
33+
this.webpackBaseConfig = webpackMerge(this.webpackBaseConfig, this.webpackMobileConfigPartial);
3434
this.webpackProdConfigPartial = webpackMerge(this.webpackProdConfigPartial, this.webpackMobileProdConfigPartial);
3535
}
3636

tests/e2e/e2e_workflow.spec.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,21 @@ describe('Basic end-to-end Workflow', function () {
8989
expect(mainBundleContent).to.include('production:!0');
9090
});
9191

92-
it_mobile('Enables mobile-specific production features', () => {
93-
let index = fs.readFileSync(path.join(process.cwd(), 'dist/index.html'), 'utf-8');
92+
it_mobile('Enables mobile-specific production features in prod builds', () => {
93+
let indexHtml = fs.readFileSync(path.join(process.cwd(), 'dist/index.html'), 'utf-8');
9494
// Service Worker
95-
expect(index.includes('if (\'serviceWorker\' in navigator) {')).to.be.equal(true);
96-
expect(existsSync(path.join(process.cwd(), 'dist/worker.js'))).to.be.equal(true);
97-
98-
// Asynchronous bundle
99-
expect(index.includes('<script src="/app-concat.js" async=""></script>')).to.be.equal(true);
100-
expect(existsSync(path.join(process.cwd(), 'dist/app-concat.js'))).to.be.equal(true);
95+
expect(indexHtml).to.match(/sw-install\.[0-9a-f]{20}\.bundle\.js/);
96+
expect(existsSync(path.join(process.cwd(), 'dist/sw.js' ))).to.be.equal(true);
10197

10298
// App Manifest
103-
expect(index.includes('<link rel="manifest" href="/manifest.webapp">')).to.be.equal(true);
99+
expect(indexHtml.includes('<link rel="manifest" href="/manifest.webapp">')).to.be.equal(true);
104100
expect(existsSync(path.join(process.cwd(), 'dist/manifest.webapp'))).to.be.equal(true);
101+
102+
// Icons folder
103+
expect(existsSync(path.join(process.cwd(), 'dist/icons'))).to.be.equal(true);
104+
105+
// Prerender content
106+
expect(indexHtml).to.match(/app works!/);
105107
});
106108

107109
it('Can run `ng build` in created project', function () {

tests/runner.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var Mocha = require('mocha');
3434
var glob = require('glob');
3535
var path = require('path');
3636

37-
var root = 'tests/{acceptance,models,e2e}';
37+
var root = 'tests/{models,e2e}';
3838
var specFiles = glob.sync(root + '/**/*.spec.*');
3939
var mocha = new Mocha({ timeout: 5000, reporter: 'spec' });
4040

0 commit comments

Comments
 (0)