Skip to content

Conversation

@shige
Copy link
Member

@shige shige commented Oct 15, 2025

Summary

Extract getStatusLabel helper function.

Related Issue

fix:
https://github.com/giselles-ai/giselle/pull/1981/files#r2431220995
https://github.com/giselles-ai/giselle/pull/1981/files#r2427669906
https://github.com/giselles-ai/giselle/pull/1981/files#r2431229666

Changes

Consolidate duplicate status label logic into a reusable helper function that handles all repository content status types (idle, running, queued, failed, completed, unknown) consistently across blob and pull request statuses.

Testing

Other Information


Note

Consolidates status label rendering into a reusable helper used for both blob and pull request statuses in repository-item.tsx.

  • Frontend
    • Status labeling in apps/studio.giselles.ai/app/(main)/settings/team/vector-stores/repository-item.tsx:
      • Add getStatusLabel helper (derives effective status considering isIngesting and supports idle, running, queued, failed → "Error", completed, unknown).
      • Replace duplicated inline label logic for blob and pull_request with the helper.
      • Introduce RepositoryContentStatusValue type alias from githubRepositoryContentStatus.

Written by Cursor Bugbot for commit 01d399b. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • New Features
    • Unified status display for repository content across Code and Pull Requests.
    • Consistent, user-friendly labels now shown: Idle, Running, Queued, Error, Completed, and Unknown.
    • Status automatically reflects ingest activity and enablement for clearer real-time feedback.
    • Improves readability and reduces ambiguity when monitoring processing states.

…r function

Consolidate duplicate status label logic into a reusable helper function that handles all repository content status types (idle, running, queued, failed, completed, unknown) consistently across blob and pull request statuses.

fix:
https://github.com/giselles-ai/giselle/pull/1981/files#r2431220995
https://github.com/giselles-ai/giselle/pull/1981/files#r2427669906
https://github.com/giselles-ai/giselle/pull/1981/files#r2431229666
@shige shige self-assigned this Oct 15, 2025
@Copilot Copilot AI review requested due to automatic review settings October 15, 2025 08:11
@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2025

⚠️ No Changeset found

Latest commit: 01d399b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "giselle-sdk" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.

@giselles-ai
Copy link

giselles-ai bot commented Oct 15, 2025

Finished running flow.

Step Status Updated(UTC)
1 Oct 15, 2025 8:11am
2 Oct 15, 2025 8:14am
3 Oct 15, 2025 8:18am
4 Oct 15, 2025 8:18am

@vercel
Copy link

vercel bot commented Oct 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
giselle Error Error Oct 15, 2025 8:14am
ui Ready Ready Preview Comment Oct 15, 2025 8:14am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

Adds a local getStatusLabel helper to compute user-facing status labels based on content status and enablement, and replaces inline conditional status rendering for code (blob) and pull request sections in repository-item.tsx to standardize display.

Changes

Cohort / File(s) Summary of changes
Status label refactor
apps/studio.giselles.ai/app/(main)/settings/team/vector-stores/repository-item.tsx
Introduced getStatusLabel(status, enabled) and RepositoryContentStatusValue; replaced inline status conditionals for blob and pull request sections to use the helper, unifying labels (Idle, Running, Queued, Error, Completed, Unknown).

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Review effort 3/5

Suggested reviewers

  • satococoa

Poem

I hop through code with whiskers keen,
Mapping states to labels clean;
Idle, Running—carrots queued—
Errors too, but never rude.
Pulls and blobs now speak the same,
A tidy warren in our UI game. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description includes the Summary, Related Issue, and Changes sections but leaves the Testing and Other Information sections blank. The Related Issue section is misused by listing review comment URLs instead of referencing an actual issue number. This results in incomplete documentation and missing testing context that reviewers need. Please add concrete testing steps or results in the Testing section and provide a valid issue reference or remove the Related Issue section if no issue exists. Populate the Other Information section with any additional context required for review. Ensuring all template sections are completed will improve clarity and reviewability.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly specifies the main change by indicating the extraction of the getStatusLabel helper function in the vector-stores repository-item component using a conventional commit style, making it concise and immediately understandable.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/extract-status-label-function

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f93d0e and 01d399b.

📒 Files selected for processing (1)
  • apps/studio.giselles.ai/app/(main)/settings/team/vector-stores/repository-item.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development-guide.mdc)

**/*.{ts,tsx}: Use Biome for formatting with tab indentation and double quotes
Follow organized imports pattern (enabled in biome.json)
Use TypeScript for type safety; avoid any types
Use Next.js patterns for web applications
Use async/await for asynchronous code rather than promises
Error handling: use try/catch blocks and propagate errors appropriately
Use kebab-case for all filenames (e.g., user-profile.ts)
Use camelCase for variables, functions, and methods (e.g., userEmail)
Use prefixes like is, has, can, should for boolean variables and functions for clarity
Use verbs or verb phrases that clearly indicate purpose for function naming (e.g., calculateTotalPrice(), not process())

If breaking changes are introduced in new AI SDK versions, update code to accommodate those changes

**/*.{ts,tsx}: Avoid using the any type in TypeScript
Use async/await for asynchronous code and include proper error handling
Variables and functions should be camelCase
Boolean variables and functions should use is/has/can/should prefixes where appropriate
Function names should clearly indicate their purpose

Files:

  • apps/studio.giselles.ai/app/(main)/settings/team/vector-stores/repository-item.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/development-guide.mdc)

**/*.tsx: Use functional components with React hooks
Use PascalCase for React components and classes (e.g., UserProfile)

**/*.tsx: React components should use React hooks and Next.js patterns
Component identifiers (names) should be PascalCase

Files:

  • apps/studio.giselles.ai/app/(main)/settings/team/vector-stores/repository-item.tsx
**/*

📄 CodeRabbit inference engine (.cursor/rules/naming-guide.mdc)

All filenames should use kebab-case (lowercase with hyphens)

Files:

  • apps/studio.giselles.ai/app/(main)/settings/team/vector-stores/repository-item.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/naming-guide.mdc)

**/*.{js,jsx,ts,tsx}: React components and classes should use PascalCase
Variables, functions, and methods should use camelCase
Use verbs or verb phrases for function names; names should clearly indicate what the function does; avoid ambiguous names that could lead to misuse
Use nouns or noun phrases for variable names; names should describe what the variable represents; avoid single-letter variables except in very short scopes
Use prefixes like 'is', 'has', 'can', 'should' for both variables and functions returning boolean values; make the true/false meaning clear

Files:

  • apps/studio.giselles.ai/app/(main)/settings/team/vector-stores/repository-item.tsx
🧬 Code graph analysis (1)
apps/studio.giselles.ai/app/(main)/settings/team/vector-stores/repository-item.tsx (1)
apps/studio.giselles.ai/drizzle/schema.ts (1)
  • githubRepositoryContentStatus (506-549)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: check
🔇 Additional comments (3)
apps/studio.giselles.ai/app/(main)/settings/team/vector-stores/repository-item.tsx (3)

233-255: LGTM! Well-structured helper function.

The getStatusLabel helper successfully consolidates the status display logic:

  • Type inference from schema is correct
  • The effectiveStatus logic properly handles the ingesting state override
  • All status values from the schema are covered in the switch statement
  • The "failed" → "Error" mapping improves user-facing messaging

304-307: LGTM! Correct usage in Code section.

The helper function is properly invoked with optional chaining to handle cases where blobStatus is undefined. The refactor successfully replaces the previous inline conditional logic.


396-399: LGTM! Consistent usage in Pull Requests section.

The second usage mirrors the Code section implementation, successfully achieving the refactor's goal of eliminating duplicate status-label logic across both content types.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-merge-for-open-source
Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
- [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true -->

</details></td></tr>
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Extracts duplicate status label logic into a reusable helper function to improve code maintainability and consistency.

  • Created getStatusLabel helper function to consolidate status mapping logic
  • Replaced duplicate inline status label logic for both blob and pull request statuses
  • Improved consistency in handling different repository content status types

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +235 to 256
const getStatusLabel = (
status: RepositoryContentStatusValue | undefined,
enabled: boolean | undefined,
) => {
const effectiveStatus =
isIngesting && enabled ? "running" : (status ?? "unknown");
switch (effectiveStatus) {
case "idle":
return "Idle";
case "running":
return "Running";
case "queued":
return "Queued";
case "failed":
return "Error";
case "completed":
return "Completed";
default:
return "Unknown";
}
};

Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helper function should be extracted outside the component to avoid recreation on every render. Consider moving it above the component or creating it as a module-level function.

Suggested change
const getStatusLabel = (
status: RepositoryContentStatusValue | undefined,
enabled: boolean | undefined,
) => {
const effectiveStatus =
isIngesting && enabled ? "running" : (status ?? "unknown");
switch (effectiveStatus) {
case "idle":
return "Idle";
case "running":
return "Running";
case "queued":
return "Queued";
case "failed":
return "Error";
case "completed":
return "Completed";
default:
return "Unknown";
}
};
function getStatusLabel(
status: (typeof githubRepositoryContentStatus.$inferSelect)["status"] | undefined,
enabled: boolean | undefined,
isIngesting: boolean,
) {
const effectiveStatus =
isIngesting && enabled ? "running" : (status ?? "unknown");
switch (effectiveStatus) {
case "idle":
return "Idle";
case "running":
return "Running";
case "queued":
return "Queued";
case "failed":
return "Error";
case "completed":
return "Completed";
default:
return "Unknown";
}
}

Copilot uses AI. Check for mistakes.
(typeof githubRepositoryContentStatus.$inferSelect)["status"];
const getStatusLabel = (
status: RepositoryContentStatusValue | undefined,
enabled: boolean | undefined,
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isIngesting variable is captured from component scope, making this function dependent on component state. Consider passing isIngesting as a parameter to make the function pure and more testable.

Suggested change
enabled: boolean | undefined,
enabled: boolean | undefined,
isIngesting: boolean,

Copilot uses AI. Check for mistakes.
@qodo-merge-for-open-source
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Prioritize terminal statuses over running state

Update the getStatusLabel function to prevent the global isIngesting flag from
overriding terminal statuses like "failed" or "completed". The "Running" status
should only be set if the current status is "idle".

apps/studio.giselles.ai/app/(main)/settings/team/vector-stores/repository-item.tsx [235-255]

 	const getStatusLabel = (
 		status: RepositoryContentStatusValue | undefined,
 		enabled: boolean | undefined,
 	) => {
-		const effectiveStatus =
-			isIngesting && enabled ? "running" : (status ?? "unknown");
+		let effectiveStatus = status ?? "unknown";
+
+		if (isIngesting && enabled && effectiveStatus === "idle") {
+			effectiveStatus = "running";
+		}
+
 		switch (effectiveStatus) {
 			case "idle":
 				return "Idle";
 			case "running":
 				return "Running";
 			case "queued":
 				return "Queued";
 			case "failed":
 				return "Error";
 			case "completed":
 				return "Completed";
 			default:
 				return "Unknown";
 		}
 	};
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a logic bug in the new getStatusLabel function where a global isIngesting flag incorrectly overrides terminal statuses like "failed" or "completed", which would mislead the user.

High
Learned
best practice
Add disabled state guard

Add a guard for disabled sources so they consistently show a clear label (e.g.,
"Disabled") instead of inferring status; also return a string type and narrow
inputs to avoid undefined drift.

apps/studio.giselles.ai/app/(main)/settings/team/vector-stores/repository-item.tsx [235-255]

 const getStatusLabel = (
-	status: RepositoryContentStatusValue | undefined,
-	enabled: boolean | undefined,
-) => {
-	const effectiveStatus =
-		isIngesting && enabled ? "running" : (status ?? "unknown");
-	switch (effectiveStatus) {
-		case "idle":
-			return "Idle";
-		case "running":
-			return "Running";
-		case "queued":
-			return "Queued";
-		case "failed":
-			return "Error";
-		case "completed":
-			return "Completed";
-		default:
-			return "Unknown";
-	}
+  status: RepositoryContentStatusValue | undefined,
+  enabled: boolean | undefined
+): string => {
+  if (enabled === false) return "Disabled";
+  const effectiveStatus: RepositoryContentStatusValue | "unknown" =
+    isIngesting && enabled ? "running" : (status ?? "unknown");
+  switch (effectiveStatus) {
+    case "idle":
+      return "Idle";
+    case "running":
+      return "Running";
+    case "queued":
+      return "Queued";
+    case "failed":
+      return "Error";
+    case "completed":
+      return "Completed";
+    default:
+      return "Unknown";
+  }
 };
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Use safe defaults and guard clauses to avoid assuming values during render; handle undefined/null inputs gracefully.

Low
  • More

@giselles-ai
Copy link

giselles-ai bot commented Oct 15, 2025

## 🔍 QA Testing Assistant by Giselle

### 📋 Manual QA Checklist

Based on the changes in this PR, here are the key areas to test manually:

  • Idle Status: When the content type has a status of idle, verify the label displayed is "Idle".
  • Running Status (Ingesting): When the repository is actively ingesting (isIngesting is true) and the content type is enabled, verify the label is "Running" (even if the underlying status is idle).
  • Running Status (Direct): When the content type has a status of running, verify the label is "Running".
  • Queued Status: When the content type has a status of queued, verify the label is "Queued".
  • Completed Status: When the content type has a status of completed, the label displayed should be "Completed".
  • Error Status: When the content type has a status of failed, verify the label is "Error". Confirm that the detailed error message/link still appears below the status.
  • Unknown Status: When the content type has a null, undefined, or an unrecognized status value, verify the label is "Unknown".

### ✨ Prompt for AI Agents

Use the following prompts with Cursor or Claude Code to automate E2E testing:

📝 E2E Test Generation Prompt

```

Prompt for AI Agent: E2E Test Generation for Vector Store Status Display

You are an expert QA engineer tasked with writing automated E2E tests using Playwright. Your goal is to validate the changes introduced in a recent Pull Request. The PR refactors and enhances the UI component that displays the status of repository content within the "Vector Stores" settings page.

Please follow the instructions below to generate a complete Playwright test suite.

1. Context Summary

  • PR Goal: The PR refactors UI logic by extracting a getStatusLabel helper function. This function is now responsible for consistently displaying the status label for different repository content types (blob and pull_request).
  • Functionality Change: Previously, the logic was duplicated and only handled a few statuses. The new function correctly maps a comprehensive set of statuses (idle, running, queued, failed, completed, unknown) to user-friendly labels (Idle, Running, Queued, Error, Completed, Unknown). It also introduces a special case where if the global isIngesting flag is true for an enabled content type, the status is always shown as "Running".
  • Key User Flow: A user navigates to the team settings, selects "Vector Stores," and views a specific configured repository. The user should see an accurate, human-readable status for both "Code" (blobs) and "Pull Requests" content sources.
  • Critical Path to Test: The primary focus is visual regression and enhancement testing. We must verify that for every possible backend status, the correct text label is displayed on the UI. This includes the new statuses (queued, completed) and the special failed state which conditionally shows a "Details" link.

2. Test Scenarios

Create a test suite that covers the following scenarios. Use API mocking to simulate the different data states required for each test.

Test Suite: Vector Store Repository Status

  • Navigation:

    • A beforeEach block should handle logging in and navigating to the specific Vector Stores settings page where the repository-item component is rendered.
  • Scenario Group: Code (Blob) Status

    • Happy Path - Idle: When the blobStatus.status is idle, the UI should display the text "Idle".
    • Happy Path - Running: When isIngesting is true and blobStatus.enabled is true, the UI should display "Running", regardless of the actual blobStatus.status.
    • Happy Path - Queued: When the blobStatus.status is queued, the UI should display "Queued".
    • Happy Path - Completed: When the blobStatus.status is completed, the UI should display "Completed".
    • Failure Case: When the blobStatus.status is failed, the UI should display the text "Error" AND a "Details" link must become visible.
    • Edge Case - Unknown: When the blobStatus.status is null, undefined, or any other unexpected value, the UI should display "Unknown".
  • Scenario Group: Pull Request Status

    • Happy Path - Idle: When the pullRequestStatus.status is idle, the UI should display "Idle".
    • Happy Path - Running: When isIngesting is true and pullRequestStatus.enabled is true, the UI should display "Running".
    • Happy Path - Queued: When the pullRequestStatus.status is queued, the UI should display "Queued".
    • Happy Path - Completed: When the pullRequestStatus.status is completed, the UI should display "Completed".
    • Failure Case: When pullRequestStatus.status is failed, the UI should display "Error" AND a "Details" link must become visible.
    • Edge Case - Unknown: When pullRequestStatus.status is null, undefined, or any other unexpected value, the UI should display "Unknown".

3. Playwright Implementation Instructions

  • Test File: Create a new file at apps/studio.giselles.ai/tests/e2e/settings/vector-stores/repository-status.spec.ts.

  • Data Mocking:

    • Use page.route() to intercept the API call that fetches the repository and its content statuses. You will need to identify the correct API endpoint. Let's assume it's something like **/api/v1/teams/*/vector-stores/**.
    • Create a helper function or a base mock object that can be easily modified for each test case. This object should represent the JSON response for the vector store, including the profileStatuses array.
    // Example Mock Data Structure (adapt as needed)
    const createMockStatusResponse = (
      blobStatus: string | null,
      pullRequestStatus: string | null,
      isIngesting: boolean = false
    ) => {
      return {
        // ... other repository properties
        isIngesting,
        profileStatuses: [
          {
            contentType: 'blob',
            status: blobStatus,
            enabled: true,
            // ... other properties
          },
          {
            contentType: 'pull_request',
            status: pullRequestStatus,
            enabled: true,
            // ... other properties
          }
        ]
      };
    };
  • Selectors:

    • The component is repository-item.tsx. Assume it has a data-testid for easy selection.
    • To make tests robust, add data-testid attributes to the status elements in the source code if they don't exist, and use them in your tests.
    • Repository Item: page.getByTestId('repository-item-github-some-repo-name')
    • Blob Status Label: page.getByTestId('repository-content-status-blob')
    • Pull Request Status Label: page.getByTestId('repository-content-status-pull_request')
    • Details Link: page.getByRole('link', { name: 'Details' }). Note that there might be two, so you may need to scope your selector to the correct section (e.g., within a div for blob status).
  • Assertions:

    • Use expect(selector).toHaveText() to verify the status label.
    • Use expect(selector).toBeVisible() to check for the presence of the "Details" link in failure cases.
    • Use expect(selector).not.toBeVisible() to ensure the "Details" link is not present in non-failure cases.
    // Example test for a 'failed' blob status
    test('should display "Error" and a details link for a failed blob status', async ({ page }) => {
      // 1. Setup mock route
      const mockResponse = createMockStatusResponse('failed', 'idle');
      await page.route('**/api/v1/teams/**', (route) => {
        route.fulfill({ status: 200, json: mockResponse });
      });
    
      // 2. Navigate to the page
      await page.goto('/settings/team/vector-stores');
    
      // 3. Locate the specific elements and assert
      const blobStatusLabel = page.getByTestId('repository-content-status-blob');
      await expect(blobStatusLabel).toHaveText('Error');
    
      // Scope the link search to the 'blob' section to avoid ambiguity
      const blobSection = page.getByTestId('repository-item-github-some-repo-name')./* selector for blob section */;
      const detailsLink = blobSection.getByRole('link', { name: 'Details' });
      await expect(detailsLink).toBeVisible();
    });

4. MCP Integration Guidelines

  • Command Structure: The tests should be executable via Playwright MCP. The standard command will apply.
    # Example command to run the new test file
    npx mcp playwright:test --spec "apps/studio.giselles.ai/tests/e2e/settings/vector-stores/repository-status.spec.ts"
  • Environment Configuration: Ensure your local .env file is configured with the necessary BASE_URL for the studio application, as MCP will use this to run the tests. No special MCP parameters are required for this test suite.

5. CI-Ready Code Requirements

  • Organization:
    • Use test.describe('Vector Store Repository Status', () => { ... }); to group all related tests.
    • Use nested test.describe('Code (Blob) Status', () => { ... }); and test.describe('Pull Request Status', () => { ... }); for better organization and reporting.
  • Naming Conventions: Test names should clearly describe the condition and the expected outcome.
    • Good: test('should display "Queued" when status is "queued"')
    • Bad: test('test 5')
  • Isolation and Atomicity: Each test() block must be fully independent. Use test.beforeEach to set up common conditions (like navigation and routing) and ensure mocks are specific to each test, preventing state leakage between tests.
  • Parallelization: By making each test atomic and self-contained with its own API mock, the suite will be fully compatible with parallel execution in CI, leading to faster test runs. Do not rely on state from a previous test.

-->

---

## Manual QA

Here is the Manual QA checklist for the developer.


Manual QA Checklist

Thank you for your work on this refactor! The goal of this Pull Request is to consolidate the logic for displaying repository content status into a single helper function, ensuring consistent behavior for all possible statuses.

Please perform the following manual checks to ensure that the status labels for repository content are displayed correctly and that there are no regressions.

Testing Pre-conditions:

  1. Navigate to the Vector Stores settings page (/settings/team/vector-stores).
  2. Locate a configured repository item in the list. This component displays statuses for "Code" and "Pull Request" content types.

Note: It may be difficult to trigger every backend status naturally. Please feel free to mock the profileStatuses data for the EmbeddingModelCard component using browser developer tools to simulate each of the following scenarios.

Happy Path

Repository Content Status Display

For both the "Code" and "Pull Request" sections of a repository item, please verify that the status label updates correctly based on its status value:

  • Idle Status: When the content type has a status of idle, verify the label displayed is "Idle".
  • Running Status (Ingesting): When the repository is actively ingesting (isIngesting is true) and the content type is enabled, verify the label is "Running" (even if the underlying status is idle).
  • Running Status (Direct): When the content type has a status of running, verify the label is "Running".
  • Queued Status: When the content type has a status of queued, verify the label is "Queued".
  • Completed Status: When the content type has a status of completed, verify the label is "Completed".
  • Error Status: When the content type has a status of failed, verify the label is "Error".
    • Also, confirm that the detailed error message/link still appears below the status.
  • Unknown Status: When the content type has a null, undefined, or an unrecognized status value, verify the label is "Unknown".

---

## Prompt for AI Agents

Excellent! As an expert QA engineer, I will now analyze the provided PR information and generate a comprehensive prompt for an AI agent to create the necessary E2E tests.

Here is the prompt:


Prompt for AI Agent: E2E Test Generation for Vector Store Status Display

You are an expert QA engineer tasked with writing automated E2E tests using Playwright. Your goal is to validate the changes introduced in a recent Pull Request. The PR refactors and enhances the UI component that displays the status of repository content within the "Vector Stores" settings page.

Please follow the instructions below to generate a complete Playwright test suite.

1. Context Summary

  • PR Goal: The PR refactors UI logic by extracting a getStatusLabel helper function. This function is now responsible for consistently displaying the status label for different repository content types (blob and pull_request).
  • Functionality Change: Previously, the logic was duplicated and only handled a few statuses. The new function correctly maps a comprehensive set of statuses (idle, running, queued, failed, completed, unknown) to user-friendly labels (Idle, Running, Queued, Error, Completed, Unknown). It also introduces a special case where if the global isIngesting flag is true for an enabled content type, the status is always shown as "Running".
  • Key User Flow: A user navigates to the team settings, selects "Vector Stores," and views a specific configured repository. The user should see an accurate, human-readable status for both "Code" (blobs) and "Pull Requests" content sources.
  • Critical Path to Test: The primary focus is visual regression and enhancement testing. We must verify that for every possible backend status, the correct text label is displayed on the UI. This includes the new statuses (queued, completed) and the special failed state which conditionally shows a "Details" link.

2. Test Scenarios

Create a test suite that covers the following scenarios. Use API mocking to simulate the different data states required for each test.

Test Suite: Vector Store Repository Status

  • Navigation:

    • A beforeEach block should handle logging in and navigating to the specific Vector Stores settings page where the repository-item component is rendered.
  • Scenario Group: Code (Blob) Status

    • Happy Path - Idle: When the blobStatus.status is idle, the UI should display the text "Idle".
    • Happy Path - Running: When isIngesting is true and blobStatus.enabled is true, the UI should display "Running", regardless of the actual blobStatus.status.
    • Happy Path - Queued: When the blobStatus.status is queued, the UI should display "Queued".
    • Happy Path - Completed: When the blobStatus.status is completed, the UI should display "Completed".
    • Failure Case: When the blobStatus.status is failed, the UI should display the text "Error" AND a "Details" link must become visible.
    • Edge Case - Unknown: When the blobStatus.status is null, undefined, or any other unexpected value, the UI should display "Unknown".
  • Scenario Group: Pull Request Status

    • Happy Path - Idle: When the pullRequestStatus.status is idle, the UI should display "Idle".
    • Happy Path - Running: When isIngesting is true and pullRequestStatus.enabled is true, the UI should display "Running".
    • Happy Path - Queued: When the pullRequestStatus.status is queued, the UI should display "Queued".
    • Happy Path - Completed: When the pullRequestStatus.status is completed, the UI should display "Completed".
    • Failure Case: When pullRequestStatus.status is failed, the UI should display "Error" AND a "Details" link must become visible.
    • Edge Case - Unknown: When pullRequestStatus.status is null, undefined, or any other unexpected value, the UI should display "Unknown".

3. Playwright Implementation Instructions

  • Test File: Create a new file at apps/studio.giselles.ai/tests/e2e/settings/vector-stores/repository-status.spec.ts.

  • Data Mocking:

    • Use page.route() to intercept the API call that fetches the repository and its content statuses. You will need to identify the correct API endpoint. Let's assume it's something like **/api/v1/teams/*/vector-stores/**.
    • Create a helper function or a base mock object that can be easily modified for each test case. This object should represent the JSON response for the vector store, including the profileStatuses array.
    // Example Mock Data Structure (adapt as needed)
    const createMockStatusResponse = (
      blobStatus: string | null,
      pullRequestStatus: string | null,
      isIngesting: boolean = false
    ) => {
      return {
        // ... other repository properties
        isIngesting,
        profileStatuses: [
          {
            contentType: 'blob',
            status: blobStatus,
            enabled: true,
            // ... other properties
          },
          {
            contentType: 'pull_request',
            status: pullRequestStatus,
            enabled: true,
            // ... other properties
          }
        ]
      };
    };
  • Selectors:

    • The component is repository-item.tsx. Assume it has a data-testid for easy selection.
    • To make tests robust, add data-testid attributes to the status elements in the source code if they don't exist, and use them in your tests.
    • Repository Item: page.getByTestId('repository-item-github-some-repo-name')
    • Blob Status Label: page.getByTestId('repository-content-status-blob')
    • Pull Request Status Label: page.getByTestId('repository-content-status-pull_request')
    • Details Link: page.getByRole('link', { name: 'Details' }). Note that there might be two, so you may need to scope your selector to the correct section (e.g., within a div for blob status).
  • Assertions:

    • Use expect(selector).toHaveText() to verify the status label.
    • Use expect(selector).toBeVisible() to check for the presence of the "Details" link in failure cases.
    • Use expect(selector).not.toBeVisible() to ensure the "Details" link is not present in non-failure cases.
    // Example test for a 'failed' blob status
    test('should display "Error" and a details link for a failed blob status', async ({ page }) => {
      // 1. Setup mock route
      const mockResponse = createMockStatusResponse('failed', 'idle');
      await page.route('**/api/v1/teams/**', (route) => {
        route.fulfill({ status: 200, json: mockResponse });
      });
    
      // 2. Navigate to the page
      await page.goto('/settings/team/vector-stores');
    
      // 3. Locate the specific elements and assert
      const blobStatusLabel = page.getByTestId('repository-content-status-blob');
      await expect(blobStatusLabel).toHaveText('Error');
    
      // Scope the link search to the 'blob' section to avoid ambiguity
      const blobSection = page.getByTestId('repository-item-github-some-repo-name')./* selector for blob section */;
      const detailsLink = blobSection.getByRole('link', { name: 'Details' });
      await expect(detailsLink).toBeVisible();
    });

4. MCP Integration Guidelines

  • Command Structure: The tests should be executable via Playwright MCP. The standard command will apply.
    # Example command to run the new test file
    npx mcp playwright:test --spec "apps/studio.giselles.ai/tests/e2e/settings/vector-stores/repository-status.spec.ts"
  • Environment Configuration: Ensure your local .env file is configured with the necessary BASE_URL for the studio application, as MCP will use this to run the tests. No special MCP parameters are required for this test suite.

5. CI-Ready Code Requirements

  • Organization:
    • Use test.describe('Vector Store Repository Status', () => { ... }); to group all related tests.
    • Use nested test.describe('Code (Blob) Status', () => { ... }); and test.describe('Pull Request Status', () => { ... }); for better organization and reporting.
  • Naming Conventions: Test names should clearly describe the condition and the expected outcome.
    • Good: test('should display "Queued" when status is "queued"')
    • Bad: test('test 5')
  • Isolation and Atomicity: Each test() block must be fully independent. Use test.beforeEach to set up common conditions (like navigation and routing) and ensure mocks are specific to each test, preventing state leakage between tests.
  • Parallelization: By making each test atomic and self-contained with its own API mock, the suite will be fully compatible with parallel execution in CI, leading to faster test runs. Do not rely on state from a previous test.

-->

---

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant