- Add subuser ID management to `selfserve_lane_command_arguments`. - Update `invoice` function to include optional command arguments. - Attach metadata to orders with self-serve and subuser details. - Introduce `OTHER_TYPE_SELF_SERVE_WASH` in `attachment_content`.
114 lines
3.7 KiB
PHP
114 lines
3.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
usesApiSuite();
|
|
|
|
it('requires notes when adding the extraordinary chemistry product to an order', function (): void {
|
|
api_test_covers('POST /order/items', 'validation');
|
|
|
|
$customer = api_fixtures()->createUser(['display_name' => 'Order Item Customer']);
|
|
$department = api_fixtures()->createDepartment();
|
|
$order = api_fixtures()->createOrder([
|
|
'customer_id' => $customer['customer_number'],
|
|
'department_id' => $department['id'],
|
|
'reference' => 'NOTE-REQUIRED',
|
|
]);
|
|
$product = api_fixtures()->createProduct([
|
|
'id' => 902701,
|
|
'name' => \objects\products_o::EXTRAORDINARY_CHEMISTRY_PRODUCT_NAME,
|
|
'price' => 299,
|
|
'requires_note' => 0,
|
|
]);
|
|
$session = api_fixtures()->createUserSession([], ['group_id' => 1]);
|
|
|
|
api_client()
|
|
->post('/order/items', [
|
|
'order_id' => $order['id'],
|
|
'product_id' => $product['id'],
|
|
'quantity' => 1,
|
|
'notes' => ' ',
|
|
], $session['headers'])
|
|
->assertStatus(400)
|
|
->assertEnvelope()
|
|
->assertSuccess(false)
|
|
->assertMessage('Notes is required for this product');
|
|
|
|
$response = api_client()->post('/order/items', [
|
|
'order_id' => $order['id'],
|
|
'product_id' => $product['id'],
|
|
'quantity' => 1,
|
|
'notes' => 'Graffiti removal on left side',
|
|
], $session['headers']);
|
|
|
|
$response
|
|
->assertStatus(200)
|
|
->assertEnvelope()
|
|
->assertSuccess();
|
|
|
|
expect($response->data()['notes'] ?? null)->toBe('Graffiti removal on left side');
|
|
});
|
|
|
|
it('does not allow clearing notes for order items whose product requires notes', function (): void {
|
|
api_test_covers('PUT /order/items', 'validation');
|
|
|
|
$customer = api_fixtures()->createUser(['display_name' => 'Order Item Edit Customer']);
|
|
$department = api_fixtures()->createDepartment();
|
|
$cashier = api_fixtures()->createUser(['display_name' => 'Order Item Cashier']);
|
|
$order = api_fixtures()->createOrder([
|
|
'customer_id' => $customer['customer_number'],
|
|
'department_id' => $department['id'],
|
|
'cashier_id' => $cashier['id'],
|
|
'reference' => 'NOTE-EDIT',
|
|
]);
|
|
$product = api_fixtures()->createProduct([
|
|
'id' => 902702,
|
|
'name' => 'API Note Required Product',
|
|
'price' => 199,
|
|
'requires_note' => 1,
|
|
]);
|
|
$orderItem = api_fixtures()->createOrderItem([
|
|
'order_id' => $order['id'],
|
|
'product_id' => $product['id'],
|
|
'cashier_id' => $cashier['id'],
|
|
'price' => 199,
|
|
'quantity' => 1,
|
|
'notes' => 'Initial note',
|
|
]);
|
|
$session = api_fixtures()->createUserSession(['edit_order_items']);
|
|
|
|
api_client()
|
|
->put('/order/items', [
|
|
'id' => $orderItem['id'],
|
|
'price' => 199,
|
|
'quantity' => 1,
|
|
'reference' => '',
|
|
'notes' => '',
|
|
], $session['headers'])
|
|
->assertStatus(400)
|
|
->assertEnvelope()
|
|
->assertSuccess(false)
|
|
->assertMessage('Notes is required for this product');
|
|
});
|
|
|
|
it('returns the extraordinary chemistry product with requires_note enabled', function (): void {
|
|
api_test_covers('GET /products', 'happy');
|
|
|
|
$product = api_fixtures()->createProduct([
|
|
'id' => 902703,
|
|
'name' => \objects\products_o::EXTRAORDINARY_CHEMISTRY_PRODUCT_NAME,
|
|
'price' => 299,
|
|
'requires_note' => 0,
|
|
]);
|
|
$session = api_fixtures()->createUserSession([], ['group_id' => 1]);
|
|
|
|
$response = api_client()->get('/products?id=' . $product['id'], $session['headers']);
|
|
|
|
$response
|
|
->assertStatus(200)
|
|
->assertEnvelope()
|
|
->assertSuccess();
|
|
|
|
expect($response->data()['requires_note'] ?? null)->toBeTrue();
|
|
});
|