use pollFor in failing test

This commit is contained in:
Jörg Breitbart
2023-06-27 16:20:11 +02:00
parent d4ddac704c
commit e16f87f973
@@ -4,7 +4,7 @@
*/
import { assert } from 'chai';
import { openTerminal, launchBrowser } from '../../../out-test/api/TestUtils';
import { openTerminal, launchBrowser, pollFor } from '../../../out-test/api/TestUtils';
import { Browser, Page } from 'playwright';
import { IImageAddonOptions } from '../src/Types';
import { FINALIZER, introducer, sixelEncode } from 'sixel';
@@ -179,24 +179,20 @@ describe('ImageAddon', () => {
});
describe('image lifecycle & eviction', () => {
it('delete image once scrolled off', async () => {
// note: the waits in between are needed to make sure,
// that the state got updated on the remote browser,
// otherwise the test might fail in heavy load CI
it.only('delete image once scrolled off', async () => {
await writeToTerminal(SIXEL_SEQ_0);
await new Promise(r => setTimeout(r, 50));
assert.equal(await getImageStorageLength(), 1);
pollFor(page, 'window.imageAddon._storage._images.size', 1);
// scroll to scrollback + rows - 1
await page.evaluate(
scrollback => new Promise(res => (window as any).term.write('\n'.repeat(scrollback), res)),
(await getScrollbackPlusRows() - 1)
);
await new Promise(r => setTimeout(r, 50));
assert.equal(await getImageStorageLength(), 1);
// wait here, as we have to make sure, that eviction did not yet occur
await new Promise(r => setTimeout(r, 100));
pollFor(page, 'window.imageAddon._storage._images.size', 1);
// scroll one further should delete the image
await page.evaluate(() => new Promise(res => (window as any).term.write('\n', res)));
await new Promise(r => setTimeout(r, 50));
assert.equal(await getImageStorageLength(), 0);
pollFor(page, 'window.imageAddon._storage._images.size', 0);
});
it('get storageUsage', async () => {
assert.equal(await page.evaluate('imageAddon.storageUsage'), 0);