Skip to content
This repository was archived by the owner on Feb 14, 2026. It is now read-only.

Proposal: Add tests for column state and formatted state validation#322

Draft
dissto wants to merge 2 commits into4.xfrom
has-the-correct-state-test
Draft

Proposal: Add tests for column state and formatted state validation#322
dissto wants to merge 2 commits into4.xfrom
has-the-correct-state-test

Conversation

@dissto
Copy link
Collaborator

@dissto dissto commented Sep 7, 2025

Let me know

it('`:dataset` column has the correct state', function (string $column): void {
    $records = App\Models\User::factory(3)->create();

    $record = $records->first();

    $value = data_get($record, $column);

    if ($value instanceof Carbon\Carbon || $value instanceof Carbon\CarbonImmutable) {
        $value = $value->toDateTimeString();
    }

    livewire(App\Filament\Resources\Users\Pages\ListUsers::class)
        ->assertTableColumnStateSet($column, $value, record: $record)
        ->assertTableColumnStateNotSet($column, 'non-existent-value', record: $record);
})
    ->with(['name', 'email', 'email_verified_at', 'created_at', 'updated_at']);

it('`:dataset` column has the correct formatted state', function (string $column): void {
    $records = App\Models\User::factory(3)->create();

    $record = $records->first();

    $value = data_get($record, $column);

    //     if ($value instanceof Carbon\Carbon || $value instanceof Carbon\CarbonImmutable ) {
    //        $value = $value->format('Y-m-d H:i:s');
    //     }

    livewire(App\Filament\Resources\Users\Pages\ListUsers::class)
        ->assertTableColumnFormattedStateSet($column, $value, record: $record)
        ->assertTableColumnFormattedStateNotSet($column, 'non-existent-value', record: $record);

})->with(['name', 'email', 'email_verified_at', 'created_at', 'updated_at'])
    ->skip('This test requires additional attention because the formatted state is likely to differ from the raw state.');

@dissto dissto marked this pull request as draft September 7, 2025 17:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments