I'm using Filament and I write tests to check if sorting works correctly. After running my tests locally, with Postgresql set as my database, none of my tests failed. Then I pushed my changes to the repository and I found out that some tests are failing (which were the ones that tested the sorting functionality).
I checked which database the CI uses and it is MySQL, so I decided to change my phpunit.xml and set the database to MySQL. Yup, there it is, the same tests that failed in the pipeline also fail locally now.
After some research I though that maybe the sortBy functionality returns different results per database. Which seems to be the case. I did not verify this 100% yet but I can show you how I came to that conclussion.
The code for the test is:
it('can sort users by `name` on index page', function () {
$user = createUserWithPermissions(['view users']);
actingAs($user);
$users = User::factory()->count(3)->create();
// @phpstan-ignore-next-line
livewire(ListUsers::class)
->assertCanSeeTableRecords($users)
->sortTable('name')
->assertCanSeeTableRecords($users->sortBy('name'), inOrder: true) // it fails on this line
->sortTable('name', 'desc')
->assertCanSeeTableRecords($users->sortByDesc('name'), inOrder: true);
});