UnitTest (bug)?
I am wondering why the code below only works for sorting 'name' but not 'email'.
UserResource:
30 Replies
will try again.. thank you
I've also tried using the example given in the filament docs.. and it returned as failed.
Do you have more than 10 users?
Usually, tests are supposed to be run with clean data coming from a factory. Also using a different database then your apps database.
i make sure to have 10 users, so yes. i reduced the text in the error messages because of discord text limit. i do test it on different database.
i have tried this and it still returning as failed
Can you show the complete error?
Do you have any setup method? Like the ->beforeEach etc?
You are testing locally, right?
the error is too long.. and this is my setup.. yes im testing it locally.
Can you for testing purpose assertOk on livewire(UserResource\Pages\ListUsers::class)
Only run this for now
Ok can you run your previous test line by line and see where it fails. Like:
etc
Can you run this test exactly like that:
->assertCanRenderTableColumn()
you are passing a user instance as opposed to a column name. Didn't notice before 😁ohh.. i see.. but even removing that the test is still failing
And $users is not more than 10 users?
can a plugins also influence these test?
yep not more than 10 users. because the table can only render 10 users per page.
In your resource do you have a defaultSort or something?
if i try it with 'name', it does not return as failed.
this is my UserResource.
It passes for
name
but not for email
?yes
Im having troubles reproducing your error ☹️
Do you do something out of the ordinary in the
ListUsers
class?I dont think I meddle with the ListUsers class yet.
Please confirm that $users is not more than 10. The only time i can reproduce anything remotely close is with more than 10 users
9 // tests\Feature\Admin\UserResourceTest.php:107
I assume if you remove both
inOrder: true
it passes?
Have you manually tested the sorting? Can you sort both by hand?you are correct about removing the . it passes
yes, i did manually sorting and it is working fine.
Im at the same point now. It works for all but name and email 🤣
I am at my wits end now, sorry 🤔
its okay and thank you..
Do you have a custom getter or setter for the user's name in your User class?
in my model?
Yes
i dont think i have
also i just do it like this. just adding condition to the inOrder. cause i figures that if one column is inOrder then the other is not, thus that what trigger the error.