From eb69c7ec8c1f732c67978355f6efff1f7dfe2fac Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Mon, 6 Dec 2021 11:04:07 -0600 Subject: Allow default branch to be inferred on compare page (#17908) * Allow default branch to be inferred Signed-off-by: jolheiser * Add test for inferred default branch Signed-off-by: jolheiser Co-authored-by: Lunny Xiao --- integrations/compare_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'integrations') diff --git a/integrations/compare_test.go b/integrations/compare_test.go index e8efe7cd09..0fb2ae6c91 100644 --- a/integrations/compare_test.go +++ b/integrations/compare_test.go @@ -27,3 +27,15 @@ func TestCompareTag(t *testing.T) { resp = session.MakeRequest(t, req, http.StatusNotFound) assert.False(t, strings.Contains(resp.Body.String(), "/assets/img/500.png"), "expect 404 page not 500") } + +// Compare with inferred default branch (master) +func TestCompareDefault(t *testing.T) { + defer prepareTestEnv(t)() + + session := loginUser(t, "user2") + req := NewRequest(t, "GET", "/user2/repo1/compare/v1.1") + resp := session.MakeRequest(t, req, http.StatusOK) + htmlDoc := NewHTMLParser(t, resp.Body) + selection := htmlDoc.doc.Find(".choose.branch .filter.dropdown") + assert.Lenf(t, selection.Nodes, 2, "The template has changed") +} -- cgit v1.2.3