import { createClient } from '../helpers/client.js';
import { getSharedEnv } from './sharedEnv.js';
describe('Scroll', () => {
let serverUrl;
let testSiteUrl;
beforeAll(() => {
const env = getSharedEnv();
serverUrl = env.serverUrl;
testSiteUrl = env.testSiteUrl;
});
test('scroll down page', async () => {
const client = createClient(serverUrl);
try {
const { tabId } = await client.createTab(`${testSiteUrl}/scroll`);
const result = await client.scroll(tabId, {
direction: 'down',
amount: 500
});
expect(result.ok).toBe(true);
} finally {
await client.cleanup();
}
});
test('scroll to bottom of page', async () => {
const client = createClient(serverUrl);
try {
const { tabId } = await client.createTab(`${testSiteUrl}/scroll`);
const result = await client.scroll(tabId, {
direction: 'down',
amount: 10000
});
expect(result.ok).toBe(true);
} finally {
await client.cleanup();
}
});
test('scroll up page', async () => {
const client = createClient(serverUrl);
try {
const { tabId } = await client.createTab(`${testSiteUrl}/scroll`);
await client.scroll(tabId, { direction: 'down', amount: 1000 });
const result = await client.scroll(tabId, {
direction: 'up',
amount: 500
});
expect(result.ok).toBe(true);
} finally {
await client.cleanup();
}
});
});