참고소스 수정본

This commit is contained in:
LASTA_DEV01\lasta
2026-05-12 19:40:31 +09:00
parent 0f34a451fc
commit 2e9204243d
8708 changed files with 3259488 additions and 869 deletions

View File

@@ -0,0 +1,64 @@
// @ts-check
const { test, expect } = require('@playwright/test');
test.beforeEach(async ({page}) => {
await page.addInitScript(() => {
class FileSystemHandleMock {
constructor({name, children}) {
this.name = name;
children ??= [];
this.kind = children.length ? 'directory' : 'file';
this._children = children;
}
values() {
// Wrap children data in the same mock.
return this._children.map(c => new FileSystemHandleMock(c));
}
}
// Create mock directory
const mockDir = new FileSystemHandleMock({
name: 'root',
children: [
{
name: 'file1',
},
{
name: 'dir1',
children: [
{
name: 'file2',
},
{
name: 'file3',
}
]
},
{
name: 'dir2',
children: [
{
name: 'file4',
},
{
name: 'file5',
}
]
}
]
});
// Make the picker return mock directory
window.showDirectoryPicker = async () => mockDir;
});
});
test('should display directory tree', async ({ page }) => {
await page.goto('/ls-dir.html');
await page.locator('button', { hasText: 'Open directory' }).click();
// Check that the displayed entries match mock directory.
await expect(page.locator('#dir')).toContainText([
'file1',
'dir1', 'file2', 'file3',
'dir2', 'file4', 'file5'
]);
});

View File

@@ -0,0 +1,24 @@
// @ts-check
const { test, expect } = require('@playwright/test');
test.beforeEach(async ({page}) => {
await page.addInitScript(() => {
class FileSystemFileHandleMock {
constructor(file) {
this._file = file;
}
async getFile() {
return this._file;
}
}
window.showOpenFilePicker = async () => [new FileSystemFileHandleMock(new File(['Test content.'], "foo.txt"))];
});
});
test('show file picker with mock class', async ({ page }) => {
await page.goto('/file-picker.html');
await page.locator('button', { hasText: 'Open File' }).click();
// Check that the content of the mock file has been loaded.
await expect(page.locator('textarea')).toHaveValue('Test content.');
});