generate URLs for all demos and use those to run the tests

This commit is contained in:
Hans Pagel
2021-01-26 00:35:36 +01:00
parent 26fb84fe27
commit 5c93c6e560
54 changed files with 157 additions and 101 deletions

View File

@@ -57,6 +57,35 @@ module.exports = function (api) {
})
api.loadSource(({ addCollection }) => {
/**
* Generate pages for all demo components for testing purposes
*/
globby.sync('./src/demos/**/index.vue').forEach(file => {
const match = file.match(
new RegExp(/\.\/src\/demos\/([\S]+)\/index.vue/i),
)
if (!match) {
return
}
api.createPages(({ createPage }) => {
createPage({
// name: '/demos/Extensions/CharacterCount'
path: `/demos/${match[1]}`,
component: './src/templates/DemoPage/index.vue',
context: {
// name: 'Extensions/CharacterCount'
name: match[1],
},
})
})
})
/**
* Read out all packages?
*/
const appCollection = addCollection({ typeName: 'Package' })
// packages.forEach(package => {

View File

@@ -1,6 +1,6 @@
context('/examples/default', () => {
context('/demos/Examples/Book', () => {
before(() => {
cy.visit('/examples/default')
cy.visit('/demos/Examples/Book')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/examples/collaborative-editing', () => {
context('/demos/Examples/CollaborativeEditing', () => {
before(() => {
cy.visit('/examples/collaborative-editing')
cy.visit('/demos/Examples/CollaborativeEditing')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/examples/default', () => {
context('/demos/Examples/Default', () => {
before(() => {
cy.visit('/examples/default')
cy.visit('/demos/Examples/Default')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/examples/formatting', () => {
context('/demos/Examples/Formatting', () => {
before(() => {
cy.visit('/examples/formatting')
cy.visit('/demos/Examples/Formatting')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/examples/markdown-shortcuts', () => {
context('/demos/Examples/MarkdownShortcuts', () => {
before(() => {
cy.visit('/examples/markdown-shortcuts')
cy.visit('/demos/Examples/MarkdownShortcuts')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/examples/minimalistic', () => {
context('/demos/Examples/Minimalistic', () => {
before(() => {
cy.visit('/examples/minimalistic')
cy.visit('/demos/Examples/Minimalistic')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/examples/multiple-editors', () => {
context('/demos/Examples/MultipleEditors', () => {
before(() => {
cy.visit('/examples/multiple-editors')
cy.visit('/demos/Examples/MultipleEditors')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/examples/todo-app', () => {
context('/demos/Examples/TodoApp', () => {
before(() => {
cy.visit('/examples/todo-app')
cy.visit('/demos/Examples/TodoApp')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/api/extensions/annotations', () => {
context('/demos/Extensions/Annotations', () => {
before(() => {
cy.visit('/api/extensions/annotations')
cy.visit('/demos/Extensions/Annotations')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/examples/annotations', () => {
context('/demos/Examples/Annotations', () => {
before(() => {
cy.visit('/examples/annotations')
cy.visit('/demos/Examples/Annotations')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/api/extensions/collaboration', () => {
context('/demos/Extensions/Collaboration', () => {
before(() => {
cy.visit('/api/extensions/collaboration')
cy.visit('/demos/Extensions/Collaboration')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/api/extensions/collaboration-cursor', () => {
context('/demos/Extensions/CollaborationCursor', () => {
before(() => {
cy.visit('/api/extensions/collaboration-cursor')
cy.visit('/demos/Extensions/CollaborationCursor')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/examples/dropcursor', () => {
context('/demos/Examples/Dropcursor', () => {
before(() => {
cy.visit('/examples/dropcursor')
cy.visit('/demos/Examples/Dropcursor')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/api/extensions/focus', () => {
context('/demos/Extensions/Focus', () => {
before(() => {
cy.visit('/api/extensions/focus')
cy.visit('/demos/Extensions/Focus')
})
it('should have class', () => {

View File

@@ -1,6 +1,6 @@
context('/api/extensions/font-family', () => {
context('/demos/Extensions/FontFamily', () => {
before(() => {
cy.visit('/api/extensions/font-family')
cy.visit('/demos/Extensions/FontFamily')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/examples/gapcursor', () => {
context('/demos/Examples/Gapcursor', () => {
before(() => {
cy.visit('/examples/gapcursor')
cy.visit('/demos/Examples/Gapcursor')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/api/extensions/history', () => {
context('/demos/Extensions/History', () => {
before(() => {
cy.visit('/api/extensions/history')
cy.visit('/demos/Extensions/History')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/extensions/text-align', () => {
context('/demos/Extensions/TextAlign', () => {
before(() => {
cy.visit('/api/extensions/text-align')
cy.visit('/demos/Extensions/TextAlign')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/extensions/typography', () => {
context('/demos/Extensions/Typography', () => {
before(() => {
cy.visit('/api/extensions/typography')
cy.visit('/demos/Extensions/Typography')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/examples/v-model', () => {
context('/demos/Examples/VModel', () => {
before(() => {
cy.visit('/examples/v-model')
cy.visit('/demos/Examples/VModel')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/guide/store-content', () => {
context('/demos/Guide/StoreContent/ExportHTML', () => {
before(() => {
cy.visit('/guide/store-content')
cy.visit('/demos/Guide/StoreContent/ExportHTML')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/guide/store-content', () => {
context('/demos/Guide/StoreContent/ExportJSON', () => {
before(() => {
cy.visit('/guide/store-content')
cy.visit('/demos/Guide/StoreContent/ExportJSON')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/guide/store-content', () => {
context('/demos/Guide/StoreContent/ReadOnly', () => {
beforeEach(() => {
cy.visit('/guide/store-content')
cy.visit('/demos/Guide/StoreContent/ReadOnly')
})
it.skip('should be read-only', () => {
@@ -13,7 +13,7 @@ context('/guide/store-content', () => {
})
})
it.skip('should be editable', () => {
it('should be editable', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
cy.get('#editable').check()

View File

@@ -1,6 +1,6 @@
context('/api/marks/bold', () => {
context('/demos/Marks/Bold', () => {
before(() => {
cy.visit('/api/marks/bold')
cy.visit('/demos/Marks/Bold')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/marks/code', () => {
context('/demos/Marks/Code', () => {
before(() => {
cy.visit('/api/marks/code')
cy.visit('/demos/Marks/Code')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/marks/highlight', () => {
context('/demos/Marks/Highlight', () => {
before(() => {
cy.visit('/api/marks/highlight')
cy.visit('/demos/Marks/Highlight')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/marks/italic', () => {
context('/demos/Marks/Italic', () => {
before(() => {
cy.visit('/api/marks/italic')
cy.visit('/demos/Marks/Italic')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/marks/link', () => {
context('/demos/Marks/Link', () => {
before(() => {
cy.visit('/api/marks/link')
cy.visit('/demos/Marks/Link')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/marks/strike', () => {
context('/demos/Marks/Strike', () => {
before(() => {
cy.visit('/api/marks/strike')
cy.visit('/demos/Marks/Strike')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/marks/text-style', () => {
context('/demos/Marks/TextStyle', () => {
before(() => {
cy.visit('/api/marks/text-style')
cy.visit('/demos/Marks/TextStyle')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/api/marks/underline', () => {
context('/demos/Marks/Underline', () => {
before(() => {
cy.visit('/api/marks/underline')
cy.visit('/demos/Marks/Underline')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/blockquote', () => {
context('/demos/Nodes/Blockquote', () => {
before(() => {
cy.visit('/api/nodes/blockquote')
cy.visit('/demos/Nodes/Blockquote')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/bullet-list', () => {
context('/demos/Nodes/BulletList', () => {
before(() => {
cy.visit('/api/nodes/bullet-list')
cy.visit('/demos/Nodes/BulletList')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/code-block', () => {
context('/demos/Nodes/CodeBlock', () => {
before(() => {
cy.visit('/api/nodes/code-block')
cy.visit('/demos/Nodes/CodeBlock')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/document', () => {
context('/demos/Nodes/Document', () => {
before(() => {
cy.visit('/api/nodes/document')
cy.visit('/demos/Nodes/Document')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/hard-break', () => {
context('/demos/Nodes/HardBreak', () => {
before(() => {
cy.visit('/api/nodes/hard-break')
cy.visit('/demos/Nodes/HardBreak')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/heading', () => {
context('/demos/Nodes/Heading', () => {
before(() => {
cy.visit('/api/nodes/heading')
cy.visit('/demos/Nodes/Heading')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/horizontal-rule', () => {
context('/demos/Nodes/HorizontalRule', () => {
before(() => {
cy.visit('/api/nodes/horizontal-rule')
cy.visit('/demos/Nodes/HorizontalRule')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/image', () => {
context('/demos/Nodes/Image', () => {
before(() => {
cy.visit('/api/nodes/image')
cy.visit('/demos/Nodes/Image')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/list-item', () => {
context('/demos/Nodes/ListItem', () => {
before(() => {
cy.visit('/api/nodes/list-item')
cy.visit('/demos/Nodes/ListItem')
})
beforeEach(() => {

View File

@@ -1,5 +1,7 @@
context('/api/nodes/mention', () => {
context('/demos/Nodes/Mention', () => {
before(() => {
cy.visit('/api/nodes/mention')
cy.visit('/demos/Nodes/Mention')
})
// TODO: Write tests
})

View File

@@ -1,6 +1,6 @@
context('/api/nodes/ordered-list', () => {
context('/demos/Nodes/OrderedList', () => {
before(() => {
cy.visit('/api/nodes/ordered-list')
cy.visit('/demos/Nodes/OrderedList')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/paragraph', () => {
context('/demos/Nodes/Paragraph', () => {
before(() => {
cy.visit('/api/nodes/paragraph')
cy.visit('/demos/Nodes/Paragraph')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/table', () => {
context('/demos/Nodes/Table', () => {
before(() => {
cy.visit('/api/nodes/table')
cy.visit('/demos/Nodes/Table')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/api/nodes/task-item', () => {
context('/demos/Nodes/TaskItem', () => {
before(() => {
cy.visit('/api/nodes/task-item')
cy.visit('/demos/Nodes/TaskItem')
})
// TODO: Write tests

View File

@@ -1,6 +1,6 @@
context('/api/nodes/task-list', () => {
context('/demos/Nodes/TaskList', () => {
before(() => {
cy.visit('/api/nodes/task-list')
cy.visit('/demos/Nodes/TaskList')
})
beforeEach(() => {

View File

@@ -1,6 +1,6 @@
context('/api/nodes/text', () => {
context('/demos/Nodes/Text', () => {
before(() => {
cy.visit('/api/nodes/text')
cy.visit('/demos/Nodes/Text')
})
beforeEach(() => {

View File

@@ -0,0 +1,23 @@
<template>
<div class="demo-page">
<demo :name="$context.name" :show-source="false" />
</div>
</template>
<script>
export default {
metaInfo() {
return {
title: this.$context.name,
meta: [
{
name: 'robots',
content: 'noindex',
},
],
}
},
}
</script>
<style lang="scss" src="./style.scss" scoped></style>

View File

@@ -0,0 +1,4 @@
.demo-page {
max-width: 40rem;
margin: 2rem auto;
}

View File

@@ -1,6 +1,6 @@
context('clearContent', () => {
before(() => {
cy.visit('/examples/default')
cy.visit('/demos/Examples/default')
})
it('returns true for the clearContent command', () => {

View File

@@ -1,6 +1,6 @@
context('insertHTML', () => {
before(() => {
cy.visit('/examples/default')
cy.visit('/demos/Examples/default')
})
it('returns true for the insertHTML command', () => {

View File

@@ -1,6 +1,6 @@
context('setContent', () => {
before(() => {
cy.visit('/examples/default')
cy.visit('/demos/Examples/default')
})
it('returns true for the setContent command', () => {

View File

@@ -1,7 +1,5 @@
{
"baseUrl": "http://localhost:3000",
"integrationFolder": "../",
"testFiles": "{docs,tests}/**/*.spec.{js,ts}",
"viewportWidth": 1280,
"viewportHeight": 1280
"testFiles": "{docs,tests}/**/*.spec.{js,ts}"
}