-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AA test for Search Results #3053
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module AbTests::ElasticSearchAaTestable | ||
def elastic_search_aa_test | ||
GovukAbTesting::AbTest.new( | ||
"EsSixPointSeven", | ||
dimension: 41, | ||
allowed_variants: %w[A B Z], | ||
control_variant: "Z", | ||
) | ||
end | ||
|
||
def page_under_test? | ||
request.path.include?("/search/all") | ||
end | ||
|
||
def set_requested_variant | ||
@requested_variant = elastic_search_aa_test.requested_variant(request.headers) | ||
@requested_variant.configure_response(response) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
after { Rails.cache.clear } | ||
|
||
describe "GET show" do | ||
render_views | ||
describe "a finder content item exists" do | ||
before do | ||
stub_content_store_has_item( | ||
|
@@ -108,6 +109,52 @@ | |
get :show, params: { slug: "lunch-finder" } | ||
expect(response.status).to eq(406) | ||
end | ||
|
||
context "with AA test" do | ||
%w[A B Z].each do |variant| | ||
it "renders the #{variant} variant for /search/all pages" do | ||
stub_content_store_has_item( | ||
"/search/all", | ||
all_content_finder, | ||
) | ||
|
||
@request.headers["GOVUK-ABTest-EsSixPointSeven"] = variant | ||
|
||
get :show, params: { slug: "search/all" } | ||
|
||
expect(response.header["Vary"]).to eq("GOVUK-ABTest-EsSixPointSeven") | ||
expect(response.body).to include("EsSixPointSeven:#{variant}") | ||
end | ||
|
||
it "doesn't render the #{variant} for finders" do | ||
stub_content_store_has_item( | ||
"/lunch-finder", | ||
lunch_finder, | ||
) | ||
|
||
@request.headers["GOVUK-ABTest-EsSixPointSeven"] = variant | ||
|
||
get :show, params: { slug: "lunch-finder" } | ||
|
||
expect(response.status).to eq(200) | ||
expect(response.header["Vary"]).not_to eq("GOVUK-ABTest-EsSixPointSeven") | ||
expect(response.body).not_to include("EsSixPointSeven:#{variant}") | ||
end | ||
end | ||
|
||
it "should render the page without an AB test variant for search" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I follow how this test is different from "renders the #{variant} variant for /search/all pages". Is it because the variant is not being passed in the header? But the Vary header is still being set? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, tbh this was more out of paranoia to test that the page would still render if something went wrong with setting the variant, but its probably not needed as it should work! |
||
stub_content_store_has_item( | ||
"/search/all", | ||
all_content_finder, | ||
) | ||
|
||
get :show, params: { slug: "search/all" } | ||
|
||
expect(response.status).to eq(200) | ||
expect(response.header["Vary"]).to eq("GOVUK-ABTest-EsSixPointSeven") | ||
expect(response.body).not_to include("<meta name=\"govuk:ab-test\">") | ||
end | ||
end | ||
end | ||
|
||
describe "a finder content item with a default order exists" do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!