53 lines
2.4 KiB
TypeScript
53 lines
2.4 KiB
TypeScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
describe('VNC container entrypoint', () => {
|
|
it('starts x11vnc with supported arguments and verifies its port before noVNC', () => {
|
|
const script = fs.readFileSync(path.resolve('docker/entrypoint.sh'), 'utf8');
|
|
|
|
expect(script).not.toContain('-nopw_warn');
|
|
expect(script).toContain('kill -0 "${X11VNC_PID}"');
|
|
expect(script).toContain('/dev/tcp/127.0.0.1/${VNC_PORT}');
|
|
expect(script.indexOf('VNC server is ready')).toBeLessThan(
|
|
script.indexOf('starting noVNC'),
|
|
);
|
|
});
|
|
|
|
it('removes only stale Chromium singleton artifacts before launching the bot', () => {
|
|
const script = fs.readFileSync(path.resolve('docker/entrypoint.sh'), 'utf8');
|
|
|
|
expect(script).toContain('"${BROWSER_SESSION_DIR}/SingletonLock"');
|
|
expect(script).toContain('"${BROWSER_SESSION_DIR}/SingletonSocket"');
|
|
expect(script).toContain('"${BROWSER_SESSION_DIR}/SingletonCookie"');
|
|
expect(script.indexOf('SingletonLock')).toBeLessThan(script.indexOf('launching bot'));
|
|
});
|
|
|
|
it('supports a native login phase with no DevTools before the controlled browser starts', () => {
|
|
const script = fs.readFileSync(path.resolve('docker/entrypoint.sh'), 'utf8');
|
|
|
|
expect(script).toContain('google-chrome');
|
|
expect(script).toContain('--user-data-dir="${BROWSER_SESSION_DIR}"');
|
|
expect(script).toContain('start_native_login_chrome');
|
|
expect(script).toContain('https://www.reddit.com/login/');
|
|
expect(script).toContain('node dist/native-login-gate.js');
|
|
expect(script).toContain('NATIVE_LOGIN_EXIT_CODE');
|
|
expect(script).toContain('--remote-debugging-port="${CHROME_CDP_PORT}"');
|
|
expect(script).toContain('export CHROME_CDP_URL=');
|
|
expect(script).not.toContain('--enable-automation');
|
|
const nativeFunction = script.slice(
|
|
script.indexOf('start_native_login_chrome()'),
|
|
script.indexOf('start_controlled_chrome()'),
|
|
);
|
|
expect(nativeFunction).not.toContain('--remote-debugging');
|
|
});
|
|
|
|
it('installs the stable Google Chrome package rather than Chrome for Testing', () => {
|
|
const dockerfile = fs.readFileSync(path.resolve('Dockerfile'), 'utf8');
|
|
|
|
expect(dockerfile).toContain('google-chrome-stable_current_amd64.deb');
|
|
expect(dockerfile).toContain('google-chrome-stable');
|
|
expect(dockerfile).not.toContain('chrome-for-testing');
|
|
});
|
|
});
|