import { UniDriver } from '@wix/wix-ui-test-utils/unidriver';
import { AutoCompleteUniDriver } from '@wix/design-system/dist/testkit/unidriver';
import { AutoCompleteUniDriver as AutoCompleteUniDriverFactory } from '@wix/design-system/dist/types/AutoComplete/AutoComplete.uni.driver';
import { UniDriverFactory } from '../../../uniDriverFactory';
import { baseUniDriverFactory } from '../../../../unidriver';

export function SpecificValuesEditUniDriver(base: UniDriver, body: UniDriver) {
  const ac = (
    AutoCompleteUniDriver as UniDriverFactory<AutoCompleteUniDriverFactory>
  )(base, body);

  return {
    ...baseUniDriverFactory(base),
    keyDown: (
      key: string,
      opts?: { shiftKey?: boolean; ctrlKey?: boolean; metaKey?: boolean },
    ) => ac.inputDriver.keyDown({ key, ...opts }),
    blur: () => ac.inputDriver.blur(),
    clickInput: () => ac.inputDriver.click(),
    getValue: () => ac.inputDriver.getValue(),
    selectOption: async (id: string) => {
      await ac.driver.selectOptionById(id);
    },
    typeInInput: (text: string) => ac.inputDriver.enterText(text),
    getOptionsContent: () => ac.dropdownLayoutDriver.optionsContent(),
  };
}
