feat: manage cms_type and WordPress credentials in Sites UI
This commit is contained in:
@@ -48,3 +48,60 @@ test('a site can be deleted', function () {
|
||||
|
||||
expect(Site::find($site->id))->toBeNull();
|
||||
});
|
||||
|
||||
test('a new WordPress site can be created with credentials', function () {
|
||||
Livewire::test(Index::class)
|
||||
->set('name', 'WP Site')
|
||||
->set('url', 'https://wp.example.com')
|
||||
->set('cmsType', 'wordpress')
|
||||
->set('wpUsername', 'admin')
|
||||
->set('wpAppPassword', 'abcd 1234 efgh 5678')
|
||||
->call('save');
|
||||
|
||||
$site = Site::where('name', 'WP Site')->first();
|
||||
|
||||
expect($site)
|
||||
->cms_type->toBe('wordpress')
|
||||
->wp_username->toBe('admin')
|
||||
->wp_app_password->toBe('abcd 1234 efgh 5678');
|
||||
});
|
||||
|
||||
test('WordPress username and app password are required together when cms_type is wordpress', function () {
|
||||
Livewire::test(Index::class)
|
||||
->set('name', 'WP Site')
|
||||
->set('url', 'https://wp.example.com')
|
||||
->set('cmsType', 'wordpress')
|
||||
->set('wpUsername', '')
|
||||
->set('wpAppPassword', '')
|
||||
->call('save')
|
||||
->assertHasErrors(['wpUsername', 'wpAppPassword']);
|
||||
});
|
||||
|
||||
test('a site defaults to custom cms_type with no WordPress fields required', function () {
|
||||
Livewire::test(Index::class)
|
||||
->set('name', 'Plain Site')
|
||||
->set('url', 'https://plain.example.com')
|
||||
->call('save')
|
||||
->assertHasNoErrors();
|
||||
|
||||
expect(Site::where('name', 'Plain Site')->first()->cms_type)->toBe('custom');
|
||||
});
|
||||
|
||||
test('editing a site loads its WordPress fields', function () {
|
||||
$site = Site::factory()->wordpress()->create(['wp_username' => 'editor']);
|
||||
|
||||
Livewire::test(Index::class)
|
||||
->call('edit', $site->id)
|
||||
->assertSet('cmsType', 'wordpress')
|
||||
->assertSet('wpUsername', 'editor');
|
||||
});
|
||||
|
||||
test('WordPress app password can be revealed and hidden in the table', function () {
|
||||
$site = Site::factory()->wordpress()->create();
|
||||
|
||||
Livewire::test(Index::class)
|
||||
->call('toggleReveal', $site->id)
|
||||
->assertSet('revealedId', $site->id)
|
||||
->call('toggleReveal', $site->id)
|
||||
->assertSet('revealedId', null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user