Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions clis/twitter/reply.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ describe('twitter reply command', () => {
text: 'text-only reply',
});

expect(page.goto).toHaveBeenCalledWith('https://x.com/_kop6/status/2040254679301718161?s=20');
expect(page.wait).toHaveBeenCalledWith({ selector: '[data-testid="primaryColumn"]' });
expect(page.goto).toHaveBeenCalledWith(
'https://x.com/compose/post?in_reply_to=2040254679301718161',
{ waitUntil: 'load', settleMs: 2500 }
);
expect(page.wait).toHaveBeenCalledWith({ selector: '[data-testid="tweetTextarea_0"]', timeout: 8 });
expect(result).toEqual([
{
status: 'success',
Expand Down Expand Up @@ -86,8 +89,11 @@ describe('twitter reply command', () => {
image: imagePath,
});

expect(page.goto).toHaveBeenCalledWith('https://x.com/compose/post?in_reply_to=2040254679301718161');
expect(page.wait).toHaveBeenNthCalledWith(1, { selector: '[data-testid="tweetTextarea_0"]' });
expect(page.goto).toHaveBeenCalledWith(
'https://x.com/compose/post?in_reply_to=2040254679301718161',
{ waitUntil: 'load', settleMs: 2500 }
);
expect(page.wait).toHaveBeenNthCalledWith(1, { selector: '[data-testid="tweetTextarea_0"]', timeout: 8 });
expect(page.wait).toHaveBeenNthCalledWith(2, { selector: 'input[type="file"][data-testid="fileInput"]', timeout: 20 });
expect(setFileInput).toHaveBeenCalledWith([imagePath], 'input[type="file"][data-testid="fileInput"]');
expect(result).toEqual([
Expand Down
12 changes: 5 additions & 7 deletions clis/twitter/reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,14 @@ cli({
cleanupDir = path.dirname(localImagePath);
}

// Dedicated composer is more reliable for image replies because the media
// toolbar and file input are consistently present there.
// Dedicated reply composer is more reliable than the inline tweet page
// reply box because the textarea and action button are mounted more
// consistently there.
await page.goto(buildReplyComposerUrl(kwargs.url), { waitUntil: 'load', settleMs: 2500 });
await page.wait({ selector: '[data-testid="tweetTextarea_0"]', timeout: 8 });
if (localImagePath) {
await page.goto(buildReplyComposerUrl(kwargs.url));
await page.wait({ selector: '[data-testid="tweetTextarea_0"]' });
await page.wait({ selector: REPLY_FILE_INPUT_SELECTOR, timeout: 20 });
await attachReplyImage(page, localImagePath);
} else {
await page.goto(kwargs.url);
await page.wait({ selector: '[data-testid="primaryColumn"]' });
}

const result = await submitReply(page, kwargs.text);
Expand Down