import { InProductTestCase } from '@atlaskit/in-product-testing';
import { EmbedCardPageObject, embedSmartLinkRendersTestCase } from '@atlaskit/smart-card/in-product';
import { EditorPageObject } from '../../../../page-objects/Editor';
import { EditorSmartLinkPageObject } from '../../../../page-objects/EditorSmartLink';
export var editEmbedSmartLinkTitleTestCase = function editEmbedSmartLinkTitleTestCase(_ref) {
  var ui = _ref.ui,
    url = _ref.url;
  return new InProductTestCase({
    title: 'editing an Embed Smart Link renders as Blue Link (title)',
    id: 'embed-smart-link-edit-title',
    assertions: function assertions(cy) {
      var editor = new EditorPageObject(cy);
      var editorWithSmartLinks = new EditorSmartLinkPageObject(cy, editor);
      var embedCard = new EmbedCardPageObject(cy);
      editorWithSmartLinks.insertSmartLinkByTyping(url);
      editorWithSmartLinks.switchAfterInsert('embed');
      embedSmartLinkRendersTestCase({
        url: url
      }).assertions(cy);
      editorWithSmartLinks.changeLinkLabel('Avocorne is watching you 🥑', 'embed');
      embedCard.assertHrefRendered(url);
      embedCard.expectCardNotExists();
      if (ui !== null && ui !== void 0 && ui.publishButton) {
        var renderer = editor.publish(ui);
        renderer.expectContentReady();
        embedCard.assertHrefRendered(url);
        embedCard.expectCardNotExists();
      }
    }
  });
};
export var editEmbedSmartLinkUrlTestCase = function editEmbedSmartLinkUrlTestCase(_ref2) {
  var ui = _ref2.ui,
    url = _ref2.url;
  return new InProductTestCase({
    title: 'editing an Embed Smart Link renders as Blue Link (URL)',
    id: 'embed-smart-link-edit',
    assertions: function assertions(cy) {
      var editor = new EditorPageObject(cy);
      var editorWithSmartLinks = new EditorSmartLinkPageObject(cy, editor);
      var embedCard = new EmbedCardPageObject(cy);
      editorWithSmartLinks.insertSmartLinkByTyping(url);
      editorWithSmartLinks.switchAfterInsert('embed');
      embedSmartLinkRendersTestCase({
        url: url
      }).assertions(cy);
      var newUrl = 'https://avo.corne.com';
      editorWithSmartLinks.changeLinkUrl(newUrl, 'embed');
      embedCard.expectCardNotExists();
      embedCard.assertHrefRendered(newUrl);
      if (ui !== null && ui !== void 0 && ui.publishButton) {
        var renderer = editor.publish(ui);
        renderer.expectContentReady();
        embedCard.assertHrefRendered(newUrl);
        embedCard.expectCardNotExists();
      }
    }
  });
};