diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2019-02-06 12:58:29 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-02-06 12:58:29 +0000 |
commit | 81429f619319da663d4dc0a993c3933f3910fdf6 (patch) | |
tree | 1e0710e47c923e88842e6543d2ab4b69958d375d /spec/features/markdown | |
parent | 7c54409fe91b73f3e5ddfe7078d0421be2cab772 (diff) | |
download | gitlab-ce-81429f619319da663d4dc0a993c3933f3910fdf6.tar.gz |
Reduce Bundle Size by lazy loading markdown-it
Diffstat (limited to 'spec/features/markdown')
-rw-r--r-- | spec/features/markdown/copy_as_gfm_spec.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/spec/features/markdown/copy_as_gfm_spec.rb b/spec/features/markdown/copy_as_gfm_spec.rb index 16754035076..60ddb02da2c 100644 --- a/spec/features/markdown/copy_as_gfm_spec.rb +++ b/spec/features/markdown/copy_as_gfm_spec.rb @@ -843,6 +843,7 @@ describe 'Copy as GFM', :js do def verify(selector, gfm, target: nil) html = html_for_selector(selector) output_gfm = html_to_gfm(html, 'transformCodeSelection', target: target) + wait_for_requests expect(output_gfm.strip).to eq(gfm.strip) end end @@ -861,6 +862,9 @@ describe 'Copy as GFM', :js do def html_to_gfm(html, transformer = 'transformGFMSelection', target: nil) js = <<~JS (function(html) { + // Setting it off so the import already starts + window.CopyAsGFM.nodeToGFM(document.createElement('div')); + var transformer = window.CopyAsGFM[#{transformer.inspect}]; var node = document.createElement('div'); @@ -875,9 +879,18 @@ describe 'Copy as GFM', :js do node = transformer(node, target); if (!node) return null; - return window.CopyAsGFM.nodeToGFM(node); + + window.gfmCopytestRes = null; + window.CopyAsGFM.nodeToGFM(node) + .then((res) => { + window.gfmCopytestRes = res; + }); })("#{escape_javascript(html)}") JS - page.evaluate_script(js) + page.execute_script(js) + + loop until page.evaluate_script('window.gfmCopytestRes !== null') + + page.evaluate_script('window.gfmCopytestRes') end end |