mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
fix(#123): normalizes non-named select config options for recipes
This commit is contained in:
parent
dac8064938
commit
7c8e55588a
2 changed files with 88 additions and 0 deletions
|
|
@ -388,6 +388,45 @@ it('does not set icon_url when importing from URL without iconUrl parameter', fu
|
|||
->and($plugin->icon_url)->toBeNull();
|
||||
});
|
||||
|
||||
it('normalizes non-named select options to named values', function (): void {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$settingsYaml = <<<'YAML'
|
||||
name: Test Plugin
|
||||
refresh_interval: 30
|
||||
strategy: static
|
||||
polling_verb: get
|
||||
static_data: '{}'
|
||||
custom_fields:
|
||||
- keyname: display_incident
|
||||
field_type: select
|
||||
options:
|
||||
- true
|
||||
- false
|
||||
default: true
|
||||
YAML;
|
||||
|
||||
$zipContent = createMockZipFile([
|
||||
'src/settings.yml' => $settingsYaml,
|
||||
'src/full.liquid' => getValidFullLiquid(),
|
||||
]);
|
||||
|
||||
$zipFile = UploadedFile::fake()->createWithContent('test-plugin.zip', $zipContent);
|
||||
|
||||
$pluginImportService = new PluginImportService();
|
||||
$plugin = $pluginImportService->importFromZip($zipFile, $user);
|
||||
|
||||
$customFields = $plugin->configuration_template['custom_fields'];
|
||||
$displayIncidentField = collect($customFields)->firstWhere('keyname', 'display_incident');
|
||||
|
||||
expect($displayIncidentField)->not->toBeNull()
|
||||
->and($displayIncidentField['options'])->toBe([
|
||||
['true' => 'true'],
|
||||
['false' => 'false'],
|
||||
])
|
||||
->and($displayIncidentField['default'])->toBe('true');
|
||||
});
|
||||
|
||||
// Helper methods
|
||||
function createMockZipFile(array $files): string
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue