Browse Source

Maintenance: Added test for token user preferences.

Martin Gruner 9 months ago
parent
commit
a174e95fab
1 changed files with 24 additions and 0 deletions
  1. 24 0
      spec/system/apps/desktop/account_spec.rb

+ 24 - 0
spec/system/apps/desktop/account_spec.rb

@@ -57,6 +57,30 @@ RSpec.describe 'Desktop > Account', app: :desktop_view, authenticated_as: :agent
     end
   end
 
+  describe 'token handling' do
+    let(:agent) { create(:admin) }
+
+    it 'user can create and use a token' do
+      click_on 'Profile settings'
+      click_on 'Token Access'
+
+      click_on 'New Personal Access Token'
+
+      fill_in 'Name', with: 'Test Token'
+
+      # Activate some permissions for the token
+      find('span', text: 'Configure your system.').click
+      find('span', text: 'Manage personal settings.').click
+
+      click_on 'Create'
+      wait_for_mutation('userCurrentAccessTokenAdd')
+
+      expect(Token.last.name).to eq('Test Token')
+      expect(Token.last.permissions.map(&:name)).to eq(%w[admin user_preferences])
+      expect(Token.last.check?).to be(true)
+    end
+  end
+
   describe 'avatar handling', authenticated_as: :agent do
     let(:agent) { create(:agent, firstname: 'Jane', lastname: 'Doe') }