fix: preserve file paths for local playlist refresh

Refs https://github.com/4gray/iptvnator/issues/891

Entire-Checkpoint: f957cd9849e0
This commit is contained in:
4gray committed 2026-05-04 10:06:39 +02:00
1 parent 568c03fe0e
commit 2efdfea0c1
12 files changed
+457 -5

No files matched your search

@@ -289,6 +289,60 @@ export async function importM3uPlaylistFromNativeDialog(
await dialog.waitFor({ state: 'detached' });
}
export async function dropM3uPlaylistOntoWorkspace(
page: Page,
filePath: string
): Promise<void> {
await expect(page.locator('.workspace-shell')).toBeVisible({
timeout: 20000,
});
const inputHandle = await page.evaluateHandle(() => {
const input = document.createElement('input');
input.type = 'file';
input.style.position = 'fixed';
input.style.left = '-9999px';
document.body.append(input);
return input;
});
const inputElement = inputHandle.asElement();
if (!inputElement) {
await inputHandle.dispose();
throw new Error('Could not create temporary file input.');
}
await inputElement.setInputFiles(filePath);
await page.evaluate((element) => {
const input = element as HTMLInputElement;
const file = input.files?.[0];
if (!file) {
throw new Error('Temporary file input did not receive a file.');
}
const target = document.querySelector('.workspace-shell');
if (!target) {
throw new Error('Workspace drop target was not found.');
}
const dataTransfer = new DataTransfer();
dataTransfer.items.add(file);
for (const type of ['dragenter', 'dragover', 'drop']) {
target.dispatchEvent(
new DragEvent(type, {
bubbles: true,
cancelable: true,
dataTransfer,
})
);
}
input.remove();
}, inputElement);
await inputHandle.dispose();
}
export async function addXtreamPortal(
page: Page,
options: {
+41 -1
View File
@@ -4,11 +4,13 @@ import {
closeElectronApp,
createMutableTextServer,
deleteSource,
dropM3uPlaylistOntoWorkspace,
dragSourceBefore,
expect,
expectPlaylistUpdatedToast,
expectSourceDialogValues,
getVisibleSourceTitles,
goToDashboard,
importM3uPlaylistFromNativeDialog,
importM3uPlaylistFromUrl,
launchElectronApp,
@@ -425,7 +427,37 @@ https://streams.example.test/original-url.m3u8
const app = await launchElectronApp(dataDir);
try {
await importM3uPlaylistFromNativeDialog(app, localFilePath);
await dropM3uPlaylistOntoWorkspace(
app.mainWindow,
localFilePath
);
await waitForM3uCatalog(app.mainWindow);
await expect(
app.mainWindow.locator(
'app-playlist-switcher .trigger-refresh-button'
)
).toBeVisible();
await goToDashboard(app.mainWindow);
const sourceCard = app.mainWindow
.getByTestId('dashboard-recent-sources-rail-card')
.filter({
hasText: refreshLocalSourceDisplayName,
})
.first();
await expect(sourceCard).toBeVisible({ timeout: 20000 });
await sourceCard.hover();
await sourceCard
.getByTestId('dashboard-recent-sources-rail-card-actions')
.click();
await expect(
app.mainWindow.getByRole('menuitem', {
name: 'Refresh playlist',
exact: true,
})
).toBeVisible();
await app.mainWindow.keyboard.press('Escape');
await importM3uPlaylistFromUrl(
app.mainWindow,
urlServer.resourceUrl
@@ -434,6 +466,14 @@ https://streams.example.test/original-url.m3u8
name: 'Refresh Xtream Source',
});
await openSources(app.mainWindow);
await expect(
sourceRowByTitle(
app.mainWindow,
refreshLocalSourceDisplayName
)
.first()
.locator('.refresh-btn')
).toBeVisible();
writeTemporaryM3uFile(dataDir, 'refresh-local-source.m3u', [
{