Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected function setUp(): void

$name = $this->getName();

$this->formatStateUsing(static function (Model $record) use ($name) {
$this->state(static function (Model $record) use ($name) {
return $record->translate($name);
});
}
Expand Down Expand Up @@ -58,7 +58,7 @@ public function attributeData(): static

$name = $this->getFieldHydrated();

$this->formatStateUsing(static function (Model $record) use ($name) {
$this->state(static function (Model $record) use ($name) {
return $record->translateAttribute($name);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Livewire\Livewire;
use Lunar\Admin\Filament\Resources\AttributeGroupResource;
use Lunar\Admin\Filament\Resources\AttributeGroupResource\Pages\ListAttributeGroups;
use Lunar\Models\AttributeGroup;
use Lunar\Tests\Admin\Feature\Filament\TestCase;

uses(TestCase::class)
->group('resource.attribute-group');

it('can render attribute group index page', function () {
$this->asStaff(admin: true)
->get(AttributeGroupResource::getUrl('index'))
->assertSuccessful();
});

it('shows translated attribute group names as a single state', function () {
$this->asStaff();

$attributeGroup = AttributeGroup::factory()->create([
'name' => ['en' => 'Details'],
]);

Livewire::test(ListAttributeGroups::class)
->assertCountTableRecords(1)
->assertTableColumnStateSet('name', 'Details', $attributeGroup);
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@
])->assertSuccessful();
});

it('shows translated attribute names as a single state', function () {
$this->asStaff();

$attributeGroup = AttributeGroup::factory()->create();

$attribute = Attribute::factory()->create([
'attribute_group_id' => $attributeGroup->id,
'name' => ['en' => 'Details'],
]);

Livewire::test(AttributesRelationManager::class, [
'ownerRecord' => $attributeGroup,
'pageClass' => EditAttributeGroup::class,
])
->assertCountTableRecords(1)
->assertTableColumnStateSet('name', 'Details', $attribute);
});

it('can create attributes', function ($type, $configuration = [], $expectedData = []) {

$lang = Language::factory()->create([
Expand Down
Loading