mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
chore(snapshot): include css tests
This commit is contained in:
@@ -11,7 +11,7 @@ module.exports = {
|
||||
description: 'Output demos to their files on ionic-demo website',
|
||||
runAfter: ['files-read'],
|
||||
runBefore: ['processing-docs'],
|
||||
process: function(docs, config) {
|
||||
process: function(docs, config, extraData) {
|
||||
|
||||
var contentsFolder = config.rendering.contentsFolder;
|
||||
var assetOutputPath = '${component}/${name}/${fileName}';
|
||||
@@ -23,9 +23,12 @@ module.exports = {
|
||||
};
|
||||
var transform = {
|
||||
'.scenario.js': function(doc) {
|
||||
doc.url = 'http://localhost:' + config.get('buildConfig.protractorPort') +
|
||||
'/' + config.versionData.current.folder +
|
||||
'/' + _.template(assetOutputPath, _.assign({},doc,{fileName:''}));
|
||||
doc.url = 'http://localhost:' +
|
||||
config.get('buildConfig.protractorPort') + path.join(
|
||||
config.demoFolderPrefix || '',
|
||||
config.versionData.current.folder,
|
||||
_.template(assetOutputPath, _.assign({},doc,{fileName:''}))
|
||||
);
|
||||
return doc;
|
||||
}
|
||||
};
|
||||
@@ -118,6 +121,8 @@ module.exports = {
|
||||
outputPath: path.join(contentsFolder, 'index-ionic-demo-app.js')
|
||||
});
|
||||
|
||||
extraData.demoFolderPrefix = config.get('demoFolderPrefix');
|
||||
|
||||
return pages;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
|
||||
<link rel="stylesheet" href="/{$ version.current.folder $}/ionic/css/ionic.min.css">
|
||||
<script src="/{$ version.current.folder $}/ionic/js/ionic.bundle.min.js"></script>
|
||||
<script src="/{$ version.current.folder $}/pages-data.js"></script>
|
||||
<link rel="stylesheet" href="{$ demoFolderPrefix $}/{$ version.current.folder $}/ionic/css/ionic.min.css">
|
||||
<script src="{$ demoFolderPrefix $}/{$ version.current.folder $}/ionic/js/ionic.bundle.min.js"></script>
|
||||
<script src="{$ demoFolderPrefix $}/{$ version.current.folder $}/pages-data.js"></script>
|
||||
|
||||
{% for file in doc.demoData.files.css %}
|
||||
<link rel="stylesheet" href="{$ file.fileName $}">
|
||||
|
||||
@@ -5,8 +5,11 @@ var cp = require('child_process');
|
||||
var gutil = require('gulp-util');
|
||||
var http = require('http');
|
||||
var karma = require('karma').server;
|
||||
var path = require('canonical-path');
|
||||
var uuid = require('node-uuid');
|
||||
|
||||
var projectRoot = path.resolve(__dirname, '../..');
|
||||
|
||||
var karmaConf = require('../karma.conf.js');
|
||||
var karmaSauceConf = require('../karma-sauce.conf.js');
|
||||
|
||||
@@ -62,7 +65,7 @@ module.exports = function(gulp, argv) {
|
||||
*/
|
||||
var protractorHttpServer;
|
||||
gulp.task('protractor-server', function() {
|
||||
var app = connect().use(connect.static(__dirname + '/../../dist/ionic-demo'));
|
||||
var app = connect().use(connect.static(projectRoot));
|
||||
protractorHttpServer = http.createServer(app).listen(buildConfig.protractorPort);
|
||||
});
|
||||
|
||||
@@ -105,7 +108,9 @@ module.exports = function(gulp, argv) {
|
||||
}
|
||||
|
||||
function protractor(done, args) {
|
||||
var child = cp.spawn('node', [__dirname+'/../../node_modules/.bin/protractor'].concat(args), {
|
||||
var child = cp.spawn('node', [
|
||||
path.resolve(projectRoot, 'node_modules/.bin/protractor')
|
||||
].concat(args), {
|
||||
stdio: [process.stdin, process.stdout, 'pipe']
|
||||
});
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
var buildConfig = require('./build.config');
|
||||
var path = require('canonical-path');
|
||||
var projectRoot = path.resolve(__dirname, '..');
|
||||
|
||||
exports.config = {
|
||||
|
||||
// Spec patterns are relative to the location of the spec file. They may
|
||||
// include glob patterns.
|
||||
specs: [__dirname + '/../dist/ionic-demo/nightly/**/*.scenario.js'],
|
||||
specs: [
|
||||
path.resolve(projectRoot, 'test/css/**/*.scenario.js'),
|
||||
path.resolve(projectRoot, 'dist/ionic-demo/**/*.scenario.js'),
|
||||
],
|
||||
|
||||
// Options to be passed to Jasmine-node.
|
||||
jasmineNodeOpts: {
|
||||
|
||||
187
gulpfile.js
187
gulpfile.js
@@ -9,15 +9,11 @@ var argv = require('minimist')(process.argv.slice(2));
|
||||
var _ = require('lodash');
|
||||
var buildConfig = require('./config/build.config.js');
|
||||
var changelog = require('conventional-changelog');
|
||||
var dgeni = require('dgeni');
|
||||
var es = require('event-stream');
|
||||
var htmlparser = require('htmlparser2');
|
||||
var irc = require('ircb');
|
||||
var lunr = require('lunr');
|
||||
var marked = require('marked');
|
||||
var mkdirp = require('mkdirp');
|
||||
var twitter = require('node-twitter-api');
|
||||
var yaml = require('js-yaml');
|
||||
|
||||
var cp = require('child_process');
|
||||
var fs = require('fs');
|
||||
@@ -50,6 +46,11 @@ if (IS_RELEASE_BUILD) {
|
||||
*/
|
||||
require('./config/gulp-tasks/test')(gulp, argv);
|
||||
|
||||
/**
|
||||
* Load Docs Tasks
|
||||
*/
|
||||
require('./config/gulp-tasks/docs')(gulp, argv);
|
||||
|
||||
if (argv.dist) {
|
||||
buildConfig.dist = argv.dist;
|
||||
}
|
||||
@@ -58,53 +59,6 @@ gulp.task('default', ['build']);
|
||||
gulp.task('build', ['bundle', 'sass']);
|
||||
gulp.task('validate', ['jshint', 'ddescribe-iit', 'karma']);
|
||||
|
||||
gulp.task('docs', function() {
|
||||
var docVersion = argv['doc-version'] || 'nightly';
|
||||
if (docVersion != 'nightly' && !semver.valid(docVersion)) {
|
||||
console.log('Usage: gulp docs --doc-version=(nightly|versionName)');
|
||||
return process.exit(1);
|
||||
}
|
||||
|
||||
var config = dgeni.loadConfig(path.join(__dirname, '/config/docs/docs.config.js'));
|
||||
config.set('currentVersion', docVersion);
|
||||
config.set(
|
||||
'rendering.outputFolder',
|
||||
argv.dist ? argv.dist : path.resolve(__dirname, buildConfig.dist, 'ionic-site')
|
||||
);
|
||||
|
||||
return dgeni.generator(config)().then(function() {
|
||||
gutil.log('Docs for', gutil.colors.cyan(docVersion), 'generated!');
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('demos', function(done) {
|
||||
var demoVersion = argv['demo-version'] || 'nightly';
|
||||
if (demoVersion != 'nightly' && !semver.valid(demoVersion)) {
|
||||
console.log('Usage: gulp docs --doc-version=(nightly|versionName)');
|
||||
return process.exit(1);
|
||||
}
|
||||
|
||||
var config = dgeni.loadConfig(path.join(__dirname, '/config/demos/demos.config.js'));
|
||||
config.set('currentVersion', demoVersion);
|
||||
config.set('dist', buildConfig.dist);
|
||||
config.set(
|
||||
'rendering.outputFolder',
|
||||
argv.dist ? argv.dist : path.resolve(__dirname, buildConfig.dist, 'ionic-demo')
|
||||
);
|
||||
|
||||
dgeni.generator(config)().then(function() {
|
||||
gutil.log('Demos for', gutil.colors.cyan(demoVersion), 'generated!');
|
||||
gutil.log('Building ionic into demo folder...');
|
||||
cp.spawn('node', [
|
||||
__dirname + '/node_modules/.bin/gulp',
|
||||
'build',
|
||||
IS_RELEASE_BUILD ? '--release' : '--no-release',
|
||||
'--dist=' + config.rendering.outputFolder + '/' +
|
||||
config.rendering.contentsFolder + '/ionic'
|
||||
])
|
||||
.on('exit', done);
|
||||
});
|
||||
});
|
||||
|
||||
var IS_WATCH = false;
|
||||
gulp.task('watch', ['build'], function() {
|
||||
@@ -288,137 +242,6 @@ gulp.task('release-irc', function(done) {
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('docs-index', function() {
|
||||
var idx = lunr(function() {
|
||||
this.field('path');
|
||||
this.field('title', {boost: 10});
|
||||
this.field('body');
|
||||
this.ref('id');
|
||||
});
|
||||
var ref = {};
|
||||
var refId = 0;
|
||||
|
||||
function addToIndex(path, title, layout, body) {
|
||||
// Add the data to the indexer and ref object
|
||||
idx.add({'path': path, 'body': body, 'title': title, id: refId});
|
||||
ref[refId] = {'p': path, 't': title, 'l': layout};
|
||||
refId++;
|
||||
}
|
||||
|
||||
return gulp.src([
|
||||
'temp/ionic-site/docs/{components,guide,api,overview}/**/*.{md,html,markdown}',
|
||||
'temp/ionic-site/docs/index.html',
|
||||
'temp/ionic-site/getting-started/index.html',
|
||||
'temp/ionic-site/tutorials/**/*.{md,html,markdown}',
|
||||
'temp/ionic-site/_posts/**/*.{md,html,markdown}'
|
||||
])
|
||||
.pipe(es.map(function(file, callback) {
|
||||
//docs for gulp file objects: https://github.com/wearefractal/vinyl
|
||||
var contents = file.contents.toString(); //was buffer
|
||||
|
||||
// Grab relative path from ionic-site root
|
||||
var relpath = file.path.replace(/^.*?temp\/ionic-site\//, '');
|
||||
|
||||
// Read out the yaml portion of the Jekyll file
|
||||
var yamlStartIndex = contents.indexOf('---');
|
||||
|
||||
if (yamlStartIndex === -1) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
// read Jekyll's page yaml variables at the top of the file
|
||||
var yamlEndIndex = contents.indexOf('---', yamlStartIndex+3); //starting from start
|
||||
var yamlRaw = contents.substring(yamlStartIndex+3, yamlEndIndex);
|
||||
|
||||
var pageData = yaml.safeLoad(yamlRaw);
|
||||
if(!pageData.title || !pageData.layout) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
// manually set to not be searchable, or for a blog post, manually set to be searchable
|
||||
if(pageData.searchable === false || (pageData.layout == 'post' && pageData.searchable !== true)) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
// clean up some content so code variables are searchable too
|
||||
contents = contents.substring(yamlEndIndex+3);
|
||||
contents = contents.replace(/<code?>/gi, '');
|
||||
contents = contents.replace(/<\/code>/gi, '');
|
||||
contents = contents.replace(/<code?></gi, '');
|
||||
contents = contents.replace(/><\/code>/gi, '');
|
||||
contents = contents.replace(/`</gi, '');
|
||||
contents = contents.replace(/>`/gi, '');
|
||||
|
||||
// create a clean path to the URL
|
||||
var path = '/' + relpath.replace('index.md', '')
|
||||
.replace('index.html', '')
|
||||
.replace('.md', '.html')
|
||||
.replace('.markdown', '.html');
|
||||
if(pageData.layout == 'post') {
|
||||
path = '/blog/' + path.substring(19).replace('.html', '/');
|
||||
}
|
||||
|
||||
var parser;
|
||||
if(pageData.search_sections === true) {
|
||||
// each section within the content should be its own search result
|
||||
var section = { body: '', title: '' };
|
||||
var isTitleOpen = false;
|
||||
|
||||
parser = new htmlparser.Parser({
|
||||
ontext: function(text){
|
||||
if(isTitleOpen) {
|
||||
section.title += text; // get the title of this section
|
||||
} else {
|
||||
section.body += text.replace(/{%.*%}/, '', 'g'); // Ignore any Jekyll expressions
|
||||
}
|
||||
},
|
||||
onopentag: function(name, attrs) {
|
||||
if(name == 'section' && attrs.id) {
|
||||
// start building new section data
|
||||
section = { body: '', path: path + '#' + attrs.id, title: '' };
|
||||
} else if( (name == 'h1' || name == 'h2' || name == 'h3') && attrs.class == 'title') {
|
||||
isTitleOpen = true; // the next text will be this sections title
|
||||
}
|
||||
},
|
||||
onclosetag: function(name) {
|
||||
if(name == 'section') {
|
||||
// section closed, index this section then clear it out
|
||||
addToIndex(section.path, section.title, pageData.layout, section.body);
|
||||
section = { body: '', title: '' };
|
||||
} else if( (name == 'h1' || name == 'h2' || name == 'h3') && isTitleOpen) {
|
||||
isTitleOpen = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
parser.write(contents);
|
||||
parser.end();
|
||||
|
||||
} else {
|
||||
// index the entire page
|
||||
var body = '';
|
||||
parser = new htmlparser.Parser({
|
||||
ontext: function(text){
|
||||
body += text.replace(/{%.*%}/, '', 'g'); // Ignore any Jekyll expressions
|
||||
}
|
||||
});
|
||||
parser.write(contents);
|
||||
parser.end();
|
||||
|
||||
addToIndex(path, pageData.title, pageData.layout, body);
|
||||
}
|
||||
|
||||
callback();
|
||||
|
||||
})).on('end', function() {
|
||||
// Write out as one json file
|
||||
mkdirp.sync('temp/ionic-site/data');
|
||||
fs.writeFileSync(
|
||||
'temp/ionic-site/data/index.json',
|
||||
JSON.stringify({'ref': ref, 'index': idx.toJSON()})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function notContains(disallowed) {
|
||||
disallowed = disallowed || [];
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe('css snapshot', function() {
|
||||
|
||||
var tests = [
|
||||
[
|
||||
'bars-clear',
|
||||
'buttons',
|
||||
'cards-header-footer',
|
||||
@@ -22,15 +22,12 @@ describe('css snapshot', function() {
|
||||
'input-toogle',
|
||||
'list',
|
||||
'modals',
|
||||
];
|
||||
|
||||
for(var x=0; x<tests.length; x++) {
|
||||
(function(){
|
||||
var testId = tests[x];
|
||||
it(testId, function() {
|
||||
].forEach(function(testId) {
|
||||
describe(testId, function() {
|
||||
it('init', function() {
|
||||
browser.get('http://localhost:8876/test/css/' + testId + '.html');
|
||||
});
|
||||
})();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user