From 59728fbbd911875227760488ce4752eadaf34574 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Fri, 29 Jan 2021 16:33:47 +0100 Subject: [PATCH] Set base url --- app/test/notebook.spec.ts | 20 ++++++++++---------- app/test/smoke.spec.ts | 4 ++-- app/test/tree.spec.ts | 6 ++---- app/test/utils.ts | 2 ++ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/test/notebook.spec.ts b/app/test/notebook.spec.ts index 800f8f78a..3d0b133aa 100644 --- a/app/test/notebook.spec.ts +++ b/app/test/notebook.spec.ts @@ -3,10 +3,10 @@ import { chromium, firefox, Browser } from 'playwright'; -import { BrowserName } from './utils'; +import { BrowserName, BASE_URL } from './utils'; -const JUPYTERLAB_CLASSIC = - 'http://localhost:8889/classic/notebooks/app/test/data/example.ipynb'; +const NOTEBOOK_PATH = 'app/test/data/example.ipynb'; +const NOTEBOOK_URL = `${BASE_URL}classic/notebooks/${NOTEBOOK_PATH}`; describe('Notebook', () => { let browser: Browser; @@ -23,7 +23,7 @@ describe('Notebook', () => { describe('Title', () => { it('should be rendered', async () => { const page = await browser.newPage(); - await page.goto(JUPYTERLAB_CLASSIC); + await page.goto(NOTEBOOK_URL); await page.waitForTimeout(2000); const href = await page.evaluate(() => { return document.querySelector('#jp-ClassicLogo')?.getAttribute('href'); @@ -35,23 +35,23 @@ describe('Notebook', () => { describe('Renaming', () => { it('should be possible to rename the notebook', async () => { const page = await browser.newPage(); - await page.goto(JUPYTERLAB_CLASSIC); + await page.goto(NOTEBOOK_URL); - // Click text="Untitled.ipynb" + // Click on the title await page.click('text="example.ipynb"'); + // Rename in the input dialog const newName = 'test.ipynb'; await page.fill( - "//div[normalize-space(.)='File Pathapp/test/data/example.ipynbNew Name']/input", + `//div[normalize-space(.)='File Path${NOTEBOOK_PATH}New Name']/input`, newName ); - - // Click text="Rename" await Promise.all([ - page.waitForNavigation(/*{ url: 'http://localhost:8889/classic/notebooks/test.ipynb' }*/), + page.waitForNavigation(), page.click('text="Rename"') ]); + // Check the URL contains the new name const url = page.url(); expect(url).toContain(newName); }); diff --git a/app/test/smoke.spec.ts b/app/test/smoke.spec.ts index 9f326feab..8fe89dc9a 100644 --- a/app/test/smoke.spec.ts +++ b/app/test/smoke.spec.ts @@ -1,6 +1,6 @@ import { chromium, firefox, Browser, BrowserContext } from 'playwright'; -import { BrowserName } from './utils'; +import { BrowserName, BASE_URL } from './utils'; describe('Smoke', () => { let browser: Browser; @@ -25,7 +25,7 @@ describe('Smoke', () => { const tree = await context.newPage(); // Open the tree page - await tree.goto('http://localhost:8889/classic/tree?'); + await tree.goto(`${BASE_URL}classic/tree`); await tree.click('text="Running"'); await tree.click('text="Files"'); diff --git a/app/test/tree.spec.ts b/app/test/tree.spec.ts index 0d07db24a..36c1f8ab4 100644 --- a/app/test/tree.spec.ts +++ b/app/test/tree.spec.ts @@ -1,8 +1,6 @@ import { chromium, firefox, Browser } from 'playwright'; -import { BrowserName } from './utils'; - -const JUPYTERLAB_CLASSIC = 'http://localhost:8889/classic/tree'; +import { BASE_URL, BrowserName } from './utils'; describe('Tree', () => { let browser: Browser; @@ -20,7 +18,7 @@ describe('Tree', () => { describe('File Browser', () => { it('should render a New Notebook button', async () => { const page = await browser.newPage(); - await page.goto(JUPYTERLAB_CLASSIC); + await page.goto(`${BASE_URL}classic/tree`); const button = await page.$('text="New Notebook"'); expect(button).toBeDefined(); diff --git a/app/test/utils.ts b/app/test/utils.ts index 41d8bb460..95959ee48 100644 --- a/app/test/utils.ts +++ b/app/test/utils.ts @@ -1 +1,3 @@ export type BrowserName = 'chromium' | 'firefox'; + +export const BASE_URL = 'http://localhost:8889/';