application_build_checksum_spec.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Gql::Queries::ApplicationBuildChecksum, authenticated_as: false, type: :graphql do
  4. context 'when checking the application build checksum' do
  5. let(:vite_path) { Rails.public_path.join('assets/mobile/vite') }
  6. let(:filename) { "#{vite_path}/manifest.json" }
  7. let!(:initial_checksum) do
  8. # Create some content to the file at the beginning, because normally it not exists for the graphql tests.
  9. if !File.exist? filename
  10. Dir.mkdir(vite_path, 0o755)
  11. File.open(filename, 'a') do |file|
  12. file.write('{}')
  13. end
  14. end
  15. Digest::MD5.hexdigest(File.read(filename))
  16. end
  17. let(:query) do
  18. <<~QUERY
  19. query applicationBuildChecksum {
  20. applicationBuildChecksum
  21. }
  22. QUERY
  23. end
  24. before do
  25. File.open(filename, 'a') do |file|
  26. file.write("\n")
  27. end
  28. gql.execute(query)
  29. end
  30. after do
  31. if Digest::MD5.hexdigest('{}') == initial_checksum
  32. FileUtils.rm_rf vite_path
  33. end
  34. end
  35. it 'returns the checksum of the manifest file' do
  36. expect(gql.result.data).to not_eq(initial_checksum)
  37. end
  38. end
  39. end