Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✅ test: add more smoke bdd tests (#10014)

Arvin Xu5c9baf490fc6
diff --git a/e2e/src/features/discover/smoke.feature b/e2e/src/features/discover/smoke.feature
index e7ab5bf176b..cef3248d84e 100644
--- a/e2e/src/features/discover/smoke.feature
+++ b/e2e/src/features/discover/smoke.feature
@@ -3,9 +3,42 @@ Feature: Discover Smoke Tests
Critical path tests to ensure the discover module is functional
@DISCOVER-SMOKE-001 @P0
- Scenario: Load discover assistant list page
+ Scenario: Load Discover Home Page
+ Given I navigate to "/discover"
+ Then the page should load without errors
+ And I should see the page body
+ And I should see the featured assistants section
+ And I should see the featured MCP tools section
+
+ @DISCOVER-SMOKE-002 @P0
+ Scenario: Load Assistant List Page
Given I navigate to "/discover/assistant"
Then the page should load without errors
And I should see the page body
And I should see the search bar
+ And I should see the category menu
And I should see assistant cards
+ And I should see pagination controls
+
+ @DISCOVER-SMOKE-003 @P0
+ Scenario: Load Model List Page
+ Given I navigate to "/discover/model"
+ Then the page should load without errors
+ And I should see the page body
+ And I should see model cards
+ And I should see the sort dropdown
+
+ @DISCOVER-SMOKE-004 @P0
+ Scenario: Load Provider List Page
+ Given I navigate to "/discover/provider"
+ Then the page should load without errors
+ And I should see the page body
+ And I should see provider cards
+
+ @DISCOVER-SMOKE-005 @P0
+ Scenario: Load MCP List Page
+ Given I navigate to "/discover/mcp"
+ Then the page should load without errors
+ And I should see the page body
+ And I should see MCP cards
+ And I should see the category filter
diff --git a/e2e/src/steps/discover/smoke.steps.ts b/e2e/src/steps/discover/smoke.steps.ts
index a9807b8c27d..0f0323adcdb 100644
--- a/e2e/src/steps/discover/smoke.steps.ts
+++ b/e2e/src/steps/discover/smoke.steps.ts
@@ -7,8 +7,31 @@ import { CustomWorld } from '../../support/world';
// Then Steps (Assertions)
// ============================================
+// Home Page Steps
+Then('I should see the featured assistants section', async function (this: CustomWorld) {
+ await this.page.waitForLoadState('networkidle', { timeout: 120_000 });
+
+ // Look for featured assistants section by data-testid or heading
+ const featuredSection = this.page
+ .locator(
+ '[data-testid="featured-assistants"], h2:has-text("Featured"), h3:has-text("Featured")',
+ )
+ .first();
+ await expect(featuredSection).toBeVisible({ timeout: 120_000 });
+});
+
+Then('I should see the featured MCP tools section', async function (this: CustomWorld) {
+ await this.page.waitForLoadState('networkidle', { timeout: 120_000 });
+
+ // Look for featured MCP section by data-testid or heading
+ const mcpSection = this.page
+ .locator('[data-testid="featured-mcp"], h2:has-text("MCP"), h3:has-text("MCP")')
+ .first();
+ await expect(mcpSection).toBeVisible({ timeout: 120_000 });
+});
+
+// Assistant List Page Steps
Then('I should see the search bar', async function (this: CustomWorld) {
- // Wait for network to be idle to ensure Suspense components are loaded
await this.page.waitForLoadState('networkidle', { timeout: 120_000 });
// The SearchBar component from @lobehub/ui may not pass through data-testid
@@ -17,12 +40,20 @@ Then('I should see the search bar', async function (this: CustomWorld) {
await expect(searchBar).toBeVisible({ timeout: 120_000 });
});
+Then('I should see the category menu', async function (this: CustomWorld) {
+ await this.page.waitForLoadState('networkidle', { timeout: 120_000 });
+
+ // Look for category menu/filter by data-testid or role
+ const categoryMenu = this.page
+ .locator('[data-testid="category-menu"], [role="menu"], nav[aria-label*="categor" i]')
+ .first();
+ await expect(categoryMenu).toBeVisible({ timeout: 120_000 });
+});
+
Then('I should see assistant cards', async function (this: CustomWorld) {
- // Wait for content to load
await this.page.waitForLoadState('networkidle', { timeout: 120_000 });
- // After migrating to SPA (react-router), links use relative paths like /assistant/:id
- // Look for assistant items by data-testid instead of href
+ // Look for assistant items by data-testid
const assistantItems = this.page.locator('[data-testid="assistant-item"]');
// Wait for at least one item to be visible
@@ -32,3 +63,84 @@ Then('I should see assistant cards', async function (this: CustomWorld) {
const count = await assistantItems.count();
expect(count).toBeGreaterThan(0);
});
+
+Then('I should see pagination controls', async function (this: CustomWorld) {
+ await this.page.waitForLoadState('networkidle', { timeout: 120_000 });
+
+ // Look for pagination controls by data-testid, role, or common pagination elements
+ const pagination = this.page
+ .locator(
+ '[data-testid="pagination"], nav[aria-label*="pagination" i], .pagination, button:has-text("Next"), button:has-text("Previous")',
+ )
+ .first();
+ await expect(pagination).toBeVisible({ timeout: 120_000 });
+});
+
+// Model List Page Steps
+Then('I should see model cards', async function (this: CustomWorld) {
+ await this.page.waitForLoadState('networkidle', { timeout: 120_000 });
+
+ // Look for model items by data-testid
+ const modelItems = this.page.locator('[data-testid="model-item"]');
+
+ // Wait for at least one item to be visible
+ await expect(modelItems.first()).toBeVisible({ timeout: 120_000 });
+
+ // Check we have multiple items
+ const count = await modelItems.count();
+ expect(count).toBeGreaterThan(0);
+});
+
+Then('I should see the sort dropdown', async function (this: CustomWorld) {
+ await this.page.waitForLoadState('networkidle', { timeout: 120_000 });
+
+ // Look for sort dropdown by data-testid, role, or select element
+ const sortDropdown = this.page
+ .locator(
+ '[data-testid="sort-dropdown"], select, button[aria-label*="sort" i], [role="combobox"]',
+ )
+ .first();
+ await expect(sortDropdown).toBeVisible({ timeout: 120_000 });
+});
+
+// Provider List Page Steps
+Then('I should see provider cards', async function (this: CustomWorld) {
+ await this.page.waitForLoadState('networkidle', { timeout: 120_000 });
+
+ // Look for provider items by data-testid
+ const providerItems = this.page.locator('[data-testid="provider-item"]');
+
+ // Wait for at least one item to be visible
+ await expect(providerItems.first()).toBeVisible({ timeout: 120_000 });
+
+ // Check we have multiple items
+ const count = await providerItems.count();
+ expect(count).toBeGreaterThan(0);
+});
+
+// MCP List Page Steps
+Then('I should see MCP cards', async function (this: CustomWorld) {
+ await this.page.waitForLoadState('networkidle', { timeout: 120_000 });
+
+ // Look for MCP items by data-testid
+ const mcpItems = this.page.locator('[data-testid="mcp-item"]');
+
+ // Wait for at least one item to be visible
+ await expect(mcpItems.first()).toBeVisible({ timeout: 120_000 });
+
+ // Check we have multiple items
+ const count = await mcpItems.count();
+ expect(count).toBeGreaterThan(0);
+});
+
+Then('I should see the category filter', async function (this: CustomWorld) {
+ await this.page.waitForLoadState('networkidle', { timeout: 120_000 });
+
+ // Look for category filter by data-testid or similar to category menu
+ const categoryFilter = this.page
+ .locator(
+ '[data-testid="category-filter"], [data-testid="category-menu"], [role="menu"], nav[aria-label*="categor" i]',
+ )
+ .first();
+ await expect(categoryFilter).toBeVisible({ timeout: 120_000 });
+});
diff --git a/src/app/[variants]/(main)/discover/(list)/features/Pagination.tsx b/src/app/[variants]/(main)/discover/(list)/features/Pagination.tsx
index c31bb79fab0..0d085efa14c 100644
--- a/src/app/[variants]/(main)/discover/(list)/features/Pagination.tsx
+++ b/src/app/[variants]/(main)/discover/(list)/features/Pagination.tsx
@@ -52,6 +52,7 @@ const Pagination = memo<PaginationProps>(({ tab, currentPage, total, pageSize })
<Page
className={styles.page}
current={page ? Number(page) : currentPage}
+ data-testid="pagination"
onChange={handlePageChange}
pageSize={pageSize}
showSizeChanger={false}
diff --git a/src/app/[variants]/(main)/discover/(list)/features/SortButton/index.tsx b/src/app/[variants]/(main)/discover/(list)/features/SortButton/index.tsx
index f489dc2d291..acd3e4e1c82 100644
--- a/src/app/[variants]/(main)/discover/(list)/features/SortButton/index.tsx
+++ b/src/app/[variants]/(main)/discover/(list)/features/SortButton/index.tsx
@@ -174,7 +174,7 @@ const SortButton = memo(() => {
}}
trigger={['click', 'hover']}
>
- <Button icon={<Icon icon={ArrowDownWideNarrow} />} type={'text'}>
+ <Button data-testid="sort-dropdown" icon={<Icon icon={ArrowDownWideNarrow} />} type={'text'}>
{activeItem.label}
<Icon icon={ChevronDown} />
</Button>
diff --git a/src/app/[variants]/(main)/discover/(list)/mcp/features/List/Item.tsx b/src/app/[variants]/(main)/discover/(list)/mcp/features/List/Item.tsx
index 4b61e5c8684..66884315eef 100644
--- a/src/app/[variants]/(main)/discover/(list)/mcp/features/List/Item.tsx
+++ b/src/app/[variants]/(main)/discover/(list)/mcp/features/List/Item.tsx
@@ -82,6 +82,7 @@ const McpItem = memo<DiscoverMcpItem>(
return (
<Block
clickable
+ data-testid="mcp-item"
height={'100%'}
onClick={() => {
navigate(link);
diff --git a/src/app/[variants]/(main)/discover/(list)/model/features/List/Item.tsx b/src/app/[variants]/(main)/discover/(list)/model/features/List/Item.tsx
index a46c4c86ab9..9b9545a7628 100644
--- a/src/app/[variants]/(main)/discover/(list)/model/features/List/Item.tsx
+++ b/src/app/[variants]/(main)/discover/(list)/model/features/List/Item.tsx
@@ -61,6 +61,7 @@ const ModelItem = memo<DiscoverModelItem>(
return (
<Block
clickable
+ data-testid="model-item"
height={'100%'}
onClick={() => {
navigate(link);
diff --git a/src/app/[variants]/(main)/discover/(list)/provider/features/List/Item.tsx b/src/app/[variants]/(main)/discover/(list)/provider/features/List/Item.tsx
index a157feafbf7..446449bc63f 100644
--- a/src/app/[variants]/(main)/discover/(list)/provider/features/List/Item.tsx
+++ b/src/app/[variants]/(main)/discover/(list)/provider/features/List/Item.tsx
@@ -54,6 +54,7 @@ const ProviderItem = memo<DiscoverProviderItem>(
return (
<Block
clickable
+ data-testid="provider-item"
height={'100%'}
onClick={() => {
navigate(link);
diff --git a/src/app/[variants]/(main)/discover/components/CategoryMenu.tsx b/src/app/[variants]/(main)/discover/components/CategoryMenu.tsx
index a75f76022ad..1a709c44e0c 100644
--- a/src/app/[variants]/(main)/discover/components/CategoryMenu.tsx
+++ b/src/app/[variants]/(main)/discover/components/CategoryMenu.tsx
@@ -31,7 +31,15 @@ const useStyles = createStyles(({ css, prefixCls }) => {
const CategoryMenu = memo<MenuProps>(({ style, ...rest }) => {
const { styles } = useStyles();
- return <Menu className={styles.menu} mode="inline" style={style} {...rest} />;
+ return (
+ <Menu
+ className={styles.menu}
+ data-testid="category-menu"
+ mode="inline"
+ style={style}
+ {...rest}
+ />
+ );
});
export default CategoryMenu;