macros_spec.rb 882 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Gql::Queries::Macros, type: :graphql do
  4. let(:agent) { create(:agent, groups: [group]) }
  5. let(:group) { create(:group) }
  6. let(:query) do
  7. <<~QUERY
  8. query macros($groupId: ID!) {
  9. macros(groupId: $groupId) {
  10. id
  11. active
  12. name
  13. uxFlowNextUp
  14. }
  15. }
  16. QUERY
  17. end
  18. let(:variables) { { groupId: gql.id(group) } }
  19. let(:macro) { create(:macro) }
  20. before do
  21. Macro.destroy_all
  22. macro
  23. gql.execute(query, variables: variables)
  24. end
  25. context 'with authenticated session', authenticated_as: :agent do
  26. it 'returns macros' do
  27. expect(gql.result.data).to match_array(include('id' => gql.id(macro)))
  28. end
  29. end
  30. it_behaves_like 'graphql responds with error if unauthenticated'
  31. end