notebook-max-outputs.test.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. import { expect, galata, test } from '@jupyterlab/galata';
  4. test.use({
  5. mockSettings: {
  6. ...galata.DEFAULT_SETTINGS,
  7. '@jupyterlab/notebook-extension:tracker': {
  8. ...galata.DEFAULT_SETTINGS['@jupyterlab/notebook-extension:tracker'],
  9. maxNumberOutputs: 5
  10. }
  11. }
  12. });
  13. test('Limit cell outputs', async ({ page }) => {
  14. await page.notebook.createNew();
  15. await page.waitForSelector('text=| Idle');
  16. await page.locator('div[role="main"] >> textarea')
  17. .fill(`from IPython.display import display, Markdown
  18. for i in range(10):
  19. display(Markdown('_Markdown_ **text**'))
  20. `);
  21. await page.notebook.run();
  22. await expect(page.locator('.jp-RenderedMarkdown')).toHaveCount(5);
  23. await expect(page.locator('.jp-TrimmedOutputs')).toHaveText(
  24. `
  25. Output of this cell has been trimmed on the initial display.
  26. Displaying the first 5 top outputs.
  27. Click on this message to get the complete output.
  28. `
  29. );
  30. });
  31. test("Don't limit cell outputs if input is requested", async ({ page }) => {
  32. await page.notebook.createNew();
  33. await page.waitForSelector('text=| Idle');
  34. await page.locator('div[role="main"] >> textarea')
  35. .fill(`from IPython.display import display, Markdown
  36. for i in range(10):
  37. display(Markdown('_Markdown_ **text**'))
  38. input('Your age:')
  39. `);
  40. await page.menu.clickMenuItem('Run>Run All Cells');
  41. await page.waitForSelector('.jp-Stdin >> text=Your age:');
  42. expect(await page.locator('.jp-RenderedMarkdown').count()).toBeGreaterThan(5);
  43. await page.keyboard.press('Enter');
  44. });
  45. test('Display input value', async ({ page }) => {
  46. await page.notebook.createNew();
  47. await page.waitForSelector('text=| Idle');
  48. await page.locator('div[role="main"] >> textarea')
  49. .fill(`from IPython.display import display, Markdown
  50. for i in range(10):
  51. display(Markdown('_Markdown_ **text**'))
  52. input('Your age:')
  53. for i in range(10):
  54. display(Markdown('_Markdown_ **text**'))
  55. `);
  56. await page.menu.clickMenuItem('Run>Run All Cells');
  57. await page.waitForSelector('.jp-Stdin >> text=Your age:');
  58. await page.keyboard.type('42');
  59. await page.keyboard.press('Enter');
  60. expect(await page.locator('.jp-RenderedMarkdown').count()).toBeGreaterThan(5);
  61. await expect(page.locator('.jp-RenderedText').first()).toHaveText(
  62. 'Your age: 42'
  63. );
  64. });