2022-02-01 10:58:02 +00:00
|
|
|
/// <reference types="cypress" />
|
|
|
|
/// <reference types="../../../support"/>
|
|
|
|
|
|
|
|
import faker from "faker";
|
|
|
|
|
|
|
|
import { getGiftCardsWithCode } from "../../../support/api/requests/GiftCard";
|
|
|
|
import { addToDate } from "../../../support/api/utils/misc";
|
|
|
|
import { formatDate } from "../../../support/formatData/formatDate";
|
|
|
|
import {
|
|
|
|
expiryPeriods,
|
|
|
|
openAndFillUpCreateGiftCardDialog,
|
|
|
|
saveGiftCard,
|
|
|
|
setExpiryDate,
|
2022-06-27 16:49:35 +00:00
|
|
|
setExpiryPeriod,
|
2022-02-01 10:58:02 +00:00
|
|
|
} from "../../../support/pages/catalog/giftCardPage";
|
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
describe("As an admin I want to create gift card", () => {
|
2022-08-16 10:49:22 +00:00
|
|
|
const startsWith = "CreateGCards";
|
2022-06-27 09:30:51 +00:00
|
|
|
const amount = 50;
|
|
|
|
const currency = "USD";
|
2022-02-01 10:58:02 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
before(() => {
|
2023-07-28 07:48:41 +00:00
|
|
|
cy.loginUserViaRequest();
|
2022-06-27 09:30:51 +00:00
|
|
|
});
|
2022-02-01 10:58:02 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
beforeEach(() => {
|
2023-07-28 07:48:41 +00:00
|
|
|
cy.loginUserViaRequest();
|
2022-06-27 09:30:51 +00:00
|
|
|
});
|
2022-02-01 10:58:02 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should be able to create never expire gift card. TC: SALEOR_1001",
|
|
|
|
{ tags: ["@giftCard", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2022-02-01 10:58:02 +00:00
|
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
let giftCard;
|
|
|
|
|
|
|
|
openAndFillUpCreateGiftCardDialog({
|
|
|
|
note: name,
|
|
|
|
tag: name,
|
|
|
|
amount,
|
2022-06-27 16:49:35 +00:00
|
|
|
currency,
|
2022-02-01 10:58:02 +00:00
|
|
|
});
|
|
|
|
saveGiftCard()
|
|
|
|
.then(giftCardResp => {
|
|
|
|
giftCard = giftCardResp;
|
|
|
|
getGiftCardsWithCode(giftCard.code);
|
|
|
|
})
|
|
|
|
.then(giftCardsResp => {
|
|
|
|
expect(giftCardsResp[0].node.code).to.eq(giftCard.code);
|
|
|
|
expect(giftCardsResp[0].node.initialBalance.amount).to.eq(amount);
|
|
|
|
expect(giftCardsResp[0].node.initialBalance.currency).to.eq(currency);
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2022-02-01 10:58:02 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should be able to create gift card with two moths expiry. TC: SALEOR_1002",
|
|
|
|
{ tags: ["@giftCard", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2022-02-01 10:58:02 +00:00
|
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
let giftCard;
|
|
|
|
const expectedExpiryDate = addToDate(new Date(), 2, "M");
|
|
|
|
|
|
|
|
openAndFillUpCreateGiftCardDialog({
|
|
|
|
note: name,
|
|
|
|
tag: name,
|
|
|
|
amount,
|
2022-06-27 16:49:35 +00:00
|
|
|
currency,
|
2022-02-01 10:58:02 +00:00
|
|
|
});
|
|
|
|
setExpiryPeriod(2, expiryPeriods.MONTH);
|
|
|
|
saveGiftCard()
|
|
|
|
.then(giftCardResp => {
|
|
|
|
giftCard = giftCardResp;
|
|
|
|
getGiftCardsWithCode(giftCard.code);
|
|
|
|
})
|
|
|
|
.then(giftCardsResp => {
|
|
|
|
expect(giftCardsResp[0].node.code).to.eq(giftCard.code);
|
|
|
|
expect(giftCardsResp[0].node.initialBalance.amount).to.eq(amount);
|
|
|
|
expect(giftCardsResp[0].node.initialBalance.currency).to.eq(currency);
|
|
|
|
expect(giftCardsResp[0].node.expiryDate).to.eq(expectedExpiryDate);
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2022-02-01 10:58:02 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should be able to create gift card with date expiry. TC: SALEOR_1003",
|
|
|
|
{ tags: ["@giftCard", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2022-02-01 10:58:02 +00:00
|
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
const date = formatDate(new Date(new Date().getFullYear() + 2, 1, 1));
|
|
|
|
let giftCard;
|
|
|
|
|
|
|
|
openAndFillUpCreateGiftCardDialog({
|
|
|
|
note: name,
|
|
|
|
tag: name,
|
|
|
|
amount,
|
2022-06-27 16:49:35 +00:00
|
|
|
currency,
|
2022-02-01 10:58:02 +00:00
|
|
|
});
|
|
|
|
setExpiryDate(date);
|
|
|
|
saveGiftCard()
|
|
|
|
.then(giftCardResp => {
|
|
|
|
giftCard = giftCardResp;
|
|
|
|
getGiftCardsWithCode(giftCard.code);
|
|
|
|
})
|
|
|
|
.then(giftCardsResp => {
|
|
|
|
expect(giftCardsResp[0].node.code).to.eq(giftCard.code);
|
|
|
|
expect(giftCardsResp[0].node.initialBalance.amount).to.eq(amount);
|
|
|
|
expect(giftCardsResp[0].node.initialBalance.currency).to.eq(currency);
|
|
|
|
expect(giftCardsResp[0].node.expiryDate).to.eq(date);
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2022-02-01 10:58:02 +00:00
|
|
|
});
|