Skip to content

Commit

Permalink
added test that fails without PR but passes with it
Browse files Browse the repository at this point in the history
  • Loading branch information
Meriem-BenIsmail committed Nov 19, 2024
1 parent aa0277f commit 1f4ad46
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions ui-tests/tests/timeline-slider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,36 @@
*/

import { expect, test } from '@jupyterlab/galata';
import { Page } from '@playwright/test';

test.describe('Timeline Slider', () => {
test('should not show errors when opening file from path', async ({ page, tmpPath }) => {
await page.notebook.createNew();
await page.notebook.save();
await page.notebook.close();

// Step 1: Click on the "File" menu
await page.click('text=File');
await page.waitForSelector('.lm-Menu-itemLabel:text("Open from Path…")', { state: 'visible' });
async function capturePageErrors(page: Page) {
const pageErrors: string[] = [];
page.on('pageerror', (error) => pageErrors.push(error.message));
return pageErrors;
}

// Step 2: Select "Open from Path..."
async function openNotebook(page: Page, notebookPath: string) {
await page.click('text=File');
await page.click('.lm-Menu-itemLabel:text("Open from Path…")');
await page.fill(
'input[placeholder="/path/relative/to/jlab/root"]',
notebookPath
);
await page.click('.jp-Dialog-buttonLabel:text("Open")');
await page.waitForSelector('.jp-Notebook', { state: 'visible' });
}

// Step 3: Enter the path for the notebook
await page.waitForSelector('input[placeholder="/path/relative/to/jlab/root"]');
await page.fill('input[placeholder="/path/relative/to/jlab/root"]', `${tmpPath}/Untitled.ipynb`);
await page.click('.jp-Dialog-buttonLabel:text("Open")');
test('should fail if there are console errors', async ({ page, tmpPath }) => {
const pageErrors = await capturePageErrors(page);

await page.waitForSelector('.jp-Notebook', { state: 'visible' });


// Step 6: Assert that no error is thrown
const consoleMessages: any[] = [];
page.on('console', (msg) => {
if (msg.type() === 'error') {
consoleMessages.push(msg.text());
}
});
await page.waitForTimeout(1000);
await page.notebook.createNew();
await page.notebook.save();
await page.notebook.close();

// Ensure there are no errors in the console
expect(consoleMessages).toHaveLength(0);
await openNotebook(page, `${tmpPath}/Untitled.ipynb`);

expect(pageErrors).toHaveLength(0);
});
});

0 comments on commit 1f4ad46

Please sign in to comment.