]> BookStack Code Mirror - bookstack/blobdiff - tests/Permissions/RolesTest.php
Fixed tests from streaming changes
[bookstack] / tests / Permissions / RolesTest.php
index c880bdd008938e9ea5ae4660ccf762b9e0add4c8..fe2139e59e786f0038119ed0c4b4b3706a230b63 100644 (file)
@@ -27,7 +27,7 @@ class RolesTest extends TestCase
 
     public function test_admin_can_see_settings()
     {
-        $this->asAdmin()->get('/settings')->assertSee('Settings');
+        $this->asAdmin()->get('/settings/features')->assertSee('Settings');
     }
 
     public function test_cannot_delete_admin_role()
@@ -58,7 +58,7 @@ class RolesTest extends TestCase
         $testRoleUpdateName = 'An Super Updated role';
 
         // Creation
-        $resp = $this->asAdmin()->get('/settings');
+        $resp = $this->asAdmin()->get('/settings/features');
         $resp->assertElementContains('a[href="' . url('/settings/roles') . '"]', 'Roles');
 
         $resp = $this->get('/settings/roles');
@@ -163,6 +163,23 @@ class RolesTest extends TestCase
         $this->assertEquals($this->user->id, $roleA->users()->first()->id);
     }
 
+    public function test_copy_role_button_shown()
+    {
+        /** @var Role $role */
+        $role = Role::query()->first();
+        $resp = $this->asAdmin()->get("/settings/roles/{$role->id}");
+        $resp->assertElementContains('a[href$="/roles/new?copy_from=' . $role->id . '"]', 'Copy');
+    }
+
+    public function test_copy_from_param_on_create_prefills_with_other_role_data()
+    {
+        /** @var Role $role */
+        $role = Role::query()->first();
+        $resp = $this->asAdmin()->get("/settings/roles/new?copy_from={$role->id}");
+        $resp->assertOk();
+        $resp->assertElementExists('input[name="display_name"][value="' . ($role->display_name . ' (Copy)') . '"]');
+    }
+
     public function test_manage_user_permission()
     {
         $this->actingAs($this->user)->get('/settings/users')->assertRedirect('/');
@@ -230,13 +247,13 @@ class RolesTest extends TestCase
 
     public function test_settings_manage_permission()
     {
-        $this->actingAs($this->user)->get('/settings')->assertRedirect('/');
+        $this->actingAs($this->user)->get('/settings/features')->assertRedirect('/');
         $this->giveUserPermissions($this->user, ['settings-manage']);
-        $this->get('/settings')->assertOk();
+        $this->get('/settings/features')->assertOk();
 
-        $resp = $this->post('/settings', []);
-        $resp->assertRedirect('/settings');
-        $resp = $this->get('/settings');
+        $resp = $this->post('/settings/features', []);
+        $resp->assertRedirect('/settings/features');
+        $resp = $this->get('/settings/features');
         $resp->assertSee('Settings saved');
     }
 
@@ -745,7 +762,7 @@ class RolesTest extends TestCase
 
     public function test_public_role_visible_in_default_role_setting()
     {
-        $this->asAdmin()->get('/settings')
+        $this->asAdmin()->get('/settings/registration')
             ->assertElementExists('[data-system-role-name="admin"]')
             ->assertElementExists('[data-system-role-name="public"]');
     }