Skip to content

Commit 4436e6c

Browse files
committed
test: make compose visibility queue-aware
1 parent 90c6bf1 commit 4436e6c

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

tests/e2e/steps/us17-compose-instant-visibility.spec.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ test.describe('US-17: Instant Submission Visibility', () => {
3939
await stopAndClearQueue(page);
4040
});
4141

42-
test.afterEach(async ({ authedPage: page }) => {
43-
await stopAndClearQueue(page);
44-
});
45-
4642
test('typed message appears in timeline after Enter', async ({ authedPage: page }) => {
4743
await page.waitForSelector(sel.timeline);
4844

@@ -87,17 +83,22 @@ test.describe('US-17: Instant Submission Visibility', () => {
8783
await page.waitForTimeout(200);
8884
await sendViaCompose(page, msg2);
8985

90-
// Both should appear
86+
// First submit should be a timeline post. The second is allowed to be an
87+
// explicit queued follow-up if the first agent turn is still active.
9188
const post1 = page.locator(sel.postContent, { hasText: msg1 });
92-
const post2 = page.locator(sel.postContent, { hasText: msg2 });
9389
await expect(post1).toBeVisible({ timeout: 5000 });
94-
await expect(post2).toBeVisible({ timeout: 5000 });
9590

96-
// Order: msg1 should come before msg2 in the DOM
97-
const allPosts = await page.locator(sel.postContent).allTextContents();
98-
const idx1 = allPosts.findIndex(t => t.includes(msg1));
99-
const idx2 = allPosts.findIndex(t => t.includes(msg2));
100-
expect(idx1).toBeLessThan(idx2);
91+
const post2 = page.locator(sel.postContent, { hasText: msg2 });
92+
const queued2 = page.locator(sel.queueItem, { hasText: msg2 });
93+
const post2Visible = await post2.isVisible({ timeout: 3000 }).catch(() => false);
94+
if (!post2Visible) await expect(queued2).toBeVisible({ timeout: 3000 });
95+
96+
if (post2Visible) {
97+
const allPosts = await page.locator(sel.postContent).allTextContents();
98+
const idx1 = allPosts.findIndex(t => t.includes(msg1));
99+
const idx2 = allPosts.findIndex(t => t.includes(msg2));
100+
expect(idx1).toBeLessThan(idx2);
101+
}
101102
});
102103

103104
test('long multi-line message appears completely', async ({ authedPage: page }) => {
@@ -121,13 +122,13 @@ test.describe('US-17: Instant Submission Visibility', () => {
121122
}
122123
await page.keyboard.press('Enter');
123124

124-
// All lines should appear in the timeline
125-
await page.waitForTimeout(2000);
126-
const posts = await page.locator(sel.postContent).allTextContents();
127-
const lastPost = posts[posts.length - 1] || '';
128-
// At least first and last line should be present (not truncated)
129-
expect(lastPost).toContain('Line 1');
130-
expect(lastPost).toContain('Line 5');
125+
// All lines should appear in the submitted user post, even if an agent
126+
// status/error post is appended after it.
127+
const submitted = page.locator(sel.postContent, { hasText: 'Line 1: This is a multi-line test' }).last();
128+
await expect(submitted).toBeVisible({ timeout: 5000 });
129+
const text = await submitted.textContent();
130+
expect(text).toContain('Line 1');
131+
expect(text).toContain('Line 5');
131132
});
132133

133134
test('compose box clears and stays focused after submission', async ({ authedPage: page }) => {

0 commit comments

Comments
 (0)