Update statusCode to status

This commit is contained in:
Greg 2021-10-14 15:45:39 -06:00
parent 2663eb1955
commit 7fe341f144
11 changed files with 48 additions and 60 deletions

41
package-lock.json generated
View File

@ -5638,10 +5638,7 @@
"@types/moxios": {
"version": "0.4.9",
"resolved": "https://registry.npmjs.org/@types/moxios/-/moxios-0.4.9.tgz",
"integrity": "sha512-Sd1b24QRW2N194j2LEDPQAZK1h0TBtpN+2EIH+rERCgm38qm14JZwC7NlpE7n3jULhlCIPZBG8uNcbjF8KcCaQ==",
"requires": {
"axios": "^0.19.0"
}
"integrity": "sha512-Sd1b24QRW2N194j2LEDPQAZK1h0TBtpN+2EIH+rERCgm38qm14JZwC7NlpE7n3jULhlCIPZBG8uNcbjF8KcCaQ=="
},
"@types/node": {
"version": "13.13.5",
@ -5833,11 +5830,12 @@
"integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA=="
},
"axios": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz",
"integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.2.tgz",
"integrity": "sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==",
"dev": true,
"requires": {
"follow-redirects": "1.5.10"
"follow-redirects": "^1.14.0"
}
},
"babel-jest": {
@ -6289,10 +6287,7 @@
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g=="
},
"decamelize": {
"version": "1.2.0",
@ -6477,10 +6472,7 @@
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA=="
},
"define-property": {
"version": "0.2.5",
@ -6642,12 +6634,10 @@
}
},
"follow-redirects": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
"requires": {
"debug": "=3.1.0"
}
"version": "1.14.4",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz",
"integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==",
"dev": true
},
"for-in": {
"version": "1.0.2",
@ -8659,10 +8649,7 @@
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA=="
},
"define-property": {
"version": "0.2.5",
@ -9778,7 +9765,7 @@
}
},
"prettier": {
"version": "npm:prettier@1.19.1",
"version": "npm:wp-prettier@1.19.1",
"resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-1.19.1.tgz",
"integrity": "sha512-mqAC2r1NDmRjG+z3KCJ/i61tycKlmADIjxnDhQab+KBxSAGbF/W7/zwB2guy/ypIeKrrftNsIYkNZZQKf3vJcg==",
"dev": true

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

@ -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.