Skip to content

Commit

Permalink
Merge branch 'main' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored Jul 24, 2024
2 parents 05cee0f + b32bac2 commit 33d8d65
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 49 deletions.
80 changes: 40 additions & 40 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,49 @@ jobs:
${{ runner.os }}-build-
${{ runner.os }}-
# - name: Cache Playwright binaries
# uses: actions/cache@v4
# id: playwright-cache
# with:
# path: ~/.cache/ms-playwright
# key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-playwright-
- name: Cache Playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-playwright-
# - name: Install dependencies
# run: npm ci
- name: Install dependencies
run: npm ci

# - name: Install Playwright
# # if: steps.playwright-cache.outputs.cache-hit != 'true'
# run: npx playwright install --with-deps chromium
- name: Install Playwright
# if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps chromium

# - name: Start backend
# env:
# DATABASE_URL: ${{ secrets.DATABASE_URL }}
# JWT_SECRET: ${{ secrets.JWT_SECRET }}
# APP_URL: http://0.0.0.0:8080
# API_URL: http://0.0.0.0:3333
# LUNARY_PUBLIC_KEY: 259d2d94-9446-478a-ae04-484de705b522
# OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# timeout-minutes: 1
# run: npm run start:backend & npx wait-on http://localhost:3333/v1/health
- name: Start backend
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
APP_URL: http://0.0.0.0:8080
API_URL: http://0.0.0.0:3333
LUNARY_PUBLIC_KEY: 259d2d94-9446-478a-ae04-484de705b522
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
timeout-minutes: 1
run: npm run start:backend & npx wait-on http://localhost:3333/v1/health

# - name: Start frontend
# env:
# API_URL: http://0.0.0.0:3333
# NEXT_PUBLIC_API_URL: http://0.0.0.0:3333
# timeout-minutes: 3
# run: (npm run build:frontend && npm run start:frontend) & npx wait-on http://0.0.0.0:8080/
- name: Start frontend
env:
API_URL: http://0.0.0.0:3333
NEXT_PUBLIC_API_URL: http://0.0.0.0:3333
timeout-minutes: 3
run: (npm run build:frontend && npm run start:frontend) & npx wait-on http://0.0.0.0:8080/

# - name: Run tests
- name: Run tests

# run: npx playwright test
# env:
# BASE_URL: http://0.0.0.0:8080
# DATABASE_URL: ${{ secrets.DATABASE_URL }}
# - uses: actions/upload-artifact@v4
# if: ${{ !cancelled() }}
# with:
# name: playwright-report
# path: playwright-report/
# retention-days: 30
run: npx playwright test
env:
BASE_URL: http://0.0.0.0:8080
DATABASE_URL: ${{ secrets.DATABASE_URL }}
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
17 changes: 8 additions & 9 deletions e2e/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ let publicKey = null
// run tests one after another
test.describe.configure({ mode: "serial" })

const apiUrl = process.env.API_URL || "http://localhost:3333"

test("regenerate api keys", async ({ page }) => {
await page.goto("/settings")

Expand All @@ -22,14 +24,11 @@ test("regenerate api keys", async ({ page }) => {

await page.getByTestId("regenerate-private-key-button").click()

const promise = page.waitForResponse((resp) =>
resp.url().includes("/regenerate-key"),
)
await page.getByTestId("confirm-button").click()
// wait until button re-contain "Regenerate"
await promise

await page.waitForTimeout(100)
await page.waitForResponse((resp) => resp.url().includes("/regenerate-key"))

await page.waitForTimeout(1000)

const secondPrivateKey = await page.getByTestId("private-key").textContent()

Expand All @@ -41,7 +40,7 @@ test("regenerate api keys", async ({ page }) => {
test("private api /logs", async ({ page }) => {
// Test API query

const res = await fetch(process.env.API_URL + "/v1/runs", {
const res = await fetch(apiUrl + "/v1/runs", {
method: "GET",
headers: {
"Content-Type": "application/json",
Expand All @@ -56,7 +55,7 @@ test("private api /logs", async ({ page }) => {
test("create dataset", async ({ page }) => {
// Test API query

const res = await fetch(process.env.API_URL + "/v1/datasets", {
const res = await fetch(apiUrl + "/v1/datasets", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -75,7 +74,7 @@ test("create dataset", async ({ page }) => {
test("get dataset publicly via slug", async ({ page }) => {
// Test API query

const res = await fetch(process.env.API_URL + "/v1/datasets/test-dataset", {
const res = await fetch(apiUrl + "/v1/datasets/test-dataset", {
method: "GET",
headers: {
// Use the legacy way to pass the API key (used in old SDKs)
Expand Down

0 comments on commit 33d8d65

Please sign in to comment.