forked from jupyterlab-contrib/jupyterlab-variableInspector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlckr_jupyterlab_variableinspector.spec.ts
111 lines (97 loc) · 4.11 KB
/
lckr_jupyterlab_variableinspector.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { expect, test } from '@jupyterlab/galata';
test('test', async ({ page }) => {
await page.getByText('Python 3 (ipykernel)').first().click();
await page.getByText('Python 3 (ipykernel) | Idle').waitFor();
await page.getByLabel('notebook content').getByRole('textbox').fill('a = 1');
await page.keyboard.press('Shift+Enter');
await page.getByRole('textbox').nth(1).fill('b = "hello"');
await page.keyboard.press('Control+Enter');
await page.getByRole('tabpanel').click({
button: 'right'
});
await page.getByRole('menu').getByText('Open Variable Inspector').click();
// const rows = await page.locator('.jp-VarInspector-table-row');
const firstRow = await page.locator('.jp-VarInspector-table-row').first();
await expect
.soft(firstRow.locator('.jp-VarInspector-varName'))
.toHaveText(/a/);
await expect
.soft(firstRow.locator('.jp-VarInspector-type'))
.toHaveText(/int/);
await expect
.soft(firstRow.locator('jp-data-grid-cell').nth(4))
.toHaveText(/\d\d/);
await expect
.soft(firstRow.locator('jp-data-grid-cell').last())
.toHaveText(/1/);
const secondRow = await page.locator('.jp-VarInspector-table-row').last();
await expect
.soft(secondRow.locator('.jp-VarInspector-varName'))
.toHaveText(/b/);
await expect
.soft(secondRow.locator('.jp-VarInspector-type'))
.toHaveText(/str/);
await expect
.soft(secondRow.locator('jp-data-grid-cell').nth(4))
.toHaveText(/\d\d/);
await expect
.soft(secondRow.locator('jp-data-grid-cell').last())
.toHaveText(/hello/);
});
test('variable filter', async ({ page }) => {
await page.getByText('Python 3 (ipykernel)').first().click();
await page.getByText('Python 3 (ipykernel) | Idle').waitFor();
await page.getByLabel('notebook content').getByRole('textbox').fill('a1 = 1');
await page.keyboard.press('Shift+Enter');
await page.getByRole('textbox').nth(1).fill('b1 = "hello"');
await page.keyboard.press('Control+Enter');
await page.getByRole('tabpanel').click({
button: 'right'
});
await page.getByRole('menu').getByText('Open Variable Inspector').click();
//Filter out rows with int type
await page.locator('.filter-input').pressSequentially('int');
await page.locator('.filter-button').click();
//expect.soft only to have one row with name b and type str
await expect
.soft(await page.locator('.jp-VarInspector-table-row').count())
.toEqual(1);
const bRow = await page.locator('.jp-VarInspector-table-row').first();
await expect.soft(bRow.locator('.jp-VarInspector-varName')).toHaveText(/b1/);
await expect.soft(bRow.locator('.jp-VarInspector-type')).toHaveText(/str/);
await expect
.soft(bRow.locator('jp-data-grid-cell').nth(4))
.toHaveText(/\d\d/);
await expect
.soft(bRow.locator('jp-data-grid-cell').last())
.toHaveText(/hello/);
// Remove filter
await page.locator('.filtered-variable-button').click();
//Filter out all variables with 1 in the name
await page.evaluate('document.querySelector(".filter-type").value="name"');
await page.locator('.filter-input').pressSequentially('*1');
await page.locator('.filter-button').click();
//expect.softs no rows except for header
await expect
.soft(await page.locator('.jp-VarInspector-table-row').count())
.toEqual(0);
//Remove the filter
await page.locator('.filtered-variable-button').click();
await expect
.soft(await page.locator('.jp-VarInspector-table-row').count())
.toEqual(2);
//Filter out variables name b1
await page.locator('.filter-input').pressSequentially('b1');
await page.locator('.filter-button').click();
//expect.soft one row with name a1 and type int
await expect
.soft(await page.locator('.jp-VarInspector-table-row').count())
.toEqual(1);
const aRow = await page.locator('.jp-VarInspector-table-row').first();
await expect.soft(aRow.locator('.jp-VarInspector-varName')).toHaveText(/a1/);
await expect.soft(aRow.locator('.jp-VarInspector-type')).toHaveText(/int/);
await expect
.soft(aRow.locator('jp-data-grid-cell').nth(4))
.toHaveText(/\d\d/);
await expect.soft(aRow.locator('jp-data-grid-cell').last()).toHaveText(/1/);
});