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 12, 2022
1 parent 5665b99 commit 744a2f2
Show file tree
Hide file tree
Showing 7 changed files with 388 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ jobs:
- name: Clean up the database
run: docker-compose down --volumes

gui_tests:
runs-on: ubuntu-latest
needs: build

steps:
- name: Run GUI tests
run: ./dockerfiles/run-gui-tests.sh

build_tests:
runs-on: ubuntu-latest
needs: build
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
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
80 changes: 80 additions & 0 deletions dockerfiles/Dockerfile-gui-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
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

COPY .env.sample .env

RUN source .env
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 [email protected] --unsafe-perm=true

EXPOSE 3000

CMD ["node", "/build/out/gui-tests/tester.js"]
25 changes: 25 additions & 0 deletions dockerfiles/run-gui-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/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
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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)
Loading

0 comments on commit 744a2f2

Please sign in to comment.