Skip to content

Commit

Permalink
Get Beanie ID from API
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoumpierre committed Feb 4, 2025
1 parent 8ee6d5b commit f7da404
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/e2e-pw/utils/rest-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { config } from '../config/default';
const userEndpoint = '/wc/v3/customers';
const ordersEndpoint = '/wc/v3/orders';
const widgetEndpoint = '/wp/v2/widgets';
const productsEndpoint = '/wc/v3/products';

export type CustomerType = typeof config.users.customer;
export type AddressType = Omit<
Expand Down Expand Up @@ -157,10 +158,20 @@ class RestAPI {
async createOrder(): Promise< string > {
const client = this.getAdminClient();

const products = await client.get(
`${ productsEndpoint }?search=${ config.products.simple.name }`
);

if ( ! products.data || ! products.data.length ) {
throw new Error( 'No products found.' );
}

const [ product ] = products.data;

const order = await client.post( ordersEndpoint, {
line_items: [
{
product_id: 16,
product_id: product.id,
quantity: 1,
},
],
Expand Down

0 comments on commit f7da404

Please sign in to comment.