util.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. import { galata, test } from '@jupyterlab/galata';
  4. const menuPaths = [
  5. 'Edit',
  6. 'View',
  7. 'Run',
  8. 'Kernel',
  9. 'Tabs',
  10. 'Settings',
  11. 'Settings>JupyterLab Theme',
  12. 'Settings>Language',
  13. 'Settings>Console Run Keystroke',
  14. 'Settings>Text Editor Key Map',
  15. 'Settings>Text Editor Theme',
  16. 'Settings>Text Editor Indentation',
  17. 'Settings>Terminal Theme',
  18. 'Help'
  19. ];
  20. const sidebarIds: galata.SidebarTabId[] = [
  21. 'filebrowser',
  22. 'jp-property-inspector',
  23. 'jp-running-sessions',
  24. 'table-of-contents',
  25. 'extensionmanager.main-view'
  26. ];
  27. // eslint-disable-next-line jest/no-export
  28. export function runMenuOpenTest() {
  29. test('Open menu items', async () => {
  30. for (const menuPath of menuPaths) {
  31. await galata.menu.open(menuPath);
  32. expect(await galata.menu.isOpen(menuPath)).toBeTruthy();
  33. const imageName = `opened-menu-${menuPath}`;
  34. const menu = await galata.menu.getOpenMenu();
  35. await galata.capture.screenshot(imageName, menu);
  36. expect(await galata.capture.compareScreenshot(imageName)).toBe('same');
  37. }
  38. });
  39. test('Close all menus', async () => {
  40. await galata.menu.closeAll();
  41. });
  42. }
  43. // eslint-disable-next-line jest/no-export
  44. export function runSidebarOpenTest() {
  45. test('Open Sidebar tabs', async () => {
  46. for (const sidebarId of sidebarIds) {
  47. await galata.sidebar.openTab(sidebarId);
  48. expect(await galata.sidebar.isTabOpen(sidebarId)).toBeTruthy();
  49. const imageName = `opened-sidebar-${sidebarId}`;
  50. const position = await galata.sidebar.getTabPosition(sidebarId);
  51. const sidebar = await galata.sidebar.getContentPanel(position);
  52. await galata.capture.screenshot(imageName, sidebar);
  53. expect(await galata.capture.compareScreenshot(imageName)).toBe('same');
  54. }
  55. });
  56. test('Open file browser tab', async () => {
  57. await galata.sidebar.openTab('filebrowser');
  58. });
  59. }