Merge pull request #30942 from woocommerce/fix/update-api-tests-package-lock

Update package lock files for API core tests to use Jest 25 instead of 27
This commit is contained in:
Ron Rennick 2021-10-15 11:36:33 -03:00 committed by GitHub
commit 7486c0540a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 2756 additions and 2364 deletions

1641
package-lock.json generated

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -46,7 +46,7 @@ describe('Orders API tests', () => {
it('can create an order', async () => {
const response = await ordersApi.create.order( order );
expect( response.statusCode ).toEqual( ordersApi.create.responseCode );
expect( response.status ).toEqual( ordersApi.create.responseCode );
expect( response.body.id ).toBeDefined();
orderId = response.body.id;
@ -57,7 +57,7 @@ describe('Orders API tests', () => {
it('can retrieve an order', async () => {
const response = await ordersApi.retrieve.order( orderId );
expect( response.statusCode ).toEqual( ordersApi.retrieve.responseCode );
expect( response.status ).toEqual( ordersApi.retrieve.responseCode );
expect( response.body.id ).toEqual( orderId );
});
@ -67,7 +67,7 @@ describe('Orders API tests', () => {
order.shipping = updatedCustomerShipping;
const response = await ordersApi.update.order( orderId, order );
expect( response.statusCode).toEqual( ordersApi.update.responseCode );
expect( response.status).toEqual( ordersApi.update.responseCode );
expect( response.body.billing ).toEqual( updatedCustomerBilling );
expect( response.body.shipping ).toEqual( updatedCustomerShipping );
@ -75,9 +75,9 @@ describe('Orders API tests', () => {
it('can permanently delete an order', async () => {
const response = await ordersApi.delete.order( orderId, true );
expect( response.statusCode ).toEqual( ordersApi.delete.responseCode );
expect( response.status ).toEqual( ordersApi.delete.responseCode );
const getOrderResponse = await ordersApi.retrieve.order( orderId );
expect( getOrderResponse.statusCode ).toEqual( 404 );
expect( getOrderResponse.status ).toEqual( 404 );
});
});

View File

@ -36,7 +36,7 @@ client = HTTPClientFactory.build( 'https://example.com' )
// You can then use the client to make API requests.
client.get( '/wc/v3/products' ).then( ( response ) => {
// Access the status code from the response.
response.statusCode;
response.status;
// Access the headers from the response.
response.headers;
// Access the data from the response, in this case, the products.

View File

@ -1,4 +1,3 @@
/* eslint-disable jest/no-export, jest/no-disabled-tests */
/**
* External dependencies
*/
@ -82,7 +81,7 @@ const runInitialStoreSettingsTest = () => {
.create();
const response = await client.get( '/wc/v3/products' );
expect( response.statusCode ).toBe( 200 );
expect( response.status ).toBe( 200 );
});
});
};

View File

@ -1,4 +1,3 @@
/* eslint-disable jest/no-export, jest/no-disabled-tests */
/**
* Internal dependencies
*/
@ -53,7 +52,7 @@ const runCouponApiTest = () => {
// Read coupon directly from API to compare.
const response = await client.get( `/wc/v3/coupons/${coupon.id}` );
expect( response.statusCode ).toBe( 200 );
expect( response.status ).toBe( 200 );
expect( response.data ).toEqual( expect.objectContaining( couponProperties ) );
});
@ -68,7 +67,7 @@ const runCouponApiTest = () => {
// Check the coupon response for the updated values.
const response = await client.get( `/wc/v3/coupons/${coupon.id}` );
expect( response.statusCode ).toBe( 200 );
expect( response.status ).toBe( 200 );
expect( response.data ).toEqual( expect.objectContaining( updatedCouponProperties ) );
});

View File

@ -1,4 +1,3 @@
/* eslint-disable jest/no-export, jest/no-disabled-tests */
/**
* Internal dependencies
*/
@ -54,7 +53,7 @@ const runExternalProductAPITest = () => {
// Read product directly from api.
const response = await client.get( `/wc/v3/products/${product.id}` );
expect( response.statusCode ).toBe( 200 );
expect( response.status ).toBe( 200 );
expect( response.data ).toEqual( expect.objectContaining( rawProperties ) );
});

View File

@ -1,4 +1,3 @@
/* eslint-disable jest/no-export, jest/no-disabled-tests */
/**
* Internal dependencies
*/
@ -67,7 +66,7 @@ const runGroupedProductAPITest = () => {
// Read product directly from api.
const response = await client.get( `/wc/v3/products/${product.id}` );
expect( response.statusCode ).toBe( 200 );
expect( response.status ).toBe( 200 );
expect( response.data ).toEqual( expect.objectContaining( rawProperties ) );
});

View File

@ -1,4 +1,3 @@
/* eslint-disable jest/no-export, jest/no-disabled-tests */
/**
* Internal dependencies
*/
@ -51,7 +50,7 @@ const runOrderApiTest = () => {
// Read order directly from API to compare.
const response = await client.get( `/wc/v3/orders/${order.id}` );
expect( response.statusCode ).toBe( 200 );
expect( response.status ).toBe( 200 );
expect( response.data ).toEqual( expect.objectContaining( orderProperties ) );
});
@ -65,7 +64,7 @@ const runOrderApiTest = () => {
// Check the order response for the updated values.
const response = await client.get( `/wc/v3/orders/${order.id}` );
expect( response.statusCode ).toBe( 200 );
expect( response.status ).toBe( 200 );
expect( response.data ).toEqual( expect.objectContaining( updatedOrderProperties ) );
});

View File

@ -1,8 +1,7 @@
/* eslint-disable jest/no-export, jest/no-disabled-tests */
/**
* Internal dependencies
*/
const { HTTPClientFactory, Coupon } = require( '@woocommerce/api' );
const { HTTPClientFactory } = require( '@woocommerce/api' );
/**
* External dependencies
@ -40,7 +39,7 @@ const runTelemetryAPITest = () => {
const response = await client
.post( `/wc-telemetry/tracker`, data )
.catch( err => {
expect( err.statusCode ).toBe( 400 );
expect( err.response.status ).toBe( 400 );
} );
expect( response ).toBeUndefined();
@ -53,7 +52,7 @@ const runTelemetryAPITest = () => {
version: '1.0',
})
expect( response.statusCode ).toBe( 200 );
expect( response.status ).toBe( 200 );
} );
} );
};

View File

@ -22,7 +22,14 @@ const orderStatus = [
['Refunded', 'wc-refunded'],
['Failed', 'wc-failed'],
];
const defaultOrder = config.get('orders.basicPaidOrder');
const defaultOrder = {
payment_method: 'cod',
billing: {
first_name: 'John',
last_name: 'Doe',
email: 'john.doe@example.com',
}
};
const runOrderStatusFiltersTest = () => {
describe('WooCommerce Orders > Filter Orders by Status', () => {

View File

@ -398,8 +398,8 @@ const batchCreateOrders = async (statuses) => {
// Set the request payload from the created orders.
// Then send the API request.
const payload = { create: orders };
const { statusCode } = await client.post(path, payload);
expect(statusCode).toEqual(200);
const response = await client.post(path, payload);
expect( response.status ).toEqual(200);
};
/**

View File

@ -63,7 +63,7 @@ export const withRestApi = {
};
const response = await client.put( onboardingProfileEndpoint, onboardingReset );
expect( response.statusCode ).toEqual( 200 );
expect( response.status ).toEqual( 200 );
},
/**
* Use api package to delete coupons.
@ -115,7 +115,7 @@ export const withRestApi = {
const path = 'wc/v3/shipping/zones';
const response = await client.post( path, { name: zoneName } );
expect(response.statusCode).toEqual(201);
expect(response.status).toEqual(201);
let zoneId = response.data.id;
// Select shipping zone location
@ -136,7 +136,7 @@ export const withRestApi = {
}
const locationResponse = await client.put( path + `/${zoneId}/locations`, zoneLocationPayload );
expect(locationResponse.statusCode).toEqual(200);
expect(locationResponse.status).toEqual(200);
// Add shipping zone method
let methodPayload = {
@ -144,7 +144,7 @@ export const withRestApi = {
}
const methodsResponse = await client.post( path + `/${zoneId}/methods`, methodPayload );
expect(methodsResponse.statusCode).toEqual(200);
expect(methodsResponse.status).toEqual(200);
let methodId = methodsResponse.data.id;
// Add in cost, if provided
@ -156,14 +156,14 @@ export const withRestApi = {
}
const costResponse = await client.put( path + `/${zoneId}/methods/${methodId}`, costPayload );
expect(costResponse.statusCode).toEqual(200);
expect(costResponse.status).toEqual(200);
}
// Add any additional zones, if provided
if (additionalZoneMethods.length > 0) {
for ( let z = 0; z < additionalZoneMethods.length; z++ ) {
let response = await client.post( path + `/${zoneId}/methods`, { method_id: additionalZoneMethods[z] } );
expect(response.statusCode).toEqual(200);
expect(response.status).toEqual(200);
}
}
},
@ -181,7 +181,7 @@ export const withRestApi = {
continue;
}
const response = await client.delete( shippingZoneEndpoint + `/${shippingZones.data[z].id}?force=true` );
expect( response.statusCode ).toBe( 200 );
expect( response.status ).toBe( 200 );
}
}
},
@ -195,7 +195,7 @@ export const withRestApi = {
if ( shippingClasses.data && shippingClasses.data.length ) {
for ( let c = 0; c < shippingClasses.data.length; c++ ) {
const response = await client.delete( shippingClassesEndpoint + `/${shippingClasses.data[c].id}?force=true` );
expect( response.statusCode ).toBe( 200 );
expect( response.status ).toBe( 200 );
}
}
},
@ -272,7 +272,7 @@ export const withRestApi = {
*/
updatePaymentGateway: async ( paymentGatewayId, payload = {} ) => {
const response = await client.put( `/wc/v3/payment_gateways/${paymentGatewayId}`, payload );
expect( response.statusCode ).toBe( 200 );
expect( response.status ).toBe( 200 );
},
/**
* Create a batch of orders using the "Batch Create Order" API endpoint.
@ -283,9 +283,8 @@ export const withRestApi = {
const path = '/wc/v3/orders/batch';
const payload = { create: orders };
const { statusCode } = await client.post(path, payload);
expect(statusCode).toEqual(200);
const response = await client.post(path, payload);
expect( response.status ).toEqual(200);
},
/**
* Get the current environment from the WooCommerce system status API.