-
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 merx-1310-add-source-header
- Loading branch information
Showing
12 changed files
with
256 additions
and
4 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 | ||
--- | ||
|
||
Added switch focus using tab button, that may delay saving before input is filled. |
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 | ||
--- | ||
|
||
Now category and subcategories show proper description |
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 | ||
--- | ||
|
||
You can now close order manual transaction modal by clicking the close button |
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 | ||
--- | ||
|
||
Add GitHub Workflow to check licenses |
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,48 @@ | ||
name: Check Licenses | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
# Labels are needed to handle external contributors | ||
- labeled | ||
- unlabeled | ||
paths: | ||
# Self | ||
- ".github/workflows/check-licenses.yaml" | ||
# Python Ecosystem | ||
- "**/pyproject.toml" | ||
- "**/setup.py" | ||
- "**/requirements*.txt" | ||
- "**/Pipfile.lock" | ||
- "**/poetry.lock" | ||
# JS/TS Ecosystem | ||
- "**/package.json" | ||
- "**/pnpm-lock.yaml" | ||
- "**/package-lock.json" | ||
|
||
jobs: | ||
default: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
uses: saleor/saleor-internal-actions/.github/workflows/run-license-check.yaml@v1 | ||
with: | ||
# List of ecosystems to scan. | ||
ecosystems: >- | ||
python | ||
javascript | ||
# Grant rules (https://github.com/anchore/grant/blob/4362dc22cf5ea9baeccfa59b2863879afe0c30d7/README.md#usage) | ||
rules: | | ||
# Explicitly allow LGPL as "*GPL*" rule will cause to reject them otherwise. | ||
- pattern: "*lgpl*" | ||
name: "allow-lgpl" | ||
mode: "allow" | ||
reason: "LGPL is allowed." | ||
- pattern: "*gpl*" | ||
name: "deny-gpl" | ||
mode: "deny" | ||
reason: "GPL licenses are not compatible with BSD-3-Clause" | ||
- pattern: "*proprietary*" | ||
name: "deny-proprietary" | ||
mode: "deny" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { renderHook } from "@testing-library/react-hooks"; | ||
|
||
import { useUpdateOnRerender } from "./hooks"; | ||
|
||
describe("useUpdateOnRerender", () => { | ||
it("should call render when defaultValue changes after initial render", () => { | ||
// Arrange | ||
const mockRender = jest.fn(); | ||
|
||
const { rerender } = renderHook( | ||
({ render, defaultValue, hasRendered }) => | ||
useUpdateOnRerender({ render, defaultValue, hasRendered }), | ||
{ | ||
initialProps: { | ||
render: mockRender, | ||
defaultValue: { blocks: [{ type: "paragraph", data: { text: "Initial" } }] }, | ||
hasRendered: true, | ||
}, | ||
}, | ||
); | ||
|
||
// Act | ||
rerender({ | ||
render: mockRender, | ||
defaultValue: { blocks: [{ type: "paragraph", data: { text: "Updated" } }] }, | ||
hasRendered: true, | ||
}); | ||
|
||
// Assert | ||
expect(mockRender).toHaveBeenCalledWith({ | ||
blocks: [{ type: "paragraph", data: { text: "Updated" } }], | ||
}); | ||
}); | ||
|
||
it("should call render once when defaultValue change", () => { | ||
// Arrange | ||
const mockRender = jest.fn(); | ||
|
||
const { rerender } = renderHook( | ||
({ render, defaultValue, hasRendered }) => | ||
useUpdateOnRerender({ render, defaultValue, hasRendered }), | ||
{ | ||
initialProps: { | ||
render: mockRender, | ||
defaultValue: { blocks: [{ type: "paragraph", data: { text: "Initial" } }] }, | ||
hasRendered: false, | ||
}, | ||
}, | ||
); | ||
|
||
// Act | ||
rerender({ | ||
render: mockRender, | ||
defaultValue: { blocks: [{ type: "paragraph", data: { text: "Initial" } }] }, | ||
hasRendered: true, | ||
}); | ||
rerender({ | ||
render: mockRender, | ||
defaultValue: { blocks: [{ type: "paragraph", data: { text: "Initial" } }] }, | ||
hasRendered: true, | ||
}); | ||
|
||
// Assert | ||
expect(mockRender).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it("should not call render if hasRendered is false", () => { | ||
// Arrange | ||
const mockRender = jest.fn(); | ||
|
||
const { rerender } = renderHook( | ||
({ render, defaultValue, hasRendered }) => | ||
useUpdateOnRerender({ render, defaultValue, hasRendered }), | ||
{ | ||
initialProps: { | ||
render: mockRender, | ||
defaultValue: { blocks: [{ type: "paragraph", data: { text: "Initial" } }] }, | ||
hasRendered: false, | ||
}, | ||
}, | ||
); | ||
|
||
// Act | ||
rerender({ | ||
render: mockRender, | ||
defaultValue: { blocks: [{ type: "paragraph", data: { text: "Updated" } }] }, | ||
hasRendered: false, | ||
}); | ||
|
||
// Assert | ||
expect(mockRender).not.toHaveBeenCalled(); | ||
}); | ||
}); |
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
41 changes: 41 additions & 0 deletions
41
src/orders/components/OrderManualTransactionDialog/OrderManualTransactionDialog.test.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { act, render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import React from "react"; | ||
|
||
import { OrderManualTransactionDialog } from "./OrderManualTransactionDialog"; | ||
|
||
jest.mock("react-intl", () => ({ | ||
useIntl: jest.fn(() => ({ | ||
formatMessage: jest.fn(x => x.defaultMessage), | ||
})), | ||
defineMessages: jest.fn(x => x), | ||
FormattedMessage: ({ defaultMessage }: { defaultMessage: string }) => <>{defaultMessage}</>, | ||
})); | ||
|
||
describe("OrderManualTransactionDialog", () => { | ||
it("should call onClose when click in close button", async () => { | ||
// Arrange | ||
const onClose = jest.fn(); | ||
|
||
render( | ||
<OrderManualTransactionDialog | ||
error={undefined} | ||
dialogProps={{ | ||
open: true, | ||
onClose, | ||
}} | ||
submitState="default" | ||
currency="USD" | ||
onAddTransaction={jest.fn()} | ||
/>, | ||
); | ||
|
||
// Act | ||
await act(async () => { | ||
await userEvent.click(screen.getByTestId("close-button")); | ||
}); | ||
|
||
// Assert | ||
expect(onClose).toHaveBeenCalled(); | ||
}); | ||
}); |
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