saleor-dashboard/cypress/support/pages/catalog/giftCardPage.js
Karolina Rakoczy 2c64a966cc
Saleor 4437 refactor tests (#1389)
* reference type cypress working

* refactor

* remove screenshots

* add reference

* add slash marker

* run tests based on shop version

* fix run tests based on shop version

* fix run tests based on shop version

* change base url to localhost

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix plugins

* fix yml

* fix yml

* chage file names

* fix files names

* fix broken imports add checking for errors in grpah responses

* fix broken imports add checking for errors in grpah responses

* update jest

* fix snapshot
2021-09-27 12:04:21 +02:00

63 lines
1.8 KiB
JavaScript

import { GIFT_CARD_DIALOG } from "../../../elements/giftCard/giftCardDialog";
import { GIFT_CARD_LIST } from "../../../elements/giftCard/giftCardList";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { urlList } from "../../../fixtures/urlList";
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)
.clearAndType(amount)
.createNewOption(GIFT_CARD_DIALOG.tagInput, tag)
.get(GIFT_CARD_DIALOG.noteInput)
.type(note);
}
export function saveGiftCard() {
return cy
.get(BUTTON_SELECTORS.submit)
.click()
.get(GIFT_CARD_DIALOG.cardCodeText)
.invoke("text")
.then(text => {
const giftCardCode = text;
cy.get(BUTTON_SELECTORS.submit).click();
return cy.wrap(giftCardCode);
});
}
export function setNeverExpire() {
cy.get(GIFT_CARD_DIALOG.expirationOptions.neverExpireRadioButton).click();
}
export const expiryPeriods = {
MONTH: GIFT_CARD_DIALOG.expirationOptions.expiryPeriodMonthType
};
export function setExpiryPeriod(amount, period) {
cy.get(GIFT_CARD_DIALOG.expirationOptions.expiryPeriodRadioButton)
.click()
.get(GIFT_CARD_DIALOG.expirationOptions.expiryPeriodAmount)
.clearAndType(amount)
.get(GIFT_CARD_DIALOG.expirationOptions.expiryPeriodTypeButton)
.click()
.get(period)
.click();
}
export function setExpiryDate(date) {
cy.get(GIFT_CARD_DIALOG.expirationOptions.expiryDateRadioButton)
.click()
.get(GIFT_CARD_DIALOG.expirationOptions.expiryDateInput)
.type(date);
}