mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 17:32:15 +03:00
350e3d1481
closes https://github.com/TryGhost/Ghost/issues/8859, requires https://github.com/TryGhost/Ghost/pull/8895 - adds Unsplash app to app settings - enable/disable toggle - validation and testing of Unsplash App ID - Unsplash App ID field hidden if provided via Ghost config - adds `fetchPrivate` method to `config` service to pull config that requires authentication and updates authentication routines to fetch private config - adds Unsplash buttons to editor toolbar and `{{gh-image-uploader}}` - only present when Unsplash app is enabled - opens Unsplash image selector when clicked - `{{gh-image-uploader}}` has a new `allowUnsplash` attribute to control display of the unsplash button on a per-uploader basis - adds Unsplash image selector (`{{gh-unsplash}}`) - uses new `unsplash` service to handle API requests and maintain state - search - infinite scroll - zoom image - insert image - download image - adds `{{gh-scroll-trigger}}` that will fire an event when the component is rendered into or enters the visible screen area via scrolling - updates `ui` service - adds `isFullscreen` property and updates `gh-editor` so that it gets set/unset when toggling editor fullscreen mode - adds `hasSideNav` and `isSideNavHidden` properties - updates `media-queries` service so that it fires an event each time a breakpoint is entered/exited - removes the need for observers in certain circumstances
120 lines
5.4 KiB
JavaScript
120 lines
5.4 KiB
JavaScript
import hbs from 'htmlbars-inline-precompile';
|
|
import {describe, it} from 'mocha';
|
|
import {expect} from 'chai';
|
|
import {find} from 'ember-native-dom-helpers';
|
|
import {setupComponentTest} from 'ember-mocha';
|
|
|
|
describe('Integration: Component: gh-unsplash-photo', function() {
|
|
setupComponentTest('gh-unsplash-photo', {
|
|
integration: true
|
|
});
|
|
|
|
beforeEach(function() {
|
|
// NOTE: images.unsplash.com replaced with example.com to ensure we aren't
|
|
// loading lots of images during tests and we get an immediate 404
|
|
this.set('photo', {
|
|
'id': 'OYFHT4X5isg',
|
|
'created_at': '2017-08-09T00:20:42-04:00',
|
|
'updated_at': '2017-08-11T08:27:42-04:00',
|
|
'width': 5184,
|
|
'height': 3456,
|
|
'color': '#A8A99B',
|
|
'likes': 58,
|
|
'liked_by_user': false,
|
|
'description': null,
|
|
'user': {
|
|
'id': 'cEpP9pR9Q7E',
|
|
'updated_at': '2017-08-11T08:27:42-04:00',
|
|
'username': 'danotis',
|
|
'name': 'Dan Otis',
|
|
'first_name': 'Dan',
|
|
'last_name': 'Otis',
|
|
'twitter_username': 'danotis',
|
|
'portfolio_url': 'http://dan.exposure.co',
|
|
'bio': 'Senior Visual Designer at Huge ',
|
|
'location': 'San Jose, CA',
|
|
'total_likes': 0,
|
|
'total_photos': 8,
|
|
'total_collections': 0,
|
|
'profile_image': {
|
|
'small': 'https://example.com/profile-fb-1502251227-8fe7a0522137.jpg?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=32&w=32&s=37f67120fc464d7d920ff23c84963b38',
|
|
'medium': 'https://example.com/profile-fb-1502251227-8fe7a0522137.jpg?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=64&w=64&s=0a4f8a583caec826ac6b1ca80161fa43',
|
|
'large': 'https://example.com/profile-fb-1502251227-8fe7a0522137.jpg?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=128&w=128&s=b3aa4206e5d87f3eaa7bbe9180ebcd2b'
|
|
},
|
|
'links': {
|
|
'self': 'https://api.unsplash.com/users/danotis',
|
|
'html': 'https://unsplash.com/@danotis',
|
|
'photos': 'https://api.unsplash.com/users/danotis/photos',
|
|
'likes': 'https://api.unsplash.com/users/danotis/likes',
|
|
'portfolio': 'https://api.unsplash.com/users/danotis/portfolio',
|
|
'following': 'https://api.unsplash.com/users/danotis/following',
|
|
'followers': 'https://api.unsplash.com/users/danotis/followers'
|
|
}
|
|
},
|
|
'current_user_collections': [],
|
|
'urls': {
|
|
'raw': 'https://example.com/photo-1502252430442-aac78f397426',
|
|
'full': 'https://example.com/photo-1502252430442-aac78f397426?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&s=20f86c2f7bbb019122498a45d8260ee9',
|
|
'regular': 'https://example.com/photo-1502252430442-aac78f397426?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&s=181760db8b7a61fa60a35277d7eb434e',
|
|
'small': 'https://example.com/photo-1502252430442-aac78f397426?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&s=1e2265597b59e874a1a002b4c3fd961c',
|
|
'thumb': 'https://example.com/photo-1502252430442-aac78f397426?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&s=57c86b0692bea92a282b9ab0dbfdacf4'
|
|
},
|
|
'categories': [],
|
|
'links': {
|
|
'self': 'https://api.unsplash.com/photos/OYFHT4X5isg',
|
|
'html': 'https://unsplash.com/photos/OYFHT4X5isg',
|
|
'download': 'https://unsplash.com/photos/OYFHT4X5isg/download',
|
|
'download_location': 'https://api.unsplash.com/photos/OYFHT4X5isg/download'
|
|
},
|
|
'ratio': 0.6666666666666666
|
|
});
|
|
});
|
|
|
|
it('sets background-color style', function () {
|
|
this.render(hbs`{{gh-unsplash-photo photo=photo}}`);
|
|
|
|
expect(
|
|
find('[data-test-unsplash-photo-container]').attributes.style.value
|
|
).to.have.string('background-color: #A8A99B');
|
|
});
|
|
|
|
it('sets padding-bottom style', function () {
|
|
this.render(hbs`{{gh-unsplash-photo photo=photo}}`);
|
|
|
|
// don't check full padding-bottom value as it will likely vary across
|
|
// browsers
|
|
expect(
|
|
find('[data-test-unsplash-photo-container]').attributes.style.value
|
|
).to.have.string('padding-bottom: 66.66');
|
|
});
|
|
|
|
it('uses correct image size url', function () {
|
|
this.render(hbs`{{gh-unsplash-photo photo=photo}}`);
|
|
|
|
expect(
|
|
find('[data-test-unsplash-photo-image]').attributes.src.value
|
|
).to.have.string('&w=1200');
|
|
});
|
|
|
|
it('calculates image width/height', function () {
|
|
this.render(hbs`{{gh-unsplash-photo photo=photo}}`);
|
|
|
|
expect(
|
|
find('[data-test-unsplash-photo-image]').attributes.width.value
|
|
).to.equal('1200');
|
|
|
|
expect(
|
|
find('[data-test-unsplash-photo-image]').attributes.height.value
|
|
).to.equal('800');
|
|
});
|
|
|
|
it('triggers insert action');
|
|
it('triggers zoom action');
|
|
|
|
describe('zoomed', function () {
|
|
it('omits padding-bottom style');
|
|
it('triggers insert action');
|
|
it('triggers zoom action');
|
|
});
|
|
});
|