Set base url

This commit is contained in:
Jeremy Tuloup 2021-01-29 16:33:47 +01:00
parent e1c3197566
commit 59728fbbd9
4 changed files with 16 additions and 16 deletions

View File

@ -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);
});

View File

@ -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"');

View File

@ -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();

View File

@ -1 +1,3 @@
export type BrowserName = 'chromium' | 'firefox';
export const BASE_URL = 'http://localhost:8889/';