mysql Ver 8.0.22 for Linux on x86_64 (MySQL Community Server - GPL)
Tests are now failing when searching for text on a raw column that has <a>
tag.
https://github.com/yajra/laravel-datatables
Setup laravel datatables
public function index(Request $request)
{
if (!$request->ajax()) {
return abort(404);
}
return DataTables::of(Demo::query())
->addColumn('demo_name', function ($demo) {
return view(
'api/demo.blade',
compact('demo')
)->render();
})
->rawColumns(["demo_name"])
->make(true);
<span class="font-lg font-weight-bold">
<a href="{{ route('demo.show', $demo) }}">
{{ $demo->name }}
</a>
</span>
public function index()
{
return view('demo.index');
}
public function show(Demo $demo)
{
return view('demo.show', [
'demo' => $demo,
]);
}
<table class="table data-table" id="table">
<thead>
<tr>
<th>{{ __('id') }}</th>
<th>{{ __('name') }}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script>
$(function () {
var table = $('.data-table').DataTable({
responsive: true,
processing: true,
serverSide: true,
ajax: {
url: "{{ route('api.demo.index') }}",
type: 'GET',
},
columns: [
{ data: 'id', name: 'id'},
{ data: 'demo_name', name: 'demo_name'},
]
});
});
</script>
Dusk Test
public function test_can_see_demo()
{
$this->browse(function (Browser $browser) {
$demo = factory(Demo::class)->create();
$browser
->maximize()
->loginAs($this->user->id) // Login user
->visit(route('demo.index'))
->waitFor("#table")
->assertSee("id")
->assertSee("name")
->assertSee(e($demo->name));
});
}
This test will fail even when the text is clearly visible in the view. The test works once the<a>
tag is removed.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community