add another test

This commit is contained in:
Simon Knott 2024-12-13 13:11:24 +01:00
parent f3e651ab90
commit a53821415f
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -17,9 +17,11 @@
import { expect, test } from '@playwright/test'; import { expect, test } from '@playwright/test';
import { createReadStream, constants } from 'fs'; import { createReadStream, constants } from 'fs';
import { access, readFile, readlink } from 'fs/promises'; import { access, readFile, readlink, readdir } from 'fs/promises';
import { TarExtractor } from '../../../packages/playwright-core/src/utils/tar'; import { TarExtractor } from '../../../packages/playwright-core/src/utils/tar';
import { finished } from 'stream/promises'; import { finished } from 'stream/promises';
import { Readable } from 'stream';
import { createBrotliDecompress } from 'zlib';
test('tar extractor', async () => { test('tar extractor', async () => {
const input = createReadStream('tests/assets/archive.tar'); const input = createReadStream('tests/assets/archive.tar');
@ -33,3 +35,86 @@ test('tar extractor', async () => {
expect(await readlink(test.info().outputPath('tar-example/symlink'))).toEqual('./foo'); expect(await readlink(test.info().outputPath('tar-example/symlink'))).toEqual('./foo');
expect(await readFile(test.info().outputPath('tar-example/symlink'), { encoding: 'utf-8' })).toEqual('foo-content'); expect(await readFile(test.info().outputPath('tar-example/symlink'), { encoding: 'utf-8' })).toEqual('foo-content');
}); });
test('extract browser', async () => {
// not run by default because it's not hermetic. i'll remove this once we use the TAR extractor in our code.
test.skip(process.env.TEST_TAR_BROWSER !== '1');
const response = await fetch('https://playwright.azureedge.net/download-for-internal-testing/playwright/builds/chromium/1152/chromium-headless-shell-linux-arm64.tar.br');
const input = Readable.fromWeb(response.body as any);
const decompressor = createBrotliDecompress();
const extractor = new TarExtractor(name => test.info().outputPath(name));
await finished(input.pipe(decompressor).pipe(extractor));
expect(await readdir(test.info().outputPath('chrome-linux'))).toEqual([
'headless_command_resources.pak',
'headless_lib_data.pak',
'headless_lib_strings.pak',
'headless_shell',
'hyphen-data',
'icudtl.dat',
'libEGL.so',
'libGLESv2.so',
'libvk_swiftshader.so',
'libvulkan.so.1',
'v8_context_snapshot.bin',
'vk_swiftshader_icd.json',
]);
expect(await readFile(test.info().outputPath('chrome-linux/vk_swiftshader_icd.json'), { encoding: 'utf-8' })).toEqual(`{"file_format_version": "1.0.0", "ICD": {"library_path": "./libvk_swiftshader.so", "api_version": "1.0.5"}}`);
expect(await readdir(test.info().outputPath('chrome-linux/hyphen-data'))).toEqual([
'hyph-af.hyb',
'hyph-as.hyb',
'hyph-be.hyb',
'hyph-bg.hyb',
'hyph-bn.hyb',
'hyph-cs.hyb',
'hyph-cu.hyb',
'hyph-cy.hyb',
'hyph-da.hyb',
'hyph-de-1901.hyb',
'hyph-de-1996.hyb',
'hyph-de-ch-1901.hyb',
'hyph-el.hyb',
'hyph-en-gb.hyb',
'hyph-en-us.hyb',
'hyph-es.hyb',
'hyph-et.hyb',
'hyph-eu.hyb',
'hyph-fr.hyb',
'hyph-ga.hyb',
'hyph-gl.hyb',
'hyph-gu.hyb',
'hyph-hi.hyb',
'hyph-hr.hyb',
'hyph-hu.hyb',
'hyph-hy.hyb',
'hyph-it.hyb',
'hyph-ka.hyb',
'hyph-kn.hyb',
'hyph-la.hyb',
'hyph-lt.hyb',
'hyph-lv.hyb',
'hyph-ml.hyb',
'hyph-mn-cyrl.hyb',
'hyph-mr.hyb',
'hyph-mul-ethi.hyb',
'hyph-nb.hyb',
'hyph-nl.hyb',
'hyph-nn.hyb',
'hyph-or.hyb',
'hyph-pa.hyb',
'hyph-pt.hyb',
'hyph-ru.hyb',
'hyph-sk.hyb',
'hyph-sl.hyb',
'hyph-sq.hyb',
'hyph-sv.hyb',
'hyph-ta.hyb',
'hyph-te.hyb',
'hyph-tk.hyb',
'hyph-uk.hyb',
'hyph-und-ethi.hyb',
'manifest.json',
]);
});