Skip to content

Commit

Permalink
Add GUI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Apr 13, 2022
1 parent 5665b99 commit 6048c15
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -74,9 +74,15 @@ jobs:
$f || exit 1
done
- name: Run GUI tests
run: ./dockerfiles/run-gui-tests.sh

- name: Clean up the database
run: docker-compose down --volumes

steps:
- uses: actions/checkout@master

build_tests:
runs-on: ubuntu-latest
needs: build
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Expand Up @@ -89,6 +89,14 @@ services:
timeout: 5s
retries: 10

gui_tests:
build:
context: .
dockerfile: ./dockerfiles/Dockerfile-gui-tests
network_mode: "host"
volumes:
- "${PWD}:/build/out"

volumes:
postgres-data: {}
minio-data: {}
Expand Down
77 changes: 77 additions & 0 deletions dockerfiles/Dockerfile-gui-tests
@@ -0,0 +1,77 @@
FROM ubuntu:16.04 as build
SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
docker.io \
gcc \
git \
libssl-dev \
pkg-config \
xz-utils

# Install dependencies for chromium browser
RUN apt-get install -y \
gconf-service \
libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgbm-dev \
libgcc1 \
libgconf-2-4 \
libgdk-pixbuf2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libstdc++6 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
fonts-liberation \
libappindicator1 \
libnss3 \
lsb-release \
xdg-utils \
wget

# Install rust
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain nightly --no-modify-path --profile minimal
ENV PATH="/root/.cargo/bin:${PATH}"

RUN curl -sL https://nodejs.org/dist/v14.4.0/node-v14.4.0-linux-x64.tar.xz | tar -xJ
ENV PATH="/node-v14.4.0-linux-x64/bin:${PATH}"
ENV NODE_PATH="/node-v14.4.0-linux-x64/lib/node_modules/"

WORKDIR /build

RUN mkdir out

# For now, we need to use `--unsafe-perm=true` to go around an issue when npm tries
# to create a new folder. For reference:
# https://github.com/puppeteer/puppeteer/issues/375
#
# We also specify the version in case we need to update it to go around cache limitations.
RUN npm install -g browser-ui-test@0.8.5 --unsafe-perm=true

EXPOSE 3000

CMD ["node", "/build/out/gui-tests/tester.js"]
33 changes: 33 additions & 0 deletions dockerfiles/run-gui-tests.sh
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# Just in case it's running, we stop the web server.
docker-compose stop web

docker-compose up -d db s3

# We add the information we need.
cargo run -- database migrate
cargo run -- build crate sysinfo 0.23.4
cargo run -- build crate sysinfo 0.23.5
cargo run -- build add-essential-files

# In case we don't have a `.env`, we create one.
if [ ! -f .env ]
then
cp .env.sample .env
source .env
fi

cargo run -- start-web-server &
SERVER_PID=$!

docker build . -f dockerfiles/Dockerfile-gui-tests -t gui_tests

echo "Sleeping a bit to be sure the web server will be started..."
sleep 5

# status="docker run . -v `pwd`:/build/out:ro gui_tests"
docker-compose run gui_tests
status=$?
kill -9 $SERVER_PID
exit $status
3 changes: 3 additions & 0 deletions gui-tests/404.goml
@@ -0,0 +1,3 @@
// Checks the content of the 404 page.
goto: |DOC_PATH|/non-existing-crate
assert-text: ("#crate-title", "The requested crate does not exist")
12 changes: 12 additions & 0 deletions gui-tests/basic.goml
@@ -0,0 +1,12 @@
// Checks that the "latest" URL leads us to the last version of the `sysinfo` crate.
goto: |DOC_PATH|/sysinfo
// We first check if the redirection worked as expected:
assert-document-property: ({"URL": "/sysinfo/latest/sysinfo/"}, ENDS_WITH)
assert: "//*[@class='title' and text()='sysinfo-0.23.5']"
// And we also confirm we're on a rustdoc page.
assert: "#rustdoc_body_wrapper"

// Let's go to the docs.rs page of the crate.
goto: |DOC_PATH|/crate/sysinfo/latest
assert-false: "#rustdoc_body_wrapper"
assert-text: ("#crate-title", "sysinfo 0.23.5", CONTAINS)

0 comments on commit 6048c15

Please sign in to comment.