Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
vincelwt committed Mar 30, 2024
1 parent d59b021 commit c5da0f5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
22 changes: 17 additions & 5 deletions e2e/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,26 @@ test.describe.configure({ mode: "serial" })
test("regenerate api keys", async ({ page }) => {
await page.goto("/settings")

await page.waitForLoadState("networkidle")

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

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

// expect to not be empty string
expect(firstPrivateKey).not.toEqual("")
expect(publicKey).toHaveLength(36) // uuid length
expect(firstPrivateKey).toHaveLength(36) // uuid length

await page.waitForTimeout(300) // helps with flakiness in local

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

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

console.log({ firstPrivateKey, secondPrivateKey })
Expand All @@ -30,14 +41,15 @@ test("regenerate api keys", async ({ page }) => {
test("private api /logs", async ({ page }) => {
// Test API query

const res = await fetch(process.env.API_URL + "/api/v1/runs", {
method: "POST",
const res = await fetch(process.env.API_URL + "/v1/runs", {

Check failure on line 44 in e2e/api.spec.ts

View workflow job for this annotation

GitHub Actions / run-tests

[chromium] › api.spec.ts:41:5 › private api /logs

2) [chromium] › api.spec.ts:41:5 › private api /logs ───────────────────────────────────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TypeError: Failed to parse URL from undefined/v1/runs 42 | // Test API query 43 | > 44 | const res = await fetch(process.env.API_URL + "/v1/runs", { | ^ 45 | method: "GET", 46 | headers: { 47 | "X-API-Key": privateKey!, at /home/runner/work/lunary/lunary/e2e/api.spec.ts:44:15
method: "GET",
headers: {
"X-API-Key": privateKey!,
},
})

const json = await res.json()

expect(json).toEqual([])
// expect to be an array
expect(json).toBeInstanceOf(Array)
})
6 changes: 5 additions & 1 deletion e2e/login.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "@playwright/test"

test("logout and login flow", async ({ page }) => {
test("logout and back in login", async ({ page }) => {
await page.goto("/")

// logout
Expand All @@ -13,8 +13,12 @@ test("logout and login flow", async ({ page }) => {
await page.getByPlaceholder("Your email").click()
await page.getByPlaceholder("Your email").fill("[email protected]")

const promise = page.waitForResponse((resp) => resp.url().includes("/method"))

await page.getByTestId("continue-button").click()

await promise

await page.getByPlaceholder("Your password").click()
await page.getByPlaceholder("Your password").fill("testtest")

Expand Down
5 changes: 4 additions & 1 deletion packages/frontend/pages/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ function Keys() {
onClick={() => {
modals.openConfirmModal({
title: "Please confirm your action",
confirmProps: { color: "red" },
confirmProps: {
color: "red",
"data-testid": "confirm-button",
},
children: (
<Text size="sm">
Are you sure you want to regenerate your private key?
Expand Down

0 comments on commit c5da0f5

Please sign in to comment.