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

Incorrect behaviour for GitLab reporter on issue filtering #1129

Merged
merged 5 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased [minor]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this changeset corrects an unintended behavior in the software without introducing new features or breaking compatibility, it is considered as a patch in SemVer

Suggested change
## Unreleased [minor]
## Unreleased [patch]


> Development of this release was supported by the [European Union](https://commission.europa.eu/).

### Fixed
- Fix functionality of filtering by status for the issues list on GitLab

## 4.0.1 - 2024-12-11

_Full changeset and discussions: [#1124](https://github.com/OpenTermsArchive/engine/pull/1124)._
Expand Down
1 change: 1 addition & 0 deletions data (copy)/snapshots
Submodule snapshots added at 49af2f
1 change: 1 addition & 0 deletions data (copy)/versions
Submodule versions added at dc53f9
5 changes: 2 additions & 3 deletions src/reporter/gitlab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,9 @@ export default class GitLab {

async getIssue({ title, ...searchParams }) {
try {
let apiUrl = `${this.apiBaseURL}/projects/${this.projectId}/issues?state=${searchParams.state}&per_page=100`;
let apiUrl = `${this.apiBaseURL}/projects/${this.projectId}/issues?search=${encodeURIComponent(title)}&state=${searchParams.state}&per_page=100`;

if (searchParams.state == 'all') apiUrl = `${this.apiBaseURL}/projects/${this.projectId}/issues?per_page=100`;
apiUrl = `${this.apiBaseURL}/projects/${this.projectId}/issues?search=${encodeURIComponent(title)}&per_page=100`;
if (searchParams.state == 'all') apiUrl = `${this.apiBaseURL}/projects/${this.projectId}/issues?search=${encodeURIComponent(title)}&per_page=100`;

const options = GitLab.baseOptionsHttpReq();

Expand Down
30 changes: 28 additions & 2 deletions src/reporter/gitlab/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,33 @@ describe('GitLab', function () {
.get(`/projects/${PROJECT_ID}/issues?search=${encodeURIComponent(ISSUE.title)}&per_page=100`)
.reply(200, [ ISSUE, ANOTHER_ISSUE ]);

result = await gitlab.getIssue({ title: ISSUE.title });
result = await gitlab.getIssue({ title: ISSUE.title, state: GitLab.ISSUE_STATE_ALL });
});

after(nock.cleanAll);

it('searches for the issue', () => {
expect(scope.isDone()).to.be.true;
});

it('returns the expected issue', () => {
expect(result).to.deep.equal(ISSUE);
});
});

describe('#getIssueWithStatus', () => {
let scope;
let result;

const ISSUE = { number: 123, title: 'Test Issue', state: 'opened' };
const ANOTHER_ISSUE = { number: 124, title: 'Test Issue 2', state: 'opened' };

before(async () => {
scope = nock(gitlab.apiBaseURL)
.get(`/projects/${PROJECT_ID}/issues?search=${encodeURIComponent(ISSUE.title)}&state=${GitLab.ISSUE_STATE_OPEN}&per_page=100`)
.reply(200, [ ISSUE, ANOTHER_ISSUE ]);

result = await gitlab.getIssue({ title: ISSUE.title, state: GitLab.ISSUE_STATE_OPEN });
});

after(nock.cleanAll);
Expand Down Expand Up @@ -265,7 +291,7 @@ describe('GitLab', function () {

before(async () => {
nock(gitlab.apiBaseURL)
.get(`/projects/${PROJECT_ID}/issues?search=${encodeURIComponent(ISSUE.title)}&per_page=100`)
.get(`/projects/${PROJECT_ID}/issues?search=${encodeURIComponent(ISSUE.title)}&state=${GitLab.ISSUE_STATE_OPEN}&per_page=100`)
.reply(200, [ISSUE]);

addCommentScope = nock(gitlab.apiBaseURL)
Expand Down
Loading