2022-02-01 10:58:02 +00:00
|
|
|
import { GIFT_CARD_DIALOG } from "../../../elements/catalog/giftCard/giftCardDialog";
|
|
|
|
import {
|
|
|
|
GIFT_CARD_LIST,
|
|
|
|
giftCardRow
|
|
|
|
} from "../../../elements/catalog/giftCard/giftCardList";
|
|
|
|
import { GIFT_CARD_UPDATE } from "../../../elements/catalog/giftCard/giftCardUpdate";
|
2021-09-27 10:04:21 +00:00
|
|
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
2021-09-29 13:24:47 +00:00
|
|
|
import { giftCardDetailsUrl, urlList } from "../../../fixtures/urlList";
|
2021-09-08 11:32:05 +00:00
|
|
|
|
|
|
|
export function openAndFillUpCreateGiftCardDialog({
|
|
|
|
note,
|
|
|
|
tag,
|
|
|
|
amount,
|
|
|
|
currency
|
|
|
|
}) {
|
|
|
|
cy.visit(urlList.giftCards)
|
|
|
|
.get(GIFT_CARD_LIST.issueCardButton)
|
|
|
|
.click()
|
|
|
|
.get(GIFT_CARD_DIALOG.currencySelectButton)
|
|
|
|
.click();
|
|
|
|
cy.contains(GIFT_CARD_DIALOG.currenciesOptions, currency)
|
|
|
|
.click()
|
|
|
|
.get(GIFT_CARD_DIALOG.amountInput)
|
2021-09-27 10:04:21 +00:00
|
|
|
.clearAndType(amount)
|
|
|
|
.createNewOption(GIFT_CARD_DIALOG.tagInput, tag)
|
|
|
|
.get(GIFT_CARD_DIALOG.noteInput)
|
|
|
|
.type(note);
|
2021-09-08 11:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function saveGiftCard() {
|
|
|
|
return cy
|
2022-01-31 08:37:49 +00:00
|
|
|
.addAliasToGraphRequest("GiftCardCreate")
|
2021-09-08 11:32:05 +00:00
|
|
|
.get(BUTTON_SELECTORS.submit)
|
|
|
|
.click()
|
2022-01-31 08:37:49 +00:00
|
|
|
.get(BUTTON_SELECTORS.submit)
|
|
|
|
.click()
|
|
|
|
.waitForRequestAndCheckIfNoErrors("@GiftCardCreate")
|
|
|
|
.its("response.body.data.giftCardCreate.giftCard");
|
2021-09-08 11:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const expiryPeriods = {
|
|
|
|
MONTH: GIFT_CARD_DIALOG.expirationOptions.expiryPeriodMonthType
|
|
|
|
};
|
|
|
|
|
|
|
|
export function setExpiryPeriod(amount, period) {
|
2021-09-29 13:24:47 +00:00
|
|
|
cy.get(GIFT_CARD_DIALOG.expirationOptions.setExpiryDateCheckbox)
|
|
|
|
.click()
|
|
|
|
.get(GIFT_CARD_DIALOG.expirationOptions.expiryPeriodRadioButton)
|
2021-09-08 11:32:05 +00:00
|
|
|
.click()
|
|
|
|
.get(GIFT_CARD_DIALOG.expirationOptions.expiryPeriodAmount)
|
|
|
|
.clearAndType(amount)
|
|
|
|
.get(GIFT_CARD_DIALOG.expirationOptions.expiryPeriodTypeButton)
|
|
|
|
.click()
|
|
|
|
.get(period)
|
|
|
|
.click();
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setExpiryDate(date) {
|
2021-09-29 13:24:47 +00:00
|
|
|
cy.get(GIFT_CARD_DIALOG.expirationOptions.setExpiryDateCheckbox)
|
|
|
|
.click()
|
|
|
|
.get(GIFT_CARD_DIALOG.expirationOptions.expiryDateRadioButton)
|
2021-09-08 11:32:05 +00:00
|
|
|
.click()
|
|
|
|
.get(GIFT_CARD_DIALOG.expirationOptions.expiryDateInput)
|
|
|
|
.type(date);
|
|
|
|
}
|
2021-09-29 13:24:47 +00:00
|
|
|
|
|
|
|
export function changeGiftCardActiveStatus(giftCardId) {
|
|
|
|
cy.visit(giftCardDetailsUrl(giftCardId))
|
|
|
|
.get(GIFT_CARD_UPDATE.changeActiveStatusButton)
|
|
|
|
.click()
|
|
|
|
.confirmationMessageShouldDisappear();
|
|
|
|
}
|
2022-02-01 10:58:02 +00:00
|
|
|
|
|
|
|
export function selectGiftCard(giftCardId) {
|
|
|
|
return cy
|
|
|
|
.get(giftCardRow(giftCardId))
|
|
|
|
.find(GIFT_CARD_LIST.selectGiftCardCheckbox)
|
|
|
|
.click();
|
|
|
|
}
|