Add compression estimates, transparent image output and full format selection
This commit is contained in:
1 parent
65cebb31ca
commit
2b897267d1
22 files changed
+220
-30
No files matched your search
@@ -15,3 +15,9 @@ test('all advertised file categories expose valid bounded radial actions',()=>{
|
||||
test('PDF password removal stays available without guessing encryption from bytes',()=>{
|
||||
assert.ok(wheelContent(['encrypted.pdf'],'tools').options.some(x=>x.id==='password-remove'));
|
||||
});
|
||||
test('image GIF and further formats, and video audio extraction are reachable',()=>{
|
||||
const images=wheelContent(['photo.png']).options;
|
||||
assert.ok(images.some(x=>x.id==='convert-gif'));
|
||||
assert.ok(images.some(x=>x.id==='more-formats'));
|
||||
assert.ok(wheelContent(['clip.mp4']).options.some(x=>x.id==='extract-audio'));
|
||||
});
|
||||
@@ -68,6 +68,30 @@ class ConversionTests(unittest.TestCase):
|
||||
result=self.run_job('compress',[self.image],quality=65,maxSizeMB=.05)[0];self.assertTrue(result['targetMet'])
|
||||
pdf=self.output('convert',[self.text],'pdf');self.output('compress',[pdf]);out=self.output('strip-metadata',[pdf]);self.assertFalse(PdfReader(out).metadata)
|
||||
self.output('strip-metadata',[self.image]);self.output('strip-metadata',[self.video])
|
||||
def test_compression_estimate_and_transparency(self):
|
||||
before=set(self.root.iterdir())
|
||||
estimate=self.run_job('estimate-compression',[self.image],quality=65)[0]
|
||||
after=set(self.root.iterdir())-({self.root/'job.json'} if os.environ.get('FILEBOW_PACKAGED_ENGINE') else set())
|
||||
self.assertEqual(before-({self.root/'job.json'}),after)
|
||||
result=self.run_job('compress',[self.image],quality=65)[0]
|
||||
self.assertEqual(estimate['size'],result['size']);self.assertTrue(estimate['exact'])
|
||||
self.assertEqual(Path(result['output']).suffix,'.png')
|
||||
with Image.open(result['output']) as image:
|
||||
self.assertEqual(image.convert('RGBA').getpixel((0,0))[3],160)
|
||||
webp=self.output('convert',[self.image],'webp')
|
||||
result=self.run_job('compress',[webp],quality=55)[0]
|
||||
self.assertEqual(Path(result['output']).suffix,'.webp')
|
||||
with Image.open(result['output']) as image:self.assertIn('A',image.getbands())
|
||||
palette=self.root/'Palette.png'
|
||||
image=Image.new('P',(40,30),0);image.putpalette([255,0,0]+[0,0,0]*255);image.save(palette,transparency=0)
|
||||
result=self.run_job('compress',[palette])[0]
|
||||
with Image.open(result['output']) as image:self.assertEqual(image.convert('RGBA').getpixel((0,0))[3],0)
|
||||
video=self.run_job('estimate-compression',[self.video],maxSizeMB=.1)[0]
|
||||
self.assertFalse(video['exact']);self.assertGreater(video['size'],0)
|
||||
pdf=self.output('convert',[self.text],'pdf')
|
||||
estimate=self.run_job('estimate-compression',[pdf])[0]
|
||||
result=self.run_job('compress',[pdf])[0]
|
||||
self.assertEqual(estimate['size'],result['size'])
|
||||
def test_media(self):
|
||||
for fmt in ['mp4','webm','gif']:
|
||||
with self.subTest(fmt=fmt):self.output('convert',[self.video],fmt)
|
||||
|
||||
+23
-5
@@ -1,5 +1,11 @@
|
||||
const { _electron: electron } = require('playwright');
|
||||
const fs=require('node:fs/promises'),path=require('node:path'),assert=require('node:assert/strict');
|
||||
async function saveDialog(dialog){
|
||||
const closed=dialog.waitForEvent('close');
|
||||
try { await dialog.locator('#save').click({noWaitAfter:true}); }
|
||||
catch(error){ if(!dialog.isClosed() || !String(error.message).includes('has been closed')) throw error; }
|
||||
await closed;
|
||||
}
|
||||
const root=path.resolve(__dirname,'..'),out=path.join(root,'test-results');
|
||||
(async()=>{
|
||||
await fs.mkdir(out,{recursive:true});
|
||||
@@ -20,26 +26,38 @@ const root=path.resolve(__dirname,'..'),out=path.join(root,'test-results');
|
||||
const pdf=updated.history[0].outputs[0];await page.evaluate(file=>window.orbit.selectFiles([file]),pdf);
|
||||
await page.locator('#tab-tools').click();
|
||||
const passwordPromise=app.waitForEvent('window');await page.locator('[data-action="password-add"]').click();const password=await passwordPromise;
|
||||
await password.locator('#password').fill('FileBow-Test');await password.locator('#confirm').fill('FileBow-Test');await password.locator('#save').click();
|
||||
await password.locator('#password').fill('FileBow-Test');await password.locator('#confirm').fill('FileBow-Test');await saveDialog(password);
|
||||
await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success');
|
||||
await page.evaluate(file=>window.orbit.selectFiles([file]),updated.history[0].outputs[0]);
|
||||
const unlockPromise=app.waitForEvent('window');await page.locator('[data-action="password-remove"]').click();const unlock=await unlockPromise;await unlock.locator('#password').fill('FileBow-Test');await unlock.locator('#save').click();
|
||||
const unlockPromise=app.waitForEvent('window');await page.locator('[data-action="password-remove"]').click();const unlock=await unlockPromise;await unlock.locator('#password').fill('FileBow-Test');await saveDialog(unlock);
|
||||
await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success');
|
||||
await page.evaluate(files=>window.orbit.selectFiles(files),[pdf,updated.history[0].outputs[0]]);
|
||||
const combinePromise=app.waitForEvent('window');await page.locator('[data-action="combine"]').click();const combine=await combinePromise;await combine.locator('#save').click();
|
||||
const combinePromise=app.waitForEvent('window');await page.locator('[data-action="combine"]').click();const combine=await combinePromise;await saveDialog(combine);
|
||||
await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success');
|
||||
const imageFile=path.join(out,'Beispielbild.png');await fs.copyFile(path.join(root,'assets/icon.png'),imageFile);await page.evaluate(file=>window.orbit.selectFiles([file]),imageFile);
|
||||
await page.locator('#tab-tools').click();
|
||||
const dialogPromise=app.waitForEvent('window');await page.locator('[data-action="edit-resize"]').click();const edit=await dialogPromise;
|
||||
await edit.waitForSelector('#width',{timeout:30000});await edit.locator('#width').fill('96');await edit.screenshot({path:path.join(out,'02-resize.png')});
|
||||
await edit.locator('#save').click();await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));
|
||||
await saveDialog(edit);await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));
|
||||
updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success');
|
||||
const compressPromise=app.waitForEvent('window');await page.locator('[data-action="compress"]').click();const compress=await compressPromise;await compress.locator('#quality').fill('65');await compress.locator('#save').click();
|
||||
const compressPromise=app.waitForEvent('window');await page.locator('[data-action="compress"]').click();const compress=await compressPromise;await compress.locator('#quality').fill('65');await compress.waitForFunction(()=>document.querySelector('#estimate').textContent.includes('Voraussichtliche Größe'),null,{timeout:30000});await compress.screenshot({path:path.join(out,'06-compression.png')});await saveDialog(compress);
|
||||
await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success');
|
||||
assert.ok(updated.history[0].outputs[0].endsWith('.png'));
|
||||
await page.locator('#tab-quick').click();
|
||||
const formatsPromise=app.waitForEvent('window');await page.locator('[data-action="more-formats"]').click();const formats=await formatsPromise;
|
||||
await formats.locator('#format').selectOption('tiff');await saveDialog(formats);
|
||||
await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success');assert.ok(updated.history[0].outputs[0].endsWith('.tiff'));
|
||||
await page.locator('[data-action="convert-gif"]').click();
|
||||
await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success');assert.ok(updated.history[0].outputs[0].endsWith('.gif'));
|
||||
const wheelPromise=app.waitForEvent('window');await page.locator('#wheel-open').click();const wheel=await wheelPromise;
|
||||
await wheel.waitForSelector('.action');await wheel.screenshot({path:path.join(out,'03-wheel.png')});await wheel.keyboard.press('Escape');
|
||||
await page.locator('[data-page="settings"]').click();await page.locator('#theme').selectOption('light');await page.waitForFunction(()=>document.documentElement.dataset.theme==='light');await page.screenshot({path:path.join(out,'04-settings-light.png')});
|
||||
await page.locator('#theme').selectOption('dark');await page.locator('[data-page="history"]').click();await page.screenshot({path:path.join(out,'05-history.png')});
|
||||
await page.locator('[data-page="about"]').click();
|
||||
await app.evaluate(({shell})=>{global.__supportUrls=[];shell.openExternal=async url=>{global.__supportUrls.push(url);};});
|
||||
await page.locator('#support').click();
|
||||
assert.deepEqual(await app.evaluate(()=>global.__supportUrls),['https://ko-fi.com/E0Z827VO8I']);
|
||||
await page.screenshot({path:path.join(out,'07-about.png')});
|
||||
assert.deepEqual(errors,[]);await fs.writeFile(path.join(out,'ui-result.json'),JSON.stringify({passed:true,native:state.native,history:updated.history.map(x=>({label:x.label,status:x.status})),errors},null,2));
|
||||
console.log('UI smoke passed: startup, native bridge, conversion, PDF passwords, combining, compression, editor, radial menu, themes, history.');
|
||||
}finally{await app.close();}
|
||||
|
||||
Reference in new issue
Block a user