F
Filament3mo ago
tuseto

How to test list table search in translatable (via spatie) field with pest

I have the following test:
it('can search page by tistle', function () {
$title = Page::first()->title;

$result = livewire(ListPages::class)
->searchTable($title)
->assertCanSeeTableRecords(Page::where('title->en', $title)->get());
});
it('can search page by tistle', function () {
$title = Page::first()->title;

$result = livewire(ListPages::class)
->searchTable($title)
->assertCanSeeTableRecords(Page::where('title->en', $title)->get());
});
So if the first page title is :
{"en": "asdasdas", "es": "spain"}
{"en": "asdasdas", "es": "spain"}
- the test passes but if it is:
{"bg": "Dolores.", "en": "Aut."}
{"bg": "Dolores.", "en": "Aut."}
- the test fails P.S. locale is EN by default Can you help me what is going on? And how to proper test it?
2 Replies
awcodes
awcodes3mo ago
Try just ‘title’ you shouldn’t have to specify the ->en since spatie package will automatically query the correct language based on locale. You may need to manually set the locale for tests though. Not 100% sure. Unless the test suite is booting up an application.
tuseto
tuseto3mo ago
Page::where('title', $title)->get()
Page::where('title', $title)->get()
Does not return any records. If I dump
app()->locale()
app()->locale()
I get 'en'
Want results from more Discord servers?
Add your server
More Posts
Listening for broadcast eventsHi folks Been working with filament for a little bit now and really enjoying it. I’ve been buildinPassword (and other fields) truncates themselves on screen (possibly due to live())Hi, I'm after some guidance on how best to debug this. When entering a password (or some text inputHow can I apply a class to fi-fo-field-wrp?have a grid, and I'm supplying extra attributes, but it's going to the parent grid (obviously) and iis that possible to sum 2 columns in tableHi i want to make new column that sum 2 columns in laravel filament, is that possible? Thank you!Filament resource for MarkableI'm using [this](https://github.com/maize-tech/laravel-markable) package. It works well however I woUncaught (in promise) Component not foundI have a delete action on my livewire component., which is an edit modal/slideover. It's working finTextArea with autosize resets to default size with Live event.Before I report this as a bug, I'd like to know if this is expected behaviour. I have a very simplesetting a custom homeUrl after login doesn't seem to worki have a new panel created and set the `homeUrl('calendar')` but everytime I login on the new panel,Wizard Form Layout with Multiple and Nested RepeaterHi all, I want to make my online course website. Anyone have a tutorial or best practice suggestionsRich Editor is very slow while using images inside the content how can I speed up that?I have a website that have a blogs system while I'm using the rich editor it's very slow with the bi