From 834e15058b6a9fea0c6bdbc6d9fe720ff9f5dd07 Mon Sep 17 00:00:00 2001 From: Jonny Hou Date: Tue, 7 Jul 2026 11:25:28 +0200 Subject: [PATCH 1/2] test: complete goto_reply fixture and assertion (#11) --- tests/mail/fixtures/draft_with_quotes.txt | 14 ++++++++++++++ tests/mail/navigate_spec.lua | 8 +++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 tests/mail/fixtures/draft_with_quotes.txt diff --git a/tests/mail/fixtures/draft_with_quotes.txt b/tests/mail/fixtures/draft_with_quotes.txt new file mode 100644 index 0000000..c5184da --- /dev/null +++ b/tests/mail/fixtures/draft_with_quotes.txt @@ -0,0 +1,14 @@ +From: me@example.com +To: alice@example.com +Subject: Re: Meeting tomorrow +Date: Mon, 7 Jul 2026 10:00:00 +0000 + +Thanks for the update, sounds good. + +> On Mon, 7 Jul 2026, Alice wrote: +> Hi, +> Just confirming the meeting is at 2pm tomorrow. +> Let me know if that still works. +> +> Thanks, +> Alice diff --git a/tests/mail/navigate_spec.lua b/tests/mail/navigate_spec.lua index 5d8f2a3..5f40f02 100644 --- a/tests/mail/navigate_spec.lua +++ b/tests/mail/navigate_spec.lua @@ -47,9 +47,11 @@ describe('mail.navigate', function() describe('goto_reply', function() it('jumps to first quoted line', function() - local buf = load_fixture('draft_reply_with_thread.txt') - -- This fixture has no quotes, so it should not move - -- Let's test with marker fixture which also has no quotes + local buf = load_fixture('draft_with_quotes.txt') + nav.goto_reply() + local pos = vim.api.nvim_win_get_cursor(0) + local line = vim.api.nvim_buf_get_lines(buf, pos[1] - 1, pos[1], false)[1] + assert.is_truthy(line:match('^>')) vim.api.nvim_buf_delete(buf, { force = true }) end) end) From 13d75014126d5485f9a8b3e286b094ad26b9c2dc Mon Sep 17 00:00:00 2001 From: Jonny Hou Date: Tue, 7 Jul 2026 16:15:16 +0200 Subject: [PATCH 2/2] test: assert exact first-quote line and no-move negative case (#20) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses gemini-code-assist review feedback on PR #20: - Assert cursor lands on line 8 (first `>` in draft_with_quotes.txt), not just any `^>` line. - Add negative test: no quoted lines → cursor does not move. --- tests/mail/navigate_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/mail/navigate_spec.lua b/tests/mail/navigate_spec.lua index 5f40f02..d1aa542 100644 --- a/tests/mail/navigate_spec.lua +++ b/tests/mail/navigate_spec.lua @@ -52,6 +52,26 @@ describe('mail.navigate', function() local pos = vim.api.nvim_win_get_cursor(0) local line = vim.api.nvim_buf_get_lines(buf, pos[1] - 1, pos[1], false)[1] assert.is_truthy(line:match('^>')) + -- Assert exact first-quote line (fixture: draft_with_quotes.txt line 8 is `> On Mon, ...`) + assert.are.equal(8, pos[1]) + vim.api.nvim_buf_delete(buf, { force = true }) + end) + + it('does not move cursor when there are no quoted lines', function() + local buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_lines(buf, 0, -1, false, { + 'From: a@b.com', + 'To: c@d.com', + 'Subject: Hello', + '', + 'Just a plain body line.', + 'No quotes here.', + }) + vim.api.nvim_set_current_buf(buf) + vim.api.nvim_win_set_cursor(0, { 5, 0 }) + nav.goto_reply() + local pos = vim.api.nvim_win_get_cursor(0) + assert.are.equal(5, pos[1]) vim.api.nvim_buf_delete(buf, { force = true }) end) end)