Skip to content

Add whereModal and whereBaseRouteUrl helpers#180

Open
TylerFiekens wants to merge 1 commit into
inertiaui:3.xfrom
TylerFiekens:feature/testing-macros
Open

Add whereModal and whereBaseRouteUrl helpers#180
TylerFiekens wants to merge 1 commit into
inertiaui:3.xfrom
TylerFiekens:feature/testing-macros

Conversation

@TylerFiekens
Copy link
Copy Markdown

Hello!

I've added a few macros that help with testing on the \Inertia\Testing\AssertableInertia class.

Here's some examples of how the can be used.

Before:

it('uses the correct modal', function () {
    $user = User::factory()->create();

    $this->actingAs($user)
        ->get(route('customers.create'))
        ->assertInertia(fn (AssertableInertia $page) => $page
            ->where('_inertiaui_modal.component', 'Customers/Create')
        );
});

it('uses the correct base route', function () {
    $user = User::factory()->create();

    $this->actingAs($user)
        ->get(route('customers.create'))
        ->assertInertia(fn (AssertableInertia $page) => $page
            ->where('_inertiaui_modal.baseUrl', route('customers.index'))
        );
});

After:

it('uses the correct modal', function () {
    $user = User::factory()->create();

    $this->actingAs($user)
        ->get(route('customers.create'))
        ->assertInertia(fn (AssertableInertia $page) => $page->whereModal('Customers/Create'));
});

it('uses the correct base route', function () {
    $user = User::factory()->create();

    $this->actingAs($user)
        ->get(route('customers.create'))
        ->assertInertia(fn (AssertableInertia $page) => $page
            ->whereBaseRouteUrl(route('customers.index'))
        );
});

@SuperDJ
Copy link
Copy Markdown
Contributor

SuperDJ commented Mar 25, 2026

Perhaps adding some tests to confirm functionality will help get this merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants