From a1f11a4660f4f3f8b1ac09da9175390f23a168ad Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Wed, 5 Apr 2017 08:18:15 +0530 Subject: [PATCH] Fix production tests. --- test/integration/production/pages/about.js | 3 ++ test/integration/production/pages/index.js | 7 +++- .../integration/production/test/index.test.js | 36 ++++++------------- 3 files changed, 19 insertions(+), 27 deletions(-) create mode 100644 test/integration/production/pages/about.js diff --git a/test/integration/production/pages/about.js b/test/integration/production/pages/about.js new file mode 100644 index 00000000..870b2037 --- /dev/null +++ b/test/integration/production/pages/about.js @@ -0,0 +1,3 @@ +export default () => ( +
About Page
+) diff --git a/test/integration/production/pages/index.js b/test/integration/production/pages/index.js index 3d446a4e..e72a01d9 100644 --- a/test/integration/production/pages/index.js +++ b/test/integration/production/pages/index.js @@ -1,3 +1,8 @@ +import Link from 'next/link' + export default () => ( -
Hello World
+
+ About Page +

Hello World

+
) diff --git a/test/integration/production/test/index.test.js b/test/integration/production/test/index.test.js index 2cd043c2..b15c02ee 100644 --- a/test/integration/production/test/index.test.js +++ b/test/integration/production/test/index.test.js @@ -1,6 +1,5 @@ /* global jasmine, describe, it, expect, beforeAll, afterAll */ -import fetch from 'node-fetch' import { join } from 'path' import { nextServer, @@ -9,6 +8,7 @@ import { stopApp, renderViaHTTP } from 'next-test-utils' +import webdriver from 'next-webdriver' const appDir = join(__dirname, '../') let appPort @@ -37,32 +37,16 @@ describe('Production Usage', () => { }) }) - describe('JSON pages', () => { - describe('when asked for a normal page', () => { - it('should serve the normal page', async () => { - const url = `http://localhost:${appPort}/_next/${app.renderOpts.buildId}/pages` - const res = await fetch(url, { compress: false }) - expect(res.headers.get('Content-Encoding')).toBeNull() + describe('With navigation', () => { + it('should navigate via client side', async () => { + const browser = await webdriver(appPort, '/') + const text = await browser + .elementByCss('a').click() + .waitForElementByCss('.about-page') + .elementByCss('div').text() - const page = await res.json() - expect(page.component).toBeDefined() - }) - }) - - describe('when asked for a page with an unknown encoding', () => { - it('should serve the normal page', async () => { - const url = `http://localhost:${appPort}/_next/${app.renderOpts.buildId}/pages` - const res = await fetch(url, { - compress: false, - headers: { - 'Accept-Encoding': 'br' - } - }) - expect(res.headers.get('Content-Encoding')).toBeNull() - - const page = await res.json() - expect(page.component).toBeDefined() - }) + expect(text).toBe('About Page') + browser.close() }) }) })