-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic initialisation test for Editor.js #1410
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
cce5738
Initial commit
ranemihir 1dcefbd
Fixed test.html file
ranemihir ca0bb6b
Create editor instance in the test
ranemihir f4c65d5
Assert paragraph data in editor instance
ranemihir 4b46f9d
Moving cypress folder to test folder
ranemihir 1ab1eb1
Minor Fixes
ranemihir 73b75d3
Removed config test for now
ranemihir 8fcda10
Fixed example.html
ranemihir 23b8bb9
Fixed editor.js dist path
ranemihir df0bfea
Minor Fixes
ranemihir 234bc02
Stored Host in a const
ranemihir 01c5bf5
Add nodemon and Fix commands
ranemihir e655d4d
Add and configure cypress eslint plugin
ranemihir 9e2b71a
Updated Tests according to best practices
ranemihir 3117f9b
Minor FIxes
ranemihir 0f7237e
Minor FIxes
ranemihir 891bce9
Merge branch 'next' into pr/ranemihir/1410
neSpecc 7a6fb6b
adjust eslint and ts
neSpecc c947c2d
Update .eslintrc
neSpecc 9c9dc53
improve config
neSpecc 96087f3
debug tests
neSpecc aa9be1c
fix tests
neSpecc 9e8db53
Fix declarations
gohabereg b493bbc
descrease debounce
neSpecc 18d9921
rm timeout
neSpecc b8c65bc
Update CHANGELOG.md
neSpecc d203dae
Update CHANGELOG.md
neSpecc 27795c6
Merge branch 'next' into pr/ranemihir/1410
neSpecc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ node_modules/* | |
|
||
npm-debug.log | ||
yarn-error.log | ||
|
||
test/cypress/screenshots | ||
test/cypress/videos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"projectId": "tivr7e", | ||
"env": { | ||
}, | ||
"fixturesFolder": "test/cypress/fixtures", | ||
"integrationFolder": "test/cypress/tests", | ||
"pluginsFile": "test/cypress/plugins/index.ts", | ||
"screenshotsFolder": "test/cypress/screenshots", | ||
"videosFolder": "test/cypress/videos", | ||
"supportFile": "test/cypress/support/index.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"plugins": [ | ||
"cypress" | ||
], | ||
"env": { | ||
"cypress/globals": true | ||
}, | ||
"extends": [ | ||
"plugin:cypress/recommended" | ||
], | ||
"rules": { | ||
"cypress/require-data-selectors": 2 | ||
}, | ||
"globals": { | ||
"EditorJS": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<body> | ||
<!-- Load Editor.js's Core --> | ||
<script src="./../../../dist/editor.js"></script> | ||
<h1>Editor.js test page</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* This file contains connection of Cypres plugins | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
export default function(on, config): void {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* This file contains custom commands for Cypress. | ||
* Also it can override the existing commands. | ||
* | ||
* -------------------------------------------------- | ||
*/ | ||
|
||
import type { EditorConfig } from './../../../types/index'; | ||
import type EditorJS from '../../../types/index'; | ||
import Chainable = Cypress.Chainable; | ||
|
||
/** | ||
* Create a wrapper and initialize the new instance of editor.js | ||
* Then return the instance | ||
* | ||
* @param editorConfig - config to pass to the editor | ||
* @returns EditorJS - created instance | ||
*/ | ||
Cypress.Commands.add('createEditor', (editorConfig: EditorConfig = {}): Chainable<EditorJS> => { | ||
return cy.window() | ||
.then((window) => { | ||
return new Promise((resolve: (instance: EditorJS) => void) => { | ||
const editorContainer = window.document.createElement('div'); | ||
|
||
editorContainer.setAttribute('id', 'editorjs'); | ||
editorContainer.dataset.cy = 'editorjs'; | ||
editorContainer.style.border = '1px dotted #388AE5'; | ||
|
||
window.document.body.appendChild(editorContainer); | ||
|
||
const editorInstance: EditorJS = new window.EditorJS(editorConfig); | ||
|
||
editorInstance.isReady.then(() => { | ||
resolve(editorInstance); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// in cypress/support/index.d.ts | ||
// load type definitions that come with Cypress module | ||
/// <reference types="cypress" /> | ||
|
||
import type { EditorConfig } from './../../../types/index'; | ||
import type EditorJS from '../../../types/index' | ||
|
||
declare global { | ||
namespace Cypress { | ||
interface Chainable<Subject = any> { | ||
/** | ||
* Custom command to select DOM element by data-cy attribute. | ||
* @param editorConfig - config to pass to the editor | ||
* @example cy.createEditor({}) | ||
*/ | ||
createEditor(editorConfig: EditorConfig): Chainable<EditorJS> | ||
} | ||
|
||
interface ApplicationWindow { | ||
EditorJS: typeof EditorJS | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* This file is processed and | ||
* loaded automatically before the test files. | ||
* | ||
* This is a great place to put global configuration and | ||
* behavior that modifies Cypress. | ||
*/ | ||
|
||
/** | ||
* File with the helpful commands | ||
*/ | ||
import './commands'; | ||
|
||
/** | ||
* Before-each hook for the cypress tests | ||
*/ | ||
beforeEach((): void => { | ||
cy.visit('test/cypress/fixtures/test.html'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// eslint-disable-next-line spaced-comment | ||
/// <reference path="../support/index.d.ts" /> | ||
|
||
describe('Editor basic initialization', () => { | ||
describe('Zero-config initialization', () => { | ||
/** | ||
* In this test suite we use zero (omitted) configuration | ||
*/ | ||
const editorConfig = {}; | ||
|
||
beforeEach(() => { | ||
if (this.editorInstance) { | ||
this.editorInstance.destroy(); | ||
} else { | ||
cy.createEditor(editorConfig).as('editorInstance'); | ||
} | ||
}); | ||
|
||
it('should create a visible UI', () => { | ||
cy.window().then((window) => { | ||
/** | ||
* Assert if created instance is visible or not. | ||
*/ | ||
cy.get('[data-cy=editorjs]') | ||
.get('div.codex-editor') | ||
.should('be.visible'); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2017", | ||
"lib": ["es2017", "dom"], | ||
"types": ["cypress"] | ||
}, | ||
"include": [ | ||
"**/*.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cypress open: Open cypress GUI window.
cypress run: Run cypress test in CUI.