aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--e2e/__image_snapshots__/frontend-fetch-test-ts-frontend-fetch-desktop-viewport-matches-image-snapshot-1-snap.pngbin0 -> 100483 bytes
-rw-r--r--e2e/__image_snapshots__/frontend-fetch-test-ts-frontend-fetch-mobile-viewport-matches-image-snapshot-1-snap.pngbin0 -> 324775 bytes
-rw-r--r--e2e/__snapshots__/frontend-fetch.test.ts.snap186
-rw-r--r--e2e/frontend-fetch.test.ts49
4 files changed, 235 insertions, 0 deletions
diff --git a/e2e/__image_snapshots__/frontend-fetch-test-ts-frontend-fetch-desktop-viewport-matches-image-snapshot-1-snap.png b/e2e/__image_snapshots__/frontend-fetch-test-ts-frontend-fetch-desktop-viewport-matches-image-snapshot-1-snap.png
new file mode 100644
index 00000000..b54eeb60
--- /dev/null
+++ b/e2e/__image_snapshots__/frontend-fetch-test-ts-frontend-fetch-desktop-viewport-matches-image-snapshot-1-snap.png
Binary files differ
diff --git a/e2e/__image_snapshots__/frontend-fetch-test-ts-frontend-fetch-mobile-viewport-matches-image-snapshot-1-snap.png b/e2e/__image_snapshots__/frontend-fetch-test-ts-frontend-fetch-mobile-viewport-matches-image-snapshot-1-snap.png
new file mode 100644
index 00000000..fc66e3f9
--- /dev/null
+++ b/e2e/__image_snapshots__/frontend-fetch-test-ts-frontend-fetch-mobile-viewport-matches-image-snapshot-1-snap.png
Binary files differ
diff --git a/e2e/__snapshots__/frontend-fetch.test.ts.snap b/e2e/__snapshots__/frontend-fetch.test.ts.snap
new file mode 100644
index 00000000..2bd7dfe3
--- /dev/null
+++ b/e2e/__snapshots__/frontend-fetch.test.ts.snap
@@ -0,0 +1,186 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Frontend Fetch accessibility tree matches snapshot 1`] = `
+Object {
+ "children": Array [
+ Object {
+ "name": "Black Lives Matter",
+ "role": "text",
+ },
+ Object {
+ "name": "Support the Equal Justice Initiative",
+ "role": "link",
+ },
+ Object {
+ "name": "Link to Go homepage",
+ "role": "link",
+ },
+ Object {
+ "name": "Search for a package",
+ "role": "button",
+ },
+ Object {
+ "description": "Search for a package",
+ "name": "Search for a package",
+ "role": "textbox",
+ },
+ Object {
+ "description": "Why Go",
+ "name": "Why Go",
+ "role": "link",
+ },
+ Object {
+ "description": "Getting Started",
+ "name": "Getting Started",
+ "role": "link",
+ },
+ Object {
+ "description": "Discover Packages",
+ "name": "Discover Packages",
+ "role": "link",
+ },
+ Object {
+ "name": "About",
+ "role": "link",
+ },
+ Object {
+ "name": "The Go Gopher",
+ "role": "img",
+ },
+ Object {
+ "level": 3,
+ "name": "Oops! We couldn't find “golang.org/x/tools/gopls@v0.6.6”.",
+ "role": "heading",
+ },
+ Object {
+ "name": "Check that you entered the URL correctly, try fetching it following the",
+ "role": "text",
+ },
+ Object {
+ "name": "instructions here",
+ "role": "link",
+ },
+ Object {
+ "name": ", or request to add “golang.org/x/tools/gopls@v0.6.6” to pkg.go.dev.",
+ "role": "text",
+ },
+ Object {
+ "name": "Request “golang.org/x/tools/gopls@v0.6.6”",
+ "role": "button",
+ },
+ Object {
+ "description": "Why Go",
+ "name": "Why Go",
+ "role": "link",
+ },
+ Object {
+ "description": "Use Cases",
+ "name": "Use Cases",
+ "role": "link",
+ },
+ Object {
+ "description": "Case Studies",
+ "name": "Case Studies",
+ "role": "link",
+ },
+ Object {
+ "description": "Getting Started",
+ "name": "Getting Started",
+ "role": "link",
+ },
+ Object {
+ "name": "Playground",
+ "role": "link",
+ },
+ Object {
+ "name": "Tour",
+ "role": "link",
+ },
+ Object {
+ "name": "Stack Overflow",
+ "role": "link",
+ },
+ Object {
+ "description": "Discover Packages",
+ "name": "Discover Packages",
+ "role": "link",
+ },
+ Object {
+ "description": "About",
+ "name": "About",
+ "role": "link",
+ },
+ Object {
+ "name": "Download",
+ "role": "link",
+ },
+ Object {
+ "name": "Blog",
+ "role": "link",
+ },
+ Object {
+ "name": "Release Notes",
+ "role": "link",
+ },
+ Object {
+ "name": "Brand Guidelines",
+ "role": "link",
+ },
+ Object {
+ "name": "Code of Conduct",
+ "role": "link",
+ },
+ Object {
+ "description": "Connect",
+ "name": "Connect",
+ "role": "link",
+ },
+ Object {
+ "name": "Twitter",
+ "role": "link",
+ },
+ Object {
+ "name": "GitHub",
+ "role": "link",
+ },
+ Object {
+ "name": "Slack",
+ "role": "link",
+ },
+ Object {
+ "name": "Meetup",
+ "role": "link",
+ },
+ Object {
+ "name": "Gopher in flight goggles",
+ "role": "img",
+ },
+ Object {
+ "name": "Copyright",
+ "role": "link",
+ },
+ Object {
+ "name": "Terms of Service",
+ "role": "link",
+ },
+ Object {
+ "name": "Privacy Policy",
+ "role": "link",
+ },
+ Object {
+ "name": "Report an Issue",
+ "role": "link",
+ },
+ Object {
+ "name": "golang.org",
+ "role": "link",
+ },
+ Object {
+ "name": "Google logo",
+ "role": "link",
+ },
+ ],
+ "name": "404 Not Found · pkg.go.dev",
+ "role": "WebArea",
+}
+`;
diff --git a/e2e/frontend-fetch.test.ts b/e2e/frontend-fetch.test.ts
new file mode 100644
index 00000000..6965fb85
--- /dev/null
+++ b/e2e/frontend-fetch.test.ts
@@ -0,0 +1,49 @@
+/**
+ * @license
+ * Copyright 2020 The Go Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file.
+ */
+
+import './globals';
+import puppeteer from 'puppeteer';
+
+const baseUrl = process.env.FRONTEND_URL ?? '';
+
+const selectors = {
+ fetchButton: '.js-fetchButton',
+ fetchMessage: '.js-fetchMessage',
+};
+
+describe('Frontend Fetch', () => {
+ beforeAll(async () => {
+ await page.goto(baseUrl + '/golang.org/x/tools/gopls@v0.6.6');
+ });
+
+ test('accessibility tree matches snapshot', async () => {
+ const a11yTree = await page.accessibility.snapshot();
+ expect(a11yTree).toMatchSnapshot();
+ });
+
+ test('desktop viewport matches image snapshot', async () => {
+ const image = await page.screenshot({ fullPage: true });
+ expect(image).toMatchImageSnapshot();
+ });
+
+ test('mobile viewport matches image snapshot', async () => {
+ await page.emulate(puppeteer.devices['Pixel 2']);
+ const image = await page.screenshot({ fullPage: true });
+ expect(image).toMatchImageSnapshot();
+ });
+
+ test('clicking fetch button fetches module and navigates to page', async () => {
+ expect(await page.title()).toBe('404 Not Found · pkg.go.dev');
+
+ await page.click(selectors.fetchButton);
+ const message = await page.$eval(selectors.fetchMessage, el => el.textContent);
+ expect(message).toBe('Fetching golang.org/x/tools/gopls@v0.6.6');
+
+ await page.waitForNavigation();
+ expect(await page.title()).toBe('gopls · pkg.go.dev');
+ }, 30000);
+});