Skip to content

test: add end-to-end tests, fix #2249 #2258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: End-to-end tests
on:
push:
branches: "*"

jobs:
test:
runs-on: ubuntu-18.04

env:
FFMPEG_PATH: /usr/bin/ffmpeg # for recording video
QAW_ARTIFACT_PATH: ${{ github.workspace }}/artifacts # save video and logs

steps:
- name: Install browser dependencies
run: |
sudo apt update
# chromium dependencies
sudo apt-get install libgbm1
# webkit dependencies
sudo apt-get install libwoff1 libopus0 libwebp6 libwebpdemux2 libenchant1c2a libgudev-1.0-0 libsecret-1-0 libhyphen0 libgdk-pixbuf2.0-0 libegl1 libgles2 libevent-2.1-6 libnotify4 libvpx5 libxslt1.1
# ffmpeg
sudo apt-get install -y ffmpeg

- uses: actions/setup-node@v1

- name: Add yarn global bin to path
run: echo "::add-path::$(yarn global bin)"

- uses: actions/checkout@v2
with:
path: ./vuepress

- name: Install and register VuePress
run: |
yarn
yarn register-vuepress
yarn tsc
working-directory: ./vuepress

- name: Install end-to-end test dependencies
run: yarn
working-directory: ./vuepress/__e2e__

- name: Create test project
run: |
mkdir test_project
cd test_project
yarn init -y
yarn link vuepress
echo '# Hello VuePress' > README.md

- name: Run VuePress
run: vuepress dev &
working-directory: ./test_project

- name: Test first page
run: npx qawolf test --all-browsers --headless initialSetup
working-directory: ./vuepress/__e2e__

- name: Add another page
run: |
mkdir get_started
echo '# Get Started' > get_started/README.md
echo '[Get Started](/get_started/)' >> README.md
working-directory: ./test_project

- name: Test additional page
run: npx qawolf test --all-browsers --headless linkAndSearch
working-directory: ./vuepress/__e2e__

- name: Upload artifacts
if: always()
uses: actions/upload-artifact@master
with:
name: e2e
path: ${{ github.workspace }}/artifacts
24 changes: 24 additions & 0 deletions __e2e__/initialSetup.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const qawolf = require('qawolf')

let browser
let page

/* eslint-env jest */
beforeAll(async () => {
browser = await qawolf.launch()
const context = await browser.newContext()
await qawolf.register(context)
page = await context.newPage()
})

afterAll(async () => {
await qawolf.stopVideos()
await browser.close()
})

test('initialSetup', async () => {
await page.goto('http://localhost:8080/')

// test will fail if the header never appears
await page.waitFor('h1#hello-vuepress')
})
31 changes: 31 additions & 0 deletions __e2e__/linkAndSearch.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const qawolf = require('qawolf')

let browser
let page

/* eslint-env jest */
beforeAll(async () => {
browser = await qawolf.launch()
const context = await browser.newContext()
await qawolf.register(context)
page = await context.newPage()
})

afterAll(async () => {
await qawolf.stopVideos()
await browser.close()
})

test('linkAndSearch', async () => {
await page.goto('http://localhost:8080/')
await page.click('text="Get Started"')

// test will fail if header never appears
await page.waitFor('h1#get-started')

await page.type('[aria-label="Search"]', 'hello')
await page.click('ul a[href="/"]')

// test will fail if header never appears
await page.waitFor('h1#hello-vuepress')
})
11 changes: 11 additions & 0 deletions __e2e__/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "e2e",
"version": "1.0.0",
"license": "MIT",
"main": "index.js",
"devDependencies": {
"jest": "~25.1.0",
"playwright": "~0.12.1",
"qawolf": "~0.12.4"
}
}
6 changes: 6 additions & 0 deletions __e2e__/qawolf.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
config: '{}',
rootDir: '.',
testTimeout: 60000,
useTypeScript: false
}
Loading