mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-28 01:10:58 +01:00
Implemented Gemini screenshot testing base
This commit is contained in:
parent
8f46cc6f09
commit
3783eceb09
@ -18,10 +18,11 @@
|
|||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
# IN THE SOFTWARE.
|
# IN THE SOFTWARE.
|
||||||
|
|
||||||
# Build files
|
# Files generated by build
|
||||||
/build
|
/build
|
||||||
/material
|
/material
|
||||||
/site
|
/site
|
||||||
|
|
||||||
# Gemini reports
|
# Files generated by visual tests
|
||||||
/gemini-report
|
/gemini-report
|
||||||
|
/tests/visual/data
|
||||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -25,14 +25,16 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
/npm-debug.log
|
/npm-debug.log
|
||||||
|
|
||||||
# Build files
|
# Files generated by build
|
||||||
/build
|
/build
|
||||||
/manifest.json
|
/manifest.json
|
||||||
/MANIFEST
|
/MANIFEST
|
||||||
/site
|
/site
|
||||||
|
|
||||||
# Gemini reports
|
# Files generated by visual tests
|
||||||
/gemini-report
|
/gemini-report
|
||||||
|
/tests/visual/baseline/local
|
||||||
|
/tests/visual/data
|
||||||
|
|
||||||
# Distribution files
|
# Distribution files
|
||||||
/dist
|
/dist
|
||||||
|
@ -37,7 +37,7 @@ const config = {
|
|||||||
},
|
},
|
||||||
lib: "lib", /* Libraries and tasks */
|
lib: "lib", /* Libraries and tasks */
|
||||||
tests: {
|
tests: {
|
||||||
visual: "tests/visual" /* Visual regression tests */
|
visual: "tests/visual" /* Base directory for visual tests */
|
||||||
},
|
},
|
||||||
views: {
|
views: {
|
||||||
src: "src", /* Source directory for views */
|
src: "src", /* Source directory for views */
|
||||||
@ -95,7 +95,10 @@ gulp.src = (...glob) => {
|
|||||||
* Helper function to load a task
|
* Helper function to load a task
|
||||||
*/
|
*/
|
||||||
const load = task => {
|
const load = task => {
|
||||||
return require(`./${config.lib}/tasks/${task}`)(gulp, config, args)
|
return done => {
|
||||||
|
return require(`./${config.lib}/tasks/${task}`)
|
||||||
|
.call(gulp, gulp, config, args)(done)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
@ -269,22 +272,37 @@ gulp.task("mkdocs:serve",
|
|||||||
load("mkdocs/serve"))
|
load("mkdocs/serve"))
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* Tests
|
* Visual tests
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generate visual tests
|
||||||
|
*/
|
||||||
|
gulp.task("tests:visual:generate", (args.clean ? [
|
||||||
|
// "assets:build", // TODO: only commented out for dev
|
||||||
|
// "views:build",
|
||||||
|
"tests:visual:clean"
|
||||||
|
] : []),
|
||||||
|
load("tests/visual/generate"))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Run visual tests
|
* Run visual tests
|
||||||
*/
|
*/
|
||||||
gulp.task("tests:visual:run", [
|
gulp.task("tests:visual:run", [
|
||||||
// "assets:build",
|
"tests:visual:generate"
|
||||||
// "views:build"
|
|
||||||
], load("tests/visual/run"))
|
], load("tests/visual/run"))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start karma test runner
|
* Update reference images for visual tests
|
||||||
*/
|
*/
|
||||||
gulp.task("tests:unit:watch",
|
gulp.task("tests:visual:update",
|
||||||
() => {})
|
load("tests/visual/update"))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clean files generated by visual tests
|
||||||
|
*/
|
||||||
|
gulp.task("tests:visual:clean",
|
||||||
|
load("tests/visual/clean"))
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* Interface
|
* Interface
|
||||||
|
50
lib/servers/ecstatic.js
Normal file
50
lib/servers/ecstatic.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import ecstatic from "ecstatic"
|
||||||
|
import * as http from "http"
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Locals
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* Static file server */
|
||||||
|
let server = null
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Functions
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
export const start = (directory, port, done) => {
|
||||||
|
server = http.createServer(ecstatic({
|
||||||
|
root: directory
|
||||||
|
}))
|
||||||
|
|
||||||
|
/* Listen and register signal handlers */
|
||||||
|
server.listen(port, "127.0.0.1", done)
|
||||||
|
for (const signal of ["SIGTERM", "SIGINT", "exit"])
|
||||||
|
process.on(signal, stop)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const stop = done => {
|
||||||
|
server.close(done)
|
||||||
|
}
|
@ -35,15 +35,24 @@ let server = null
|
|||||||
|
|
||||||
export const start = done => {
|
export const start = done => {
|
||||||
selenium.start({}, (err, proc) => {
|
selenium.start({}, (err, proc) => {
|
||||||
|
|
||||||
|
/* Register signal handlers */
|
||||||
|
for (const signal of ["SIGTERM", "SIGINT", "exit"])
|
||||||
|
process.on(signal, stop)
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
||||||
/* Install selenium, if not present */
|
/* Install selenium, if not present */
|
||||||
if (/^Missing(.*)chromedriver$/.test(err.message)) {
|
if (/^Missing(.*)chromedriver$/.test(err.message)) {
|
||||||
selenium.install(done)
|
new Promise(resolve => {
|
||||||
|
selenium.install({}, resolve)
|
||||||
|
})
|
||||||
|
|
||||||
/* Start selenium again */
|
/* Start selenium again */
|
||||||
|
.then(() => {
|
||||||
selenium.start({}, (err_, proc_) => {
|
selenium.start({}, (err_, proc_) => {
|
||||||
server = proc_
|
server = proc_
|
||||||
|
done()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
/* Otherwise, throw error */
|
/* Otherwise, throw error */
|
||||||
@ -53,19 +62,18 @@ export const start = done => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Remember process handle */
|
/* Remember process handle */
|
||||||
server = server || proc
|
server = proc
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const stop = () => {
|
export const stop = done => {
|
||||||
if (server)
|
if (server) {
|
||||||
|
if (typeof done === "function")
|
||||||
|
server.on("exit", done)
|
||||||
server.kill()
|
server.kill()
|
||||||
|
|
||||||
|
/* Unset, so we don't try to kill the server twice */
|
||||||
|
server = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
* Signals
|
|
||||||
* ------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
for (const signal of ["SIGTERM", "SIGINT", "exit"])
|
|
||||||
process.on(signal, stop)
|
|
||||||
|
38
lib/tasks/tests/visual/clean.js
Normal file
38
lib/tasks/tests/visual/clean.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import clean from "del"
|
||||||
|
import vinyl from "vinyl-paths"
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Task: clean files generated by visual tests
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
export default (gulp, config) => {
|
||||||
|
return () => {
|
||||||
|
return gulp.src([
|
||||||
|
`${config.tests.visual}/data`,
|
||||||
|
"./gemini-report"
|
||||||
|
])
|
||||||
|
.pipe(vinyl(clean))
|
||||||
|
}
|
||||||
|
}
|
63
lib/tasks/tests/visual/generate.js
Normal file
63
lib/tasks/tests/visual/generate.js
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import child from "child_process"
|
||||||
|
import path from "path"
|
||||||
|
import through from "through2"
|
||||||
|
import util from "gulp-util"
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Task: generate visual tests
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
export default (gulp, config) => {
|
||||||
|
const theme = path.resolve(process.cwd(), config.views.build)
|
||||||
|
return () => {
|
||||||
|
return gulp.src(`${config.tests.visual}/suites/**/mkdocs.yml`)
|
||||||
|
.pipe(
|
||||||
|
through.obj(function(file, enc, done) {
|
||||||
|
if (file.isNull() || file.isStream())
|
||||||
|
return done()
|
||||||
|
|
||||||
|
/* Resolve test name and destination */
|
||||||
|
const name = path.relative(`${config.tests.visual}/suites`,
|
||||||
|
path.dirname(file.path))
|
||||||
|
const site = path.resolve(process.cwd(),
|
||||||
|
`${config.tests.visual}/data`, name, "_")
|
||||||
|
|
||||||
|
/* Generate test fixtures with freshly built theme */
|
||||||
|
const proc = child.spawnSync("mkdocs", [
|
||||||
|
"build", "--site-dir", site, "--theme-dir", theme
|
||||||
|
], {
|
||||||
|
cwd: path.dirname(file.path)
|
||||||
|
})
|
||||||
|
|
||||||
|
/* Emit error, if any */
|
||||||
|
if (proc.status)
|
||||||
|
this.emit("error", new util.PluginError("mkdocs",
|
||||||
|
`Terminated with errors: ${proc.stderr.toString()}`))
|
||||||
|
|
||||||
|
/* Terminate */
|
||||||
|
done()
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
@ -20,62 +20,91 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import child from "child_process"
|
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
import * as ecstatic from "~/lib/servers/ecstatic"
|
||||||
import * as selenium from "~/lib/servers/selenium"
|
import * as selenium from "~/lib/servers/selenium"
|
||||||
|
|
||||||
import Gemini from "gemini"
|
import Gemini from "gemini"
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* Task: start test runner
|
* Test runner: Selenium
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* MkDocs server */
|
class SeleniumTestRunner {
|
||||||
let server = null
|
|
||||||
|
/**
|
||||||
|
* Start Selenium
|
||||||
|
*
|
||||||
|
* @param {Function} done - Resolve callback
|
||||||
|
*/
|
||||||
|
start(done) {
|
||||||
|
selenium.start(done)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop Selenium
|
||||||
|
*
|
||||||
|
* @param {Function} done - Resolve callback
|
||||||
|
*/
|
||||||
|
stop(done) {
|
||||||
|
selenium.stop(done)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* Task: start test runner
|
* Task: run visual tests
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
export default (gulp, config) => {
|
export default (gulp, config, args) => {
|
||||||
return () => {
|
return done => {
|
||||||
|
|
||||||
/* Start MkDocs server */
|
/* Start static file server */
|
||||||
return new Promise(resolve => {
|
new Promise(resolve => {
|
||||||
server = child.spawn("mkdocs", [
|
ecstatic.start(`${config.tests.visual}/data`, 8000, resolve)
|
||||||
"serve", "--dev-addr", "127.0.0.1:8000"
|
|
||||||
], {
|
|
||||||
cwd: config.tests.visual,
|
|
||||||
stdio: [process.stdin, process.stdout, "pipe"]
|
|
||||||
})
|
|
||||||
|
|
||||||
/* Wait for MkDocs server and resolve promise */
|
/* Create and start test runner */
|
||||||
server.stderr.on("data", data => {
|
|
||||||
if (data.toString().match("Serving")) {
|
|
||||||
server.stderr.removeAllListeners("data")
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
/* Start Selenium */
|
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
selenium.start(() => resolve())
|
const runner = new SeleniumTestRunner()
|
||||||
|
runner.start(err => {
|
||||||
/* Start Gemini test runner depending on environment */
|
return err ? reject(err) : resolve(runner)
|
||||||
}).then(() => {
|
|
||||||
const gemini = require(path.join(
|
|
||||||
process.cwd(), `${config.tests.visual}/.gemini-local.json`))
|
|
||||||
return new Gemini(gemini).test("tests/visual/suites", {
|
|
||||||
reporters: ["html"]
|
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/* Setup and run Gemini */
|
||||||
|
.then(runner => {
|
||||||
|
const gemini = require(
|
||||||
|
path.join(process.cwd(), `${config.tests.visual}/config`,
|
||||||
|
process.env.CI || process.env.SAUCE
|
||||||
|
? "gemini-sauce.json"
|
||||||
|
: "gemini-local.json"))
|
||||||
|
|
||||||
|
/* Start Gemini and return runner upon finish */
|
||||||
|
return new Gemini(gemini).test(`${config.tests.visual}/suites`, {
|
||||||
|
reporters: [process.env.CI ? "flat" : "html"],
|
||||||
|
grep: args.grep ? new RegExp(args.grep, "i") : null,
|
||||||
|
browsers: args.browsers ? [].concat(args.browsers) : null
|
||||||
|
})
|
||||||
|
|
||||||
|
/* Return runner for graceful stop */
|
||||||
|
.then(() => {
|
||||||
|
return runner
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/* Stop test runner */
|
||||||
|
.then(runner => {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
runner.stop(resolve)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/* Stop static file server */
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
selenium.stop()
|
ecstatic.stop(done)
|
||||||
})
|
}, err => {
|
||||||
})
|
return done(err)
|
||||||
.then(() => {
|
|
||||||
server.kill()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
72
lib/tasks/tests/visual/update.js
Normal file
72
lib/tasks/tests/visual/update.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import fs from "fs"
|
||||||
|
import path from "path"
|
||||||
|
import through from "through2"
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Task: update reference images for visual tests
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
export default (gulp, config) => {
|
||||||
|
return () => {
|
||||||
|
const base = path.join(
|
||||||
|
process.cwd(), `${config.tests.visual}/config`)
|
||||||
|
|
||||||
|
/* Read Gemini configs and map browsers to screenshot directories */
|
||||||
|
const mapping = fs.readdirSync(base)
|
||||||
|
.reduce((result, filename) => {
|
||||||
|
return Object.assign(result, (gemini => {
|
||||||
|
return Object.keys(gemini.browsers)
|
||||||
|
.reduce((browsers, name) => {
|
||||||
|
browsers[name] = gemini.screenshotsDir
|
||||||
|
return browsers
|
||||||
|
}, {})
|
||||||
|
})(require(path.join(base, filename))))
|
||||||
|
}, {})
|
||||||
|
|
||||||
|
/* Prepare filenames */
|
||||||
|
const dest = path.join(process.cwd(), `${config.tests.visual}/baseline`)
|
||||||
|
return gulp.src("gemini-report/images/**/*~current.png")
|
||||||
|
.pipe(
|
||||||
|
through.obj(function(file, enc, done) {
|
||||||
|
if (file.isNull() || file.isStream())
|
||||||
|
return done()
|
||||||
|
|
||||||
|
/* Remove the state from the filename */
|
||||||
|
file.path = file.path.replace("~current", "")
|
||||||
|
|
||||||
|
/* Retrieve the folder for the environment of the baseline */
|
||||||
|
const folder = path.relative(dest,
|
||||||
|
mapping[path.basename(file.path, ".png")])
|
||||||
|
file.path = file.path.replace("images", `images/${folder}`)
|
||||||
|
|
||||||
|
/* Push file to next stage */
|
||||||
|
this.push(file)
|
||||||
|
done()
|
||||||
|
}))
|
||||||
|
|
||||||
|
/* Update reference images */
|
||||||
|
.pipe(gulp.dest(dest))
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
@ -45,7 +45,7 @@
|
|||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block styles %}
|
{% block styles %}
|
||||||
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-bc099a55ca.css">
|
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-e21055ee85.css">
|
||||||
{% if config.extra.palette %}
|
{% if config.extra.palette %}
|
||||||
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-02ce7adcc2.palette.css">
|
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-02ce7adcc2.palette.css">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
"clean": "scripts/clean",
|
"clean": "scripts/clean",
|
||||||
"lint": "scripts/lint",
|
"lint": "scripts/lint",
|
||||||
"start": "scripts/start",
|
"start": "scripts/start",
|
||||||
"test": "scripts/test"
|
"test:visual:run": "scripts/test/visual/run",
|
||||||
|
"test:visual:update": "scripts/test/visual/update"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -45,6 +46,7 @@
|
|||||||
"css-mqpacker": "^5.0.1",
|
"css-mqpacker": "^5.0.1",
|
||||||
"custom-event-polyfill": "^0.3.0",
|
"custom-event-polyfill": "^0.3.0",
|
||||||
"del": "^2.2.2",
|
"del": "^2.2.2",
|
||||||
|
"ecstatic": "^2.1.0",
|
||||||
"eslint": "^3.14.0",
|
"eslint": "^3.14.0",
|
||||||
"eslint-plugin-mocha": "^4.8.0",
|
"eslint-plugin-mocha": "^4.8.0",
|
||||||
"fastclick": "^1.0.6",
|
"fastclick": "^1.0.6",
|
||||||
|
@ -28,4 +28,4 @@ if [[ ! -d `npm bin` ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run command
|
# Run command
|
||||||
`npm bin`/gulp build --clean --optimize --revision
|
`npm bin`/gulp build --clean --optimize --revision $@
|
||||||
|
@ -28,4 +28,4 @@ if [[ ! -d `npm bin` ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run command
|
# Run command
|
||||||
`npm bin`/gulp clean
|
`npm bin`/gulp clean $@
|
||||||
|
@ -28,4 +28,4 @@ if [[ ! -d `npm bin` ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run command
|
# Run command
|
||||||
`npm bin`/gulp watch --no-lint
|
`npm bin`/gulp watch --no-lint $@
|
||||||
|
31
scripts/test/visual/run
Executable file
31
scripts/test/visual/run
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||||
|
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to
|
||||||
|
# deal in the Software without restriction, including without limitation the
|
||||||
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
# sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
# IN THE SOFTWARE.
|
||||||
|
|
||||||
|
# Check if "npm install" was executed
|
||||||
|
if [[ ! -d `npm bin` ]]; then
|
||||||
|
echo "\"node_modules\" not found:"
|
||||||
|
echo "npm install"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run command
|
||||||
|
`npm bin`/gulp tests:visual:run --clean --optimize --revision $@
|
@ -28,4 +28,4 @@ if [[ ! -d `npm bin` ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run command
|
# Run command
|
||||||
`npm bin`/gulp test
|
`npm bin`/gulp tests:visual:update $@
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"rootUrl": "http://localhost:8000",
|
"rootUrl": "http://localhost:8000",
|
||||||
"screenshotsDir": "./tests/visual/baseline",
|
"screenshotsDir": "./tests/visual/baseline/local",
|
||||||
"browsers": {
|
"browsers": {
|
||||||
"local-chrome": {
|
"local-chrome": {
|
||||||
"desiredCapabilities": {
|
"desiredCapabilities": {
|
||||||
@ -10,6 +10,6 @@
|
|||||||
},
|
},
|
||||||
"system": {
|
"system": {
|
||||||
"projectRoot": "./",
|
"projectRoot": "./",
|
||||||
"sourceRoot": "src/assets/stylesheets"
|
"sourceRoot": "./src/assets/stylesheets"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,75 +0,0 @@
|
|||||||
# Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
|
||||||
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to
|
|
||||||
# deal in the Software without restriction, including without limitation the
|
|
||||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
||||||
# sell copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
||||||
# IN THE SOFTWARE.
|
|
||||||
|
|
||||||
# Project information
|
|
||||||
site_name: Material for MkDocs Tests
|
|
||||||
site_description: A Material Design theme for MkDocs
|
|
||||||
site_author: Martin Donath
|
|
||||||
site_url: http://squidfunk.github.io/mkdocs-material/
|
|
||||||
|
|
||||||
# Repository
|
|
||||||
repo_name: squidfunk/mkdocs-material
|
|
||||||
repo_url: https://github.com/squidfunk/mkdocs-material
|
|
||||||
|
|
||||||
# Copyright
|
|
||||||
copyright: 'Copyright © 2016 Martin Donath'
|
|
||||||
|
|
||||||
# Documentation and theme directories
|
|
||||||
docs_dir: fixtures
|
|
||||||
theme_dir: ../../material
|
|
||||||
|
|
||||||
# Options
|
|
||||||
extra:
|
|
||||||
palette:
|
|
||||||
primary: indigo
|
|
||||||
accent: indigo
|
|
||||||
social:
|
|
||||||
- type: github-alt
|
|
||||||
link: https://github.com/squidfunk
|
|
||||||
- type: twitter
|
|
||||||
link: https://twitter.com/squidfunk
|
|
||||||
- type: linkedin
|
|
||||||
link: https://de.linkedin.com/in/martin-donath-20a95039
|
|
||||||
|
|
||||||
# Extensions
|
|
||||||
markdown_extensions:
|
|
||||||
- markdown.extensions.admonition
|
|
||||||
- markdown.extensions.codehilite(guess_lang=false)
|
|
||||||
- markdown.extensions.footnotes
|
|
||||||
- markdown.extensions.meta
|
|
||||||
- markdown.extensions.toc(permalink=true)
|
|
||||||
- pymdownx.arithmatex
|
|
||||||
- pymdownx.betterem(smart_enable=all)
|
|
||||||
- pymdownx.caret
|
|
||||||
- pymdownx.critic
|
|
||||||
- pymdownx.emoji:
|
|
||||||
emoji_generator: !!python/name:pymdownx.emoji.to_svg
|
|
||||||
- pymdownx.inlinehilite
|
|
||||||
- pymdownx.magiclink
|
|
||||||
- pymdownx.mark
|
|
||||||
- pymdownx.smartsymbols
|
|
||||||
- pymdownx.superfences
|
|
||||||
- pymdownx.tasklist(custom_checkbox=true)
|
|
||||||
- pymdownx.tilde
|
|
||||||
|
|
||||||
# Page tree
|
|
||||||
pages:
|
|
||||||
- Extensions:
|
|
||||||
- Admonition: extensions/admonition.md
|
|
107
tests/visual/suites/extensions/admonition/docs/index.md
Normal file
107
tests/visual/suites/extensions/admonition/docs/index.md
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
# Admonition Tests
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.md-header {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
## Default
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
||||||
|
|
||||||
|
## Format
|
||||||
|
|
||||||
|
### Custom title
|
||||||
|
|
||||||
|
!!! note "Phasellus posuere in sem ut cursus"
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
||||||
|
|
||||||
|
### Long title
|
||||||
|
|
||||||
|
!!! note "Phasellus posuere in sem ut cursus. Nullam sit amet tincidunt ipsum, sit amet elementum turpis. Etiam ipsum quam, mattis in purus vitae, lacinia fermentum enim."
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
||||||
|
|
||||||
|
### Empty title
|
||||||
|
|
||||||
|
!!! note ""
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
||||||
|
|
||||||
|
## Types
|
||||||
|
|
||||||
|
### Note
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
!!! summary
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
||||||
|
|
||||||
|
### Tip
|
||||||
|
|
||||||
|
!!! tip
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
||||||
|
|
||||||
|
### Success
|
||||||
|
|
||||||
|
!!! success
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
||||||
|
|
||||||
|
### Warning
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
||||||
|
|
||||||
|
### Failure
|
||||||
|
|
||||||
|
!!! failure
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
||||||
|
|
||||||
|
### Danger
|
||||||
|
|
||||||
|
!!! danger
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
||||||
|
|
||||||
|
### Bug
|
||||||
|
|
||||||
|
!!! bug
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||||
|
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||||
|
massa, nec semper lorem quam in massa.
|
24
tests/visual/suites/extensions/admonition/mkdocs.yml
Normal file
24
tests/visual/suites/extensions/admonition/mkdocs.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||||
|
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to
|
||||||
|
# deal in the Software without restriction, including without limitation the
|
||||||
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
# sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
# IN THE SOFTWARE.
|
||||||
|
|
||||||
|
# Test suite
|
||||||
|
site_name: Admonition Test
|
||||||
|
markdown_extensions:
|
||||||
|
- markdown.extensions.admonition
|
@ -20,7 +20,7 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import generate from "../../generate.js"
|
import generate from "../../../generate.js"
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* Tests
|
* Tests
|
||||||
@ -34,8 +34,8 @@ generate({
|
|||||||
* The admonition block looks the same on everything above tablet
|
* The admonition block looks the same on everything above tablet
|
||||||
* portrait, so we can save a few test cases.
|
* portrait, so we can save a few test cases.
|
||||||
*/
|
*/
|
||||||
".admonition": {
|
"admonition": {
|
||||||
"url": "/extensions/admonition",
|
"url": "/extensions/admonition/_",
|
||||||
"capture": "#default + .admonition",
|
"capture": "#default + .admonition",
|
||||||
"break": "-@tablet-portrait",
|
"break": "-@tablet-portrait",
|
||||||
"suite": {
|
"suite": {
|
Loading…
Reference in New Issue
Block a user