Fix ahoy's tracking spec [skip ci] (#20825)

This commit is contained in:
Mac Siri 2024-04-02 13:09:21 -04:00 committed by GitHub
parent a0b68a6956
commit 8c71491d6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,14 +2,9 @@ require "rails_helper"
RSpec.describe "Tracking 'Clicked on Create Account'", :js do
context "when on the homepage" do
let(:user) { create(:user) }
# rubocop:disable RSpec/LetSetup
# this is to ensure that we see "ca_feed_home_page" which appears
# in a card after the fifth article
let!(:articles) { create_list(:article, 6, user: user) }
# rubocop:enable RSpec/LetSetup
before do
user = create(:user)
create_list(:article, 6, user: user)
visit root_path
end
@ -21,6 +16,7 @@ RSpec.describe "Tracking 'Clicked on Create Account'", :js do
it "has the create account tracking element in the hamburger", :aggregate_failures do
Capybara.current_session.driver.resize(425, 694)
first(".js-hamburger-trigger").click
# expect /message route to receive a request
expect(page).to have_css('a[data-tracking-id="ca_hamburger_home_page"]')
end
@ -37,10 +33,9 @@ RSpec.describe "Tracking 'Clicked on Create Account'", :js do
it "adds an ahoy event", :aggregate_failures do
article = create(:article, user: create(:user))
visit article.path
expect(Ahoy::Event.count).to eq(0)
find(".follow-action-button").click
expect do
find(".js-global-signup-modal__create-account").click
end.to change(Ahoy::Event, :count).by(1)
find(".js-global-signup-modal__create-account").click
expect(page).to have_current_path("/enter?state=new-user")
expect(Ahoy::Event.last.name).to eq("Clicked on Create Account")