Skip to content

Commit

Permalink
Fix gift cards tags multiselect (#5105)
Browse files Browse the repository at this point in the history
* Fix gift card tags multiselect handler

* Add changeset

* Rename prop

* Add tests

* Fix test
  • Loading branch information
poulch authored Aug 10, 2024
1 parent 6d79edb commit 047a4ff
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-parents-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can now add and remove tags for gift cards without any application crash
7 changes: 7 additions & 0 deletions playwright/pages/giftCardsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export class GiftCardsPage extends BasePage {
readonly exportGiftCardsBanner = page.getByText(
"We are currently exporting your gift card codes. As soon as your file is available it will be sent to your email address",
),
readonly tagsInput = page.getByTestId("gift-card-tag-select-field"),
readonly tagsInputOptions = page.locator('[data-test-id*="select-option"]'),
) {
super(page);
this.page = page;
Expand Down Expand Up @@ -95,6 +97,11 @@ export class GiftCardsPage extends BasePage {
await this.showMoreMenuButton.click();
}

async addTag() {
await this.tagsInput.click();
await this.tagsInputOptions.first().click();
}

async gotoGiftCardsListView() {
await this.waitForNetworkIdleAfterAction(async () => {
await this.page.goto(URL_LIST.giftCards);
Expand Down
2 changes: 2 additions & 0 deletions playwright/tests/giftCards.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ test("TC: SALEOR_109 Activate gift card @e2e @gift", async () => {
});
test("TC: SALEOR_110 Edit gift card @e2e @gift", async () => {
await giftCardsPage.gotoExistingGiftCardView(GIFT_CARDS.giftCardToBeEdited.id);
await giftCardsPage.addTag();
await giftCardsPage.addTag();
await giftCardsPage.clickCardExpiresCheckbox();
await giftCardsPage.metadataSeoPage.expandAndAddAllMetadata();
await giftCardsPage.clickSaveButton();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const GiftCardBulkCreateDialogForm: React.FC<GiftCardBulkCreateDialogFormProps>
error={formErrors?.tags}
name="tags"
values={tags}
toggleChange={change}
onChange={change}
/>

<Divider />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const GiftCardCreateDialogForm: React.FC<GiftCardCreateDialogFormProps> = ({
<>
<GiftCardCreateMoneyInput {...commonFormProps} set={set} />

<GiftCardTagInput error={formErrors?.tags} name="tags" values={tags} toggleChange={change} />
<GiftCardTagInput error={formErrors?.tags} name="tags" values={tags} onChange={change} />

<GiftCardSendToCustomer
selectedChannelSlug={channelSlug}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const GiftCardUpdateDetailsCard: React.FC = () => {
const { loading, giftCard } = useGiftCardDetails();
const { openSetBalanceDialog } = useGiftCardUpdateDialogs();
const {
toggleValue,
toggleValues,
data: { tags },
formErrors,
} = useGiftCardUpdateForm();
Expand Down Expand Up @@ -52,7 +52,7 @@ const GiftCardUpdateDetailsCard: React.FC = () => {
error={formErrors?.tags}
name="tags"
values={tags}
toggleChange={toggleValue}
onChange={toggleValues}
/>
<CardSpacer />
<GiftCardUpdateExpirySelect />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import { giftCardTagInputMessages as messages } from "./messages";

interface GiftCardTagInputProps {
name: string;
toggleChange: FormChange;
onChange: FormChange;
values: Option[];
error: GiftCardBulkCreateFormError;
optional?: boolean;
loading?: boolean;
}

const GiftCardTagInput: React.FC<GiftCardTagInputProps> = ({
toggleChange,
onChange,
name,
values,
error,
Expand Down Expand Up @@ -63,7 +63,7 @@ const GiftCardTagInput: React.FC<GiftCardTagInputProps> = ({
}}
value={values}
options={choices}
onChange={toggleChange}
onChange={onChange}
fetchOptions={search}
/>
</Box>
Expand Down

0 comments on commit 047a4ff

Please sign in to comment.