docbrown/spec/requests/universal_links_spec.rb
Fernando Valverde affc704c9b
Runtime Banner for Mobile Deep Linking (#13190)
* First version using custom schemes for iOS

* Starting to take shape with /r/mobile redirect page

* Wording and aasa

* Adds e2e tests

* Trigger CI

* Tweaks to AASA

* Uses external pivot domain to trigger Universal Links

* Add missing external domain deep link

* Fix test by enabling runtime_banner only in E2E tests

* Fix URL encoding mismatch in Cypress test

* banner sttyling

* Cleanup unrelated changes

* Add AASA tests + remove lingering Gemfile.lock changes

* Fix cypress test

* Remove unnecessary window global assignment

* Trigger Travis

* Replace querySelectorAll with querySelector

* Apply suggestions from code review

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* Refactor inline comments, extract URL.deep_link logic and other review feedback

* Small tweaks

* Remove untrusted user-provided redirect (CodeQL suggestion)

* Fix failing tests

* Whoops - another test fix

* Use Forem's UDL server

* Extract timeoutDelay and add comment clarifying

* Add target='_blank' to deep link

* Add TODO comment for replacing hardcoded identifiers

* Apply suggestions from code review

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Add a11y attributes

Co-authored-by: Paweł Ludwiczak <ludwiczakpawel@gmail.com>
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-04-23 15:45:34 -06:00

39 lines
1.4 KiB
Ruby

require "rails_helper"
RSpec.describe "Universal Links (Apple)", type: :request do
let(:aasa_route) { "/.well-known/apple-app-site-association" }
let(:forem_app_id) { "R9SWHSQNV8.com.forem.app" }
let(:dev_app_id) { "R9SWHSQNV8.to.dev.ios" }
describe "returns a valid Apple App Site Association file" do
context "with DEV app backwards compatibility" do
it "responds with applinks support for both" do
allow(SiteConfig).to receive(:dev_to?).and_return(true)
get aasa_route
json_response = JSON.parse(response.body)
both_app_ids = [forem_app_id, dev_app_id]
expect(response).to have_http_status(:ok)
expect(json_response.dig("applinks", "apps")).to match_array(both_app_ids)
json_response.dig("applinks", "details").each do |hash|
expect(both_app_ids).to include(hash["appID"])
expect(hash["paths"]).to match_array(["/*"])
end
end
end
context "when non-DEV Forem instance" do
it "responds with applinks support for Forem app" do
get aasa_route
json_response = JSON.parse(response.body)
expect(response).to have_http_status(:ok)
expect(json_response.dig("applinks", "apps")).to match_array([forem_app_id])
json_response.dig("applinks", "details").each do |hash|
expect(hash["appID"]).to eq(forem_app_id)
expect(hash["paths"]).to match_array(["/*"])
end
end
end
end
end