content,internal: change TestServer to differentiate between latest minor and latest major

The pagecheck.Page.IsLatest field is split into IsLatestMajor and
IsLatestMinor.

The class UnitHeader-versionBanner is also renamed to
UnitHeader-majorVersionBanner.

Change-Id: Iae3dacfba739c70b0606c264c3e2cba258839872
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/277675
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/content/static/css/unit_header.css b/content/static/css/unit_header.css
index 753276f..d7b00a0 100644
--- a/content/static/css/unit_header.css
+++ b/content/static/css/unit_header.css
@@ -99,17 +99,17 @@
 .DetailsHeader-badge--unknown {
   display: none;
 }
-.UnitHeader-versionBanner {
+.UnitHeader-majorVersionBanner {
   background-color: var(--gray-10);
   display: flex;
   margin: -0.5rem 0 1rem 0;
   padding: 0.75rem 0;
 }
 /*
- * TODO: Replace DetailsHeader-banner with UnitHeader-versionBanner in
+ * TODO: Replace DetailsHeader-banner with UnitHeader-majorVersionBanner in
  * middleware/latestversion.go after unit page is launched.
  */
-.UnitHeader-versionBanner--latest,
+.UnitHeader-majorVersionBanner--latest,
 .DetailsHeader-banner--latest {
   display: none;
 }
diff --git a/content/static/html/helpers/_unit_header.tmpl b/content/static/html/helpers/_unit_header.tmpl
index 9068e7b..33b8955 100644
--- a/content/static/html/helpers/_unit_header.tmpl
+++ b/content/static/html/helpers/_unit_header.tmpl
@@ -36,7 +36,7 @@
           <span class="UnitHeader-badge">{{.}}</span>
         {{end}}
       </div>
-      <div class="UnitHeader-versionBanner $$GODISCOVERY_LATESTMAJORCLASS$$" data-test-id="UnitHeader-versionBanner">
+      <div class="UnitHeader-majorVersionBanner $$GODISCOVERY_LATESTMAJORCLASS$$" data-test-id="UnitHeader-majorVersionBanner">
         <img height="19px" width="16px" class="UnitHeader-detailIcon" src="/static/img/pkg-icon-info_19x16.svg" alt="">
         <span>
           The highest tagged major version is <a href="/$$GODISCOVERY_LATESTMAJORVERSIONURL$$">$$GODISCOVERY_LATESTMAJORVERSION$$</a>.
diff --git a/internal/frontend/server_test.go b/internal/frontend/server_test.go
index e1221db..3c1c14d 100644
--- a/internal/frontend/server_test.go
+++ b/internal/frontend/server_test.go
@@ -323,7 +323,8 @@
 		Version:                sample.VersionString,
 		FormattedVersion:       sample.VersionString,
 		Suffix:                 sample.Suffix,
-		IsLatest:               true,
+		IsLatestMinor:          true,
+		IsLatestMajor:          true,
 		LatestLink:             "/" + sample.ModulePath + "@" + sample.VersionString + "/" + sample.Suffix,
 		LatestMajorVersionLink: "/" + sample.ModulePath + "/" + sample.Suffix,
 		LicenseType:            sample.LicenseType,
@@ -338,7 +339,8 @@
 		Version:                "v1.0.0",
 		FormattedVersion:       "v1.0.0",
 		Suffix:                 "bar",
-		IsLatest:               false,
+		IsLatestMinor:          true,
+		IsLatestMajor:          false,
 		LatestLink:             "/github.com/v2major/module_name@v1.0.0/bar",
 		LatestMajorVersion:     "v2",
 		LatestMajorVersionLink: "/github.com/v2major/module_name/v2/bar",
@@ -351,6 +353,8 @@
 	v2pkgV1Buz := *v2pkgV100
 	v2pkgV1Buz.Title = "buz"
 	v2pkgV1Buz.Suffix = "buz"
+	v2pkgV1Buz.IsLatestMajor = false
+	v2pkgV1Buz.IsLatestMinor = true
 	v2pkgV1Buz.LatestLink = "/github.com/v2major/module_name@v1.0.0/buz"
 	v2pkgV1Buz.LatestMajorVersionLink = "/github.com/v2major/module_name/v2"
 	v2pkgV1Buz.PackageURLFormat = "/github.com/v2major/module_name%s/buz"
@@ -361,7 +365,8 @@
 		Version:                "v2.0.0",
 		FormattedVersion:       "v2.0.0",
 		Suffix:                 "bar",
-		IsLatest:               true,
+		IsLatestMinor:          true,
+		IsLatestMajor:          true,
 		LatestLink:             "/github.com/v2major/module_name/v2@v2.0.0/bar",
 		LatestMajorVersion:     "v2",
 		LatestMajorVersionLink: "/github.com/v2major/module_name/v2/bar",
@@ -374,13 +379,15 @@
 	p9 := *pkgV100
 	p9.Version = "v0.9.0"
 	p9.FormattedVersion = "v0.9.0"
-	p9.IsLatest = false
+	p9.IsLatestMinor = false
+	p9.IsLatestMajor = true
 	pkgV090 := &p9
 
 	pp := *pkgV100
 	pp.Version = pseudoVersion
 	pp.FormattedVersion = "v0.0.0-...-1234567"
-	pp.IsLatest = false
+	pp.IsLatestMinor = false
+	p9.IsLatestMajor = false
 	pkgPseudo := &pp
 
 	pkgInc := &pagecheck.Page{
@@ -389,7 +396,8 @@
 		Version:                "v1.0.0+incompatible",
 		FormattedVersion:       "v1.0.0+incompatible",
 		Suffix:                 "dir/inc",
-		IsLatest:               true,
+		IsLatestMinor:          true,
+		IsLatestMajor:          true,
 		LatestLink:             "/github.com/incompatible@v1.0.0+incompatible/dir/inc",
 		LatestMajorVersionLink: "/github.com/incompatible/dir/inc",
 		LicenseType:            "MIT",
@@ -404,7 +412,8 @@
 		Version:                "v1.0.0",
 		FormattedVersion:       "v1.0.0",
 		Suffix:                 "bar",
-		IsLatest:               true,
+		IsLatestMinor:          true,
+		IsLatestMajor:          true,
 		LatestLink:             "/github.com/non_redistributable@v1.0.0/bar",
 		LatestMajorVersionLink: "/github.com/non_redistributable/bar",
 		LicenseType:            "",
@@ -420,6 +429,8 @@
 		Suffix:                 "foo/directory",
 		LicenseType:            "MIT",
 		LicenseFilePath:        "LICENSE",
+		IsLatestMinor:          true,
+		IsLatestMajor:          true,
 		ModuleURL:              "/" + sample.ModulePath,
 		PackageURLFormat:       "/" + sample.ModulePath + "%s/foo/directory",
 		LatestMajorVersionLink: "/github.com/valid/module_name/foo/directory",
@@ -433,14 +444,16 @@
 		FormattedVersion:       "v1.0.0",
 		LicenseType:            "MIT",
 		LicenseFilePath:        "LICENSE",
-		IsLatest:               true,
+		IsLatestMinor:          true,
+		IsLatestMajor:          true,
 		LatestLink:             "/" + sample.ModulePath + "@v1.0.0",
 		LatestMajorVersionLink: "/" + sample.ModulePath,
 	}
 	mp := *mod
 	mp.Version = pseudoVersion
 	mp.FormattedVersion = "v0.0.0-...-1234567"
-	mp.IsLatest = false
+	mp.IsLatestMinor = false
+	mp.IsLatestMajor = true
 
 	dirPseudo := &pagecheck.Page{
 		ModulePath:             "github.com/pseudo",
@@ -453,7 +466,8 @@
 		FormattedVersion:       mp.FormattedVersion,
 		LicenseType:            "MIT",
 		LicenseFilePath:        "LICENSE",
-		IsLatest:               true,
+		IsLatestMinor:          true,
+		IsLatestMajor:          true,
 		PackageURLFormat:       "/github.com/pseudo%s/dir",
 	}
 
@@ -465,6 +479,8 @@
 		Suffix:                 "cmd",
 		LicenseType:            "MIT",
 		LicenseFilePath:        "LICENSE",
+		IsLatestMajor:          true,
+		IsLatestMinor:          true,
 		ModuleURL:              "/std",
 		PackageURLFormat:       "/cmd%s",
 		LatestMajorVersionLink: "/cmd",
@@ -479,7 +495,8 @@
 		LicenseFilePath:        sample.LicenseFilePath,
 		ModuleURL:              "/net/http",
 		PackageURLFormat:       "/net/http%s",
-		IsLatest:               true,
+		IsLatestMinor:          true,
+		IsLatestMajor:          true,
 		LatestLink:             "/net/http@go1.13",
 		LatestMajorVersionLink: "/net/http",
 	}
diff --git a/internal/testing/pagecheck/pagecheck.go b/internal/testing/pagecheck/pagecheck.go
index 12e6022..802e740 100644
--- a/internal/testing/pagecheck/pagecheck.go
+++ b/internal/testing/pagecheck/pagecheck.go
@@ -26,7 +26,8 @@
 	Title              string
 	LicenseType        string
 	LicenseFilePath    string
-	IsLatest           bool   // is this the latest version of this module?
+	IsLatestMinor      bool   // path is in the latest minor version of this module
+	IsLatestMajor      bool   // path is in the latest major version of this series
 	LatestLink         string // href of "Go to latest" link
 	LatestMajorVersion string // is the suffix of the latest major version, empty if v0 or v1
 	// link to the latest major version for this package, or if the package does not exist
@@ -135,16 +136,16 @@
 		commitTime = time.Now().In(time.UTC).Format("Jan _2, 2006")
 	}
 
-	versionBannerClass := "UnitHeader-versionBanner"
-	if p.IsLatest {
-		versionBannerClass += "  DetailsHeader-banner--latest"
+	majorVersionBannerClass := "UnitHeader-majorVersionBanner"
+	if p.IsLatestMajor {
+		majorVersionBannerClass += "  DetailsHeader-banner--latest"
 	}
 
 	return in("header.UnitHeader",
 		in(`[data-test-id="UnitHeader-breadcrumbCurrent"]`, text(curBreadcrumb)),
 		in(`[data-test-id="UnitHeader-title"]`, text(p.Title)),
-		in(`[data-test-id="UnitHeader-versionBanner"]`,
-			attr("class", versionBannerClass),
+		in(`[data-test-id="UnitHeader-majorVersionBanner"]`,
+			attr("class", majorVersionBannerClass),
 			in("span",
 				text("The highest tagged major version is "),
 				in("a",
@@ -229,7 +230,7 @@
 // versionBadge checks the latest-version badge on a header.
 func versionBadge(p *Page) htmlcheck.Checker {
 	class := "DetailsHeader-badge"
-	if p.IsLatest {
+	if p.IsLatestMinor {
 		class += "--latest"
 	} else {
 		class += "--goToLatest"