|
@@ -72,6 +72,61 @@ class OrderControllerTest extends TestCase
|
|
|
$response->assertSee($order->object_address);
|
|
$response->assertSee($order->object_address);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function test_orders_index_displays_products_total_column_value(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $order = Order::factory()->create([
|
|
|
|
|
+ 'object_address' => 'ул. Колоночная, д. 10',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $product = Product::factory()->create();
|
|
|
|
|
+
|
|
|
|
|
+ ProductSKU::factory()->count(3)->create([
|
|
|
|
|
+ 'order_id' => $order->id,
|
|
|
|
|
+ 'product_id' => $product->id,
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $response = $this->actingAs($this->managerUser)
|
|
|
|
|
+ ->get(route('order.index'));
|
|
|
|
|
+
|
|
|
|
|
+ $response->assertOk();
|
|
|
|
|
+ $response->assertSee('Всего МАФ');
|
|
|
|
|
+ $response->assertSee('ул. Колоночная, д. 10');
|
|
|
|
|
+ $response->assertViewHas('orders', static function ($orders) use ($order) {
|
|
|
|
|
+ return (int) $orders->firstWhere('id', $order->id)?->products_total === 3;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function test_orders_index_displays_filtered_footer_stats(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $district = District::factory()->create(['shortname' => 'ЦАО']);
|
|
|
|
|
+ $area = Area::factory()->create(['district_id' => $district->id, 'name' => 'Тверской']);
|
|
|
|
|
+ $matchingOrder = Order::factory()->create([
|
|
|
|
|
+ 'district_id' => $district->id,
|
|
|
|
|
+ 'area_id' => $area->id,
|
|
|
|
|
+ 'object_address' => 'ул. Итоговая, д. 1',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $otherOrder = Order::factory()->create([
|
|
|
|
|
+ 'object_address' => 'ул. Неучтенная, д. 2',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $product = Product::factory()->create();
|
|
|
|
|
+
|
|
|
|
|
+ ProductSKU::factory()->count(2)->create([
|
|
|
|
|
+ 'order_id' => $matchingOrder->id,
|
|
|
|
|
+ 'product_id' => $product->id,
|
|
|
|
|
+ ]);
|
|
|
|
|
+ ProductSKU::factory()->count(5)->create([
|
|
|
|
|
+ 'order_id' => $otherOrder->id,
|
|
|
|
|
+ 'product_id' => $product->id,
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $response = $this->actingAs($this->managerUser)
|
|
|
|
|
+ ->get(route('order.index', ['s' => 'Итоговая']));
|
|
|
|
|
+
|
|
|
|
|
+ $response->assertOk();
|
|
|
|
|
+ $response->assertSee('Адресов: 1', false);
|
|
|
|
|
+ $response->assertSee('МАФ: 2', false);
|
|
|
|
|
+ $response->assertDontSee('МАФ: 7', false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function test_brigadier_sees_only_assigned_orders(): void
|
|
public function test_brigadier_sees_only_assigned_orders(): void
|
|
|
{
|
|
{
|
|
|
$assignedOrder = Order::factory()->create([
|
|
$assignedOrder = Order::factory()->create([
|