Skip to content

Commit

Permalink
refactor: update API client and playwright config for testing mode (#339
Browse files Browse the repository at this point in the history
)
  • Loading branch information
typeWolffo authored Jan 8, 2025
1 parent 1d7fb8c commit 7627c35
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
37 changes: 23 additions & 14 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,34 @@ jobs:
env:
PLAYWRIGHT_BROWSERS_PATH: /home/runner/.cache/ms-playwright

- name: Setup Caddy
run: |
sudo apt-get update
sudo apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt-get update
sudo apt-get install caddy=2.8.4
# - name: Setup Caddy
# run: |
# sudo apt-get update
# sudo apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl
# curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
# curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
# sudo apt-get update
# sudo apt-get install caddy=2.8.4

# - name: Setup hosts
# run: |
# echo "127.0.0.1 app.lms.localhost" | sudo tee -a /etc/hosts

- name: Debug Caddy
working-directory: ./apps/reverse-proxy
run: |
caddy version
caddy adapt --config Caddyfile
caddy validate --config Caddyfile
# - name: Debug Caddy
# working-directory: ./apps/reverse-proxy
# run: |
# caddy version
# caddy adapt --config Caddyfile
# caddy validate --config Caddyfile

# - name: Start Caddy
# working-directory: ./apps/reverse-proxy
# run: |
# sudo caddy run --config Caddyfile &

# - name: Ensure Caddy is running
# run: |
# pgrep -af caddy || exit 1

- name: Run tests
run: pnpm playwright test
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const requestManager = {
};

export const ApiClient = new API({
baseURL: import.meta.env.VITE_APP_URL,
baseURL: import.meta.env.MODE === "test" ? "http://localhost:3000" : import.meta.env.VITE_APP_URL,
secure: true,
withCredentials: true,
});
Expand Down
20 changes: 12 additions & 8 deletions apps/web/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const __dirname = path.dirname(__filename);

dotenv.config({ path: path.resolve(__dirname, ".env") });

const baseURL = process.env.VITE_APP_URL || "https://app.lms.localhost";
const baseURL = "http://localhost:5173";

export default defineConfig({
testDir: "./e2e",
Expand Down Expand Up @@ -58,13 +58,15 @@ export default defineConfig({
REDIS_HOST: "localhost",
REDIS_PORT: "6380",
NODE_ENV: "test",
MODE: "test",
},
},
{
command: "cd ../api && pnpm db:migrate && pnpm db:seed",
env: {
DATABASE_URL: `postgresql://test_user:test_password@localhost:54321/test_db`,
NODE_ENV: "test",
MODE: "test",
},
reuseExistingServer: false,
},
Expand All @@ -74,14 +76,16 @@ export default defineConfig({
timeout: 120 * 1000,
reuseExistingServer: false,
env: {
API_URL: "https://app.lms.localhost/api",
API_URL: "http://localhost:3000/api",
NODE_ENV: "test",
MODE: "test",
},
},
{
command: "cd ../reverse-proxy && pnpm run dev",
url: "http://localhost:2019/config/",
timeout: 120 * 1000,
reuseExistingServer: true,
},
// {
// command: "cd ../reverse-proxy && pnpm run dev",
// url: "http://localhost:2019/config/",
// timeout: 120 * 1000,
// reuseExistingServer: true,
// },
],
});

0 comments on commit 7627c35

Please sign in to comment.