Skip to content

Commit 36476cb

Browse files
Criar um jogo de tetris para impulsionar o engajamento do site (#7)
* Criar um jogo de tetris para impulsionar o engajamento do site - Implementar integração contínua - Resolve #5 * Fix dir name * Add initial test for Tetris game functionality * Fix test location
1 parent f64b7a4 commit 36476cb

10 files changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Run Checks on PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
actions: write
10+
checks: write
11+
contents: read
12+
security-events: write
13+
pull-requests: write
14+
15+
env:
16+
CI: true
17+
SITE_DIR: site
18+
TETRIS_APP_HOST: "127.0.0.1"
19+
TETRIS_APP_PORT: "8080"
20+
TETRIS_APP_PATH: "github-devsecops-fundamentals"
21+
22+
jobs:
23+
quality-checks:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
28+
- uses: actions/setup-python@v4
29+
with:
30+
python-version: 3.12
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: 20
34+
35+
- name: Install Dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install -r requirements.ci.txt
39+
npm ci
40+
# Install browsers for running functional tests
41+
npx playwright install --with-deps chromium
42+
43+
- name: Build
44+
run: |
45+
python -m mkdocs build --clean --strict --verbose --site-dir '${{ env.SITE_DIR }}'
46+
47+
- name: Functional Test
48+
run: npx playwright test
49+
50+
- name: Upload Functional Test Report
51+
uses: actions/upload-artifact@v4
52+
if: always()
53+
with:
54+
name: playwright-report
55+
path: playwright-report/
56+
retention-days: 30

tests/tetris.spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test("Tetris Game", async ({ page }) => {
4+
const { TETRIS_APP_HOST, TETRIS_APP_PORT, TETRIS_APP_PATH } = process.env;
5+
6+
// should be similar to http://127.0.0.1:8080/github-devsecops-fundamentals/
7+
console.log(
8+
`http://${TETRIS_APP_HOST}:${TETRIS_APP_PORT}/${TETRIS_APP_PATH}`
9+
);
10+
await page.goto(
11+
`http://${TETRIS_APP_HOST}:${TETRIS_APP_PORT}/${TETRIS_APP_PATH}`
12+
);
13+
14+
await page.getByRole("link", { name: "Tetris Game" }).click();
15+
await expect(page.getByText("score 00000")).toBeVisible();
16+
await expect(page.getByText("rows 0")).toBeVisible();
17+
await expect(page.locator("#upcoming")).toBeVisible();
18+
await expect(
19+
page.getByRole("link", { name: "Press Space to Play." })
20+
).toBeVisible();
21+
22+
await page.getByRole("link", { name: "Press Space to Play." }).click();
23+
await expect(page.getByText("score 00000")).not.toBeVisible({
24+
timeout: 0.5 * 60 * 1000,
25+
});
26+
});

0 commit comments

Comments
 (0)