-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into add/9826-payment-methods-logos-component
- Loading branch information
Showing
36 changed files
with
1,089 additions
and
520 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,4 @@ | ||
Significance: minor | ||
Type: add | ||
|
||
Show Bank reference key on top of the payout details page, whenever available. |
4 changes: 4 additions & 0 deletions
4
changelog/dev-10063-playwright-migration-shopper-checkout-purchase-site-editor
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,4 @@ | ||
Significance: patch | ||
Type: dev | ||
|
||
Convert shopper checkout with site editor theme spec to Playwright |
4 changes: 4 additions & 0 deletions
4
changelog/dev-9964-playwright-migration-order-refund-failures
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,4 @@ | ||
Significance: patch | ||
Type: dev | ||
|
||
Convert order refund failure E2E tests to Playwright |
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,4 @@ | ||
Significance: patch | ||
Type: dev | ||
|
||
Refresh customer instance with REST API, replace customer creation by new order with anonymous customer |
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,4 @@ | ||
Significance: patch | ||
Type: fix | ||
|
||
Prevent potential fatal when initializing the WooPay express checkout 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,50 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React, { useState } from 'react'; | ||
import { __ } from '@wordpress/i18n'; | ||
import classNames from 'classnames'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
|
||
interface CopyButtonProps { | ||
/** | ||
* The text to copy to the clipboard. | ||
*/ | ||
textToCopy: string; | ||
|
||
/** | ||
* The label for the button. Also used as the aria-label. | ||
*/ | ||
label: string; | ||
} | ||
|
||
export const CopyButton: React.FC< CopyButtonProps > = ( { | ||
textToCopy, | ||
label, | ||
} ) => { | ||
const [ copied, setCopied ] = useState( false ); | ||
|
||
const copyToClipboard = () => { | ||
navigator.clipboard.writeText( textToCopy ); | ||
setCopied( true ); | ||
}; | ||
|
||
return ( | ||
<button | ||
type="button" | ||
className={ classNames( 'woopayments-copy-button', { | ||
'state--copied': copied, | ||
} ) } | ||
aria-label={ label } | ||
title={ __( 'Copy to clipboard', 'woocommerce-payments' ) } | ||
onClick={ copyToClipboard } | ||
onAnimationEnd={ () => setCopied( false ) } | ||
> | ||
<i></i> | ||
</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,51 @@ | ||
.woopayments-copy-button { | ||
line-height: 1.2em; | ||
display: inline-flex; | ||
background: transparent; | ||
border: none; | ||
border-radius: 0; | ||
vertical-align: middle; | ||
font-weight: normal; | ||
cursor: pointer; | ||
color: inherit; | ||
margin-left: 2px; | ||
align-items: center; | ||
|
||
i { | ||
display: block; | ||
width: 1.2em; | ||
height: 1.2em; | ||
mask-image: url( 'assets/images/icons/copy.svg?asset' ); | ||
mask-size: contain; | ||
mask-repeat: no-repeat; | ||
mask-position: center; | ||
background-color: currentColor; | ||
|
||
&:hover { | ||
opacity: 0.7; | ||
} | ||
|
||
&:active { | ||
transform: scale( 0.9 ); | ||
} | ||
} | ||
|
||
&.state--copied i { | ||
mask-image: url( 'assets/images/icons/check-green.svg?asset' ); | ||
background-color: $studio-green-50; | ||
animation: copy-indicator 2s forwards; | ||
} | ||
|
||
@keyframes copy-indicator { | ||
0% { | ||
opacity: 1; | ||
} | ||
95% { | ||
opacity: 1; | ||
} | ||
// a quick fade-out from 1%→0% at the end | ||
100% { | ||
opacity: 0; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
client/components/copy-button/test/__snapshots__/index.test.tsx.snap
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,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`CopyButton renders the button correctly 1`] = ` | ||
<div> | ||
<button | ||
aria-label="Copy bank reference ID to clipboard" | ||
class="woopayments-copy-button" | ||
title="Copy to clipboard" | ||
type="button" | ||
> | ||
<i /> | ||
</button> | ||
</div> | ||
`; |
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,67 @@ | ||
/** @format **/ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import { act, fireEvent, render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { CopyButton } from '..'; | ||
|
||
describe( 'CopyButton', () => { | ||
it( 'renders the button correctly', () => { | ||
const { container: copyButtonContainer } = render( | ||
<CopyButton | ||
textToCopy="test_bank_reference_id" | ||
label="Copy bank reference ID to clipboard" | ||
/> | ||
); | ||
|
||
expect( copyButtonContainer ).toMatchSnapshot(); | ||
} ); | ||
|
||
describe( 'when the button is clicked', () => { | ||
it( 'copies the text to the clipboard and shows copied state', async () => { | ||
render( | ||
<CopyButton | ||
textToCopy="test_bank_reference_id" | ||
label="Copy bank reference ID to clipboard" | ||
/> | ||
); | ||
|
||
const button = screen.queryByRole( 'button', { | ||
name: /Copy bank reference ID to clipboard/i, | ||
} ); | ||
|
||
if ( ! button ) { | ||
throw new Error( 'Button not found' ); | ||
} | ||
|
||
//Mock the clipboard API | ||
Object.assign( navigator, { | ||
clipboard: { | ||
writeText: jest.fn().mockResolvedValueOnce( undefined ), | ||
}, | ||
} ); | ||
|
||
await act( async () => { | ||
fireEvent.click( button ); | ||
} ); | ||
|
||
expect( navigator.clipboard.writeText ).toHaveBeenCalledWith( | ||
'test_bank_reference_id' | ||
); | ||
expect( button ).toHaveClass( 'state--copied' ); | ||
|
||
act( () => { | ||
fireEvent.animationEnd( button ); | ||
} ); | ||
|
||
expect( button ).not.toHaveClass( 'state--copied' ); | ||
} ); | ||
} ); | ||
} ); |
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
Oops, something went wrong.