feat: custom labels toggle and inline editing in product list
Adds session-based show/hide toggle for custom labels in admin product list, inline editable fields for custom_label_0..4, and label suggestions with custom entry support. Includes repository/controller updates, UI fixes, tests, and PAUL docs release updates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1313,4 +1313,55 @@ class ProductRepositoryTest extends TestCase
|
||||
$method->setAccessible(true);
|
||||
$method->invoke($repository, 55, [], [], []);
|
||||
}
|
||||
|
||||
public function testCustomLabelNamesUsesDbSettingsWithFallback(): void
|
||||
{
|
||||
$mockDb = $this->createMock(\medoo::class);
|
||||
|
||||
$mockDb->expects($this->once())
|
||||
->method('select')
|
||||
->with(
|
||||
'pp_settings',
|
||||
['param', 'value'],
|
||||
$this->callback(function ($where) {
|
||||
return isset($where['param']) && is_array($where['param']) && count($where['param']) === 10;
|
||||
})
|
||||
)
|
||||
->willReturn([
|
||||
['param' => 'custom_label_0_name', 'value' => 'Sezon'],
|
||||
['param' => 'google_custom_label_2_name', 'value' => 'Kampania'],
|
||||
['param' => 'custom_label_4_name', 'value' => ''],
|
||||
]);
|
||||
|
||||
$repository = new ProductRepository($mockDb);
|
||||
$names = $repository->customLabelNames();
|
||||
|
||||
$this->assertSame('Sezon', $names['custom_label_0']);
|
||||
$this->assertSame('Custom label 1', $names['custom_label_1']);
|
||||
$this->assertSame('Kampania', $names['custom_label_2']);
|
||||
$this->assertSame('Custom label 3', $names['custom_label_3']);
|
||||
$this->assertSame('Custom label 4', $names['custom_label_4']);
|
||||
}
|
||||
|
||||
public function testCustomLabelSuggestionsReturnsEmptyForInvalidLabelType(): void
|
||||
{
|
||||
$mockDb = $this->createMock(\medoo::class);
|
||||
$mockDb->expects($this->never())->method('query');
|
||||
|
||||
$repository = new ProductRepository($mockDb);
|
||||
$result = $repository->customLabelSuggestions('abc', 'custom_label_10');
|
||||
|
||||
$this->assertSame([], $result);
|
||||
}
|
||||
|
||||
public function testSaveCustomLabelReturnsFalseForInvalidLabelType(): void
|
||||
{
|
||||
$mockDb = $this->createMock(\medoo::class);
|
||||
$mockDb->expects($this->never())->method('update');
|
||||
|
||||
$repository = new ProductRepository($mockDb);
|
||||
$result = $repository->saveCustomLabel(1, 'abc', 'custom_label_10');
|
||||
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ class ShopProductControllerTest extends TestCase
|
||||
$this->assertTrue(method_exists($this->controller, 'product_unarchive'));
|
||||
$this->assertTrue(method_exists($this->controller, 'product_delete'));
|
||||
$this->assertTrue(method_exists($this->controller, 'change_product_status'));
|
||||
$this->assertTrue(method_exists($this->controller, 'product_custom_labels_toggle'));
|
||||
$this->assertTrue(method_exists($this->controller, 'product_change_price_brutto'));
|
||||
$this->assertTrue(method_exists($this->controller, 'product_change_price_brutto_promo'));
|
||||
$this->assertTrue(method_exists($this->controller, 'product_change_custom_label'));
|
||||
@@ -128,6 +129,9 @@ class ShopProductControllerTest extends TestCase
|
||||
'renderCustomFieldsBox',
|
||||
'escapeHtml',
|
||||
'resolveSavePayload',
|
||||
'customLabelsEnabled',
|
||||
'isAllowedCustomLabelType',
|
||||
'renderCustomLabelsEditor',
|
||||
];
|
||||
|
||||
foreach ($expectedPrivate as $method) {
|
||||
@@ -147,4 +151,22 @@ class ShopProductControllerTest extends TestCase
|
||||
$reflection = new \ReflectionClass($this->controller);
|
||||
$this->assertEquals('void', (string)$reflection->getMethod('save')->getReturnType());
|
||||
}
|
||||
|
||||
public function testToggleCustomLabelsMethodReturnsVoid(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass($this->controller);
|
||||
$this->assertEquals('void', (string)$reflection->getMethod('product_custom_labels_toggle')->getReturnType());
|
||||
}
|
||||
|
||||
public function testAllowedCustomLabelTypeValidation(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass($this->controller);
|
||||
$method = $reflection->getMethod('isAllowedCustomLabelType');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$this->assertTrue($method->invoke($this->controller, 'custom_label_0'));
|
||||
$this->assertTrue($method->invoke($this->controller, 'custom_label_4'));
|
||||
$this->assertFalse($method->invoke($this->controller, 'custom_label_5'));
|
||||
$this->assertFalse($method->invoke($this->controller, 'invalid'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user