[cypress] Add tests for delete several gift cards (#2646)
* done * pr fixes part1 * wip * pr adjustments * remove cy log
This commit is contained in:
parent
e900f2e1df
commit
d2496679c0
7 changed files with 66 additions and 4 deletions
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
import faker from "faker";
|
import faker from "faker";
|
||||||
|
|
||||||
|
import { GIFT_CARD_LIST } from "../../../elements/catalog/giftCard/giftCardList";
|
||||||
import { GIFT_CARD_UPDATE } from "../../../elements/catalog/giftCard/giftCardUpdate";
|
import { GIFT_CARD_UPDATE } from "../../../elements/catalog/giftCard/giftCardUpdate";
|
||||||
|
import { ASSIGN_ELEMENTS_SELECTORS } from "../../../elements/shared/assign-elements-selectors.js";
|
||||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||||
import { giftCardDetailsUrl } from "../../../fixtures/urlList";
|
import { giftCardDetailsUrl } from "../../../fixtures/urlList";
|
||||||
import {
|
import {
|
||||||
|
@ -12,6 +14,7 @@ import {
|
||||||
} from "../../../support/api/requests/GiftCard";
|
} from "../../../support/api/requests/GiftCard";
|
||||||
import { deleteGiftCardsWithTagStartsWith } from "../../../support/api/utils/catalog/giftCardUtils";
|
import { deleteGiftCardsWithTagStartsWith } from "../../../support/api/utils/catalog/giftCardUtils";
|
||||||
import { formatDate } from "../../../support/formatData/formatDate";
|
import { formatDate } from "../../../support/formatData/formatDate";
|
||||||
|
import { enterAndSelectGiftCards } from "../../../support/pages/catalog/giftCardPage";
|
||||||
|
|
||||||
describe("As an admin I want to update gift card", () => {
|
describe("As an admin I want to update gift card", () => {
|
||||||
const startsWith = "updateGCard";
|
const startsWith = "updateGCard";
|
||||||
|
@ -92,4 +95,51 @@ describe("As an admin I want to update gift card", () => {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should be able to delete several gift cards. TC: SALEOR_1009",
|
||||||
|
{ tags: ["@giftCard", "@allEnv", "@stable"] },
|
||||||
|
() => {
|
||||||
|
const giftCard01 = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
const giftCard02 = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
let giftCard01hash;
|
||||||
|
let giftCard02hash;
|
||||||
|
|
||||||
|
createGiftCard({
|
||||||
|
tag: giftCard01,
|
||||||
|
amount: 3,
|
||||||
|
currency: "THB",
|
||||||
|
})
|
||||||
|
.then(hash => {
|
||||||
|
giftCard01hash = hash.id;
|
||||||
|
createGiftCard({
|
||||||
|
tag: giftCard02,
|
||||||
|
amount: 7,
|
||||||
|
currency: "THB",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(hash2 => {
|
||||||
|
giftCard02hash = hash2.id;
|
||||||
|
enterAndSelectGiftCards([giftCard01hash, giftCard02hash]);
|
||||||
|
cy.get(ASSIGN_ELEMENTS_SELECTORS.checkbox)
|
||||||
|
.first()
|
||||||
|
.check()
|
||||||
|
.should("be.checked")
|
||||||
|
.get(GIFT_CARD_LIST.selectedAmount)
|
||||||
|
.contains("Selected 2 items")
|
||||||
|
.should("be.visible")
|
||||||
|
.get(BUTTON_SELECTORS.deleteItemsButton)
|
||||||
|
.first()
|
||||||
|
.click()
|
||||||
|
.get(GIFT_CARD_UPDATE.consentCheckbox)
|
||||||
|
.click()
|
||||||
|
.get(BUTTON_SELECTORS.submit)
|
||||||
|
.click()
|
||||||
|
.get(ASSIGN_ELEMENTS_SELECTORS.checkbox)
|
||||||
|
.should("not.be.visible");
|
||||||
|
getGiftCardWithId(giftCard01.id).should("be.null");
|
||||||
|
getGiftCardWithId(giftCard02.id).should("be.null");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,8 @@ export const GIFT_CARD_LIST = {
|
||||||
issueCardButton: '[data-test-id="issue-card-button"]',
|
issueCardButton: '[data-test-id="issue-card-button"]',
|
||||||
selectGiftCardCheckbox: '[data-test-id="select-gift-card-checkbox"]',
|
selectGiftCardCheckbox: '[data-test-id="select-gift-card-checkbox"]',
|
||||||
deactivateGiftCardButton: '[data-test-id="deactivate-gift-cards"]',
|
deactivateGiftCardButton: '[data-test-id="deactivate-gift-cards"]',
|
||||||
activateGiftCardButton: '[data-test-id="activate-gift-cards"]'
|
activateGiftCardButton: '[data-test-id="activate-gift-cards"]',
|
||||||
|
selectedAmount: '[data-test-id="SelectedText"]',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const giftCardRow = giftCardId =>
|
export const giftCardRow = giftCardId =>
|
||||||
|
|
|
@ -6,5 +6,5 @@ export const GIFT_CARD_UPDATE = {
|
||||||
expireDateInput: '[name="expiryDate"]',
|
expireDateInput: '[name="expiryDate"]',
|
||||||
autocompleteCustomOption:
|
autocompleteCustomOption:
|
||||||
'[data-test-id="multi-autocomplete-select-option-custom"]',
|
'[data-test-id="multi-autocomplete-select-option-custom"]',
|
||||||
removeTagButton: '[data-test-id="remove"]'
|
removeTagButton: '[data-test-id="remove"]',
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,6 +30,12 @@ export const PRODUCTS_LIST = {
|
||||||
productType: '[data-test-id="filter-group-active-productType"]',
|
productType: '[data-test-id="filter-group-active-productType"]',
|
||||||
stock: '[data-test-id="filter-group-active-stock"]',
|
stock: '[data-test-id="filter-group-active-stock"]',
|
||||||
channel: '[data-test-id="filter-group-active-channel"]',
|
channel: '[data-test-id="filter-group-active-channel"]',
|
||||||
|
currency: '[data-test-id="filter-group-active-currency"]',
|
||||||
|
currencySpecific: {
|
||||||
|
THB: '[data-test-id="filter-option-THB"]',
|
||||||
|
PLN: '[data-test-id="filter-option-PLN"]',
|
||||||
|
USD: '[data-test-id="filter-option-USD"]',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
filterField: {
|
filterField: {
|
||||||
filterField: '[data-test-id*="filter-field"]',
|
filterField: '[data-test-id*="filter-field"]',
|
||||||
|
|
|
@ -8,6 +8,7 @@ export const BUTTON_SELECTORS = {
|
||||||
selectOption: "[data-test-id*='select-option']",
|
selectOption: "[data-test-id*='select-option']",
|
||||||
notSelectedOption: ":not([aria-selected])",
|
notSelectedOption: ":not([aria-selected])",
|
||||||
deleteButton: '[data-test="button-bar-delete"]',
|
deleteButton: '[data-test="button-bar-delete"]',
|
||||||
|
deleteItemsButton: '[data-test-id="button-delete-items"]',
|
||||||
confirmDeleteButton: '[data-test-id="confirm-delete"]',
|
confirmDeleteButton: '[data-test-id="confirm-delete"]',
|
||||||
expandIcon: '[data-test-id="expand-icon"]',
|
expandIcon: '[data-test-id="expand-icon"]',
|
||||||
nextPaginationButton: '[data-test="button-pagination-next"]',
|
nextPaginationButton: '[data-test="button-pagination-next"]',
|
||||||
|
|
|
@ -2,7 +2,11 @@ import { DeleteIcon, IconButton, IconButtonProps } from "@saleor/macaw-ui";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const DeleteIconButton: React.FC<IconButtonProps> = ({ onClick }) => (
|
const DeleteIconButton: React.FC<IconButtonProps> = ({ onClick }) => (
|
||||||
<IconButton variant="secondary" onClick={onClick}>
|
<IconButton
|
||||||
|
variant="secondary"
|
||||||
|
onClick={onClick}
|
||||||
|
data-test-id="button-delete-items"
|
||||||
|
>
|
||||||
<DeleteIcon />
|
<DeleteIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
|
|
|
@ -109,7 +109,7 @@ const TableHead: React.FC<TableHeadProps> = props => {
|
||||||
>
|
>
|
||||||
<div className={classes.container}>
|
<div className={classes.container}>
|
||||||
{selected && (
|
{selected && (
|
||||||
<Typography>
|
<Typography data-test-id="SelectedText">
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id="qu/hXD"
|
id="qu/hXD"
|
||||||
defaultMessage="Selected {number} items"
|
defaultMessage="Selected {number} items"
|
||||||
|
|
Loading…
Reference in a new issue