0

Remove no longer valid browser test

This commit is contained in:
Gabe Kangas 2022-05-09 13:08:08 -07:00
parent d6e0b55337
commit 717db25d65
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA
15 changed files with 0 additions and 9185 deletions

View File

@ -1,19 +0,0 @@
name: Automated browser tests
on: [push, pull_request]
jobs:
browser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
stable: 'false'
go-version: '1.17.2'
- name: Run browser tests
run: cd test/automated/browser && ./run.sh
- uses: actions/upload-artifact@v3
with:
name: screenshots-${{ github.run_id }}
path: test/automated/browser/screenshots/*.png

View File

@ -1,27 +0,0 @@
# Automated browser tests
The tests currently address the following interfaces:
1. The main web frontend of Owncast
1. The embeddable video player
1. The embeddable read-only chat
1. the embeddable read-write chat
Each have a set of test to make sure they load, have the expected elements on the screen, that API requests are successful, and that there are no errors being thrown in the console.
The main web frontend additionally iterates its tests over a set of different device characteristics to verify mobile and tablet usage and goes through some interactive usage of the page such as changing their name and sending a chat message by clicking and typing.
While it emulates the user agent, screen size, and touch features of different devices, they're still just a copy of Chromium running and not a true emulation of these other devices. So any "it breaks only on Safari" type bugs will not get caught.
It can't actually play video, so anything specific about video playback cannot be verified with these tests.
## Setup
`npm install`
## Run
`./run.sh`
## Screenshots
After the tests finish a set of screenshots will be saved into the `screenshots` directory to aid in troubleshooting or sanity checking different viewport sizes. three

View File

@ -1,27 +0,0 @@
const listenForErrors = require('./lib/errors.js').listenForErrors;
const ADMIN_USERNAME = 'admin';
const ADMIN_PASSWORD = 'abc123';
describe('Admin page', () => {
beforeAll(async () => {
await page.setViewport({ width: 1080, height: 720 });
listenForErrors(browser, page);
// set HTTP Basic auth
await page.authenticate({
username: ADMIN_USERNAME,
password: ADMIN_PASSWORD,
});
await page.goto('http://localhost:5309/admin');
});
afterAll(async () => {
await page.waitForTimeout(3000);
await page.screenshot({ path: 'screenshots/admin.png', fullPage: true });
});
it('should have rendered the admin home page', async () => {
await page.waitForSelector('.home-container');
});
});

View File

@ -1,48 +0,0 @@
const listenForErrors = require('./lib/errors.js').listenForErrors;
describe('Video embed page', () => {
async function getMetaTagContent(property) {
const selector = `meta[property="${property}"]`;
const tag = await page.evaluate((selector) => {
return document.head.querySelector(selector).getAttribute("content");
}, selector);
return tag;
}
beforeAll(async () => {
await page.setViewport({ width: 1080, height: 720 });
listenForErrors(browser, page);
page.setUserAgent(
"Mastodon"
);
await page.goto('http://localhost:5309');
});
afterAll(async () => {
await page.waitForTimeout(3000);
await page.screenshot({ path: 'screenshots/screenshot_bots_share_search_scrapers.png', fullPage: true });
});
it('should have rendered the simple bot accessible html page', async () => {
await page.waitForSelector('h1');
await page.waitForSelector('h3');
const ogVideo = await getMetaTagContent('og:video');
expect(ogVideo).toBe('http://localhost:5309/embed/video');
const ogVideoType = await getMetaTagContent('og:video:type');
expect(ogVideoType).toBe('text/html');
// When stream is live the thumbnail is provided as the image.
const ogImage = await getMetaTagContent('og:image');
expect(ogImage).toBe('http://localhost:5309/thumbnail.jpg');
const twitterUrl = await getMetaTagContent('twitter:url');
expect(twitterUrl).toBe('http://localhost:5309/');
const twitterImage = await getMetaTagContent('twitter:image');
expect(twitterImage).toBe('http://localhost:5309/logo/external');
});
});

View File

@ -1,33 +0,0 @@
const listenForErrors = require('./lib/errors.js').listenForErrors;
const interactiveChatTest = require('./tests/chat.js').interactiveChatTest;
describe('Chat read-write embed page', () => {
beforeAll(async () => {
await page.setViewport({ width: 600, height: 700 });
listenForErrors(browser, page);
await page.goto('http://localhost:5309/embed/chat/readwrite');
});
afterAll(async () => {
await page.waitForTimeout(3000);
await page.screenshot({ path: 'screenshots/screenshot_chat_embed.png', fullPage: true });
});
const newName = 'frontend-browser-embed-test-name-change';
const fakeMessage = 'this is a test chat message sent via the automated browser tests on the read/write chat embed page.'
interactiveChatTest(browser, page, newName, fakeMessage, 'desktop');
});
describe('Chat read-only embed page', () => {
beforeAll(async () => {
await page.setViewport({ width: 500, height: 700 });
listenForErrors(browser, page);
await page.goto('http://localhost:5309/embed/chat/readonly');
});
it('should have the messages container', async () => {
await page.waitForSelector('#messages-container');
});
});

View File

@ -1,4 +0,0 @@
{
"name": "owncast browser tests",
"preset": "jest-puppeteer"
}

View File

@ -1,51 +0,0 @@
async function listenForErrors(browser, page) {
const ignoredErrors = [
'ERR_ABORTED',
'MEDIA_ERR_SRC_NOT_SUPPORTED',
'404',
'JSHandle@error',
];
// Emitted when the page emits an error event (for example, the page crashes)
page.on('error', (error) => {
throw new Error(`${error}`);
});
browser.on('error', (error) => {
throw new Error(`${error}`);
});
// Emitted when a script within the page has uncaught exception
page.on('pageerror', (error) => {
throw new Error(`${error}`);
});
// Catch all failed requests like 4xx..5xx status codes
page.on('requestfailed', (request) => {
const ignoreError = ignoredErrors.some((e) =>
request.failure().errorText.includes(e)
);
if (!ignoreError) {
throw new Error(
`❌ url: ${request.url()}, errText: ${
request.failure().errorText
}, method: ${request.method()}`
);
}
});
// Listen for console errors in the browser.
page.on('console', (msg) => {
const type = msg._type;
if (type !== 'error') {
return;
}
const ignoreError = ignoredErrors.some((e) => msg._text.includes(e));
if (!ignoreError) {
throw new Error(`${msg._text}`);
}
});
}
module.exports.listenForErrors = listenForErrors;

View File

@ -1,47 +0,0 @@
const listenForErrors = require('./lib/errors.js').listenForErrors;
const interactiveChatTest = require('./tests/chat.js').interactiveChatTest;
const videoTest = require('./tests/video.js').videoTest;
const puppeteer = require('puppeteer');
const phone = puppeteer.devices['iPhone 11'];
const tabletLandscape = puppeteer.devices['iPad landscape'];
const tablet = puppeteer.devices['iPad Pro'];
const desktop = {
name: 'desktop',
userAgent:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',
viewport: {
width: 1920,
height: 1080,
deviceScaleFactor: 1,
isMobile: false,
hasTouch: false,
isLandscape: true,
},
};
const devices = [desktop, phone, tablet, tabletLandscape];
describe('Frontend web page', () => {
beforeAll(async () => {
listenForErrors(browser, page);
await page.goto('http://localhost:5309');
await page.waitForTimeout(3000);
});
devices.forEach(async function (device) {
const newName = 'frontend-browser-test-name-change-' + device.name;
const fakeMessage =
'this is a test chat message sent via the automated browser tests on the main web frontend from ' +
device.name;
interactiveChatTest(browser, page, newName, fakeMessage, device.name);
videoTest(browser, page);
await page.waitForTimeout(2000);
await page.screenshot({
path: 'screenshots/screenshot_main-' + device.name + '.png',
fullPage: true,
});
});
});

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +0,0 @@
{
"name": "owncast-browser-tests",
"version": "1.0.0",
"description": "Automated browser testing for Owncast",
"main": "index.js",
"scripts": {
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/owncast/owncast.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/owncast/owncast/issues"
},
"homepage": "https://github.com/owncast/owncast#readme",
"devDependencies": {
"jest": "^27.2.0",
"jest-puppeteer": "^5.0.4",
"puppeteer": "^9.1.1"
}
}

View File

@ -1,43 +0,0 @@
#!/bin/bash
TEMP_DB=$(mktemp)
# Install the node test framework
npm install --silent > /dev/null
# Download a specific version of ffmpeg
if [ ! -d "ffmpeg" ]; then
mkdir ffmpeg
pushd ffmpeg > /dev/null
curl -sL https://github.com/vot/ffbinaries-prebuilt/releases/download/v4.2.1/ffmpeg-4.2.1-linux-64.zip --output ffmpeg.zip > /dev/null
unzip -o ffmpeg.zip > /dev/null
PATH=$PATH:$(pwd)
popd > /dev/null
fi
pushd ../../.. > /dev/null
# Build and run owncast from source
go build -o owncast main.go
BROWSER_TEST=true ./owncast -rtmpport 9021 -webserverport 5309 -database $TEMP_DB &
SERVER_PID=$!
popd > /dev/null
sleep 5
# Start streaming the test file over RTMP to
# the local owncast instance.
ffmpeg -hide_banner -loglevel panic -stream_loop -1 -re -i ../test.mp4 -vcodec libx264 -profile:v main -sc_threshold 0 -b:v 1300k -acodec copy -f flv rtmp://127.0.0.1:9021/live/abc123 &
FFMPEG_PID=$!
function finish {
rm $TEMP_DB
kill $SERVER_PID $FFMPEG_PID
}
trap finish EXIT
echo "Waiting..."
sleep 15
# Run the tests against the instance.
npm test

View File

@ -1,29 +0,0 @@
async function interactiveChatTest(
browser,
page,
newName,
chatMessage,
device
) {
it('should have the chat input', async () => {
await page.waitForSelector('#message-input');
});
it('should have the chat input enabled', async () => {
const isDisabled = await page.evaluate(
'document.querySelector("#message-input").getAttribute("disabled")'
);
expect(isDisabled).not.toBe('true');
});
it('should allow typing a chat message', async () => {
await page.waitForSelector('#message-input');
await page.evaluate(() => document.querySelector('#message-input').click());
await page.waitForTimeout(1000);
await page.focus('#message-input');
await page.keyboard.type(chatMessage);
page.keyboard.press('Enter');
});
}
module.exports.interactiveChatTest = interactiveChatTest;

View File

@ -1,11 +0,0 @@
async function videoTest(browser, page) {
it('should have the video container element', async () => {
await page.waitForSelector('#video-container');
});
it('should have the stream info status bar', async () => {
await page.waitForSelector('#stream-info');
});
}
module.exports.videoTest = videoTest;

View File

@ -1,17 +0,0 @@
const listenForErrors = require('./lib/errors.js').listenForErrors;
const videoTest = require('./tests/video.js').videoTest;
describe('Video embed page', () => {
beforeAll(async () => {
await page.setViewport({ width: 1080, height: 720 });
listenForErrors(browser, page);
await page.goto('http://localhost:5309/embed/video');
});
afterAll(async () => {
await page.waitForTimeout(3000);
await page.screenshot({ path: 'screenshots/screenshot_video_embed.png', fullPage: true });
});
videoTest(browser, page);
});