Skip to content

Commit 0eb6404

Browse files
authored
Bugfix/e2e tests (#84)
2 parents 5957ed5 + 92792ca commit 0eb6404

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

.github/workflows/release-deploy.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,30 @@ jobs:
142142
registry: ghcr.io
143143
workdir: gamey
144144

145+
docker-push-gameyapi:
146+
name: Publish gameyapi image
147+
runs-on: ubuntu-latest
148+
needs: e2e
149+
permissions:
150+
contents: read
151+
packages: write
152+
steps:
153+
- name: Checkout
154+
uses: actions/checkout@v4
155+
156+
- name: Publish to Registry (gameyapi)
157+
uses: elgohr/Publish-Docker-Github-Action@v5
158+
with:
159+
name: ${{ github.repository_owner }}/${{ github.event.repository.name }}-gameyapi
160+
username: ${{ github.actor }}
161+
password: ${{ secrets.GITHUB_TOKEN }}
162+
registry: ghcr.io
163+
workdir: gameyapi
164+
145165
deploy:
146166
name: Deploy over SSH
147167
runs-on: ubuntu-latest
148-
needs: [docker-push-users, docker-push-webapp, docker-push-gamey]
168+
needs: [docker-push-users, docker-push-webapp, docker-push-gamey, docker-push-gameyapi]
149169
steps:
150170
- name: Deploy over SSH
151171
uses: fifsky/ssh-action@master

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ services:
4242
gamey-service:
4343
build: ./gameyapi
4444
container_name: gamey-service
45+
image: ghcr.io/arquisoft/yovi_en1a-gameyapi:latest
4546
ports:
4647
- "3001:3001"
4748
environment:

webapp/test/e2e/features/register.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ Feature: Register
33

44
Scenario: Successful registration
55
Given the register page is open
6-
When I enter "Alice" as the username and submit
7-
Then I should see a welcome message containing "Hello Alice"
6+
When I enter "Alice" as the username and "password123" as the password and submit
7+
Then I should be redirected to the lobby

webapp/test/e2e/steps/register.steps.mjs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,38 @@ import assert from 'assert'
44
Given('the register page is open', async function () {
55
const page = this.page
66
if (!page) throw new Error('Page not initialized')
7+
8+
// Mock the login API so the test doesn't need MongoDB
9+
await page.route('**/login', async (route) => {
10+
await route.fulfill({
11+
status: 200,
12+
contentType: 'application/json',
13+
body: JSON.stringify({
14+
message: 'Login successful for Alice',
15+
token: 'mock-jwt-token',
16+
username: 'Alice'
17+
})
18+
})
19+
})
20+
721
await page.goto('http://localhost:5173')
822
})
923

10-
When('I enter {string} as the username and submit', async function (username) {
24+
When('I enter {string} as the username and {string} as the password and submit', async function (username, password) {
1125
const page = this.page
1226
if (!page) throw new Error('Page not initialized')
1327
await page.fill('#username', username)
28+
await page.fill('#password', password)
1429
await page.click('.submit-button')
1530
})
1631

17-
Then('I should see a welcome message containing {string}', async function (expected) {
32+
Then('I should be redirected to the lobby', async function () {
1833
const page = this.page
1934
if (!page) throw new Error('Page not initialized')
20-
await page.waitForSelector('.success-message', { timeout: 5000 })
21-
const text = await page.textContent('.success-message')
22-
assert.ok(text && text.includes(expected), `Expected success message to include "${expected}", got: "${text}"`)
35+
36+
// After successful login, the app sets localStorage and navigates to ?view=lobby.
37+
// Wait for the lobby content to appear (profile-username is only rendered on the lobby page).
38+
await page.waitForSelector('.profile-username', { timeout: 10000 })
39+
const text = await page.textContent('.profile-username')
40+
assert.ok(text && text.includes('Alice'), `Expected lobby to show "Alice", got: "${text}"`)
2341
})

0 commit comments

Comments
 (0)