submitnotebookbutton.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2018-2022 Elyra Authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. describe('Submit Notebook Button tests', () => {
  17. beforeEach(() => {
  18. cy.deleteFile('*.ipynb');
  19. cy.bootstrapFile('helloworld.ipynb');
  20. cy.resetJupyterLab();
  21. });
  22. afterEach(() => {
  23. cy.deleteFile('*.ipynb');
  24. // Delete runtime configuration used for testing
  25. cy.exec('elyra-metadata remove runtimes --name=kfp_test_runtime', {
  26. failOnNonZeroExit: false
  27. });
  28. });
  29. it('check Submit Notebook button exists', () => {
  30. cy.openFile('helloworld.ipynb');
  31. cy.findByText(/run as pipeline/i).should('exist');
  32. });
  33. it('click the "Run as Pipeline" button should display dialog', () => {
  34. // Install runtime configuration
  35. cy.installRuntimeConfig({ type: 'kfp' });
  36. cy.findByRole('tab', { name: /file browser/i }).click();
  37. openNewNotebookFile();
  38. // Click submit notebook button
  39. cy.findByText(/run as pipeline/i).click();
  40. cy.findByRole('button', { name: /save and submit/i }).click();
  41. cy.findByText(/run file as pipeline/i).should('exist');
  42. // Dismiss dialog
  43. cy.findByRole('button', { name: /cancel/i }).click();
  44. });
  45. });
  46. // ------------------------------
  47. // ----- Utility Functions
  48. // ------------------------------
  49. const openNewNotebookFile = (): void => {
  50. cy.get(
  51. '.jp-LauncherCard[data-category="Notebook"][title*="Python 3"]:visible'
  52. )
  53. .first()
  54. .click();
  55. cy.wait(500);
  56. };