mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
52089705d7
issue #5841 - fix relative link checks in navlink url input component - fix navlink url input component sending absolute URLs instead of relative URLs to action handler - remove URL manipulation in navigation settings controller (url input handles URL manipulation, validator flags anything that's still incorrect) - capture cmd-s in url input to ensure changes are actioned before save - automatically add mailto: to e-mail addresses - add gh-validation-state-container component so .error/.success validation classes can be applied to any container element - add validation-state mixin that can be mixed in to any other component to give it access to validation status (used in gh-navitem component to keep alignment when inline error message elements are added) - validate and display inline errors on save - improve ember test coverage for navigation settings related controller and components
71 lines
2.7 KiB
JavaScript
71 lines
2.7 KiB
JavaScript
/* jshint expr:true */
|
|
import { expect } from 'chai';
|
|
import { describeComponent, it } from 'ember-mocha';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import Ember from 'ember';
|
|
import { NavItem } from 'ghost/controllers/settings/navigation';
|
|
|
|
const { run } = Ember;
|
|
|
|
describeComponent(
|
|
'gh-navigation',
|
|
'Integration : Component : gh-navigation',
|
|
{
|
|
integration: true
|
|
},
|
|
function () {
|
|
it('renders', function () {
|
|
this.render(hbs`{{#gh-navigation}}<div class="js-gh-blognav"><div class="gh-blognav-item"></div></div>{{/gh-navigation}}`);
|
|
expect(this.$('section.gh-view')).to.have.length(1);
|
|
expect(this.$('.ui-sortable')).to.have.length(1);
|
|
});
|
|
|
|
it('triggers reorder action', function () {
|
|
let navItems = [],
|
|
expectedOldIndex = -1,
|
|
expectedNewIndex = -1;
|
|
|
|
navItems.pushObject(NavItem.create({label: 'First', url: '/first'}));
|
|
navItems.pushObject(NavItem.create({label: 'Second', url: '/second'}));
|
|
navItems.pushObject(NavItem.create({label: 'Third', url: '/third'}));
|
|
navItems.pushObject(NavItem.create({label: '', url: '', last: true}));
|
|
this.set('navigationItems', navItems);
|
|
this.set('blogUrl', 'http://localhost:2368');
|
|
|
|
this.on('moveItem', (oldIndex, newIndex) => {
|
|
expect(oldIndex).to.equal(expectedOldIndex);
|
|
expect(newIndex).to.equal(expectedNewIndex);
|
|
});
|
|
|
|
run(() => {
|
|
this.render(hbs `
|
|
{{#gh-navigation moveItem="moveItem"}}
|
|
<form id="settings-navigation" class="gh-blognav js-gh-blognav" novalidate="novalidate">
|
|
{{#each navigationItems as |navItem|}}
|
|
{{gh-navitem navItem=navItem baseUrl=blogUrl addItem="addItem" deleteItem="deleteItem" updateUrl="updateUrl"}}
|
|
{{/each}}
|
|
</form>
|
|
{{/gh-navigation}}`);
|
|
});
|
|
|
|
// check it renders the nav item rows
|
|
expect(this.$('.gh-blognav-item')).to.have.length(4);
|
|
|
|
// move second item up one
|
|
expectedOldIndex = 1;
|
|
expectedNewIndex = 0;
|
|
Ember.$(this.$('.gh-blognav-item')[1]).simulateDragSortable({
|
|
move: -1,
|
|
handle: '.gh-blognav-grab'
|
|
});
|
|
|
|
// move second item down one
|
|
expectedOldIndex = 1;
|
|
expectedNewIndex = 2;
|
|
Ember.$(this.$('.gh-blognav-item')[1]).simulateDragSortable({
|
|
move: 1,
|
|
handle: '.gh-blognav-grab'
|
|
});
|
|
});
|
|
}
|
|
);
|