mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
cdb87e5112
refs 80f7e0b19e
- Added visibility input in PSM to control content access level for members
- Added default post visibility in editor. To be changed (moved to server-side) once `defaultContentVisibility` is available in settings service
- Added `visibility` property to post model & mirage
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
import hbs from 'htmlbars-inline-precompile';
|
|
import sinon from 'sinon';
|
|
import {blur, fillIn, find, findAll, render} from '@ember/test-helpers';
|
|
import {describe, it} from 'mocha';
|
|
import {expect} from 'chai';
|
|
import {setupRenderingTest} from 'ember-mocha';
|
|
|
|
describe('Integration: Component: gh-psm-visibility-input', function () {
|
|
setupRenderingTest();
|
|
|
|
it('renders', async function () {
|
|
this.set('post', {
|
|
visibility: 'members'
|
|
});
|
|
|
|
await render(hbs`{{gh-psm-visibility-input post=post}}`);
|
|
|
|
expect(this.element, 'top-level elements').to.exist;
|
|
expect(findAll('option'), 'number of options').to.have.length(3);
|
|
expect(find('select').value, 'selected option value').to.equal('members');
|
|
});
|
|
|
|
it('updates post visibility on change', async function () {
|
|
let setVisibility = sinon.spy();
|
|
|
|
this.set('post', {
|
|
visibility: 'public',
|
|
set: setVisibility
|
|
});
|
|
|
|
await render(hbs`{{gh-psm-visibility-input post=post}}`);
|
|
expect(this.element, 'top-level elements').to.exist;
|
|
expect(findAll('option'), 'number of options').to.have.length(3);
|
|
expect(find('select').value, 'selected option value').to.equal('public');
|
|
|
|
await fillIn('select', 'paid');
|
|
await blur('select');
|
|
|
|
expect(setVisibility.calledOnce).to.be.true;
|
|
expect(setVisibility.calledWith('visibility', 'paid')).to.be.true;
|
|
});
|
|
});
|