-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing order attribution metadata when using ECE (#3629)
* Fix missing order attribution metadata when using ECE * Adding order attribution fields to block checkout * Adding order attribution fields to PRB * Add order attribution data to ECE * Adding inputs only when they don't exist * Moving logic to a new method * Fix order attribution for PRB * Move method to shared file * Moving order attribution inputs creation to a shared trait * Fix include * Fix data not being sent for shortcode PRB * Removing unnecessary trait * Changelog and readme entries * Reverting unnecessary changes * Reverting unnecessary changes * Adding specific unit tests * Adding specific unit tests * Adding specific unit tests * Fix block checkout attribution
- Loading branch information
Showing
11 changed files
with
192 additions
and
5 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
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,46 @@ | ||
import { render } from '@testing-library/react'; | ||
import { | ||
extractOrderAttributionData, | ||
populateOrderAttributionInputs, | ||
} from 'wcstripe/blocks/utils'; | ||
|
||
describe( 'Blocks Utils', () => { | ||
describe( 'extractOrderAttributionData', () => { | ||
it( 'order attribution wrapper not found', () => { | ||
const data = extractOrderAttributionData(); | ||
expect( data ).toStrictEqual( {} ); | ||
} ); | ||
|
||
it( 'order attribution wrapper exists', () => { | ||
render( | ||
<wc-order-attribution-inputs> | ||
<input name="foo" defaultValue="bar" /> | ||
<input name="baz" defaultValue="qux" /> | ||
</wc-order-attribution-inputs> | ||
); | ||
|
||
const data = extractOrderAttributionData(); | ||
expect( data ).toStrictEqual( { | ||
foo: 'bar', | ||
baz: 'qux', | ||
} ); | ||
} ); | ||
} ); | ||
|
||
describe( 'populateOrderAttributionInputs', () => { | ||
test( 'order attribution global present', () => { | ||
global.wc_order_attribution = { | ||
params: { | ||
allowTracking: true, | ||
}, | ||
setOrderTracking: jest.fn(), | ||
}; | ||
|
||
populateOrderAttributionInputs(); | ||
|
||
expect( | ||
global.wc_order_attribution.setOrderTracking | ||
).toHaveBeenCalledWith( true ); | ||
} ); | ||
} ); | ||
} ); |
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
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