import { UniDriver } from '@wix/wix-ui-test-utils/unidriver';
import { baseUniDriverFactory } from '../../../unidriver';
import {
  CustomModalLayoutUniDriver,
  LinearProgressBarUniDriver,
  TextUniDriver,
} from '@wix/design-system/dist/testkit/unidriver';

export function AsyncJobProgressModalUniDriver(
  base: UniDriver,
  body: UniDriver,
) {
  const modalBase = () =>
    body.$(`[data-hook="async-job-progress-modal-layout"]`);
  const progressBarBase = () =>
    modalBase().$('[data-hook="async-job-progress-modal-progress-bar"]');
  const modalBodyTextBase = () =>
    modalBase().$('[data-hook="async-job-progress-modal-body-text"]');
  const getAsyncJobProgressModal = () =>
    CustomModalLayoutUniDriver(modalBase(), body);
  const getProgressBar = () =>
    LinearProgressBarUniDriver(progressBarBase(), body);
  const getModalBodyText = () => TextUniDriver(modalBodyTextBase(), body);

  return {
    ...baseUniDriverFactory(base),
    ...getAsyncJobProgressModal(),
    getProgressBar,
    getModalBodyText,
  };
}
