Skip to content
Open
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
5 changes: 4 additions & 1 deletion clis/twitter/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ async function submitTweet(page, text) {

const boxes = Array.from(document.querySelectorAll('[data-testid="tweetTextarea_0"]')).filter(visible);
const composerStillHasText = boxes.some((box) => normalize(box.innerText || box.textContent || '').includes(expectedText));
const hasMedia = !!document.querySelector('[data-testid="attachments"], [data-testid="tweetPhoto"]')
// Drop the global tweetPhoto query: tweetPhoto exists for every
// timeline tweet's image and would pin hasMedia true past the
// success path. attachments + blob: URLs are composer-only.
const hasMedia = !!document.querySelector('[data-testid="attachments"]')
|| document.querySelectorAll('img[src^="blob:"], video[src^="blob:"]').length > 0;
if (!composerStillHasText && !hasMedia) {
return { ok: true, message: 'Tweet posted successfully.', ...statusUrl() };
Expand Down
17 changes: 17 additions & 0 deletions clis/twitter/post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,23 @@ describe('twitter post command', () => {
expect(submitScript).toContain('your post was sent');
});

it('does not let global timeline tweetPhoto nodes keep the submit poll pending', async () => {
const command = getCommand();
const page = makePage([
{ ok: true }, // focus composer
{ ok: true }, // verify native insertText
{ ok: true }, // click post
{ ok: true, message: 'Tweet posted successfully.' },
]);

await command.func(page, { text: 'global media should not block' });

const submitScript = page.evaluate.mock.calls[3][0];
expect(submitScript).toContain("document.querySelector('[data-testid=\"attachments\"]')");
expect(submitScript).not.toContain("[data-testid=\"attachments\"], [data-testid=\"tweetPhoto\"]");
expect(submitScript).not.toContain("document.querySelectorAll('[data-testid=\"tweetPhoto\"]");
});

it('returns failed when image upload times out', async () => {
const command = getCommand();
const page = makePage([
Expand Down
Loading