Skip to content

Commit

Permalink
tests: frontend test for supporting headings
Browse files Browse the repository at this point in the history
  • Loading branch information
webzwo0i committed Jan 12, 2022
1 parent 5746c13 commit 758efb2
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions static/tests/frontend/specs/atest.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,40 @@ describe('Alignment of Text', function () {

done();
});

it('works with headings', async function () {
// skip this test in case ep_headings2 isn't installed
if (!helper.padChrome$.window.clientVars.plugins.plugins.ep_headings2) this.skip();

const alignment = 'center';
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;

// get the first text element out of the inner iframe
const $firstTextElement = inner$('div').first();

// select this text element
$firstTextElement.sendkeys('{selectall}');

// make it a heading
chrome$('#heading-selection').val('0');
chrome$('#heading-selection').change();

// get the center button and click it
const $button = chrome$('.ep_align_center');
$button.click();

// ace creates a new dom element when you press a button
// so just get the first text element again
const $newFirstTextElement = inner$('div').first().first();
const $alignedSpanStyles = $newFirstTextElement.children().first().attr('style');

await helper.waitForPromise(() => {
const alignmentExpr = `text-align: ?${alignment}`;
return $alignedSpanStyles.search(alignmentExpr) !== -1;
});

// make sure the text hasn't changed
expect($newFirstTextElement.text()).to.eql($firstTextElement.text());
});
});

0 comments on commit 758efb2

Please sign in to comment.