-
Notifications
You must be signed in to change notification settings - Fork 176
fix(twap): label open orders as unfillable when Safe fallback handler is reset #7802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tenderdeve
wants to merge
10
commits into
cowprotocol:develop
Choose a base branch
from
tenderdeve:fix/5426-twap-unfillable-handler
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f0a7af1
fix(twap): label open orders as unfillable when Safe fallback handler…
tenderdeve 4b3f47f
fix(twap): show unfillable order in Unfillable tab and Fills-at column
tenderdeve 8dfe4b6
Merge branch 'develop' into fix/5426-twap-unfillable-handler
elena-zh e44a66c
fix(twap): show unfillable reason and failure design for reset fallba…
tenderdeve d38b7f0
Merge branch 'develop' into fix/5426-twap-unfillable-handler
elena-zh 6db4785
fix(twap): surface fallback-handler warning on parent TWAP status badge
tenderdeve b4aafd1
Merge branch 'develop' into fix/5426-twap-unfillable-handler
elena-zh 7847dfe
refactor(twap): resolve fallback-handler unfillable in the view layer
tenderdeve 1b9ad33
Merge remote-tracking branch 'upstream/develop' into fix/5426-twap-un…
tenderdeve 94656aa
Merge branch 'develop' into fix/5426-twap-unfillable-handler
elena-zh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
65 changes: 65 additions & 0 deletions
65
.../ordersTable/pure/OrderEstimatedExecutionPrice/OrderEstimatedExecutionPrice.pure.test.tsx
This file contains hidden or 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,65 @@ | ||
| import { ReactNode } from 'react' | ||
|
|
||
| import { i18n } from '@lingui/core' | ||
| import { I18nProvider } from '@lingui/react' | ||
| import { fireEvent, render, screen } from '@testing-library/react' | ||
|
|
||
| import { UPDATE_FALLBACK_HANDLER_WARNING } from './orderEstimatedExecutionPrice.constants' | ||
| import { OrderEstimatedExecutionPrice } from './OrderEstimatedExecutionPrice.pure' | ||
|
|
||
| jest.mock('react-inlinesvg', () => { | ||
| return function MockSvg() { | ||
| return <svg /> | ||
| } | ||
| }) | ||
|
|
||
| function renderWithI18n(ui: ReactNode): ReturnType<typeof render> { | ||
| return render(<I18nProvider i18n={i18n}>{ui}</I18nProvider>) | ||
| } | ||
|
|
||
| beforeAll(() => { | ||
| window.matchMedia = | ||
| window.matchMedia || | ||
| (() => | ||
| ({ | ||
| matches: false, | ||
| addEventListener: () => undefined, | ||
| removeEventListener: () => undefined, | ||
| addListener: () => undefined, | ||
| removeListener: () => undefined, | ||
| }) as unknown as MediaQueryList) | ||
| }) | ||
|
|
||
| describe('OrderEstimatedExecutionPrice() – fallback handler warning', () => { | ||
| it('renders the "Update fallback handler" reason label', () => { | ||
| renderWithI18n( | ||
| <OrderEstimatedExecutionPrice | ||
| amount={undefined} | ||
| tokenSymbol={undefined} | ||
| isInverted={false} | ||
| isUnfillable={true} | ||
| canShowWarning={true} | ||
| warningText={UPDATE_FALLBACK_HANDLER_WARNING} | ||
| />, | ||
| ) | ||
|
|
||
| expect(screen.getByText('Update fallback handler')).not.toBeNull() | ||
| }) | ||
|
|
||
| it('reveals the fallback handler explanation on hover', async () => { | ||
| renderWithI18n( | ||
| <OrderEstimatedExecutionPrice | ||
| amount={undefined} | ||
| tokenSymbol={undefined} | ||
| isInverted={false} | ||
| isUnfillable={true} | ||
| canShowWarning={true} | ||
| warningText={UPDATE_FALLBACK_HANDLER_WARNING} | ||
| />, | ||
| ) | ||
|
|
||
| fireEvent.mouseEnter(screen.getByText('Update fallback handler')) | ||
|
|
||
| expect(await screen.findByText(/Your Safe fallback handler was changed/i)).not.toBeNull() | ||
| }) | ||
| }) |
This file contains hidden or 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
3 changes: 3 additions & 0 deletions
3
...s/ordersTable/pure/OrderEstimatedExecutionPrice/orderEstimatedExecutionPrice.constants.ts
This file contains hidden or 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,3 @@ | ||
| // warningText flag (not internationalized on purpose, matches the other flags): an open TWAP order | ||
| // whose Safe ComposableCoW fallback handler was reset can no longer be created (see issue #5426). | ||
| export const UPDATE_FALLBACK_HANDLER_WARNING = 'Update fallback handler' |
This file contains hidden or 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
65 changes: 65 additions & 0 deletions
65
...wswap-frontend/src/modules/ordersTable/pure/TwapOrderStatus/TwapOrderStatus.pure.test.tsx
This file contains hidden or 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,65 @@ | ||
| import { render, screen } from '@testing-library/react' | ||
|
|
||
| import { OrderStatus } from 'legacy/state/orders/actions' | ||
|
|
||
| import { ParsedOrder } from 'utils/orderUtils/parseOrder' | ||
|
|
||
| import { TwapOrderStatus } from './TwapOrderStatus.pure' | ||
|
|
||
| jest.mock('react-inlinesvg', () => { | ||
| return function MockSvg() { | ||
| return <svg /> | ||
| } | ||
| }) | ||
|
|
||
| beforeAll(() => { | ||
| window.matchMedia = | ||
| window.matchMedia || | ||
| (() => | ||
| ({ | ||
| matches: false, | ||
| addEventListener: () => undefined, | ||
| removeEventListener: () => undefined, | ||
| addListener: () => undefined, | ||
| removeListener: () => undefined, | ||
| }) as unknown as MediaQueryList) | ||
| }) | ||
|
|
||
| function childOrder(overrides: Partial<ParsedOrder>): ParsedOrder { | ||
| return { | ||
| status: OrderStatus.SCHEDULED, | ||
| isUnfillable: false, | ||
| executionData: { filledPercentDisplay: '0' }, | ||
| ...overrides, | ||
| } as unknown as ParsedOrder | ||
| } | ||
|
|
||
| describe('TwapOrderStatus()', () => { | ||
| it('shows the "Update fallback handler" reason when an open part is unfillable', () => { | ||
| render( | ||
| <TwapOrderStatus | ||
| orderStatus={OrderStatus.PENDING} | ||
| childOrders={[childOrder({ status: OrderStatus.PENDING, isUnfillable: true })]} | ||
| > | ||
| fallback children | ||
| </TwapOrderStatus>, | ||
| ) | ||
|
|
||
| expect(screen.getByText('Update fallback handler')).not.toBeNull() | ||
| expect(screen.queryByText('fallback children')).toBeNull() | ||
| }) | ||
|
|
||
| it('renders the passed children when no part is unfillable', () => { | ||
| render( | ||
| <TwapOrderStatus | ||
| orderStatus={OrderStatus.PENDING} | ||
| childOrders={[childOrder({ status: OrderStatus.PENDING, isUnfillable: false })]} | ||
| > | ||
| fallback children | ||
| </TwapOrderStatus>, | ||
| ) | ||
|
|
||
| expect(screen.queryByText('Update fallback handler')).toBeNull() | ||
| expect(screen.getByText('fallback children')).not.toBeNull() | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.