test: fix e2e community (#11622)

* fix community

* improve

* fix pwa entry
This commit is contained in:
Arvin Xu
2026-01-19 21:44:04 +08:00
committed by GitHub
parent 6ed280e0cc
commit 560f5de026
5 changed files with 30 additions and 14 deletions

View File

@@ -68,7 +68,7 @@ Then('I should be on an assistant detail page', async function (this: CustomWorl
const currentUrl = this.page.url();
// Check if URL matches assistant detail page pattern
const hasAssistantDetail = /\/community\/assistant\/[^#?]+/.test(currentUrl);
const hasAssistantDetail = /\/community\/agent\/[^#?]+/.test(currentUrl);
expect(
hasAssistantDetail,
`Expected URL to match assistant detail page pattern, but got: ${currentUrl}`,
@@ -138,7 +138,7 @@ Then('I should be on the assistant list page', async function (this: CustomWorld
// After back navigation, URL should be /community/agent or /community
const isListPage =
(currentUrl.includes('/community/agent') &&
!/\/community\/assistant\/[\dA-Za-z-]+$/.test(currentUrl)) ||
!/\/community\/agent\/[\dA-Za-z-]+$/.test(currentUrl)) ||
currentUrl.endsWith('/community') ||
currentUrl.includes('/community#');

View File

@@ -230,10 +230,10 @@ When('I click on the sort dropdown', async function (this: CustomWorld) {
});
When('I select a sort option', async function (this: CustomWorld) {
await this.page.waitForTimeout(500);
await this.page.waitForTimeout(1000);
// Find and click a sort option (assuming dropdown opens a menu)
const sortOptions = this.page.locator('[role="option"], [role="menuitem"]');
// The sort dropdown uses checkbox items with role="menuitemcheckbox"
const sortOptions = this.page.locator('[role="menuitemcheckbox"]');
// Wait for options to appear
await sortOptions.first().waitFor({ state: 'visible', timeout: 30_000 });
@@ -381,7 +381,7 @@ Then('the URL should contain the category parameter', async function (this: Cust
currentUrl.includes('category=') ||
currentUrl.includes('tag=') ||
// For path-based routing like /community/agent/category-name
/\/community\/assistant\/[^/?]+/.test(currentUrl);
/\/community\/agent\/[^/?]+/.test(currentUrl);
expect(
hasCategory,
@@ -433,8 +433,8 @@ Then('I should be navigated to the assistant detail page', async function (this:
await this.page.waitForLoadState('networkidle', { timeout: 30_000 });
const currentUrl = this.page.url();
// Verify that URL changed and contains /assistant/ followed by an identifier
const hasAssistantDetail = /\/community\/assistant\/[^#?]+/.test(currentUrl);
// Verify that URL changed and contains /agent/ followed by an identifier
const hasAssistantDetail = /\/community\/agent\/[^#?]+/.test(currentUrl);
const urlChanged = currentUrl !== this.testContext.previousUrl;
expect(

View File

@@ -45,10 +45,24 @@ BeforeAll({ timeout: 600_000 }, async function () {
// Navigate to signin page
await page.goto(`${baseUrl}/signin`, { waitUntil: 'networkidle' });
// Wait for the page to fully hydrate
await page.waitForTimeout(2000);
// Check if we can find the email input
const emailInput = page
.locator('input[id="email"], input[name="email"], input[type="text"]')
.first();
const emailInputVisible = await emailInput.isVisible().catch(() => false);
if (!emailInputVisible) {
console.log(
'⚠️ Login form not available, skipping authentication (tests requiring auth may fail)',
);
return;
}
// Step 1: Enter email
console.log(' Step 1: Entering email...');
const emailInput = page.locator('input[id="email"]').first();
await emailInput.waitFor({ state: 'visible', timeout: 30_000 });
await emailInput.fill(TEST_USER.email);
// Click the next button
@@ -57,7 +71,9 @@ BeforeAll({ timeout: 600_000 }, async function () {
// Step 2: Wait for password step and enter password
console.log(' Step 2: Entering password...');
const passwordInput = page.locator('input[id="password"]').first();
const passwordInput = page
.locator('input[id="password"], input[name="password"], input[type="password"]')
.first();
await passwordInput.waitFor({ state: 'visible', timeout: 30_000 });
await passwordInput.fill(TEST_USER.password);

View File

@@ -16,7 +16,7 @@ const manifest = async (): Promise<MetadataRoute.Manifest> => {
],
name: 'LobeChat',
short_name: 'LobeChat',
start_url: '/agent',
start_url: '/',
theme_color: '#000000',
};
}

View File

@@ -63,10 +63,10 @@ export class Manifest {
screenshots: screenshots.map((item) => this._getScreenshot(item)),
short_name: name,
splash_pages: null,
start_url: '/agent',
start_url: '/',
tab_strip: {
new_tab_button: {
url: '/agent',
url: '/',
},
},
theme_color: color,