diff --git a/README.md b/README.md index 5a7b9ff..7cba1ff 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Add your MailerLite API key in the Control Panel under the addon's settings (**T Every form's **Configure** page in the Control Panel gets a **MailerLite** section: - **Enable MailerLite sync** — toggle syncing for the form on or off. -- **Group** — pick the MailerLite group subscribers are added to, loaded live from your account. +- **Groups** — pick the MailerLite groups subscribers are added to, loaded live from your account. - **Field mapping** — map form fields to MailerLite subscriber fields. Map one field to `email`; submissions without an email value are skipped. The settings are saved on the form itself, so they are version controlled and deployed along with your other form YAML. diff --git a/src/StatamicMailerLiteServiceProvider.php b/src/StatamicMailerLiteServiceProvider.php index 66d475f..95c6ad6 100644 --- a/src/StatamicMailerLiteServiceProvider.php +++ b/src/StatamicMailerLiteServiceProvider.php @@ -49,10 +49,9 @@ public static function configFields(): array ], 'mailerlite_group' => [ 'type' => 'mailer_lite_groups', - 'display' => __('Group'), - 'instructions' => __('Subscribers will be added to this MailerLite group.'), + 'display' => __('Groups'), + 'instructions' => __('Subscribers will be added to these MailerLite groups.'), 'mode' => 'select', - 'max_items' => 1, 'show_when' => [ 'mailerlite_enabled' => true, ], diff --git a/tests/Feature/MailerLiteConfigFieldsTest.php b/tests/Feature/MailerLiteConfigFieldsTest.php index 995cca8..3f0983c 100644 --- a/tests/Feature/MailerLiteConfigFieldsTest.php +++ b/tests/Feature/MailerLiteConfigFieldsTest.php @@ -9,7 +9,7 @@ expect($fields['mailerlite_enabled']['type'])->toBe('toggle'); expect($fields['mailerlite_enabled']['default'])->toBeFalse(); expect($fields['mailerlite_group']['type'])->toBe('mailer_lite_groups'); - expect($fields['mailerlite_group']['max_items'])->toBe(1); + expect($fields['mailerlite_group'])->not->toHaveKey('max_items'); expect($fields['mailerlite_field_mapping']['type'])->toBe('grid'); }); diff --git a/tests/Feature/SubmissionCreatedListenerTest.php b/tests/Feature/SubmissionCreatedListenerTest.php index 4a383ea..e20900f 100644 --- a/tests/Feature/SubmissionCreatedListenerTest.php +++ b/tests/Feature/SubmissionCreatedListenerTest.php @@ -101,6 +101,23 @@ function jobProperty(CreateSubscriberJob $job, string $name): mixed ); }); +it('passes multiple selected groups to the job', function () { + fakeApiKey('key-123'); + + $event = submissionEvent([ + 'mailerlite_enabled' => true, + 'mailerlite_group' => ['42', '99'], + 'mailerlite_field_mapping' => [['form_field' => 'email', 'mailerlite_field' => 'email']], + ], ['email' => 'a@b.com']); + + (new SubmissionCreatedListener)->handle($event); + + Queue::assertPushed( + CreateSubscriberJob::class, + fn (CreateSubscriberJob $job) => jobProperty($job, 'subscriberGroups') === ['42', '99'], + ); +}); + it('dispatches without a group when none is selected', function () { fakeApiKey('key-123');