const { Given, When, Then } = require("@cucumber/cucumber")
const {
    wait,
    clearStorages,
    visitPage,
    visitPageIncognito,
    shouldSeeText,
    shouldSeeTextAt,
    shouldNotSeeText,
    shouldNotSeeTextAt,
    clickLink,
    clickLinkAt,
    pressButton,
    pressButtonAt,
    modalOpened,
    modalClosed,
    buttonShouldBeDisabled,
    buttonShouldBeEnabled,
    buttonShouldBeDisabledAt,
    buttonShouldBeEnabledAt,
    fillInputField,
    setCheckboxField,
    unsetCheckboxField,
    fillInputFieldAt,
    setCheckboxFieldAt,
    unsetCheckboxFieldAt,
    chooseRadioOptionAt,
    setCheckboxGroupOptionAt,
    unsetCheckboxGroupOptionAt,
    jsonViewContains,
    jsonViewContainsAt,
} = require('../support/actions');


Given('clear browser storages', clearStorages);

Then('wait for {string} seconds', { timeout: 60 * 1000 }, wait);

Given('visit {string} page', visitPage);
Given('visit {string} page incognito', visitPageIncognito);

When('see {string}', shouldSeeText);
When('not see {string}', shouldNotSeeText);
When('see {string} at {string}', shouldSeeTextAt);
When('not see {string} at {string}', shouldNotSeeTextAt);


When('press {string} button', pressButton);
When('press {string} button at {string}', pressButtonAt);

When('click {string} link', clickLink);
When('click {string} link at {string}', clickLinkAt);

Then('modal of {string} dialog opened', modalOpened);
Then('modal of {string} dialog closed', modalClosed);

Then('button {string} is disabled', buttonShouldBeDisabled);
Then('button {string} is enabled', buttonShouldBeEnabled);

Then('button {string} at {string} is disabled', buttonShouldBeDisabledAt);
Then('button {string} at {string} is enabled', buttonShouldBeEnabledAt);

Given('enter {string} in {string} input', fillInputField);
Given('enter {string} in {string} textarea at {string}', fillInputFieldAt);

When('set {string} checkbox', setCheckboxField);
When('unset {string} checkbox', unsetCheckboxField);

When('enter {string} in {string} input at {string}', fillInputFieldAt);
When('set {string} checkbox at {string}', setCheckboxFieldAt);
When('unset {string} checkbox at {string}', unsetCheckboxFieldAt);

Given('choose {string} in {string} radio group at {string}', chooseRadioOptionAt);
Given('set {string} in {string} checkbox group at {string}', setCheckboxGroupOptionAt);
Given('unset {string} in {string} checkbox group at {string}', unsetCheckboxGroupOptionAt);

Then('jsonView field {string} contains {string}', jsonViewContains);
Then('jsonView field {string} contains row {string} => {string}', jsonViewContainsAt);