Skip to content

Commit dce9ac3

Browse files
committed
UI test for refreshing file listing
1 parent 87d383c commit dce9ac3

1 file changed

Lines changed: 98 additions & 0 deletions

File tree

ui-tests/tests/filesystem_interaction.test.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,53 @@ const myMemFsDirectory = {
129129
]
130130
};
131131

132+
const newMemFsDirectory = {
133+
content: [
134+
{
135+
name: '/mymem/mydocs',
136+
type: 'directory',
137+
size: 128,
138+
ino: 49648960,
139+
mode: 16877
140+
},
141+
{
142+
name: '/mymem/myfile.txt',
143+
type: 'file',
144+
size: 128,
145+
ino: 49648960,
146+
mode: 33188
147+
},
148+
{
149+
name: '/mymem/myfile2.txt',
150+
type: 'file',
151+
size: 128,
152+
ino: 49638760,
153+
mode: 33188
154+
},
155+
{
156+
name: '/mymem/otherdocs',
157+
type: 'directory',
158+
size: 2002,
159+
ino: 13894260,
160+
mode: 16877
161+
},
162+
{
163+
name: '/mymem/newfile.txt',
164+
type: 'file',
165+
size: 256,
166+
ino: 49648961,
167+
mode: 33188
168+
},
169+
{
170+
name: '/mymem/anotherfile.txt',
171+
type: 'file',
172+
size: 512,
173+
ino: 49648962,
174+
mode: 33188
175+
}
176+
]
177+
};
178+
132179
test.beforeEach(async ({ page }) => {
133180
await page.route('http://localhost:8888/jupyter_fsspec/config?**', route => {
134181
route.fulfill({
@@ -336,6 +383,57 @@ test('test refresh for updated config', async ({ page }) => {
336383
expect(updatedFilesystemsCount).toEqual(2);
337384
});
338385

386+
test('test refresh for updated files list', async ({ page }) => {
387+
await page.goto();
388+
await page.getByText('FSSpec', { exact: true }).click();
389+
390+
// click on filesystem
391+
await page.locator('.jfss-fsitem-root').click();
392+
393+
// Verify the filesystem name is updated in lower area
394+
await expect.soft(page.locator('.jfss-selectedFsLabel')).toHaveText('mymem');
395+
396+
const treeItems = await page
397+
.locator('jp-tree-view')
398+
.locator('jp-tree-item')
399+
.filter({
400+
has: page.locator(':visible')
401+
});
402+
403+
const oldTreeItemsCount = await treeItems.count();
404+
405+
const filesystem_locator = page.locator('.jfss-fsitem-root');
406+
await filesystem_locator.highlight();
407+
408+
// modified the filesystem listing
409+
await page.route(
410+
'http://localhost:8888/jupyter_fsspec/files?key=mymem&item_path=&type=default&refresh=true&**',
411+
route => {
412+
route.fulfill({
413+
status: 200,
414+
contentType: 'application/json',
415+
body: JSON.stringify(newMemFsDirectory)
416+
});
417+
}
418+
);
419+
420+
await page.getByTitle('Refresh current filesystem').click();
421+
422+
// verify the filesystem listing has been updated
423+
const newTreeItems = page
424+
.locator('jp-tree-view')
425+
.locator('jp-tree-item')
426+
.filter({
427+
has: page.locator(':visible')
428+
});
429+
const newTreeItemsCount = await newTreeItems.count();
430+
const elements = await newTreeItems.elementHandles();
431+
for (const element of elements) {
432+
console.log(await element.evaluate(el => el.textContent));
433+
}
434+
expect(newTreeItemsCount).toBeGreaterThan(oldTreeItemsCount);
435+
});
436+
339437
test('insert open code snippet', async ({ page }) => {
340438
// activate extension from launcher page
341439
await page.goto();

0 commit comments

Comments
 (0)