Skip to content

Commit 62cf2a4

Browse files
marthacryannaterush
authored andcommitted
Add test for switching between cell editor and formula bar in cross-sheet formulas
1 parent 34d3128 commit 62cf2a4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/streamlit_ui_tests/grid/set_column_formula_tests.spec.ts

+35
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,38 @@ test('Can\'t use cross-sheet formula for non-vlookup calls', async ({ page }) =>
362362
await mito.locator('input#cell-editor-input').press('Enter');
363363
await expect(mito.getByText('Cross-sheet references are only allowed in calls to VLOOKUP')).toBeVisible();
364364
});
365+
366+
test('Start writing a cross-sheet formula using cel editor and switch to formula bar', async ({ page }) => {
367+
const mito = await getMitoFrameWithTestCSV(page);
368+
// Add a new column to this sheet because the dropdown covers the columns when the formula bar is open
369+
await mito.locator('.mito-toolbar-button', { hasText: 'Insert' }).click();
370+
371+
await importCSV(page, mito, 'merge.csv');
372+
373+
// Add a new column to put the VLOOKUP call in
374+
await mito.locator('.mito-toolbar-button', { hasText: 'Insert' }).click();
375+
await mito.locator('.mito-grid-cell[mito-col-index="1"]').first().dblclick();
376+
377+
// Start the VLOOKUP formula
378+
await mito.locator('input#cell-editor-input').fill('=VLOOKUP(');
379+
// Click on the first cell in Column1 to reference it as the first argument
380+
await mito.locator('.mito-grid-cell[mito-col-index="0"]').first().click();
381+
// Type the comma to separate the arguments
382+
await mito.locator('input#cell-editor-input').press('End');
383+
await mito.locator('input#cell-editor-input').press(',');
384+
385+
// Switch to the formula bar
386+
await mito.locator('.formula-bar').dblclick();
387+
388+
// Navigate to the other sheet and select the range of columns
389+
await mito.locator('.tab', { hasText: 'test' }).click();
390+
await mito.locator('.endo-column-header-final-text', { hasText: 'Column1' }).click();
391+
await mito.locator('.endo-column-header-final-text', { hasText: 'Column3' }).click({ modifiers: ['Shift'] });
392+
// Finish the formula
393+
await mito.locator('#cell-editor-input').press('End');
394+
await mito.locator('#cell-editor-input').pressSequentially(', 3)');
395+
await mito.locator('#cell-editor-input').press('Enter');
396+
397+
// Expect that it navigated automatically back to the original sheet and that the values are correct
398+
await checkColumnCellsHaveExpectedValues(mito, 1, ['2.00', '5.00', '5.00', 'NaN', '11.00'])
399+
});

0 commit comments

Comments
 (0)