Update Journaux page to increase default results limit and ensure results are sent as strings
- Changed the default results limit from 10 to 30 in the Journaux page. - Updated the `searchJournaux` method to cast the results parameter to a string to prevent HTTP 400 errors. - Modified related tests to reflect the new results format and updated expected data structure in API responses. - Enhanced documentation for the `jnl_list` endpoint to clarify the requirement for the results parameter to be a string.
This commit is contained in:
@@ -46,23 +46,43 @@ it('shows validation error when TYPE is empty', function () {
|
||||
it('searches journaux via jnl_list', function () {
|
||||
Http::fake([
|
||||
'*/jnl_list' => Http::response([
|
||||
'data' => [['jnlid' => 'VEN', 'jnlname' => 'Ventes']],
|
||||
'metadata' => ['rowcount' => 1, 'issuccess' => true],
|
||||
'data' => [['jnl' => '03VEN', 'name' => 'FACTURE CLIENT', 'type' => 'CI']],
|
||||
'metadata' => ['rowCount' => 1, 'source' => 'DBF', 'unlimited' => false],
|
||||
'error' => null,
|
||||
]),
|
||||
]);
|
||||
|
||||
Livewire::test(Journaux::class)
|
||||
->set('type', 'V')
|
||||
->set('select', 'jnlid,jnlname')
|
||||
->set('type', 'I')
|
||||
->set('select', 'jnl,name,type')
|
||||
->call('searchJournaux')
|
||||
->assertSet('hasSearched', true)
|
||||
->assertSet('data', [['jnlid' => 'VEN', 'jnlname' => 'Ventes']])
|
||||
->assertSet('data', [['jnl' => '03VEN', 'name' => 'FACTURE CLIENT', 'type' => 'CI']])
|
||||
->assertSet('errorMessage', null);
|
||||
|
||||
Http::assertSent(function ($request) {
|
||||
return str_contains($request->url(), 'jnl_list')
|
||||
&& $request->data()['TYPE'] === 'V';
|
||||
&& $request->data()['TYPE'] === 'I';
|
||||
});
|
||||
});
|
||||
|
||||
it('sends results as string to avoid HTTP 400', function () {
|
||||
Http::fake([
|
||||
'*/jnl_list' => Http::response([
|
||||
'data' => [],
|
||||
'metadata' => ['rowCount' => 0, 'source' => 'DBF', 'unlimited' => false],
|
||||
'error' => null,
|
||||
]),
|
||||
]);
|
||||
|
||||
Livewire::test(Journaux::class)
|
||||
->set('type', 'C')
|
||||
->set('results', 50)
|
||||
->call('searchJournaux');
|
||||
|
||||
Http::assertSent(function ($request) {
|
||||
return str_contains($request->url(), 'jnl_list')
|
||||
&& $request->data()['results'] === '50';
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user