🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore: upgrade playwright tests (#6359)
Max Deichmann9bc745d64782
diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.ymlindex 3d55fff77b..6d3cd142c7 100644--- a/.github/workflows/pipeline.yml+++ b/.github/workflows/pipeline.yml@@ -339,14 +339,28 @@ jobs:run: |cp .env.dev.example .envcp .env.dev.example web/.env+ - name: Install golang-migrate for Clickhouse migrations+ run: |+ curl -L https://github.com/golang-migrate/migrate/releases/download/v4.18.2/migrate.linux-amd64.tar.gz | tar xvz+ sudo mv migrate /usr/bin/migrate+ which migrate- name: Run + migraterun: |docker compose -f docker-compose.dev.yml up -ddocker compose pssleep 5 # Wait for PostgreSQL to accept connections+ - name: Ensure Docker dependencies are healthy+ run: |+ if docker-compose ps | grep "(unhealthy)"; then+ echo "One or more services are unhealthy"+ exit 1+ else+ echo "All services are healthy"+ fi- name: Seed DBrun: |pnpm run db:migrate+ pnpm --filter=shared run ch:uppnpm run db:seed- name: Buildrun: pnpm run builddiff --git a/.gitignore b/.gitignoreindex b19a07361e..b85e6a7e11 100644--- a/.gitignore+++ b/.gitignore@@ -62,4 +62,6 @@ node_modules**/.next/***/.turbo/*.yarn-.turbo\ No newline at end of file+.turbo++web/test-results/*\ No newline at end of filediff --git a/web/package.json b/web/package.jsonindex f5c17a6028..92177feb91 100644--- a/web/package.json+++ b/web/package.json@@ -18,7 +18,7 @@"test-sync": "cross-env NODE_OPTIONS='--no-experimental-require-module' dotenv -e ../.env -- jest --silent false --verbose false --runInBand --detectOpenHandles --selectProjects sync-server","test-client": "cross-env NODE_OPTIONS='--no-experimental-require-module' dotenv -e ../.env -- jest --silent false --verbose false --runInBand --detectOpenHandles --selectProjects client","test:watch": "cross-env NODE_OPTIONS='--no-experimental-require-module' dotenv -e ../.env -- jest --watch --runInBand",- "test:e2e": "dotenv -e ../.env -- playwright test",+ "test:e2e": "dotenv -e ../.env -- playwright test --reporter=line","test:e2e:server": "cross-env NODE_OPTIONS='--no-experimental-require-module' dotenv -e ../.env -- jest --runInBand --detectOpenHandles --verbose --selectProjects e2e-server"},"dependencies": {diff --git a/web/src/__e2e__/create-project.spec.ts b/web/src/__e2e__/create-project.spec.tsindex 06d9255a5a..4f78885547 100644--- a/web/src/__e2e__/create-project.spec.ts+++ b/web/src/__e2e__/create-project.spec.ts@@ -1,59 +1,173 @@-import { test, expect } from "@playwright/test";+import { test, expect, type Page } from "@playwright/test";+import { prisma } from "@langfuse/shared/src/db";-test("Sign in, create an organization, create a project", async ({ page }) => {- test.setTimeout(60000);+const checkConsoleErrors = async (page: Page) => {+ const errors: string[] = [];+ page.on("pageerror", (err) => {+ errors.push(err.message);+ });+ page.on("console", (msg) => {+ if (msg.type() === "error") {+ errors.push(msg.text());+ }+ });- // Sign in+ page.on("response", async (response) => {+ if (response.status() === 500) {+ console.error(+ "Network request error: ",+ response.url,+ await response.text(),+ );+ }+ });++ return errors;+};++const cleanUpConsoleEventListeners = (page: Page) => {+ page.removeAllListeners("pageerror");+ page.removeAllListeners("console");+};++test.describe("Create project", () => {+ test("Sign in, create an organization, create a project", async ({+ page,+ }) => {+ test.setTimeout(60000);+ const errors = await checkConsoleErrors(page);++ // Sign in+ await page.goto("/auth/sign-in");+ await page.fill('input[name="email"]', "[email protected]");+ await page.fill('input[type="password"]', "password");+ await page.click(+ 'button[data-testid="submit-email-password-sign-in-form"]',+ );+ await page.waitForTimeout(2000);+ await expect(page).toHaveURL("/");++ // Start create org flow+ await page.isVisible('[data-testid="create-organization-btn"]');+ await page.click('[data-testid="create-organization-btn"]');+ await page.waitForTimeout(2000);+ await expect(page).toHaveURL("/setup");++ // Create an organization+ await expect(page.locator("data-testid=new-org-form")).toBeVisible();+ await page.fill('[data-testid="new-org-name-input"]', "e2e test org");+ await page.click('button[type="submit"]');+ await page.waitForTimeout(5000);+ expect(page.url()).toContain("/organization/");+ expect(page.url()).toContain("/setup?orgstep=invite-members");++ // Parse the organization ID from the URL using a simpler method+ const url = new URL(page.url());+ const organizationId = url.pathname.split("/")[2];+ console.log("organization", organizationId);++ // Skip add new members step+ await page.isVisible('[data-testid="btn-skip-add-members"]');+ await page.click('[data-testid="btn-skip-add-members"]');+ expect(page.url()).toContain(+ "/organization/" + organizationId + "/setup?orgstep=create-project",+ );++ // Create project+ await expect(page.locator("data-testid=new-project-form")).toBeVisible();+ await page.fill(+ '[data-testid="new-project-name-input"]',+ "e2e test project",+ );+ await page.click('button[type="submit"]');+ await page.waitForTimeout(5000);+ expect(page.url()).toContain("/project/");+ expect(page.url()).toContain("/setup");++ const projectUrl = new URL(page.url());+ const projectId = projectUrl.pathname.split("/")[2];++ // check that the project exists by navigating to its dashboard+ await page.goto("/project/" + projectId);+ await page.waitForTimeout(2000);+ expect(page.url()).toContain("/project/" + projectId);+ expect(page.url()).not.toContain("/setup");++ const headings = await page.locator("h2").allTextContents();+ expect(headings).toContain("Dashboard");++ // Check for console errors+ expect(errors).toHaveLength(0);+ });++ test("Sign in", async ({ page }) => {+ const errors = await checkConsoleErrors(page);+ await signin(page);+ expect(errors).toHaveLength(0);+ cleanUpConsoleEventListeners(page);+ });++ [+ { title: "Traces", url: "/traces" },+ { title: "Sessions", url: "/sessions" },+ { title: "Observations", url: "/observations" },+ { title: "Scores", url: "/scores" },+ ].forEach(({ title, url }) => {+ test(`Check ${title} page`, async ({ page }) => {+ const errors = await checkConsoleErrors(page);+ await signin(page);++ await page.waitForTimeout(2000);++ const projectUrl = await getProjectUrlForEmail("[email protected]");+ await page.goto(projectUrl + url);+ await page.waitForTimeout(2000);+ await expect(page).toHaveURL(projectUrl + url);+ await checkPageHeaderTitle(page, title);++ // Check that each error contains the expected string++ errors.forEach((error) => {+ expect(error).toContain(+ "Document policy violation: js-profiling is not allowed in this document.",+ );+ });+ cleanUpConsoleEventListeners(page);+ });+ });+});++const signin = async (page: Page) => {await page.goto("/auth/sign-in");await page.fill('input[name="email"]', "[email protected]");await page.fill('input[type="password"]', "password");await page.click('button[data-testid="submit-email-password-sign-in-form"]');await page.waitForTimeout(2000);await expect(page).toHaveURL("/");+};- // Start create org flow- await page.isVisible('[data-testid="create-organization-btn"]');- await page.click('[data-testid="create-organization-btn"]');- await page.waitForTimeout(2000);- await expect(page).toHaveURL("/setup");-- // Create an organization- await expect(page.locator("data-testid=new-org-form")).toBeVisible();- await page.fill('[data-testid="new-org-name-input"]', "e2e test org");- await page.click('button[type="submit"]');- await page.waitForTimeout(5000);- expect(page.url()).toContain("/organization/");- expect(page.url()).toContain("/setup?orgstep=invite-members");-- // Parse the organization ID from the URL using a simpler method- const url = new URL(page.url());- const organizationId = url.pathname.split("/")[2];- console.log("organization", organizationId);-- // Skip add new members step- await page.isVisible('[data-testid="btn-skip-add-members"]');- await page.click('[data-testid="btn-skip-add-members"]');- expect(page.url()).toContain(- "/organization/" + organizationId + "/setup?orgstep=create-project",- );-- // Create project- await expect(page.locator("data-testid=new-project-form")).toBeVisible();- await page.fill('[data-testid="new-project-name-input"]', "e2e test project");- await page.click('button[type="submit"]');- await page.waitForTimeout(5000);- expect(page.url()).toContain("/project/");- expect(page.url()).toContain("/setup");-- const projectUrl = new URL(page.url());- const projectId = projectUrl.pathname.split("/")[2];-- // check that the project exists by navigating to its dashboard- await page.goto("/project/" + projectId);- await page.waitForTimeout(2000);- expect(page.url()).toContain("/project/" + projectId);- expect(page.url()).not.toContain("/setup");+const checkPageHeaderTitle = async (page: Page, title: string) => {+ const pageHeaderTitle = await page+ .locator('[data-testid="page-header-title"]')+ .textContent();+ expect(pageHeaderTitle).toContain(title);+};- const headings = await page.locator("h2").allTextContents();- expect(headings).toContain("Dashboard");-});+const getProjectUrlForEmail = async (email: string) => {+ const user = await prisma.user.findUnique({+ where: { email },+ include: {+ organizationMemberships: {+ include: {+ organization: {+ include: {+ projects: true,+ },+ },+ },+ },+ },+ });++ return `/project/${user?.organizationMemberships[0].organization.projects[0].id}`;+};diff --git a/web/src/components/layouts/page-header.tsx b/web/src/components/layouts/page-header.tsxindex 30da0ad16a..ba9c2f1964 100644--- a/web/src/components/layouts/page-header.tsx+++ b/web/src/components/layouts/page-header.tsx@@ -63,7 +63,11 @@ const PageHeader = ({)}<div className="relative inline-block max-w-md md:max-w-none"><h2 className="line-clamp-1 text-lg font-semibold leading-7">- <span className="break-words" title={title}>+ <span+ className="break-words"+ title={title}+ data-testid="page-header-title"+ >{title}{help && (<span className="whitespace-nowrap">