🐛 Fixed "Enable email open-rate" toggle

closes https://github.com/TryGhost/Team/issues/1381
refs 21b4b15a1c

- when the email newsletter settings was refactored, the `emailTrackOpens: reads('settings.emailTrackOpens')` was removed as it's a confusing redirection but it's usage in the toggle action was missed
This commit is contained in:
Kevin Ansfield 2022-02-21 14:31:19 +00:00
parent f98aafb08b
commit 15510221c5
3 changed files with 45 additions and 1 deletions

View File

@ -125,7 +125,7 @@ export default class MembersEmail extends Component {
if (event) {
event.preventDefault();
}
this.set('settings.emailTrackOpens', !this.emailTrackOpens);
this.set('settings.emailTrackOpens', !this.settings.get('emailTrackOpens'));
}
@action

View File

@ -252,5 +252,15 @@ export default [
updated_at: '2022-02-16T09:38:00.000Z',
updated_by: 1,
value: '[]'
},
{
id: 31,
created_at: '2022-02-21T13:47:00.000Z',
created_by: 1,
key: 'email_track_opens',
group: 'email',
updated_at: '2022-02-21T13:47:00.000Z',
updated_by: 1,
value: 'true'
}
];

View File

@ -0,0 +1,34 @@
import {authenticateSession} from 'ember-simple-auth/test-support';
import {click, find} from '@ember/test-helpers';
import {expect} from 'chai';
import {setupApplicationTest} from 'ember-mocha';
import {setupMirage} from 'ember-cli-mirage/test-support';
import {visit} from '../../helpers/visit';
describe('Acceptance: Settings - Members email', function () {
const hooks = setupApplicationTest();
setupMirage(hooks);
beforeEach(async function () {
this.server.loadFixtures('configs');
const role = this.server.create('role', {name: 'Owner'});
this.server.create('user', {roles: [role]});
return await authenticateSession();
});
it('can manage open rate tracking', async function () {
this.server.db.settings.update({key: 'email_track_opens'}, {value: 'true'});
await visit('/settings/members-email');
expect(find('[data-test-checkbox="email-track-opens"]')).to.be.checked;
await click('label[for="email-track-opens"]');
expect(find('[data-test-checkbox="email-track-opens"]')).to.not.be.checked;
await click('[data-test-button="save-members-settings"]');
expect(this.server.db.settings.findBy({key: 'email_track_opens'}).value).to.equal(false);
});
});