From 758efb2e952d13ec47b1e03af824befca1e7e652 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Wed, 12 Jan 2022 06:03:59 +0100 Subject: [PATCH] tests: frontend test for supporting headings --- static/tests/frontend/specs/atest.js | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/static/tests/frontend/specs/atest.js b/static/tests/frontend/specs/atest.js index 68f665c..f05e612 100644 --- a/static/tests/frontend/specs/atest.js +++ b/static/tests/frontend/specs/atest.js @@ -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()); + }); });