Merge branch 'trunk' into e2e/e2e-merchant-search-orders
This commit is contained in:
commit
449f3809b4
|
@ -46,8 +46,6 @@ jobs:
|
|||
|
||||
- name: Load docker images and start containers.
|
||||
working-directory: package/woocommerce
|
||||
env:
|
||||
WP_VERSION: 5.6.2
|
||||
run: npx wc-e2e docker:up
|
||||
|
||||
- name: Move current directory to code. We will install zip file in this dir later.
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
|
@ -180,6 +180,7 @@ jQuery( function( $ ) {
|
|||
*/
|
||||
toggle_shipping: function() {
|
||||
$( '.shipping-calculator-form' ).slideToggle( 'slow' );
|
||||
$( 'select.country_to_state, input.country_to_state' ).trigger( 'change' );
|
||||
$( document.body ).trigger( 'country_to_state_changed' ); // Trigger select2 to load.
|
||||
return false;
|
||||
},
|
||||
|
|
|
@ -525,7 +525,7 @@ jQuery( function( $ ) {
|
|||
wc_checkout_form.detachUnloadEventsOnSubmit();
|
||||
|
||||
try {
|
||||
if ( 'success' === result.result && $form.triggerHandler( 'checkout_place_order_success' ) !== false ) {
|
||||
if ( 'success' === result.result && $form.triggerHandler( 'checkout_place_order_success', result ) !== false ) {
|
||||
if ( -1 === result.redirect.indexOf( 'https://' ) || -1 === result.redirect.indexOf( 'http://' ) ) {
|
||||
window.location = result.redirect;
|
||||
} else {
|
||||
|
|
|
@ -972,6 +972,8 @@ class WC_Checkout {
|
|||
|
||||
// Redirect to success/confirmation/payment page.
|
||||
if ( isset( $result['result'] ) && 'success' === $result['result'] ) {
|
||||
$result['order_id'] = $order_id;
|
||||
|
||||
$result = apply_filters( 'woocommerce_payment_successful_result', $result, $order_id );
|
||||
|
||||
if ( ! is_ajax() ) {
|
||||
|
|
|
@ -440,6 +440,8 @@ class WC_Form_Handler {
|
|||
|
||||
// Redirect to success/confirmation/payment page.
|
||||
if ( isset( $result['result'] ) && 'success' === $result['result'] ) {
|
||||
$result['order_id'] = $order_id;
|
||||
|
||||
$result = apply_filters( 'woocommerce_payment_successful_result', $result, $order_id );
|
||||
|
||||
wp_redirect( $result['redirect'] ); //phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
|
||||
|
|
|
@ -100,7 +100,7 @@ if ( ! class_exists( 'WC_Email_New_Order' ) ) :
|
|||
* Controls if new order emails can be resend multiple times.
|
||||
*
|
||||
* @since 5.0.0
|
||||
* @param bool $allows Defaults to true.
|
||||
* @param bool $allows Defaults to false.
|
||||
*/
|
||||
if ( 'true' === $email_already_sent && ! apply_filters( 'woocommerce_new_order_email_allows_resend', false ) ) {
|
||||
return;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
const {
|
||||
import { SimpleProduct } from '@woocommerce/api';
|
||||
import {
|
||||
visitAdminPage,
|
||||
switchUserToTest,
|
||||
clearLocalStorage,
|
||||
setBrowserViewport
|
||||
} = require( "@wordpress/e2e-test-utils" );
|
||||
setBrowserViewport,
|
||||
factories,
|
||||
} from '@woocommerce/e2e-utils';
|
||||
|
||||
const { merchant } = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
|
@ -37,32 +39,21 @@ async function trashExistingPosts() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Navigates to the product listing screen and bulk-trashes any product which exist.
|
||||
* Use api package to delete products.
|
||||
*
|
||||
* @return {Promise} Promise resolving once products have been trashed.
|
||||
*/
|
||||
async function trashExistingProducts() {
|
||||
await merchant.login();
|
||||
// Visit `/wp-admin/edit.php?post_type=product` so we can see a list of products and delete them.
|
||||
await visitAdminPage( 'edit.php', 'post_type=product' );
|
||||
async function deleteAllProducts() {
|
||||
const repository = SimpleProduct.restRepository( factories.api.withDefaultPermalinks );
|
||||
let products;
|
||||
|
||||
// If this selector doesn't exist there are no products for us to delete.
|
||||
const bulkSelector = await page.$( '#bulk-action-selector-top' );
|
||||
if ( ! bulkSelector ) {
|
||||
return;
|
||||
products = await repository.list();
|
||||
while ( products.length > 0 ) {
|
||||
for( let p = 0; p < products.length; p++ ) {
|
||||
await repository.delete( products[ p ].id );
|
||||
}
|
||||
products = await repository.list();
|
||||
}
|
||||
|
||||
// Select all products.
|
||||
await page.waitForSelector( '#cb-select-all-1' );
|
||||
await page.click( '#cb-select-all-1' );
|
||||
// Select the "bulk actions" > "trash" option.
|
||||
await page.select( '#bulk-action-selector-top', 'trash' );
|
||||
// Submit the form to send all draft/scheduled/published posts to the trash.
|
||||
await page.click( '#doaction' );
|
||||
await page.waitForXPath(
|
||||
'//*[contains(@class, "updated notice")]/p[contains(text(), "moved to the Trash.")]'
|
||||
);
|
||||
await switchUserToTest();
|
||||
}
|
||||
|
||||
// Before every test suite run, delete all content created by the test. This ensures
|
||||
|
@ -70,8 +61,7 @@ async function trashExistingProducts() {
|
|||
// each other's side-effects.
|
||||
beforeAll( async () => {
|
||||
await trashExistingPosts();
|
||||
await trashExistingProducts();
|
||||
await switchUserToTest();
|
||||
await deleteAllProducts();
|
||||
await clearLocalStorage();
|
||||
await setBrowserViewport( 'large' );
|
||||
} );
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"url": "http://localhost:8084/",
|
||||
"appName": "woocommerce_e2e",
|
||||
"users": {
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
|
@ -12,8 +13,7 @@
|
|||
},
|
||||
"products": {
|
||||
"simple": {
|
||||
"name": "Simple product",
|
||||
"price": "9.99"
|
||||
"name": "Simple product"
|
||||
},
|
||||
"variable": {
|
||||
"name": "Variable Product with Three Variations"
|
||||
|
|
|
@ -52,6 +52,10 @@ services:
|
|||
WORDPRESS_LOGIN: ${WORDPRESS_LOGIN}
|
||||
WORDPRESS_PASSWORD: ${WORDPRESS_PASSWORD}
|
||||
WORDPRESS_EMAIL: "${WORDPRESS_EMAIL}"
|
||||
WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST}
|
||||
WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME}
|
||||
WORDPRESS_DB_USER: ${WORDPRESS_DB_USER}
|
||||
WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}
|
||||
DOMAIN_NAME:
|
||||
|
||||
volumes:
|
||||
|
|
|
@ -1,15 +1,25 @@
|
|||
import { HTTPClientFactory } from '@woocommerce/api';
|
||||
const config = require( 'config' );
|
||||
|
||||
const httpClient = HTTPClientFactory.build( config.get( 'url' ) )
|
||||
.withBasicAuth( config.get( 'users.admin.username' ), config.get( 'users.admin.password' ) )
|
||||
.create();
|
||||
|
||||
import { simpleProductFactory } from './factories/simple-product';
|
||||
|
||||
const apiUrl = config.get( 'url' );
|
||||
const adminUsername = config.get( 'users.admin.username' );
|
||||
const adminPassword = config.get( 'users.admin.password' );
|
||||
const withDefaultPermalinks = HTTPClientFactory.build( apiUrl )
|
||||
.withBasicAuth( adminUsername, adminPassword )
|
||||
.create();
|
||||
const withIndexPermalinks = HTTPClientFactory.build( apiUrl )
|
||||
.withBasicAuth( adminUsername, adminPassword )
|
||||
.withIndexPermalinks()
|
||||
.create();
|
||||
|
||||
const factories = {
|
||||
api: {
|
||||
withDefaultPermalinks,
|
||||
withIndexPermalinks,
|
||||
},
|
||||
products: {
|
||||
simple: simpleProductFactory( httpClient ),
|
||||
simple: simpleProductFactory( withDefaultPermalinks ),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ export * from '@wordpress/e2e-test-utils';
|
|||
/*
|
||||
* Internal dependencies
|
||||
*/
|
||||
import factories from './factories';
|
||||
export { factories };
|
||||
export * from './flows';
|
||||
export * from './old-flows';
|
||||
export * from './components';
|
||||
export * from './page-utils';
|
||||
|
||||
|
|
Loading…
Reference in New Issue