import { MessageModalLayoutUniDriver } from '@wix/design-system/dist/testkit/unidriver';
import { UniDriver } from '@wix/wix-ui-test-utils/unidriver';

export function ArchiveFieldModalUniDriver(_base: UniDriver, body: UniDriver) {
  const getArchiveFieldModal = () =>
    MessageModalLayoutUniDriver(
      body.$('[data-hook="archive-custom-field-modal"]'),
      body,
    );

  const exists = () => getArchiveFieldModal().exists();
  const clickConfirm = () =>
    getArchiveFieldModal()
      .getPrimaryButtonDriver()
      .then((driver: any) => driver.click());
  const clickClose = () => getArchiveFieldModal().clickCloseButton();
  const getModalTitle = () => getArchiveFieldModal().getTitleText();
  const getModalBody = () =>
    body.$('[data-hook="archive-custom-field-body"]').text();

  return {
    exists,
    clickConfirm,
    clickClose,
    getModalTitle,
    getModalBody,
  };
}
