-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into tests-for-setting-balance-and-exporting-gift…
…-cards
- Loading branch information
Showing
16 changed files
with
276 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"saleor-dashboard": patch | ||
--- | ||
|
||
Fix variant availability |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"saleor-dashboard": patch | ||
--- | ||
|
||
Fix action that configures login to staging Saleor Cloud for CLI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 23 additions & 8 deletions
31
src/products/components/ProductVariantChannels/ChannelsAvailabilityCard/AvailabilityCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
...ucts/components/ProductVariantChannels/ChannelsAvailabilityCard/availabilityCount.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
import { | ||
ChannelPriceAndPreorderData, | ||
IChannelPriceAndPreorderArgs, | ||
} from "@dashboard/channels/utils"; | ||
import { | ||
ProductVariantCreateDataQuery, | ||
ProductVariantFragment, | ||
} from "@dashboard/graphql"; | ||
import { FormsetData } from "@dashboard/hooks/useFormset"; | ||
|
||
import { | ||
getAvailabilityCountForProduct, | ||
getAvailabilityCountForVariant, | ||
} from "./availabilityCount"; | ||
|
||
const mockedListings = [ | ||
{ | ||
id: "1", | ||
label: "Channel-PLN", | ||
}, | ||
{ | ||
id: "2", | ||
label: "Channel-USD", | ||
}, | ||
] as unknown as FormsetData< | ||
ChannelPriceAndPreorderData, | ||
IChannelPriceAndPreorderArgs | ||
>; | ||
|
||
const mockedVariant = { | ||
product: { | ||
channelListings: [ | ||
{ | ||
channel: { id: "1" }, | ||
isPublished: true, | ||
}, | ||
{ | ||
channel: { id: "2" }, | ||
isPublished: true, | ||
}, | ||
], | ||
}, | ||
} as unknown as ProductVariantFragment; | ||
|
||
const mockedProduct = { | ||
channelListings: [ | ||
{ | ||
channel: { id: "1" }, | ||
isPublished: true, | ||
}, | ||
{ | ||
channel: { id: "2" }, | ||
isPublished: true, | ||
}, | ||
], | ||
} as unknown as ProductVariantCreateDataQuery["product"]; | ||
|
||
describe("getAvailabilityCountForVariant", () => { | ||
it("should return correct counts when all channels are selected", () => { | ||
// Arrange | ||
const item = mockedVariant; | ||
const listings = mockedListings; | ||
|
||
// Act | ||
const result = getAvailabilityCountForVariant(item, listings); | ||
|
||
// Assert | ||
expect(result).toEqual({ | ||
publishedInChannelsCount: 2, | ||
availableChannelsCount: 2, | ||
}); | ||
}); | ||
|
||
it("should return correct counts when some channels are selected", () => { | ||
// Arrange | ||
const item = mockedVariant; | ||
const listings = mockedListings.slice(0, 1); | ||
|
||
// Act | ||
const result = getAvailabilityCountForVariant(item, listings); | ||
|
||
// Assert | ||
expect(result).toEqual({ | ||
publishedInChannelsCount: 1, | ||
availableChannelsCount: 2, | ||
}); | ||
}); | ||
|
||
it("should return correct counts when no channels are available", () => { | ||
// Arrange | ||
const item = mockedVariant; | ||
const listings = [] as FormsetData< | ||
ChannelPriceAndPreorderData, | ||
IChannelPriceAndPreorderArgs | ||
>; | ||
|
||
// Act | ||
const result = getAvailabilityCountForVariant(item, listings); | ||
|
||
// Assert | ||
expect(result).toEqual({ | ||
publishedInChannelsCount: 0, | ||
availableChannelsCount: 2, | ||
}); | ||
}); | ||
}); | ||
|
||
describe("getAvailabilityCountForProduct", () => { | ||
it("should return correct counts when all channels are selected", () => { | ||
// Arrange | ||
const item = mockedProduct; | ||
const listings = mockedListings; | ||
|
||
// Act | ||
const result = getAvailabilityCountForProduct(item, listings); | ||
|
||
// Assert | ||
expect(result).toEqual({ | ||
publishedInChannelsCount: 2, | ||
availableChannelsCount: 2, | ||
}); | ||
}); | ||
|
||
it("should return correct counts when some channels are selected", () => { | ||
// Arrange | ||
const item = mockedProduct; | ||
const listings = mockedListings.slice(0, 1); | ||
|
||
// Act | ||
const result = getAvailabilityCountForProduct(item, listings); | ||
|
||
// Assert | ||
expect(result).toEqual({ | ||
publishedInChannelsCount: 1, | ||
availableChannelsCount: 2, | ||
}); | ||
}); | ||
|
||
it("should return correct counts when no channels are available", () => { | ||
// Arrange | ||
const item = mockedProduct; | ||
const listings = [] as FormsetData< | ||
ChannelPriceAndPreorderData, | ||
IChannelPriceAndPreorderArgs | ||
>; | ||
|
||
// Act | ||
const result = getAvailabilityCountForProduct(item, listings); | ||
|
||
// Assert | ||
expect(result).toEqual({ | ||
publishedInChannelsCount: 0, | ||
availableChannelsCount: 2, | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.