ItsClassified's avatar

Livewire Test: I can't test the contents of an input field with assertSee

Hello!

I'm trying to create a test where I can test an edit page where i can edit settings.

The current settings are filled in the input fields and that is what i want to test.

    /**
     * @title Check if the email reciever field is visable with perms
     * @description Check if the email reciever field is visable with perms
     *
     * @group DA_ClienteleSettingsMail
     */
    public function test_email_reciever_shown_with_perms()
    {
        $this->actingAs($this->clienteleUser);

        $this->clienteleUser->givePermissionTo('directaanmelden settings edit mail reciever');

        Livewire::test(EmailSettingsForm::class, ['clientele' => $this->testClientele])
                ->assertSeeInOrder([
                    "Reciever email",
                    "This is the email that will be used to send emails",
                    $this->testClientele->DA_Settings()->email_reciever
                ]);
    }

This is my current Test to check the form.

$this->testClientele->DA_Settings()->email_reciever = "[email protected]"

Everything passes, except it cant see the email on the page so that test fails.

What am I doing wrong? Is this not the way to test the data of the input field?

This is my view:

{{-- Email ontvangen email --}}
            @can('directaanmelden settings edit mail reciever')
                <x-form-section-item>
                    <x-form-section-label>
                        <x-slot name="title">
                            {{ __('Reciever email') }}
                        </x-slot>
                        <x-slot name="description">
                            {{ __("This is the email that will be used to send emails") }}
                        </x-slot>
                    </x-form-section-label>
                    <x-form-section-input wire:model="settings.email_reciever" type="text" class="mt-1 w-full" placeholder="{{ __('[email protected]') }}"/>
                    <x-form-section-input-error for="settings.email_reciever" class="mt-2" />
                </x-form-section-item>
  		@endcan
0 likes
1 reply

Please or to participate in this conversation.