mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
Fixed tests partially for updated member counts
no issue Also moves some reused test methods to the test helpers folder (wasn't able to move it to the fixtures because too many tests were failing): - enableNewsletters helper - enableStripe helper - enableMailgun helper
This commit is contained in:
parent
04aff7f51b
commit
18f4748e8b
@ -1,5 +1,5 @@
|
||||
<div class="gh-publishmenu-send-to-option">
|
||||
<p>Free members <span class="gh-publishmenu-emailcount">{{this.freeMemberCountLabel}}</span></p>
|
||||
<p>Free members <span class="gh-publishmenu-emailcount" data-test-email-count="free-members">{{this.freeMemberCountLabel}}</span></p>
|
||||
<div class="for-switch x-small {{if @disabled "disabled"}}">
|
||||
<label class="switch" for="send-email-to-free">
|
||||
<input
|
||||
@ -18,7 +18,7 @@
|
||||
</div>
|
||||
{{#if this.isPaidAvailable}}
|
||||
<div class="gh-publishmenu-send-to-option">
|
||||
<p>Paid members <span class="gh-publishmenu-emailcount">{{this.paidMemberCountLabel}}</span></p>
|
||||
<p>Paid members <span class="gh-publishmenu-emailcount" data-test-email-count="paid-members">{{this.paidMemberCountLabel}}</span></p>
|
||||
<div class="for-switch x-small {{if @disabled "disabled"}}">
|
||||
<label class="switch" for="send-email-to-paid">
|
||||
<input
|
||||
|
@ -97,7 +97,7 @@ export default function mockMembers(server) {
|
||||
});
|
||||
|
||||
// similar deal for associated models
|
||||
['labels', 'products', 'subscriptions'].forEach((association) => {
|
||||
['labels', 'products', 'subscriptions', 'newsletters'].forEach((association) => {
|
||||
serializedMember[association] = [];
|
||||
|
||||
member[association].models.forEach((associatedModel) => {
|
||||
|
@ -6,11 +6,14 @@ import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-sup
|
||||
import {beforeEach, describe, it} from 'mocha';
|
||||
import {blur, click, currentRouteName, currentURL, fillIn, find, findAll, triggerEvent} from '@ember/test-helpers';
|
||||
import {datepickerSelect} from 'ember-power-datepicker/test-support';
|
||||
import {enableMailgun} from '../helpers/mailgun';
|
||||
import {enableNewsletters} from '../helpers/newsletters';
|
||||
import {expect} from 'chai';
|
||||
import {selectChoose} from 'ember-power-select/test-support';
|
||||
import {setupApplicationTest} from 'ember-mocha';
|
||||
import {setupMirage} from 'ember-cli-mirage/test-support';
|
||||
import {visit} from '../helpers/visit';
|
||||
import { enableStripe } from '../helpers/stripe';
|
||||
|
||||
// TODO: update ember-power-datepicker to expose modern test helpers
|
||||
// https://github.com/cibernox/ember-power-datepicker/issues/30
|
||||
@ -841,7 +844,7 @@ describe('Acceptance: Editor', function () {
|
||||
beforeEach(async function () {
|
||||
const role = this.server.create('role', {name: 'Administrator'});
|
||||
user = this.server.create('user', {roles: [role]});
|
||||
|
||||
this.server.loadFixtures('settings');
|
||||
return await authenticateSession();
|
||||
});
|
||||
|
||||
@ -866,24 +869,16 @@ describe('Acceptance: Editor', function () {
|
||||
// BUG: re-scheduling a send-only post unexpectedly switched to publish+send
|
||||
// https://github.com/TryGhost/Ghost/issues/14354
|
||||
it('can re-schedule an email-only post', async function () {
|
||||
// enable email functionality
|
||||
this.server.db.settings.find({key: 'mailgun_api_key'})
|
||||
? this.server.db.settings.update({key: 'mailgun_api_key'}, {value: 'MAILGUN_API_KEY'})
|
||||
: this.server.create('setting', {key: 'mailgun_api_key', value: 'MAILGUN_API_KEY', group: 'email'});
|
||||
// Enable newsletters (extra confirmation step)
|
||||
enableMailgun(this.server);
|
||||
enableNewsletters(this.server, true);
|
||||
|
||||
this.server.db.settings.find({key: 'mailgun_domain'})
|
||||
? this.server.db.settings.update({key: 'mailgun_domain'}, {value: 'MAILGUN_DOMAIN'})
|
||||
: this.server.create('setting', {key: 'mailgun_domain', value: 'MAILGUN_DOMAIN', group: 'email'});
|
||||
// Enable stripe to also show paid members breakdown
|
||||
enableStripe(this.server);
|
||||
|
||||
this.server.db.settings.find({key: 'mailgun_base_url'})
|
||||
? this.server.db.settings.update({key: 'mailgun_base_url'}, {value: 'MAILGUN_BASE_URL'})
|
||||
: this.server.create('setting', {key: 'mailgun_base_url', value: 'MAILGUN_BASE_URL', group: 'email'});
|
||||
|
||||
this.server.db.settings.find({key: 'editor_default_email_recipients'})
|
||||
? this.server.db.settings.update({key: 'editor_default_email_recipients'}, {value: 'visibility'})
|
||||
: this.server.create('setting', {key: 'editor_default_email_recipients', value: 'visibility', group: 'editor'});
|
||||
|
||||
this.server.createList('member', 4);
|
||||
const newsletter = this.server.create('newsletter', {status: 'active'});
|
||||
this.server.createList('member', 4, {status: 'free', newsletters: [newsletter]});
|
||||
this.server.createList('member', 2, {status: 'paid', newsletters: [newsletter]});
|
||||
|
||||
const post = this.server.create('post', {status: 'draft', authors: [user]});
|
||||
|
||||
@ -894,6 +889,11 @@ describe('Acceptance: Editor', function () {
|
||||
await selectChoose('[data-test-distribution-action-select]', 'send');
|
||||
await click('[data-test-publishmenu-scheduled-option]');
|
||||
await datepickerSelect('[data-test-publishmenu-draft] [data-test-date-time-picker-datepicker]', new Date(scheduledTime.format().replace(/\+.*$/, '')));
|
||||
|
||||
// Expect 4 free and 2 paid recipients here
|
||||
expect(find('[data-test-email-count="free-members"]')).to.contain.text('4');
|
||||
expect(find('[data-test-email-count="paid-members"]')).to.contain.text('2');
|
||||
|
||||
await click('[data-test-publishmenu-save]');
|
||||
await click('[data-test-button="confirm-schedule"]');
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
import {authenticateSession} from 'ember-simple-auth/test-support';
|
||||
import {click, currentURL, find, findAll} from '@ember/test-helpers';
|
||||
import {enableLabsFlag} from '../../helpers/labs-flag';
|
||||
import {enableNewsletters} from '../../helpers/newsletters';
|
||||
import {enableStripe} from '../../helpers/stripe';
|
||||
import {expect} from 'chai';
|
||||
import {setupApplicationTest} from 'ember-mocha';
|
||||
import {setupMirage} from 'ember-cli-mirage/test-support';
|
||||
@ -20,22 +22,8 @@ describe('Acceptance: Member details', function () {
|
||||
enableLabsFlag(this.server, 'membersTimeFilters');
|
||||
enableLabsFlag(this.server, 'multipleProducts');
|
||||
|
||||
// test with stripe connected and email turned on
|
||||
// TODO: add these settings to default fixtures
|
||||
this.server.db.settings.find({key: 'stripe_connect_account_id'})
|
||||
? this.server.db.settings.update({key: 'stripe_connect_account_id'}, {value: 'stripe_account_id'})
|
||||
: this.server.create('setting', {key: 'stripe_connect_account_id', value: 'stripe_account_id', group: 'members'});
|
||||
// needed for membersUtils.isStripeEnabled
|
||||
this.server.db.settings.find({key: 'stripe_connect_secret_key'})
|
||||
? this.server.db.settings.update({key: 'stripe_connect_secret_key'}, {value: 'stripe_secret_key'})
|
||||
: this.server.create('setting', {key: 'stripe_connect_secret_key', value: 'stripe_secret_key', group: 'members'});
|
||||
this.server.db.settings.find({key: 'stripe_connect_publishable_key'})
|
||||
? this.server.db.settings.update({key: 'stripe_connect_publishable_key'}, {value: 'stripe_secret_key'})
|
||||
: this.server.create('setting', {key: 'stripe_connect_publishable_key', value: 'stripe_secret_key', group: 'members'});
|
||||
|
||||
this.server.db.settings.find({key: 'editor_default_email_recipients'})
|
||||
? this.server.db.settings.update({key: 'editor_default_email_recipients'}, {value: 'visibility'})
|
||||
: this.server.create('setting', {key: 'editor_default_email_recipients', value: 'visibility', group: 'editor'});
|
||||
enableStripe(this.server);
|
||||
enableNewsletters(this.server, true);
|
||||
|
||||
// add a default product that complimentary plans can be assigned to
|
||||
product = this.server.create('product', {
|
||||
|
@ -3,7 +3,8 @@ import sinon from 'sinon';
|
||||
import {authenticateSession} from 'ember-simple-auth/test-support';
|
||||
import {blur, click, currentURL, fillIn, find, findAll, focus} from '@ember/test-helpers';
|
||||
import {datepickerSelect} from 'ember-power-datepicker/test-support';
|
||||
import {enableLabsFlag} from '../../helpers/labs-flag';
|
||||
import {enableNewsletters} from '../../helpers/newsletters';
|
||||
import {enableStripe} from '../../helpers/stripe';
|
||||
import {expect} from 'chai';
|
||||
import {selectChoose} from 'ember-power-select/test-support/helpers';
|
||||
import {setupApplicationTest} from 'ember-mocha';
|
||||
@ -19,17 +20,9 @@ describe('Acceptance: Members filtering', function () {
|
||||
beforeEach(async function () {
|
||||
this.server.loadFixtures('configs');
|
||||
this.server.loadFixtures('settings');
|
||||
enableLabsFlag(this.server, 'multipleProducts');
|
||||
enableStripe(this.server);
|
||||
enableNewsletters(this.server, true);
|
||||
|
||||
// test with stripe connected and email turned on
|
||||
// TODO: add these settings to default fixtures
|
||||
this.server.db.settings.find({key: 'stripe_connect_account_id'})
|
||||
? this.server.db.settings.update({key: 'stripe_connect_account_id'}, {value: 'stripe_connected'})
|
||||
: this.server.create('setting', {key: 'stripe_connect_account_id', value: 'stripe_connected', group: 'members'});
|
||||
|
||||
this.server.db.settings.find({key: 'editor_default_email_recipients'})
|
||||
? this.server.db.settings.update({key: 'editor_default_email_recipients'}, {value: 'visibility'})
|
||||
: this.server.create('setting', {key: 'editor_default_email_recipients', value: 'visibility', group: 'editor'});
|
||||
|
||||
let role = this.server.create('role', {name: 'Owner'});
|
||||
this.server.create('user', {roles: [role]});
|
||||
|
13
ghost/admin/tests/helpers/mailgun.js
Normal file
13
ghost/admin/tests/helpers/mailgun.js
Normal file
@ -0,0 +1,13 @@
|
||||
export function enableMailgun(server) {
|
||||
server.db.settings.find({key: 'mailgun_api_key'})
|
||||
? server.db.settings.update({key: 'mailgun_api_key'}, {value: 'MAILGUN_API_KEY'})
|
||||
: server.create('setting', {key: 'mailgun_api_key', value: 'MAILGUN_API_KEY', group: 'email'});
|
||||
|
||||
server.db.settings.find({key: 'mailgun_domain'})
|
||||
? server.db.settings.update({key: 'mailgun_domain'}, {value: 'MAILGUN_DOMAIN'})
|
||||
: server.create('setting', {key: 'mailgun_domain', value: 'MAILGUN_DOMAIN', group: 'email'});
|
||||
|
||||
server.db.settings.find({key: 'mailgun_base_url'})
|
||||
? server.db.settings.update({key: 'mailgun_base_url'}, {value: 'MAILGUN_BASE_URL'})
|
||||
: server.create('setting', {key: 'mailgun_base_url', value: 'MAILGUN_BASE_URL', group: 'email'});
|
||||
}
|
5
ghost/admin/tests/helpers/newsletters.js
Normal file
5
ghost/admin/tests/helpers/newsletters.js
Normal file
@ -0,0 +1,5 @@
|
||||
export function enableNewsletters(server, enabled) {
|
||||
server.db.settings.find({key: 'editor_default_email_recipients'})
|
||||
? server.db.settings.update({key: 'editor_default_email_recipients'}, {value: enabled ? 'visibility' : 'disabled'})
|
||||
: server.create('setting', {key: 'editor_default_email_recipients', value: enabled ? 'visibility' : 'disabled', group: 'editor'});
|
||||
}
|
12
ghost/admin/tests/helpers/stripe.js
Normal file
12
ghost/admin/tests/helpers/stripe.js
Normal file
@ -0,0 +1,12 @@
|
||||
export function enableStripe(server) {
|
||||
server.db.settings.find({key: 'stripe_connect_account_id'})
|
||||
? server.db.settings.update({key: 'stripe_connect_account_id'}, {value: 'stripe_account_id'})
|
||||
: server.create('setting', {key: 'stripe_connect_account_id', value: 'stripe_account_id', group: 'members'});
|
||||
// needed for membersUtils.isStripeEnabled
|
||||
server.db.settings.find({key: 'stripe_connect_secret_key'})
|
||||
? server.db.settings.update({key: 'stripe_connect_secret_key'}, {value: 'stripe_secret_key'})
|
||||
: server.create('setting', {key: 'stripe_connect_secret_key', value: 'stripe_secret_key', group: 'members'});
|
||||
server.db.settings.find({key: 'stripe_connect_publishable_key'})
|
||||
? server.db.settings.update({key: 'stripe_connect_publishable_key'}, {value: 'stripe_secret_key'})
|
||||
: server.create('setting', {key: 'stripe_connect_publishable_key', value: 'stripe_secret_key', group: 'members'});
|
||||
}
|
Loading…
Reference in New Issue
Block a user