63 lines
2.2 KiB
JavaScript
63 lines
2.2 KiB
JavaScript
|
|
import { test, expect } from '@playwright/test';
|
||
|
|
|
||
|
|
test('base project comprehensive tests and scrolling benchmarks', async ({ page }) => {
|
||
|
|
test.setTimeout(60000);
|
||
|
|
page.on('console', msg => console.log('BROWSER LOG:', msg.text()));
|
||
|
|
await page.goto('http://127.0.0.1:8082/test/index.html');
|
||
|
|
|
||
|
|
// Wait for testStatus to be set (includes basic unit tests and scrolling refresh test)
|
||
|
|
await page.waitForFunction(() => window.testStatus !== undefined, { timeout: 60000 });
|
||
|
|
|
||
|
|
const status = await page.evaluate(() => window.testStatus);
|
||
|
|
expect(status).toBe('passed');
|
||
|
|
|
||
|
|
// Simulate real scrolling and check dynamic rendering for FastList
|
||
|
|
console.log('Simulating real scroll on FastList...');
|
||
|
|
const scrollInfo = await page.evaluate(async () => {
|
||
|
|
const el = document.getElementById('ll');
|
||
|
|
const results = [];
|
||
|
|
|
||
|
|
const getRenderedCount = () => el.querySelectorAll('.border-primary').length;
|
||
|
|
|
||
|
|
results.push({
|
||
|
|
id: 'initial',
|
||
|
|
scrollTop: el.scrollTop,
|
||
|
|
scrollHeight: el.scrollHeight,
|
||
|
|
clientHeight: el.clientHeight,
|
||
|
|
renderedCount: getRenderedCount(),
|
||
|
|
renderedListLen: el.state.renderedList?.length
|
||
|
|
});
|
||
|
|
|
||
|
|
// Scroll to middle
|
||
|
|
el.scrollTop = 2500;
|
||
|
|
await new Promise(r => setTimeout(r, 200));
|
||
|
|
results.push({
|
||
|
|
id: 'middle',
|
||
|
|
scrollTop: el.scrollTop,
|
||
|
|
renderedCount: getRenderedCount()
|
||
|
|
});
|
||
|
|
|
||
|
|
// Scroll to end
|
||
|
|
el.scrollTop = el.scrollHeight;
|
||
|
|
await new Promise(r => setTimeout(r, 200));
|
||
|
|
results.push({
|
||
|
|
id: 'end',
|
||
|
|
scrollTop: el.scrollTop,
|
||
|
|
renderedCount: getRenderedCount()
|
||
|
|
});
|
||
|
|
|
||
|
|
return results;
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log('Scroll Details:', JSON.stringify(scrollInfo, null, 2));
|
||
|
|
expect(scrollInfo[0].renderedCount).toBeGreaterThan(0);
|
||
|
|
expect(scrollInfo[1].scrollTop).toBeGreaterThan(0);
|
||
|
|
|
||
|
|
const bench = await page.evaluate(() => window.benchResults);
|
||
|
|
if (bench) {
|
||
|
|
Object.entries(bench).forEach(([name, time]) => {
|
||
|
|
console.log(`BENCHMARK [${name}]: ${time.toFixed(2)}ms`);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|