This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Make
cmd+s
work for all save-buttons (#700)
closes TryGhost/Ghost#8443 - Fixes a bug where the keyboard shortcut `cmd+s` would cause a `Maximum call stack size` error and not save. - Wherever there is a `save` button, the keyboard shortcut to save works now.
- Loading branch information
1 parent
ef9381b
commit 371b9fd
Showing
17 changed files
with
229 additions
and
18 deletions.
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
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
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
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
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,98 @@ | ||
/* jshint expr:true */ | ||
import { | ||
describe, | ||
it, | ||
beforeEach, | ||
afterEach | ||
} from 'mocha'; | ||
import {expect} from 'chai'; | ||
import startApp from '../../helpers/start-app'; | ||
import destroyApp from '../../helpers/destroy-app'; | ||
import {invalidateSession, authenticateSession} from 'ghost-admin/tests/helpers/ember-simple-auth'; | ||
import testSelector from 'ember-test-selectors'; | ||
import ctrlOrCmd from 'ghost-admin/utils/ctrl-or-cmd'; | ||
|
||
describe('Acceptance: Settings - Apps - AMP', function () { | ||
let application; | ||
|
||
beforeEach(function() { | ||
application = startApp(); | ||
}); | ||
|
||
afterEach(function() { | ||
destroyApp(application); | ||
}); | ||
|
||
it('redirects to signin when not authenticated', async function () { | ||
invalidateSession(application); | ||
await visit('/settings/apps/amp'); | ||
|
||
expect(currentURL(), 'currentURL').to.equal('/signin'); | ||
}); | ||
|
||
it('redirects to team page when authenticated as author', async function () { | ||
let role = server.create('role', {name: 'Author'}); | ||
server.create('user', {roles: [role], slug: 'test-user'}); | ||
|
||
authenticateSession(application); | ||
await visit('/settings/apps/amp'); | ||
|
||
expect(currentURL(), 'currentURL').to.equal('/team/test-user'); | ||
}); | ||
|
||
it('redirects to team page when authenticated as editor', async function () { | ||
let role = server.create('role', {name: 'Editor'}); | ||
server.create('user', {roles: [role], slug: 'test-user'}); | ||
|
||
authenticateSession(application); | ||
await visit('/settings/apps/amp'); | ||
|
||
expect(currentURL(), 'currentURL').to.equal('/team'); | ||
}); | ||
|
||
describe('when logged in', function () { | ||
beforeEach(function () { | ||
let role = server.create('role', {name: 'Administrator'}); | ||
server.create('user', {roles: [role]}); | ||
|
||
return authenticateSession(application); | ||
}); | ||
|
||
it('it enables or disables AMP properly and saves it', async function () { | ||
await visit('/settings/apps/amp'); | ||
|
||
// has correct url | ||
expect(currentURL(), 'currentURL').to.equal('/settings/apps/amp'); | ||
|
||
// AMP is enabled by default | ||
expect(find(testSelector('amp-checkbox')).prop('checked'), 'AMP checkbox').to.be.true; | ||
|
||
await click(testSelector('amp-checkbox')); | ||
|
||
expect(find(testSelector('amp-checkbox')).prop('checked'), 'AMP checkbox').to.be.false; | ||
|
||
await click(testSelector('save-button')); | ||
|
||
let [lastRequest] = server.pretender.handledRequests.slice(-1); | ||
let params = JSON.parse(lastRequest.requestBody); | ||
|
||
expect(params.settings.findBy('key', 'amp').value).to.equal(false); | ||
|
||
// CMD-S shortcut works | ||
await click(testSelector('amp-checkbox')); | ||
await triggerEvent('.gh-app', 'keydown', { | ||
keyCode: 83, // s | ||
metaKey: ctrlOrCmd === 'command', | ||
ctrlKey: ctrlOrCmd === 'ctrl' | ||
}); | ||
|
||
// we've already saved in this test so there's no on-screen indication | ||
// that we've had another save, check the request was fired instead | ||
let [newRequest] = server.pretender.handledRequests.slice(-1); | ||
params = JSON.parse(newRequest.requestBody); | ||
|
||
expect(find(testSelector('amp-checkbox')).prop('checked'), 'AMP checkbox').to.be.true; | ||
expect(params.settings.findBy('key', 'amp').value).to.equal(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
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
Oops, something went wrong.