Update project dependencies and enhance documentation
- Added `barryvdh/laravel-dompdf` to `composer.json` for PDF generation capabilities. - Updated `boost.json` to include `tailwindcss-development` in skills. - Modified `package.json` and `package-lock.json` to upgrade Tailwind CSS and related packages. - Improved README.md for clarity and corrected French language errors. - Created design system documentation for Filament components. - Added new Filament pages for Dashboard and Documentation with dynamic content loading. - Enhanced TablesExplorer functionality with improved table and column management.
This commit is contained in:
63
tests/Feature/DocumentationTest.php
Normal file
63
tests/Feature/DocumentationTest.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
use App\Filament\Pages\Documentation;
|
||||
use App\Models\User;
|
||||
use Livewire\Livewire;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->actingAs(User::factory()->create());
|
||||
});
|
||||
|
||||
it('renders the documentation page', function () {
|
||||
Livewire::test(Documentation::class)
|
||||
->assertSuccessful()
|
||||
->assertSee('Documentation API Logistics');
|
||||
});
|
||||
|
||||
it('converts markdown to HTML content', function () {
|
||||
$component = Livewire::test(Documentation::class);
|
||||
|
||||
expect($component->get('htmlContent'))
|
||||
->toBeString()
|
||||
->not->toBeEmpty()
|
||||
->toContain('<h1>')
|
||||
->toContain('<table>');
|
||||
});
|
||||
|
||||
it('displays the main documentation sections', function () {
|
||||
Livewire::test(Documentation::class)
|
||||
->assertSee('Pré-requis')
|
||||
->assertSee('Comment effectuer des requêtes')
|
||||
->assertSee('Structure de réponse')
|
||||
->assertSee('Tables et colonnes disponibles')
|
||||
->assertSee('Récupération de données')
|
||||
->assertSee('Envoi de données');
|
||||
});
|
||||
|
||||
it('downloads the documentation as PDF', function () {
|
||||
$response = $this->get(route('documentation.download-pdf'));
|
||||
|
||||
$response->assertSuccessful()
|
||||
->assertHeader('content-type', 'application/pdf');
|
||||
});
|
||||
|
||||
it('documents all service endpoints', function () {
|
||||
Livewire::test(Documentation::class)
|
||||
->assertSee('tables_list')
|
||||
->assertSee('column_list')
|
||||
->assertSee('art_list')
|
||||
->assertSee('art_getstk')
|
||||
->assertSee('jnl_list')
|
||||
->assertSee('document_list')
|
||||
->assertSee('document_detail')
|
||||
->assertSee('document_add')
|
||||
->assertSee('document_mod')
|
||||
->assertSee('Document_GetStatusList')
|
||||
->assertSee('Document_GetUnitPriceAndVat')
|
||||
->assertSee('Document_GetDueDate')
|
||||
->assertSee('Document_GetAttachListThumbnail')
|
||||
->assertSee('third_list')
|
||||
->assertSee('third_GetArtHistory')
|
||||
->assertSee('getserialnumber')
|
||||
->assertSee('codes_list');
|
||||
});
|
||||
46
tests/Feature/FilamentDashboardTest.php
Normal file
46
tests/Feature/FilamentDashboardTest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use App\Filament\Pages\Dashboard;
|
||||
use App\Models\User;
|
||||
use Livewire\Livewire;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->actingAs(User::factory()->create());
|
||||
});
|
||||
|
||||
it('renders the dashboard page', function () {
|
||||
Livewire::test(Dashboard::class)
|
||||
->assertSuccessful();
|
||||
});
|
||||
|
||||
it('displays the project title and description', function () {
|
||||
Livewire::test(Dashboard::class)
|
||||
->assertSee('Bienvenue sur API Logistics')
|
||||
->assertSee('Flex/ESI Gescom');
|
||||
});
|
||||
|
||||
it('shows navigation links to all pages', function () {
|
||||
Livewire::test(Dashboard::class)
|
||||
->assertSee('Tables')
|
||||
->assertSee('Articles')
|
||||
->assertSee('Documents')
|
||||
->assertSee('Journaux')
|
||||
->assertSee('Tiers')
|
||||
->assertSee('Documentation');
|
||||
});
|
||||
|
||||
it('displays project statistics', function () {
|
||||
Livewire::test(Dashboard::class)
|
||||
->assertSee('Endpoints API')
|
||||
->assertSee('Tables accessibles')
|
||||
->assertSee('Pages Filament')
|
||||
->assertSee('Tests Pest');
|
||||
});
|
||||
|
||||
it('shows technical information', function () {
|
||||
Livewire::test(Dashboard::class)
|
||||
->assertSee('Informations techniques')
|
||||
->assertSee('Laravel 12')
|
||||
->assertSee('Filament 5')
|
||||
->assertSee('Livewire 4');
|
||||
});
|
||||
147
tests/Feature/TablesExplorerTest.php
Normal file
147
tests/Feature/TablesExplorerTest.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
use App\Filament\Pages\TablesExplorer;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Livewire\Livewire;
|
||||
|
||||
beforeEach(function () {
|
||||
config([
|
||||
'logistics.base_url' => 'http://test-server.local',
|
||||
'logistics.api_key' => 'test-api-key',
|
||||
'logistics.folder' => 'testfolder',
|
||||
'logistics.timeout' => 30,
|
||||
'logistics.connect_timeout' => 10,
|
||||
'logistics.retry.times' => 1,
|
||||
'logistics.retry.sleep_ms' => 0,
|
||||
]);
|
||||
|
||||
$this->actingAs(User::factory()->create());
|
||||
});
|
||||
|
||||
it('loads the tables list on mount', function () {
|
||||
Http::fake([
|
||||
'*/tables_list' => Http::response([
|
||||
'data' => [
|
||||
['name' => 'art', 'columnCount' => 160],
|
||||
['name' => 'cust', 'columnCount' => 216],
|
||||
],
|
||||
'metadata' => ['tableCount' => 2, 'folderType' => 'DBF', 'endpoint' => 'test'],
|
||||
'error' => null,
|
||||
]),
|
||||
]);
|
||||
|
||||
Livewire::test(TablesExplorer::class)
|
||||
->assertSet('tables', [
|
||||
['name' => 'art', 'columnCount' => 160],
|
||||
['name' => 'cust', 'columnCount' => 216],
|
||||
])
|
||||
->assertSee('art')
|
||||
->assertSee('cust')
|
||||
->assertSee('160')
|
||||
->assertSee('216');
|
||||
});
|
||||
|
||||
it('loads columns when a table is selected', function () {
|
||||
Http::fake([
|
||||
'*/tables_list' => Http::response([
|
||||
'data' => [['name' => 'stk', 'columnCount' => 10]],
|
||||
'metadata' => ['tableCount' => 1],
|
||||
'error' => null,
|
||||
]),
|
||||
'*/column_list/stk' => Http::response([
|
||||
'data' => [
|
||||
['name' => 'ARTID', 'dataType' => 'C', 'length' => 20, 'precision' => 0],
|
||||
['name' => 'ARTID', 'dataType' => 'C', 'length' => 20, 'precision' => 0],
|
||||
['name' => 'STOCK', 'dataType' => 'N', 'length' => 10, 'precision' => 2],
|
||||
['name' => 'STOCK', 'dataType' => 'N', 'length' => 10, 'precision' => 2],
|
||||
],
|
||||
'metadata' => ['columnCount' => 4, 'tableName' => 'stk'],
|
||||
'error' => null,
|
||||
]),
|
||||
]);
|
||||
|
||||
Livewire::test(TablesExplorer::class)
|
||||
->call('selectTable', 'stk')
|
||||
->assertSet('selectedTable', 'stk')
|
||||
->assertSee('ARTID')
|
||||
->assertSee('STOCK')
|
||||
->assertSee('Caractère')
|
||||
->assertSee('Numérique');
|
||||
});
|
||||
|
||||
it('deduplicates columns from the API response', function () {
|
||||
Http::fake([
|
||||
'*/tables_list' => Http::response([
|
||||
'data' => [['name' => 'stk', 'columnCount' => 4]],
|
||||
'metadata' => ['tableCount' => 1],
|
||||
'error' => null,
|
||||
]),
|
||||
'*/column_list/stk' => Http::response([
|
||||
'data' => [
|
||||
['name' => 'ARTID', 'dataType' => 'C', 'length' => 20, 'precision' => 0],
|
||||
['name' => 'ARTID', 'dataType' => 'C', 'length' => 20, 'precision' => 0],
|
||||
['name' => 'STOCK', 'dataType' => 'N', 'length' => 10, 'precision' => 2],
|
||||
['name' => 'STOCK', 'dataType' => 'N', 'length' => 10, 'precision' => 2],
|
||||
],
|
||||
'metadata' => ['columnCount' => 4],
|
||||
'error' => null,
|
||||
]),
|
||||
]);
|
||||
|
||||
Livewire::test(TablesExplorer::class)
|
||||
->call('selectTable', 'stk')
|
||||
->assertSet('columns', [
|
||||
['name' => 'ARTID', 'dataType' => 'C', 'length' => 20, 'precision' => 0],
|
||||
['name' => 'STOCK', 'dataType' => 'N', 'length' => 10, 'precision' => 2],
|
||||
]);
|
||||
});
|
||||
|
||||
it('filters tables by name', function () {
|
||||
Http::fake([
|
||||
'*/tables_list' => Http::response([
|
||||
'data' => [
|
||||
['name' => 'art', 'columnCount' => 160],
|
||||
['name' => 'attach', 'columnCount' => 13],
|
||||
['name' => 'cust', 'columnCount' => 216],
|
||||
['name' => 'dochead', 'columnCount' => 212],
|
||||
['name' => 'docdet', 'columnCount' => 82],
|
||||
['name' => 'docpay', 'columnCount' => 22],
|
||||
['name' => 'stk', 'columnCount' => 20],
|
||||
],
|
||||
'metadata' => ['tableCount' => 7],
|
||||
'error' => null,
|
||||
]),
|
||||
]);
|
||||
|
||||
$component = Livewire::test(TablesExplorer::class)
|
||||
->set('tableFilter', 'doc');
|
||||
|
||||
$filteredTables = $component->get('filteredTables');
|
||||
|
||||
expect($filteredTables)->toHaveCount(3)
|
||||
->and(array_column($filteredTables, 'name'))->toBe(['dochead', 'docdet', 'docpay']);
|
||||
});
|
||||
|
||||
it('displays an error message when the API fails', function () {
|
||||
Http::fake([
|
||||
'*/tables_list' => Http::response([
|
||||
'data' => [],
|
||||
'metadata' => [],
|
||||
'error' => 'Invalid API key',
|
||||
]),
|
||||
]);
|
||||
|
||||
Livewire::test(TablesExplorer::class)
|
||||
->assertSee('Invalid API key');
|
||||
});
|
||||
|
||||
it('shows data type labels correctly', function () {
|
||||
expect(TablesExplorer::getDataTypeLabel('C'))->toBe('Caractère')
|
||||
->and(TablesExplorer::getDataTypeLabel('N'))->toBe('Numérique')
|
||||
->and(TablesExplorer::getDataTypeLabel('T'))->toBe('Date/Heure')
|
||||
->and(TablesExplorer::getDataTypeLabel('D'))->toBe('Date')
|
||||
->and(TablesExplorer::getDataTypeLabel('L'))->toBe('Logique')
|
||||
->and(TablesExplorer::getDataTypeLabel('M'))->toBe('Mémo')
|
||||
->and(TablesExplorer::getDataTypeLabel('X'))->toBe('X');
|
||||
});
|
||||
Reference in New Issue
Block a user