fix last session
This commit is contained in:
@@ -268,6 +268,101 @@ test.describe('Tmux Terminal Session', () => {
|
||||
console.log('[Test] Cleanup complete');
|
||||
});
|
||||
|
||||
test('clear command removes prior terminal content', async ({ page, request }) => {
|
||||
// Track session ID for cleanup
|
||||
let createdSessionId: string | null = null;
|
||||
|
||||
// 1. Navigate to homepage and create a tmux session
|
||||
await page.goto('/');
|
||||
await expect(page).toHaveTitle(/Spiceflow/i);
|
||||
|
||||
const createButton = page.locator('button[title="New Session"]');
|
||||
await createButton.click();
|
||||
|
||||
const tmuxOption = page.locator('button:has-text("Terminal (tmux)")');
|
||||
await tmuxOption.click();
|
||||
|
||||
// Wait for navigation to session page
|
||||
await page.waitForURL(/\/session\/.+/);
|
||||
const sessionUrl = page.url();
|
||||
createdSessionId = decodeURIComponent(sessionUrl.split('/session/')[1]);
|
||||
console.log('[Test] Created session:', createdSessionId);
|
||||
|
||||
// 2. Wait for terminal to load
|
||||
const terminalOutput = page.locator('pre.text-green-400');
|
||||
await expect(terminalOutput).toBeVisible({ timeout: 10000 });
|
||||
|
||||
const commandInput = page.locator('input[aria-label="Terminal input"]');
|
||||
await expect(commandInput).toBeEnabled({ timeout: 5000 });
|
||||
|
||||
// 3. Run commands that produce distinctive output
|
||||
const marker1 = `BEFORE-CLEAR-MARKER-${Date.now()}`;
|
||||
await commandInput.focus();
|
||||
await page.keyboard.type(`echo "${marker1}"`);
|
||||
await page.keyboard.press('Enter');
|
||||
console.log('[Test] Sent echo command with marker1:', marker1);
|
||||
|
||||
// Wait for marker to appear
|
||||
await expect(async () => {
|
||||
const content = await terminalOutput.textContent();
|
||||
expect(content).toContain(marker1);
|
||||
}).toPass({ timeout: 5000 });
|
||||
console.log('[Test] Marker1 appeared in terminal');
|
||||
|
||||
// 4. Run clear command
|
||||
await commandInput.focus();
|
||||
await page.keyboard.type('clear');
|
||||
await page.keyboard.press('Enter');
|
||||
console.log('[Test] Sent clear command');
|
||||
|
||||
// 5. Wait a moment for clear to process and verify marker is gone
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// The old marker should no longer be visible after clear
|
||||
await expect(async () => {
|
||||
const content = await terminalOutput.textContent();
|
||||
expect(content).not.toContain(marker1);
|
||||
}).toPass({ timeout: 5000 });
|
||||
console.log('[Test] Marker1 no longer visible after clear');
|
||||
|
||||
// 6. Run another command to prove terminal still works
|
||||
const marker2 = `AFTER-CLEAR-MARKER-${Date.now()}`;
|
||||
await commandInput.focus();
|
||||
await page.keyboard.type(`echo "${marker2}"`);
|
||||
await page.keyboard.press('Enter');
|
||||
console.log('[Test] Sent echo command with marker2:', marker2);
|
||||
|
||||
// Wait for marker2 to appear
|
||||
await expect(async () => {
|
||||
const content = await terminalOutput.textContent();
|
||||
expect(content).toContain(marker2);
|
||||
}).toPass({ timeout: 5000 });
|
||||
console.log('[Test] Marker2 appeared in terminal');
|
||||
|
||||
// 7. Wait for the 5-second periodic full frame refresh
|
||||
// The bug causes old content to leak back after a full frame
|
||||
console.log('[Test] Waiting 6 seconds for periodic full frame refresh...');
|
||||
await page.waitForTimeout(6000);
|
||||
|
||||
// 8. Verify marker1 has not leaked back
|
||||
const finalContent = await terminalOutput.textContent();
|
||||
console.log('[Test] Final terminal content length:', finalContent?.length);
|
||||
|
||||
// The old marker should still NOT be visible after the full frame refresh
|
||||
expect(finalContent).not.toContain(marker1);
|
||||
console.log('[Test] Marker1 still not visible after full frame refresh - clear works correctly!');
|
||||
|
||||
// marker2 should still be there
|
||||
expect(finalContent).toContain(marker2);
|
||||
console.log('[Test] Marker2 still visible');
|
||||
|
||||
// 9. Cleanup
|
||||
if (createdSessionId) {
|
||||
await deleteSession(request, createdSessionId);
|
||||
}
|
||||
console.log('[Test] Cleanup complete');
|
||||
});
|
||||
|
||||
test('eject tmux session removes from spiceflow but keeps tmux running', async ({ page, request }) => {
|
||||
// Track session ID for cleanup
|
||||
let createdSessionId: string | null = null;
|
||||
|
||||
Reference in New Issue
Block a user