Skip to content

Commit 559dfb9

Browse files
committed
Fix flaky codesnippetfromselectedcells.cy.ts 2-cells race
The 'test 2 cells' case clicks the toolbar add-cell button and then calls populateCells, which snapshots cy.get('.jp-Cell') once. If JupyterLab has not yet mounted the second cell, only one cell gets typed content. The subsequent shift-click multi-selection then includes an empty cell. save-as-snippet's isEnabled requires getSelectedCellContents().length > 0 (packages/code-snippet/src/index.ts:90-112), so when an empty cell is part of the active selection the menu item renders disabled. The retry helper only checks presence, so it exits the loop, the click fires on a disabled item and no-ops, and the test times out waiting for .elyra-metadataEditor. Wait for the .jp-Cell count to grow after the add-cell click, mirroring the formArrayAdd pattern from #3389. Signed-off-by: Luciano Resende <lresende@apple.com>
1 parent acc0f8b commit 559dfb9

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

cypress/tests/codesnippetfromselectedcells.cy.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,16 @@ describe('Code snippet from cells tests', () => {
6666
});
6767

6868
it('test 2 cells', () => {
69-
// Create new cells
70-
cy.get(
71-
'.jp-NotebookPanel-toolbar > div:nth-child(2) > jp-button:nth-child(1)'
72-
).click();
69+
// Create a new cell and wait for it to mount before populating.
70+
// populateCells snapshots cy.get('.jp-Cell') once; without this wait
71+
// the second cell may not exist yet, leaving it empty so save-as-snippet
72+
// renders disabled and the .elyra-metadataEditor wait times out.
73+
cy.get('.jp-Cell').then(($before) => {
74+
cy.get(
75+
'.jp-NotebookPanel-toolbar > div:nth-child(2) > jp-button:nth-child(1)'
76+
).click();
77+
cy.get('.jp-Cell').should('have.length.greaterThan', $before.length);
78+
});
7379

7480
waitForKernelIdle();
7581

0 commit comments

Comments
 (0)