Skip to content

Commit 46baa82

Browse files
Add GUI tests
1 parent 4514194 commit 46baa82

File tree

8 files changed

+412
-0
lines changed

8 files changed

+412
-0
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ jobs:
123123
$f || exit 1
124124
done
125125
126+
- name: Run GUI tests
127+
run: ./dockerfiles/run-gui-tests.sh
128+
126129
- name: Clean up the database
127130
run: docker-compose down --volumes
128131

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ Note that you will need docker installed no matter what, since it's used for Rus
100100
cargo test
101101
```
102102

103+
To run GUI tests:
104+
105+
```
106+
./dockerfiles/run-gui-tests.sh
107+
```
108+
109+
They use the [browser-ui-test](https://github.com/GuillaumeGomez/browser-UI-test/) framework. You
110+
can take a look at its documentation [here](https://github.com/GuillaumeGomez/browser-UI-test/blob/master/goml-script.md).
111+
103112
### Pure docker-compose
104113

105114
If you have trouble with the above commands, consider using `docker-compose up --build`,

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ services:
9090
timeout: 5s
9191
retries: 10
9292

93+
gui_tests:
94+
build:
95+
context: .
96+
dockerfile: ./dockerfiles/Dockerfile-gui-tests
97+
network_mode: "host"
98+
extra_hosts:
99+
- "host.docker.internal:host-gateway"
100+
volumes:
101+
- "${PWD}:/build/out"
102+
93103
volumes:
94104
postgres-data: {}
95105
minio-data: {}

dockerfiles/Dockerfile-gui-tests

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
FROM ubuntu:22.04 AS build
2+
3+
# Install packaged dependencies
4+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
5+
build-essential git curl cmake gcc g++ pkg-config libmagic-dev \
6+
libssl-dev zlib1g-dev ca-certificates
7+
8+
# Install the stable toolchain with rustup
9+
RUN curl https://sh.rustup.rs >/tmp/rustup-init && \
10+
chmod +x /tmp/rustup-init && \
11+
/tmp/rustup-init -y --no-modify-path --default-toolchain stable --profile minimal
12+
ENV PATH=/root/.cargo/bin:$PATH
13+
14+
RUN apt-get update && apt-get install -y \
15+
ca-certificates \
16+
curl \
17+
docker.io \
18+
gcc \
19+
git \
20+
libssl-dev \
21+
pkg-config \
22+
xz-utils
23+
24+
# Install dependencies for chromium browser
25+
RUN apt-get install -y \
26+
gconf-service \
27+
libasound2 \
28+
libatk1.0-0 \
29+
libatk-bridge2.0-0 \
30+
libc6 \
31+
libcairo2 \
32+
libcups2 \
33+
libdbus-1-3 \
34+
libexpat1 \
35+
libfontconfig1 \
36+
libgbm-dev \
37+
libgcc1 \
38+
libgconf-2-4 \
39+
libgdk-pixbuf2.0-0 \
40+
libglib2.0-0 \
41+
libgtk-3-0 \
42+
libnspr4 \
43+
libpango-1.0-0 \
44+
libpangocairo-1.0-0 \
45+
libstdc++6 \
46+
libx11-6 \
47+
libx11-xcb1 \
48+
libxcb1 \
49+
libxcomposite1 \
50+
libxcursor1 \
51+
libxdamage1 \
52+
libxext6 \
53+
libxfixes3 \
54+
libxi6 \
55+
libxrandr2 \
56+
libxrender1 \
57+
libxss1 \
58+
libxtst6 \
59+
fonts-liberation \
60+
libappindicator1 \
61+
libnss3 \
62+
lsb-release \
63+
xdg-utils \
64+
wget
65+
66+
# Install rust
67+
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain nightly --no-modify-path --profile minimal
68+
ENV PATH="/root/.cargo/bin:${PATH}"
69+
70+
RUN curl -sL https://nodejs.org/dist/v14.4.0/node-v14.4.0-linux-x64.tar.xz | tar -xJ
71+
ENV PATH="/node-v14.4.0-linux-x64/bin:${PATH}"
72+
ENV NODE_PATH="/node-v14.4.0-linux-x64/lib/node_modules/"
73+
74+
WORKDIR /build
75+
76+
RUN mkdir out
77+
78+
# For now, we need to use `--unsafe-perm=true` to go around an issue when npm tries
79+
# to create a new folder. For reference:
80+
# https://github.com/puppeteer/puppeteer/issues/375
81+
#
82+
# We also specify the version in case we need to update it to go around cache limitations.
83+
RUN npm install -g [email protected] --unsafe-perm=true
84+
85+
EXPOSE 3000
86+
87+
CMD ["node", "/build/out/gui-tests/tester.js"]

dockerfiles/run-gui-tests.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
# Just in case it's running, we stop the web server.
4+
docker-compose stop web
5+
6+
docker-compose up -d db s3
7+
8+
# We add the information we need.
9+
cargo run -- database migrate
10+
docker-compose run web build crate sysinfo 0.23.4
11+
docker-compose run web build crate sysinfo 0.23.5
12+
docker-compose run web build add-essential-files
13+
docker-compose build web
14+
15+
# In case we don't have a `.env`, we create one.
16+
if [ ! -f .env ]
17+
then
18+
cp .env.sample .env
19+
source .env
20+
fi
21+
22+
docker-compose up -d web
23+
24+
cargo run -- start-web-server &
25+
SERVER_PID=$!
26+
27+
docker build . -f dockerfiles/Dockerfile-gui-tests -t gui_tests
28+
29+
echo "Sleeping a bit to be sure the web server will be started..."
30+
sleep 5
31+
32+
# status="docker run . -v `pwd`:/build/out:ro gui_tests"
33+
docker-compose run gui_tests
34+
status=$?
35+
kill -9 $SERVER_PID
36+
exit $status

gui-tests/404.goml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Checks the content of the 404 page.
2+
goto: |DOC_PATH|/non-existing-crate
3+
assert-text: ("#crate-title", "The requested crate does not exist")

gui-tests/basic.goml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Checks that the "latest" URL leads us to the last version of the `sysinfo` crate.
2+
goto: |DOC_PATH|/sysinfo
3+
// We first check if the redirection worked as expected:
4+
assert-document-property: ({"URL": "/sysinfo/latest/sysinfo/"}, ENDS_WITH)
5+
assert: "//*[@class='title' and text()='sysinfo-0.23.5']"
6+
// And we also confirm we're on a rustdoc page.
7+
assert: "#rustdoc_body_wrapper"
8+
9+
// Let's go to the docs.rs page of the crate.
10+
goto: |DOC_PATH|/crate/sysinfo/latest
11+
assert-false: "#rustdoc_body_wrapper"
12+
assert-text: ("#crate-title", "sysinfo 0.23.5", CONTAINS)

0 commit comments

Comments
 (0)