Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions .lando.dist.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
#file: noinspection ComposeUnknownKeys,YAMLSchemaValidation
name: eclipse-catalogue
name: eclipse-catalogue-plugin
recipe: laravel
config:
webroot: workbench/public
php: '8.3'
via: nginx
database: mariadb:10.11
services:
appserver:
type: php:custom
xdebug: "debug,develop,coverage"
via: cli
environment:
TZ: "Europe/Ljubljana"
APP_BASE_PATH: "/app/workbench"
TESTBENCH_WORKING_PATH: "/app"
overrides:
image: slimdeluxe/php:8.2-v1.3
image: slimdeluxe/php:8.3-v1.3
platform: linux/amd64
run:
- composer install --no-interaction --prefer-dist
- composer run setup --no-interaction
- composer run build --no-interaction
appserver_nginx:
scanner:
path: /admin/login
retry: 5
tooling:
php:
service: appserver
Expand All @@ -23,4 +41,4 @@ tooling:
testbench:
service: appserver
description: Run testbench CLI
cmd: "vendor/bin/testbench"
cmd: "vendor/bin/testbench"
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,26 @@ Should you want to contribute, please see the development guidelines in the [Dat
````
4. You can now develop and run tests. Happy coding 😉

💡 To manually test the plugin in the browser, see our [recommendation](https://github.com/DataLinx/eclipsephp-core/blob/main/docs/Documentation.md#-plugin-development), which is also [how Filament suggests package development](https://filamentphp.com/docs/3.x/support/contributing#developing-with-a-local-copy-of-filament).
#### Workbench + Lando (browser testing)

This package ships with a minimal Testbench Workbench so you can run the Filament UI without a separate app:

1. Clone the repository
2. Start the container
```shell
lando start
```

3. Open the admin panel at `https://eclipse-catalogue-plugin.lndo.site/admin`

**No login required** - you'll be automatically signed in as a test user with full permissions.

Notes:
- The container serves `workbench/public` as the webroot.
- Use `lando test` for `package:test` and `lando testbench` for other Testbench commands.
- No Telescope, websockets or health checks are enabled to keep the setup minimal.

💡 To manually test the plugin in the browser, see our [recommendation](https://github.com/DataLinx/eclipsephp-core/blob/main/docs/Documentation.md#-plugin-development), which is also [how Filament suggests package development](https://filamentphp.com/docs/3.x/support/contributing#developing-with-a-local-copy-of-filament).
However, the plugin should be universal and not dependent on our app setup or core package.

### Changelog
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@
"@php vendor/bin/testbench serve --ansi"
],
"setup": [
"@php -r \"if (!file_exists('workbench/.env')) { copy('workbench/.env.example', 'workbench/.env'); echo '.env file created from .env.example\\n'; }\"",
"@php vendor/bin/testbench key:generate --ansi",
"npm install",
"@php vendor/bin/testbench vendor:publish --provider='Spatie\\Permission\\PermissionServiceProvider'",
"@php vendor/bin/testbench vendor:publish --tag='filament-shield-config'",
"@php vendor/bin/testbench vendor:publish --provider='Laravel\\Scout\\ScoutServiceProvider'",
"@php vendor/bin/testbench filament:assets",
"@php vendor/bin/testbench package:sync-skeleton"
]
},
Expand Down
5 changes: 2 additions & 3 deletions env/php-8.3/.lando.dist.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#file: noinspection ComposeUnknownKeys
name: eclipsephp-catalogue-plugin-8.3
name: eclipse-catalogue-8.3
services:
appserver:
type: php:custom
Expand Down Expand Up @@ -28,4 +27,4 @@ tooling:
testbench:
service: appserver
description: Run testbench CLI
cmd: "vendor/bin/testbench"
cmd: "vendor/bin/testbench"
2 changes: 1 addition & 1 deletion env/php-8.3/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
}
}
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_STORE" value="array"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
<server name="DB_DATABASE" value="workbench/database/database.sqlite"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
Expand Down
22 changes: 13 additions & 9 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
laravel: '@testbench'

env:
- DB_CONNECTION=sqlite
- DB_DATABASE=/app/workbench/database/database.sqlite
- APP_KEY=base64:ZQvPGC7uVADkjOgtGIIuCI8u3/Pzu+VaRObIbHsgjCc=
- APP_ENV=local
- APP_DEBUG=true
- SESSION_DRIVER=database
- CACHE_STORE=database
- QUEUE_CONNECTION=sync

providers:
- Workbench\App\Providers\WorkbenchServiceProvider

migrations:
- workbench/database/migrations

seeders:
- Workbench\Database\Seeders\DatabaseSeeder
- database/migrations

workbench:
start: '/'
Expand All @@ -16,7 +24,7 @@ workbench:
discovers:
web: true
api: false
commands: false
commands: true
components: false
views: false
build:
Expand All @@ -25,8 +33,4 @@ workbench:
- db-wipe
- migrate-fresh
assets:
- laravel-assets
sync:
- from: storage
to: workbench/storage
reverse: true
- laravel-assets
7 changes: 5 additions & 2 deletions tests/Feature/CategoryResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
uses(RefreshDatabase::class);

beforeEach(function (): void {
$this->setUpSuperAdmin();
$this->migrate();
$this->createPermissions();
$this->createRoles();
$this->setUpSuperAdminAndTenant();
});

it('can render category index page', function (): void {
$this->get(CategoryResource::getUrl('index'))
Livewire::test(CategoryResource\Pages\ListCategories::class)
->assertSuccessful();
});

Expand Down
14 changes: 7 additions & 7 deletions tests/Feature/CustomPropertyPermissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@
});

it('super admin can manage custom properties', function () {
// Set up super admin
$this->setUpSuperAdmin();
// Ensure permissions and roles are created
$this->createPermissions();
$this->createRoles();
// Set up super admin with tenant
$this->setUpSuperAdminAndTenant();

// Create test custom property
$customProperty = Property::create([
Expand All @@ -58,12 +61,9 @@
'is_multilang' => false,
]);

// View table
$this->get(PropertyResource::getUrl())
->assertOk();

// Create property
// View table and verify super admin can manage properties
livewire(ListProperties::class)
->assertSuccessful()
->assertActionEnabled('create');

// Edit property
Expand Down
16 changes: 10 additions & 6 deletions tests/Feature/GroupCodeUniquenessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,39 @@
});

it('allows same code across different sites', function () {
// Ensure we have at least 2 sites
$site1 = \Workbench\App\Models\Site::first() ?? \Workbench\App\Models\Site::factory()->create();
$site2 = \Workbench\App\Models\Site::factory()->create();

// Create groups with same code on different sites
$group1 = Group::create([
'site_id' => 1,
'site_id' => $site1->id,
'code' => 'same-code',
'name' => 'Group 1',
'is_active' => true,
]);

$group2 = Group::create([
'site_id' => 2,
'site_id' => $site2->id,
'code' => 'same-code',
'name' => 'Group 2',
'is_active' => true,
]);

expect($group1->code)->toBe('same-code');
expect($group2->code)->toBe('same-code');
expect($group1->site_id)->toBe(1);
expect($group2->site_id)->toBe(2);
expect($group1->site_id)->toBe($site1->id);
expect($group2->site_id)->toBe($site2->id);

$this->assertDatabaseHas('pim_group', [
'id' => $group1->id,
'site_id' => 1,
'site_id' => $site1->id,
'code' => 'same-code',
]);

$this->assertDatabaseHas('pim_group', [
'id' => $group2->id,
'site_id' => 2,
'site_id' => $site2->id,
'code' => 'same-code',
]);
});
Expand Down
14 changes: 13 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ abstract class TestCase extends BaseTestCase
protected function getEnvironmentSetUp($app): void
{
$app['config']->set('filament-shield.register_role_policy', false);

// Configure tenancy for tests so migrations create the site_id column
$app['config']->set('eclipse-catalogue.tenancy.model', 'Workbench\App\Models\Site');
$app['config']->set('eclipse-catalogue.tenancy.foreign_key', 'site_id');
}

protected function setUp(): void
Expand Down Expand Up @@ -64,14 +68,22 @@ protected function setUpSuperAdmin(): self
$this->superAdmin = User::factory()->create();

// Assign super admin role and give all permissions
$superAdminRole = \Spatie\Permission\Models\Role::where('name', 'super_admin')->first();
$superAdminRole = \Spatie\Permission\Models\Role::where('name', 'super_admin')
->where('guard_name', 'web')
->first();
if ($superAdminRole) {
$this->superAdmin->assignRole($superAdminRole);
// Give all permissions to super admin role
$permissions = \Spatie\Permission\Models\Permission::all();
$superAdminRole->syncPermissions($permissions);
}

// Clear permission cache to ensure roles are recognized
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();

// Refresh user to reload roles
$this->superAdmin->refresh();

$this->actingAs($this->superAdmin);

return $this;
Expand Down
16 changes: 9 additions & 7 deletions workbench/.env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=AckfSECXIvnK5r28GVIWUAxmbBSjTsmF
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_URL=https://eclipse-catalogue-plugin.lndo.site

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
Expand All @@ -21,23 +21,25 @@ LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=sqlite
DB_DATABASE=/app/workbench/database/database.sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

SESSION_DRIVER=cookie
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
SESSION_SECURE_COOKIE=false
SESSION_HTTP_ONLY=true
SESSION_SAME_SITE=lax

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
QUEUE_CONNECTION=sync

CACHE_STORE=database
CACHE_STORE=array
# CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1
Expand Down
23 changes: 22 additions & 1 deletion workbench/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
.env
.env.dusk
storage
storage/app/*
!storage/app/.gitkeep
!storage/app/public/
storage/app/public/*
!storage/app/public/.gitkeep
storage/framework/sessions/*
!storage/framework/sessions/.gitkeep
storage/framework/testing/*
!storage/framework/testing/.gitkeep
storage/framework/views/*
!storage/framework/views/.gitkeep
storage/logs/*
!storage/logs/.gitkeep
stubs/
resources/views/vendor/
lang/
vendor
public/build
public/hot
/public/css
/public/js
/public/fonts
Loading