Skip to content

Commit

Permalink
feat(react-notifications): add OverlappingPriceValidity and Overlappi…
Browse files Browse the repository at this point in the history
…ngStandalonePriceValidity error codes (#3517)

* fix: add missing message for `OverlappingStandalonePriceValidity` error code

* test: add cases for price related messages

* feat: add message for `OverlappingPriceValidity` error code

* fix: add changeset
  • Loading branch information
ragafus authored and Ddouglasz committed May 21, 2024
1 parent 68342b1 commit 0243abd
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/ten-buses-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-frontend/react-notifications': minor
'@commercetools-frontend/i18n': minor
---

Add messages for `OverlappingPriceValidity` and `OverlappingStandalonePriceValidity` error code
8 changes: 8 additions & 0 deletions packages/i18n/data/core.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@
"developer_comment": "User attempts to create a resource while having already reached the limit",
"string": "The project reached the limit for the resource. To add more resources delete existing ones or reach out to the administrator or contact customer support."
},
"ApiError.OverlappingPriceValidity": {
"developer_comment": "Returned when a given price validity period conflicts with an existing one",
"string": "Two prices have overlapping validity periods."
},
"ApiError.OverlappingPrices": {
"developer_comment": "",
"string": "Sorry, but a price with these details already exists. Please amend the price details so that they do not overlap with another price before saving."
},
"ApiError.OverlappingStandalonePriceValidity": {
"developer_comment": "Returned when a given standalone price validity period conflicts with an existing one",
"string": "Two standalone prices have overlapping validity periods."
},
"ApiError.PendingOperation": {
"developer_comment": "User tries to start a new process when one is already underway",
"string": "Sorry, but we are still processing the previous request. Please try again once it is complete."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,50 @@ describe('render', () => {
)
).toBeInTheDocument();
});
it('should show message for DuplicatePriceScope', () => {
const error = {
extensions: { code: 'DuplicatePriceScope' },
message: 'message-content',
};
renderMessage(<ApiErrorMessage error={error} />);
expect(
screen.getByText(
'A price with the same scope already exists for this product variant. Make sure that the combination of currency, country, customer group, channel and valid dates is unique per price.'
)
).toBeInTheDocument();
});
it('should show message for DuplicateStandalonePriceScope', () => {
const error = {
extensions: { code: 'DuplicateStandalonePriceScope' },
message: 'message-content',
};
renderMessage(<ApiErrorMessage error={error} />);
expect(
screen.getByText(
'A price with the same scope already exists for this product variant. The combination of currency, country, customer group, channel and validity date must be unique for each price per SKU.'
)
).toBeInTheDocument();
});
it('should show message for OverlappingPriceValidity', () => {
const error = {
extensions: { code: 'OverlappingPriceValidity' },
message: 'message-content',
};
renderMessage(<ApiErrorMessage error={error} />);
expect(
screen.getByText('Two prices have overlapping validity periods.')
).toBeInTheDocument();
});
it('should show message for OverlappingStandalonePriceValidity', () => {
const error = {
extensions: { code: 'OverlappingStandalonePriceValidity' },
message: 'message-content',
};
renderMessage(<ApiErrorMessage error={error} />);
expect(
screen.getByText(
'Two standalone prices have overlapping validity periods.'
)
).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ export default defineMessages({
defaultMessage:
'Slugs may only contain alphanumeric (0-9A-Z) characters, underscores and hyphens and must have a length between 2 and 256 characters.',
},
OverlappingPriceValidity: {
id: 'ApiError.OverlappingPriceValidity',
description:
'Returned when a given price validity period conflicts with an existing one',
defaultMessage: 'Two prices have overlapping validity periods.',
},
OverlappingStandalonePriceValidity: {
id: 'ApiError.OverlappingStandalonePriceValidity',
description:
'Returned when a given standalone price validity period conflicts with an existing one',
defaultMessage: 'Two standalone prices have overlapping validity periods.',
},
PendingOperation: {
id: 'ApiError.PendingOperation',
description:
Expand Down

0 comments on commit 0243abd

Please sign in to comment.