-
-
Notifications
You must be signed in to change notification settings - Fork 7
Fix KaTeX display math and chat flex layout overflow #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,31 @@ test.describe('Responsive design - Desktop', () => { | |
| expect(chatBox).toBeTruthy(); | ||
| expect(mapBox).toBeTruthy(); | ||
| }); | ||
|
|
||
| test('should prevent math content horizontal page overflow on desktop', async ({ page }) => { | ||
| const chatInput = page.locator('[data-testid="chat-input"]'); | ||
| await expect(chatInput).toBeVisible(); | ||
|
|
||
| const mathMessage = 'Inline equation: $f(x) = \\sum_{i=1}^{100} \\frac{x_i^2 + y_i^2 + z_i^2 + w_i^2}{\\sqrt{\\alpha_i + \\beta_i + \\gamma_i + \\delta_i}}$ and display equation: $$\\int_{-\\infty}^{\\infty} e^{-x^2} dx = \\sqrt{\\pi} \\cdot \\frac{\\sum_{n=1}^{50} (n^2 + 2n + 1)}{\\prod_{k=1}^{20} (k + \\frac{1}{k})} \\cdot \\text{Super Long Math Line That Extends Significantly Beyond Standard Container Width}$$'; | ||
|
|
||
| await chatInput.fill(mathMessage); | ||
| await page.click('[data-testid="chat-submit"]'); | ||
|
|
||
| const userMessage = page.locator('[data-testid="user-message"]').last(); | ||
| await expect(userMessage).toBeVisible(); | ||
|
Comment on lines
+53
to
+54
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Make the regression tests render KaTeX before measuring overflow. Both tests submit Arrange a deterministic assistant response containing the long display equation. Then wait for Suggested assertion shape- const userMessage = page.locator('[data-testid="user-message"]').last();
- await expect(userMessage).toBeVisible();
+ const botMessage = page.locator('[data-testid="bot-message"]').last();
+ await expect(botMessage).toBeVisible({ timeout: 15000 });
+ await expect(botMessage.locator('.katex-display')).toBeVisible();Also applies to: 226-227 🤖 Prompt for AI Agents |
||
|
|
||
| const chatContainer = page.locator('[data-testid="chat-container"]'); | ||
| if (await chatContainer.isVisible()) { | ||
| const chatBox = await chatContainer.boundingBox(); | ||
| expect(chatBox).toBeTruthy(); | ||
| if (chatBox) { | ||
| expect(chatBox.width).toBeLessThanOrEqual(1920); | ||
| } | ||
| } | ||
|
|
||
| const bodyWidth = await page.evaluate(() => document.body.scrollWidth); | ||
| expect(bodyWidth).toBeLessThanOrEqual(1920 + 1); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('Responsive design - Tablet', () => { | ||
|
|
@@ -183,6 +208,37 @@ test.describe('Responsive design - Mobile', () => { | |
| expect(bodyWidth).toBeLessThanOrEqual(viewportWidth + 1); // +1 for rounding | ||
| }); | ||
|
|
||
| test('should prevent math content horizontal page overflow on mobile', async ({ page }) => { | ||
| const chatInput = page.locator('[data-testid="chat-input"]'); | ||
| await expect(chatInput).toBeVisible(); | ||
|
|
||
| const mathMessage = 'Inline equation: $f(x) = \\sum_{i=1}^{100} \\frac{x_i^2 + y_i^2 + z_i^2 + w_i^2}{\\sqrt{\\alpha_i + \\beta_i + \\gamma_i + \\delta_i}}$ and display equation: $$\\int_{-\\infty}^{\\infty} e^{-x^2} dx = \\sqrt{\\pi} \\cdot \\frac{\\sum_{n=1}^{50} (n^2 + 2n + 1)}{\\prod_{k=1}^{20} (k + \\frac{1}{k})} \\cdot \\text{Super Long Math Line That Extends Significantly Beyond Standard Container Width}$$'; | ||
|
|
||
| await chatInput.fill(mathMessage); | ||
|
|
||
| const submitButton = page.locator('[data-testid="mobile-submit-button"]'); | ||
| if (await submitButton.isVisible()) { | ||
| await submitButton.click(); | ||
| } else { | ||
| await page.click('[data-testid="chat-submit"]'); | ||
| } | ||
|
|
||
| const userMessage = page.locator('[data-testid="user-message"]').last(); | ||
| await expect(userMessage).toBeVisible(); | ||
|
|
||
| const chatContainer = page.locator('[data-testid="chat-container"]'); | ||
| if (await chatContainer.isVisible()) { | ||
| const chatBox = await chatContainer.boundingBox(); | ||
| expect(chatBox).toBeTruthy(); | ||
| if (chatBox) { | ||
| expect(chatBox.width).toBeLessThanOrEqual(375); | ||
| } | ||
| } | ||
|
|
||
| const bodyWidth = await page.evaluate(() => document.body.scrollWidth); | ||
| expect(bodyWidth).toBeLessThanOrEqual(375 + 1); | ||
| }); | ||
|
|
||
| test('should stack elements vertically', async ({ page }) => { | ||
| await page.fill('[data-testid="chat-input"]', 'Mobile test message'); | ||
| await page.click('[data-testid="mobile-submit-button"]'); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Katex regression remains untested
🐞 Bug⚙ MaintainabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools