mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 04:43:12 +03:00
Merge pull request #3046 from ErisDS/issue-2988
Update shortcut for zen mode
This commit is contained in:
commit
c385ebc654
@ -21,12 +21,12 @@ var EditorRouteBase = Ember.Mixin.create(styleBody, ShortcutsRoute, loadingIndic
|
||||
this.get('controller.codemirror').shortcut(options.type);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
shortcuts: {
|
||||
//General Editor shortcuts
|
||||
'ctrl+s, command+s': 'save',
|
||||
'ctrl+alt+p': 'publish',
|
||||
'ctrl+alt+z': 'toggleZenMode',
|
||||
'alt+shift+z': 'toggleZenMode',
|
||||
//CodeMirror Markdown Shortcuts
|
||||
'ctrl+alt+u': {action: 'codeMirrorShortcut', options: {type: 'strike'}},
|
||||
'ctrl+alt+1': {action: 'codeMirrorShortcut', options: {type: 'h1'}},
|
||||
|
@ -61,17 +61,17 @@ casper.writeContentToCodeMirror = function (content) {
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
casper.waitForOpaque = function (classname, then, timeout) {
|
||||
timeout = timeout || casper.failOnTimeout(casper.test, 'waitForOpaque failed on ' + classname);
|
||||
casper.waitForOpacity = function (classname, opacity, then, timeout) {
|
||||
timeout = timeout || casper.failOnTimeout(casper.test, 'waitForOpacity failed on ' + classname + ' ' + opacity);
|
||||
casper.waitForSelector(classname).then(function () {
|
||||
casper.waitFor(function checkOpaque() {
|
||||
var value = this.evaluate(function (element) {
|
||||
var value = this.evaluate(function (element, opacity) {
|
||||
var target = document.querySelector(element);
|
||||
if (target === null) {
|
||||
return null;
|
||||
}
|
||||
return window.getComputedStyle(target).getPropertyValue('opacity') === '1';
|
||||
}, classname);
|
||||
return window.getComputedStyle(target).getPropertyValue('opacity') === opacity;
|
||||
}, classname, opacity);
|
||||
if (value !== true && value !== false) {
|
||||
casper.test.fail('Unable to find element: ' + classname);
|
||||
}
|
||||
@ -80,6 +80,15 @@ casper.waitForOpaque = function (classname, then, timeout) {
|
||||
});
|
||||
};
|
||||
|
||||
casper.waitForOpaque = function (classname, then, timeout) {
|
||||
casper.waitForOpacity(classname, '1', then, timeout);
|
||||
};
|
||||
|
||||
casper.waitForTransparent = function (classname, then, timeout) {
|
||||
casper.waitForOpacity(classname, '0', then, timeout);
|
||||
};
|
||||
|
||||
|
||||
// ### Then Open And Wait For Page Load
|
||||
// Always wait for the `#main` element as some indication that the ember app has loaded.
|
||||
casper.thenOpenAndWaitForPageLoad = function (screen, then, timeout) {
|
||||
@ -97,7 +106,7 @@ casper.thenOpenAndWaitForPageLoad = function (screen, then, timeout) {
|
||||
},
|
||||
'editor': {
|
||||
url: 'ghost/ember/editor/',
|
||||
selector: '#main-menu .editor.active'
|
||||
selector: '#entry-title'
|
||||
},
|
||||
'settings': {
|
||||
url: 'ghost/ember/settings/',
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Test the editor screen works as expected
|
||||
|
||||
/*globals casper, __utils__, url, testPost */
|
||||
CasperTest.emberBegin('Ghost editor functions correctly', 15, function suite(test) {
|
||||
CasperTest.emberBegin('Ghost editor functions correctly', 19, function suite(test) {
|
||||
casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() {
|
||||
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||
test.assertUrlMatch(/ghost\/ember\/editor\/$/, 'Landed on the correct URL');
|
||||
@ -85,6 +85,33 @@ CasperTest.emberBegin('Ghost editor functions correctly', 15, function suite(tes
|
||||
casper.waitForSelectorTextChange('.entry-word-count', function onSuccess() {
|
||||
test.assertSelectorHasText('.entry-word-count', '2 words', 'count of 2 produces plural "words".');
|
||||
});
|
||||
|
||||
// Part 5: Editor global shortcuts
|
||||
casper.then(function tryZenShortcut() {
|
||||
casper.sendKeys('#main', 'z', {modifiers: 'alt+shift'});
|
||||
});
|
||||
|
||||
casper.waitForSelector('.editor.zen', function then() {
|
||||
casper.waitForTransparent('#global-header', function then() {
|
||||
test.assert(true, 'header becomes transparent');
|
||||
});
|
||||
casper.waitForTransparent('#publish-bar', function then() {
|
||||
test.assert(true, 'publish bar becomes transparent');
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function tryZenShortcut() {
|
||||
casper.sendKeys('#main', 'z', {modifiers: 'alt+shift'});
|
||||
});
|
||||
|
||||
casper.waitWhileSelector('.editor.zen', function then() {
|
||||
casper.waitForOpaque('#global-header', function then() {
|
||||
test.assert(true, 'header becomes opaque');
|
||||
});
|
||||
casper.waitForOpaque('#publish-bar', function then() {
|
||||
test.assert(true, 'publish bar becomes opaque');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Expand markdown tests to cover more markdown, and keyboard shortcuts
|
||||
|
Loading…
Reference in New Issue
Block a user