|
|
@@ -121,6 +121,37 @@ class ReclamationControllerTest extends TestCase
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
+ public function test_creating_reclamation_from_order_preserves_nav_token(): void
|
|
|
+ {
|
|
|
+ $order = Order::factory()->create();
|
|
|
+ $product = Product::factory()->create();
|
|
|
+ $productSku = ProductSKU::factory()->create([
|
|
|
+ 'order_id' => $order->id,
|
|
|
+ 'product_id' => $product->id,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $response = $this->actingAs($this->managerUser)
|
|
|
+ ->withSession([
|
|
|
+ 'navigation' => [
|
|
|
+ 'order-nav-token' => [
|
|
|
+ 'updated_at' => time(),
|
|
|
+ 'stack' => [
|
|
|
+ route('order.index'),
|
|
|
+ route('order.show', $order),
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ ])
|
|
|
+ ->post(route('reclamations.create', ['order' => $order, 'nav' => 'order-nav-token']), [
|
|
|
+ 'skus' => [$productSku->id],
|
|
|
+ 'nav' => 'order-nav-token',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $location = $response->headers->get('Location');
|
|
|
+ $this->assertNotNull($location);
|
|
|
+ $this->assertStringContainsString('nav=order-nav-token', $location);
|
|
|
+ }
|
|
|
+
|
|
|
public function test_creating_reclamation_attaches_skus(): void
|
|
|
{
|
|
|
$order = Order::factory()->create();
|
|
|
@@ -187,6 +218,106 @@ class ReclamationControllerTest extends TestCase
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public function test_reclamations_index_starts_new_navigation_context(): void
|
|
|
+ {
|
|
|
+ $response = $this->actingAs($this->managerUser)
|
|
|
+ ->withSession([
|
|
|
+ 'navigation' => [
|
|
|
+ 'existing-card-nav' => [
|
|
|
+ 'updated_at' => time(),
|
|
|
+ 'stack' => [
|
|
|
+ route('order.show', Order::factory()->create()),
|
|
|
+ route('reclamations.show', Reclamation::factory()->create()),
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ ])
|
|
|
+ ->get(route('reclamations.index', ['nav' => 'existing-card-nav']));
|
|
|
+
|
|
|
+ $response->assertOk();
|
|
|
+ $response->assertViewHas('nav', function (string $nav): bool {
|
|
|
+ return $nav !== 'existing-card-nav';
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public function test_reclamation_show_returns_to_order_after_coming_back_from_catalog(): void
|
|
|
+ {
|
|
|
+ $order = Order::factory()->create();
|
|
|
+ $reclamation = Reclamation::factory()->create([
|
|
|
+ 'order_id' => $order->id,
|
|
|
+ 'user_id' => $this->managerUser->id,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $response = $this->actingAs($this->managerUser)
|
|
|
+ ->withSession([
|
|
|
+ 'navigation' => [
|
|
|
+ 'order-reclamation-nav' => [
|
|
|
+ 'updated_at' => time(),
|
|
|
+ 'stack' => [
|
|
|
+ route('order.show', $order),
|
|
|
+ route('reclamations.show', $reclamation),
|
|
|
+ route('catalog.show', Product::factory()->create()),
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ ])
|
|
|
+ ->get(route('reclamations.show', [
|
|
|
+ 'reclamation' => $reclamation,
|
|
|
+ 'nav' => 'order-reclamation-nav',
|
|
|
+ ]));
|
|
|
+
|
|
|
+ $response->assertOk();
|
|
|
+ $response->assertViewHas('back_url', route('order.show', [
|
|
|
+ 'order' => $order,
|
|
|
+ 'nav' => 'order-reclamation-nav',
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function test_existing_reclamation_opened_from_order_keeps_order_as_back_target_after_catalog(): void
|
|
|
+ {
|
|
|
+ $order = Order::factory()->create([
|
|
|
+ 'object_address' => 'ул. Навигационная, д. 7',
|
|
|
+ ]);
|
|
|
+ $product = Product::factory()->create();
|
|
|
+ $productSku = ProductSKU::factory()->create([
|
|
|
+ 'order_id' => $order->id,
|
|
|
+ 'product_id' => $product->id,
|
|
|
+ ]);
|
|
|
+ $reclamation = Reclamation::factory()->create([
|
|
|
+ 'order_id' => $order->id,
|
|
|
+ 'user_id' => $this->managerUser->id,
|
|
|
+ ]);
|
|
|
+ $reclamation->skus()->attach($productSku->id);
|
|
|
+
|
|
|
+ $indexResponse = $this->actingAs($this->managerUser)
|
|
|
+ ->get(route('order.index'));
|
|
|
+ $nav = $indexResponse->viewData('nav');
|
|
|
+
|
|
|
+ $orderResponse = $this->actingAs($this->managerUser)
|
|
|
+ ->get(route('order.show', ['order' => $order, 'nav' => $nav]));
|
|
|
+ $orderResponse->assertOk();
|
|
|
+
|
|
|
+ $reclamationResponse = $this->actingAs($this->managerUser)
|
|
|
+ ->get(route('reclamations.show', ['reclamation' => $reclamation, 'nav' => $nav]));
|
|
|
+ $reclamationResponse->assertOk();
|
|
|
+ $reclamationResponse->assertViewHas('back_url', route('order.show', [
|
|
|
+ 'order' => $order,
|
|
|
+ 'nav' => $nav,
|
|
|
+ ]));
|
|
|
+
|
|
|
+ $catalogResponse = $this->actingAs($this->managerUser)
|
|
|
+ ->get(route('catalog.show', ['product' => $product, 'nav' => $nav]));
|
|
|
+ $catalogResponse->assertOk();
|
|
|
+
|
|
|
+ $reclamationBackResponse = $this->actingAs($this->managerUser)
|
|
|
+ ->get(route('reclamations.show', ['reclamation' => $reclamation, 'nav' => $nav]));
|
|
|
+ $reclamationBackResponse->assertOk();
|
|
|
+ $reclamationBackResponse->assertViewHas('back_url', route('order.show', [
|
|
|
+ 'order' => $order,
|
|
|
+ 'nav' => $nav,
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+
|
|
|
public function test_reclamation_details_show_spare_part_note_in_input_instead_of_used_in_maf(): void
|
|
|
{
|
|
|
$sparePart = \App\Models\SparePart::factory()->create([
|