mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 22:01:49 +03:00
1cade0bc08
no issue - Unsplash integration is enabled by default for all users - it's no longer necessary to create your own Unsplash application and configure your application ID
97 lines
3.3 KiB
JavaScript
97 lines
3.3 KiB
JavaScript
/* jshint expr:true */
|
|
import ctrlOrCmd from 'ghost-admin/utils/ctrl-or-cmd';
|
|
import destroyApp from '../../helpers/destroy-app';
|
|
import startApp from '../../helpers/start-app';
|
|
import {afterEach, beforeEach, describe, it} from 'mocha';
|
|
import {authenticateSession, invalidateSession} from 'ghost-admin/tests/helpers/ember-simple-auth';
|
|
import {expect} from 'chai';
|
|
|
|
describe('Acceptance: Settings - Apps - Unsplash', 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/unsplash');
|
|
|
|
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/unsplash');
|
|
|
|
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/unsplash');
|
|
|
|
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 can activate/deactivate', async function () {
|
|
await visit('/settings/apps/unsplash');
|
|
|
|
// has correct url
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/apps/unsplash');
|
|
|
|
// verify we don't have an unsplash setting fixture loaded
|
|
expect(
|
|
server.db.settings.where({key: 'unsplash'}),
|
|
'initial server settings'
|
|
).to.be.empty;
|
|
|
|
// it's enabled by default when settings is empty
|
|
expect(
|
|
find('[data-test-checkbox="unsplash"]').prop('checked'),
|
|
'checked by default'
|
|
).to.be.true;
|
|
|
|
// trigger a save
|
|
await click('[data-test-save-button]');
|
|
|
|
// server should now have an unsplash setting
|
|
let [setting] = server.db.settings.where({key: 'unsplash'});
|
|
expect(setting, 'unsplash setting after save').to.exist;
|
|
expect(setting.value).to.equal('{"isActive":true}');
|
|
|
|
// disable
|
|
await click(find('[data-test-checkbox="unsplash"]'));
|
|
|
|
// save via CMD-S shortcut
|
|
await triggerEvent('.gh-app', 'keydown', {
|
|
keyCode: 83, // s
|
|
metaKey: ctrlOrCmd === 'command',
|
|
ctrlKey: ctrlOrCmd === 'ctrl'
|
|
});
|
|
|
|
// server should have an updated setting
|
|
[setting] = server.db.settings.where({key: 'unsplash'});
|
|
expect(setting.value).to.equal('{"isActive":false}');
|
|
});
|
|
});
|
|
});
|