Ghost/ghost/admin/tests/integration/components/gh-psm-visibility-input-test.js
Rishabh 64819714a7 Added custom segment option to post settings access option
refs https://github.com/TryGhost/Team/issues/822

With multiple products flag we are re-enabling segmentation by product for posts. This change adds new segment option for post access option in post-settings menu, which allows option to choose specific products for post access.

- updates post settings and post settings labs menu to add new option for segment
- handles visibility filter changes for API based on selected segment
- the new behavior is behind the alpha flag for multiple products
2021-07-05 17:14:26 +05:30

45 lines
1.5 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.calledTwice).to.be.true;
expect(setVisibility.calledWith('visibility', 'paid')).to.be.true;
expect(setVisibility.calledWith('visibilityFilter', null)).to.be.true;
});
});