Skip to content

Commit 4792dc5

Browse files
committed
feat: github action run the e2e
1 parent 390efee commit 4792dc5

13 files changed

Lines changed: 116 additions & 37 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
e2e:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: ⬇️ Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: ⚙️ Setup Node.js 20
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
cache: yarn
21+
22+
- name: 📦 Install dependencies (Yarn)
23+
run: yarn install
24+
25+
- name: 💾 Cache Playwright browsers
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.cache/ms-playwright
29+
key: playwright-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
30+
restore-keys: |
31+
playwright-${{ runner.os }}-
32+
33+
- name: 🌐 Install Playwright browsers
34+
run: cd e2e && yarn add @playwright/test && npx playwright install --with-deps && cd ..
35+
36+
- name: 🔨 Build Next.js app
37+
env:
38+
ZITADEL_URL: ${{ secrets.ZITADEL_URL }}
39+
ZITADEL_SERVICE_USER_ID: ${{ secrets.ZITADEL_SERVICE_USER_ID }}
40+
ZITADEL_SERVICE_USER_TOKEN: ${{ secrets.ZITADEL_SERVICE_USER_TOKEN }}
41+
run: |
42+
set -e
43+
echo "Creating .env file..."
44+
echo "ZITADEL_URL=$ZITADEL_URL" >> .env
45+
echo "ZITADEL_SERVICE_USER_ID=$ZITADEL_SERVICE_USER_ID" >> .env
46+
echo "ZITADEL_SERVICE_USER_TOKEN=$ZITADEL_SERVICE_USER_TOKEN" >> .env
47+
yarn build
48+
echo "Build completed successfully"
49+
50+
- name: 🚀 Start app in background on port 3333
51+
run: |
52+
PORT=3333 yarn start &
53+
echo "Deployment completed successfully"
54+
55+
- name: ⏳ Wait for app to be ready
56+
run: npx wait-on http://localhost:3333
57+
58+
- name: ✅ Run Playwright E2E tests
59+
run: cd e2e && yarn test && cd ..
60+
61+
- name: 📦 Upload Playwright report
62+
uses: actions/upload-artifact@v4
63+
if: ${{ !cancelled() }}
64+
with:
65+
name: playwright-report
66+
path: playwright-report/
67+
retention-days: 30

components/Loading.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const LoadingState = ({ loading }: { loading?: boolean }) => {
66

77
return (
88
<div className="w-full h-full opacity-60 bg-white fixed z-50 top-0 left-0">
9-
<div className="animate-spin h-[54px] w-[54px] absolute top-0 left-0 right-0 bottom-0 m-auto rounded-full border-8 border-[#DCE0E4] border-t-8 border-t-[#356BF5]" />
9+
<div className="animate-spin h-[54px] w-[54px] absolute top-0 left-0 right-0 bottom-0 m-auto rounded-full border-4 border-[#DCE0E4] border-t-4 border-t-[#356BF5]" />
1010
</div>
1111
);
1212
};

configuration.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import dotenv from 'dotenv';
44
import * as z from 'zod';
55

66
type Configuration = {
7+
server: string;
78
appUrl: string;
89
zitadel: {
910
url: string;
@@ -19,12 +20,14 @@ if (process.env.DOT_ENV_PATH) {
1920
const dotenvPath = path.join(process.cwd(), process.env.DOT_ENV_PATH);
2021
const buffer = fs.readFileSync(dotenvPath);
2122
const defaultConfig = dotenv.parse(buffer);
23+
2224
Object.entries(defaultConfig).forEach(([key, value]) => {
2325
if (!process.env[key]) process.env[key] = value;
2426
});
2527
}
2628

2729
const configurationSchema = z.object({
30+
server: z.string(),
2831
appUrl: z.string(),
2932
zitadel: z.object({
3033
url: z.string(),
@@ -37,7 +40,8 @@ const configurationSchema = z.object({
3740
});
3841

3942
const configuration: Configuration = {
40-
appUrl: process.env.APP_URL as string,
43+
server: process.env.SERVER || 'local',
44+
appUrl: process.env.APP_URL || 'http://localhost:3333',
4145
zitadel: {
4246
url: process.env.ZITADEL_URL as string,
4347
userId: process.env.ZITADEL_SERVICE_USER_ID as string,

e2e/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
```
2-
yarn test --headed
2+
(cd e2e && yarn test --headed)
33
```

e2e/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"name": "todomvc-test",
2+
"name": "e2e",
33
"version": "0.0.1",
44
"scripts": {
5-
"postinstall": "playwright install-deps && playwright install",
6-
"test": "playwright test"
5+
"postinstall": "npx playwright install-deps && npx playwright install",
6+
"test": "npx playwright test"
77
},
88
"keywords": [],
99
"author": "quochuydev",
1010
"license": "ISC",
1111
"devDependencies": {
12-
"@playwright/test": "^1.38.0"
12+
"@playwright/test": "1.53.0"
1313
}
1414
}

e2e/tests/integration.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import type { Page } from '@playwright/test';
55

66
test.describe.configure({ mode: 'parallel' });
77

8+
const appUrl = 'http://localhost:3333';
9+
810
test.beforeEach(async ({ page }: { page: Page }) => {
9-
await page.goto('https://zitadel-login-ui-v2.vercel.app/en/login');
11+
await page.goto(`${appUrl}/en/login`);
1012
});
1113

1214
test.describe('Login', () => {
@@ -22,7 +24,7 @@ test.describe('Login', () => {
2224
const loginButton = page.getByText('Log in');
2325
await loginButton.click();
2426

25-
await page.waitForURL('https://zitadel-login-ui-v2.vercel.app/en');
27+
await page.waitForURL(`${appUrl}/en`);
2628

2729
expect(true).toBeTruthy();
2830
});

e2e/yarn.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
# yarn lockfile v1
33

44

5-
"@playwright/test@^1.38.0":
6-
version "1.44.0"
7-
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.44.0.tgz#ac7a764b5ee6a80558bdc0fcbc525fcb81f83465"
8-
integrity sha512-rNX5lbNidamSUorBhB4XZ9SQTjAqfe5M+p37Z8ic0jPFBMo5iCtQz1kRWkEMg+rYOKSlVycpQmpqjSFq7LXOfg==
5+
"@playwright/test@1.53.0":
6+
version "1.53.0"
7+
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.53.0.tgz#23e0abac142f05b6b315c2da19129178aebb94e4"
8+
integrity sha512-15hjKreZDcp7t6TL/7jkAo6Df5STZN09jGiv5dbP9A6vMVncXRqE7/B2SncsyOwrkZRBH2i6/TPOL8BVmm3c7w==
99
dependencies:
10-
playwright "1.44.0"
10+
playwright "1.53.0"
1111

1212
fsevents@2.3.2:
1313
version "2.3.2"
1414
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
1515
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
1616

17-
playwright-core@1.44.0:
18-
version "1.44.0"
19-
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.44.0.tgz#316c4f0bca0551ffb88b6eb1c97bc0d2d861b0d5"
20-
integrity sha512-ZTbkNpFfYcGWohvTTl+xewITm7EOuqIqex0c7dNZ+aXsbrLj0qI8XlGKfPpipjm0Wny/4Lt4CJsWJk1stVS5qQ==
17+
playwright-core@1.53.0:
18+
version "1.53.0"
19+
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.53.0.tgz#bf2738cc143116b6130b78e0c644edf2e7e53ff4"
20+
integrity sha512-mGLg8m0pm4+mmtB7M89Xw/GSqoNC+twivl8ITteqvAndachozYe2ZA7srU6uleV1vEdAHYqjq+SV8SNxRRFYBw==
2121

22-
playwright@1.44.0:
23-
version "1.44.0"
24-
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.44.0.tgz#22894e9b69087f6beb639249323d80fe2b5087ff"
25-
integrity sha512-F9b3GUCLQ3Nffrfb6dunPOkE5Mh68tR7zN32L4jCk4FjQamgesGay7/dAAe1WaMEGV04DkdJfcJzjoCKygUaRQ==
22+
playwright@1.53.0:
23+
version "1.53.0"
24+
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.53.0.tgz#4eae78aa24e3c714bf71981f80b3310b838692fd"
25+
integrity sha512-ghGNnIEYZC4E+YtclRn4/p6oYbdPiASELBIYkBXfaTVKreQUYbMUYQDwS12a8F0/HtIjr/CkGjtwABeFPGcS4Q==
2626
dependencies:
27-
playwright-core "1.44.0"
27+
playwright-core "1.53.0"
2828
optionalDependencies:
2929
fsevents "2.3.2"

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"prettier": "prettier --write --ignore-unknown .",
99
"prettier:check": "prettier --check --ignore-unknown .",
1010
"start": "next start",
11-
"test": "yarn prettier:check && yarn lint"
11+
"test": "yarn prettier:check && yarn lint",
12+
"test:e2e": "cd e2e && yarn test --headed"
1213
},
1314
"lint-staged": {
1415
"*": "prettier --write --ignore-unknown"

readme.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### Document
2-
https://deepwiki.com/quochuydev/zitadel-login-ui
2+
3+
https://deepwiki.com/quochuydev/zitadel-login-ui
34

45
### Development
56

@@ -12,6 +13,12 @@
1213

1314
![Create service user](./docs/create-service-user.png)
1415

16+
**Run the app**
17+
18+
```bash
19+
yarn dev
20+
```
21+
1522
#### IV.Create service user token: update token to env `ZITADEL_SERVICE_USER_TOKEN`
1623

1724
![Create service user token](./docs/service-user-token.png)

0 commit comments

Comments
 (0)