mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added tests for TK indicators within editor (#19262)
closes TryGhost/Product#4225 - added basic tests for TK detection in title - added coverage for TK reminder modal popping up
This commit is contained in:
parent
813abb06e2
commit
549aaa4c5a
2 changed files with 52 additions and 0 deletions
|
@ -5,6 +5,7 @@ import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-sup
|
||||||
import {beforeEach, describe, it} from 'mocha';
|
import {beforeEach, describe, it} from 'mocha';
|
||||||
import {blur, click, currentRouteName, currentURL, fillIn, find, findAll, triggerEvent, typeIn} from '@ember/test-helpers';
|
import {blur, click, currentRouteName, currentURL, fillIn, find, findAll, triggerEvent, typeIn} from '@ember/test-helpers';
|
||||||
import {datepickerSelect} from 'ember-power-datepicker/test-support';
|
import {datepickerSelect} from 'ember-power-datepicker/test-support';
|
||||||
|
import {enableLabsFlag} from '../helpers/labs-flag';
|
||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import {selectChoose} from 'ember-power-select/test-support';
|
import {selectChoose} from 'ember-power-select/test-support';
|
||||||
import {setupApplicationTest} from 'ember-mocha';
|
import {setupApplicationTest} from 'ember-mocha';
|
||||||
|
@ -570,5 +571,38 @@ describe('Acceptance: Editor', function () {
|
||||||
'breadcrumb link'
|
'breadcrumb link'
|
||||||
).to.equal(`/ghost/posts/analytics/${post.id}`);
|
).to.equal(`/ghost/posts/analytics/${post.id}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handles TKs in title', async function () {
|
||||||
|
enableLabsFlag(this.server, 'tkReminders');
|
||||||
|
let post = this.server.create('post', {authors: [author]});
|
||||||
|
|
||||||
|
await visit(`/editor/post/${post.id}`);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
find('[data-test-editor-title-input]').value,
|
||||||
|
'initial title'
|
||||||
|
).to.equal('Post 0');
|
||||||
|
|
||||||
|
await fillIn('[data-test-editor-title-input]', 'Test TK Title');
|
||||||
|
|
||||||
|
expect(
|
||||||
|
find('[data-test-editor-title-input]').value,
|
||||||
|
'title after typing'
|
||||||
|
).to.equal('Test TK Title');
|
||||||
|
|
||||||
|
// check for TK indicator
|
||||||
|
expect(
|
||||||
|
find('[data-testid="tk-indicator"]'),
|
||||||
|
'TK indicator text'
|
||||||
|
).to.exist;
|
||||||
|
|
||||||
|
// click publish to see if confirmation comes up
|
||||||
|
await click('[data-test-button="publish-flow"]');
|
||||||
|
|
||||||
|
expect(
|
||||||
|
find('[data-test-modal="tk-reminder"]'),
|
||||||
|
'TK reminder modal'
|
||||||
|
).to.exist;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -162,4 +162,22 @@ describe('Unit: Controller: lexical-editor', function () {
|
||||||
expect(controller.get('post.slug')).to.not.be.ok;
|
expect(controller.get('post.slug')).to.not.be.ok;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('TK count in title', function () {
|
||||||
|
it('should have count 0 for no TK', async function () {
|
||||||
|
let controller = this.owner.lookup('controller:lexical-editor');
|
||||||
|
|
||||||
|
controller.set('post', EmberObject.create({titleScratch: 'this is a title'}));
|
||||||
|
|
||||||
|
expect(controller.get('tkCount')).to.equal(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should count TK reminders in the title', async function () {
|
||||||
|
let controller = this.owner.lookup('controller:lexical-editor');
|
||||||
|
|
||||||
|
controller.set('post', EmberObject.create({titleScratch: 'this is a TK'}));
|
||||||
|
|
||||||
|
expect(controller.get('tkCount')).to.equal(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue