Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch only cov feedback link #77

Merged
merged 1 commit into from
Aug 29, 2023
Merged
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
33 changes: 21 additions & 12 deletions services/notification/notifiers/mixins/message/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,29 @@ async def write_section(*args, **kwargs):

class NewFooterSectionWriter(BaseSectionWriter):
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
repo_service = comparison.repository_service.service
yield ("")
yield (
"[:umbrella: View full report in Codecov by Sentry]({0}?src=pr&el=continue). ".format(
links["pull"]
hide_project_coverage = self.settings.get("hide_project_coverage", False)
if hide_project_coverage:
yield ("")
yield (
":loudspeaker: Thoughts on this report? [Let us know!]({0}).".format(
"https://about.codecov.io/pull-request-comment-report/"
)
)
)
yield (
":loudspeaker: Have feedback on the report? [Share it here]({0}).".format(
"https://about.codecov.io/codecov-pr-comment-feedback/"
if repo_service == "github"
else "https://gitlab.com/codecov-open-source/codecov-user-feedback/-/issues/4"
else:
repo_service = comparison.repository_service.service
yield ("")
yield (
"[:umbrella: View full report in Codecov by Sentry]({0}?src=pr&el=continue). ".format(
links["pull"]
)
)
yield (
":loudspeaker: Have feedback on the report? [Share it here]({0}).".format(
"https://about.codecov.io/codecov-pr-comment-feedback/"
if repo_service == "github"
else "https://gitlab.com/codecov-open-source/codecov-user-feedback/-/issues/4"
)
)
)


class NewHeaderSectionWriter(BaseSectionWriter):
Expand Down
39 changes: 31 additions & 8 deletions services/notification/notifiers/tests/unit/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3778,8 +3778,8 @@ async def test_footer_section_writer_in_github(self, mocker):
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
settings={},
current_yaml=mocker.MagicMock(),
)
mock_comparison = mocker.MagicMock()
mock_comparison.repository_service.service = "github"
Expand All @@ -3800,8 +3800,8 @@ async def test_footer_section_writer_in_gitlab(self, mocker):
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
settings={},
current_yaml=mocker.MagicMock(),
)
mock_comparison = mocker.MagicMock()
mock_comparison.repository_service.service = "gitlab"
Expand All @@ -3822,8 +3822,8 @@ async def test_footer_section_writer_in_bitbucket(self, mocker):
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
settings={},
current_yaml=mocker.MagicMock(),
)
mock_comparison = mocker.MagicMock()
mock_comparison.repository_service.service = "bitbucket"
Expand All @@ -3838,6 +3838,30 @@ async def test_footer_section_writer_in_bitbucket(self, mocker):
":loudspeaker: Have feedback on the report? [Share it here](https://gitlab.com/codecov-open-source/codecov-user-feedback/-/issues/4).",
]

@pytest.mark.asyncio
async def test_footer_section_writer_with_project_cov_hidden(self, mocker):
writer = NewFooterSectionWriter(
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
settings={
"layout": "newheader, files, newfooter",
"hide_project_coverage": True,
},
current_yaml={},
)
mock_comparison = mocker.MagicMock()
mock_comparison.repository_service.service = "bitbucket"
res = list(
await writer.write_section(
mock_comparison, {}, [], links={"pull": "pull.link"}
)
)
assert res == [
"",
":loudspeaker: Thoughts on this report? [Let us know!](https://about.codecov.io/pull-request-comment-report/).",
]


class TestCommentNotifierInNewLayout(object):
@pytest.mark.asyncio
Expand Down Expand Up @@ -4168,8 +4192,7 @@ async def test_build_message_no_project_coverage(
f"| [file\\_1.go](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=tree#diff-ZmlsZV8xLmdv) | `66.67%` |",
f"",
f"",
f"[:umbrella: View full report in Codecov by Sentry](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=continue). ",
f":loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/).",
f":loudspeaker: Thoughts on this report? [Let us know!](https://about.codecov.io/pull-request-comment-report/).",
f"",
]
for exp, res in zip(expected_result, result):
Expand Down