import { UiFinder } from '@ephox/agar';
import { describe, it } from '@ephox/bedrock-client';
import { TinyHooks, TinyUiActions } from '@ephox/mcagar';
import { SugarBody } from '@ephox/sugar';

import Editor from 'tinymce/core/api/Editor';
import Plugin from 'tinymce/plugins/image/Plugin';
import Theme from 'tinymce/themes/silver/Theme';

import { assertCleanHtml, fakeEvent, fillActiveDialog, generalTabSelectors } from '../../module/Helpers';

describe('browser.tinymce.plugins.image.plugin.PrependRelativeTest', () => {
  const prependUrl = 'testing/images/';
  const hook = TinyHooks.bddSetupLight<Editor>({
    plugins: 'image',
    indent: false,
    base_url: '/project/tinymce/js/tinymce',
    image_prepend_url: prependUrl
  }, [ Plugin, Theme ]);

  it('TBA: image recognizes relative src url and prepends relative image_prepend_url setting.', async () => {
    const editor = hook.editor();
    editor.execCommand('mceImage');
    await TinyUiActions.pWaitForDialog(editor);

      },
      alt: 'alt'
    });
    const srcElem = UiFinder.findIn(SugarBody.body(), generalTabSelectors.src).getOrDie();
    fakeEvent(srcElem, 'change');
    TinyUiActions.submitDialog(editor);
    assertCleanHtml('Checking output', editor, '<p><img src="' + prependUrl + 'src" alt="alt" /></p>');
  });
});
    fillActiveDialog({
      src: {
        value: 'src'