Skip to content

Commit 9c041c7

Browse files
authored
Merge pull request #1241 from mito-ds/add-utils
Add utils for filling input and selects
2 parents 8c70153 + 3aadca9 commit 9c041c7

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

tests/streamlit_ui_tests/features/column_control_panel.spec.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FrameLocator, Page, expect, test } from '@playwright/test';
2-
import { awaitResponse, getMitoFrameWithTestCSV, checkColumnCellsHaveExpectedValues } from '../utils';
2+
import { awaitResponse, getMitoFrameWithTestCSV, checkColumnCellsHaveExpectedValues, fillInput, updateSelectedValue } from '../utils';
33

44
const openColumnControlPanel = async (mito: any, columnName: string) => {
55
const columnHeader = await mito.locator('.endo-column-header-final-container', { hasText: columnName });
@@ -8,15 +8,11 @@ const openColumnControlPanel = async (mito: any, columnName: string) => {
88
};
99

1010
const changeDtypeInColumnControlPanel = async (mito: FrameLocator, page: Page, dtype: string) => {
11-
await mito.locator('.spacing-row', { hasText: 'Dtype' }).locator('.select-text').click();
12-
await mito.locator('.mito-dropdown-item', { hasText: dtype }).click();
13-
await awaitResponse(page);
11+
await updateSelectedValue(mito, 'Dtype', dtype);
1412
}
1513

1614
const changeNumTypeInColumnControlPanel = async (mito: FrameLocator, page: Page, numType: string) => {
17-
await mito.locator('.spacing-row', { hasText: 'Num Type' }).locator('.select-text').click();
18-
await mito.locator('.mito-dropdown-item', { hasText: numType }).click();
19-
await awaitResponse(page);
15+
await updateSelectedValue(mito, 'Num Type', numType);
2016
}
2117

2218
const checkValuesTabHasExpectedValues = async (mito: FrameLocator, expectedValues: any[]) => {
@@ -53,7 +49,7 @@ test.describe('Column Control Panel', () => {
5349

5450
await mito.getByText('Add Filter').click();
5551
await mito.getByText('Add a Filter').click();
56-
await mito.locator('.spacing-row', { hasText: 'Where' }).locator('input').fill('4');
52+
await fillInput(mito, 'Where', '4');
5753
await awaitResponse(page);
5854

5955
await checkColumnCellsHaveExpectedValues(mito, 0, ['7', '10']);
@@ -66,7 +62,7 @@ test.describe('Column Control Panel', () => {
6662

6763
await mito.getByText('Add Filter').click();
6864
await mito.getByText('Add a Group').click();
69-
await mito.locator('.spacing-row', { hasText: 'Where' }).locator('input').fill('7');
65+
await fillInput(mito, 'Where', '7');
7066
await awaitResponse(page);
7167

7268
await checkColumnCellsHaveExpectedValues(mito, 0, ['10']);

tests/streamlit_ui_tests/taskpanes/graph.spec.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FrameLocator, Page, expect, test } from '@playwright/test';
2-
import { awaitResponse, clickButtonAndAwaitResponse, clickTab, getMitoFrameWithTestCSV, getMitoFrameWithTypeCSV } from '../utils';
2+
import { awaitResponse, clickButtonAndAwaitResponse, clickTab, fillInput, getMitoFrameWithTestCSV, getMitoFrameWithTypeCSV } from '../utils';
33

44
test.describe.configure({ mode: 'parallel' });
55

@@ -241,14 +241,13 @@ test.describe('Graph Functionality', () => {
241241
await mito.locator('.endo-column-header-final-container').first().getByTitle('Edit Filters').click();
242242
await mito.getByText('Add Filter').click();
243243
await mito.getByText('Add a Filter').click();
244-
await mito.locator('.spacing-row', { hasText: 'Where' }).locator('input').fill('1');
244+
await fillInput(mito, 'Where', '1');
245245
await expect(mito.locator('.mito-grid-cell-selected')).toHaveCount(3);
246246

247247
// Check that the graph has been updated
248248
await expect(mito.locator('.g-gtitle', { hasText: 'Column1 bar chart'})).not.toBeVisible();
249249
await mito.locator('.footer').getByText('graph0').click();
250250

251-
await awaitResponse(page);
252251
await awaitResponse(page);
253252
await expect(mito.locator('.g-gtitle', { hasText: 'Column1 bar chart'})).toBeVisible();
254253
await expect(mito.locator('g.point')).toHaveCount(6);

tests/streamlit_ui_tests/utils.ts

+9
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ export const checkColumnCellsHaveExpectedValues = async (mito: FrameLocator, col
4848
}
4949
}
5050

51+
export const fillInput = async (mito: FrameLocator, inputLabel: string, value: string): Promise<void> => {
52+
await mito.locator('.spacing-row', { hasText: inputLabel }).locator('input').fill(value);
53+
}
54+
55+
export const updateSelectedValue = async (mito: FrameLocator, selectLabel: string, value: string): Promise<void> => {
56+
await mito.locator('.spacing-row', { hasText: selectLabel }).locator('.select-text').click();
57+
await mito.locator('.mito-dropdown-item', { hasText: value }).click();
58+
}
59+
5160
export const hasExpectedNumberOfRows = async (mito: any, expectedRows: number) => {
5261
await expect(mito.locator('.index-header-container', { hasText: `${expectedRows - 1}` })).toBeVisible();
5362
await expect(mito.locator('.index-header-container', { hasText: `${expectedRows}` })).not.toBeVisible();

0 commit comments

Comments
 (0)