Skip to content

Commit

Permalink
Merge branch 'main' into 277-filters-url
Browse files Browse the repository at this point in the history
  • Loading branch information
Arif-Khalid authored Mar 30, 2024
2 parents 00d3238 + 3f0aa1f commit 97a7128
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- run: npm update
- run: npm run lint
- run: npm run build:prod:web
- run: npm run test
# - run: npm test -- "--karma-config=./tests/karma.ci.conf.js"
# - run: npm run webdriver-manager update -- --gecko false --standalone false --versions.chrome $(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$(google-chrome --version | grep -iEo "[0-9]{1,3}" | head -n1))
# - run: npm run webdriver-manager update -- --chrome false --standalone false
Expand All @@ -45,6 +46,7 @@ jobs:
- run: npm install
- run: npm update
- run: npm run lint
- run: npm run test
# - run: npm test -- "--karma-config=./tests/karma.ci.conf.js" || npm test -- "--karma-config=./tests/karma.ci.conf.js"
# retry tests once, in case they timed out on Mac OS
windows-setup-and-tests:
Expand All @@ -61,4 +63,5 @@ jobs:
- run: npm install
- run: npm update
- run: npm run lint
- run: npm run test
# - run: npm test -- "--karma-config=./tests/karma.ci.conf.js"
5 changes: 4 additions & 1 deletion src/app/issues-viewer/card-view/card-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Issue } from '../../core/models/issue.model';
import { FiltersService } from '../../core/services/filters.service';
import { GroupBy, GroupingContextService } from '../../core/services/grouping/grouping-context.service';
import { IssueService } from '../../core/services/issue.service';
import { MilestoneService } from '../../core/services/milestone.service';
import { FilterableComponent, FilterableSource } from '../../shared/issue-tables/filterableTypes';
import { IssuesDataTable } from '../../shared/issue-tables/IssuesDataTable';

Expand Down Expand Up @@ -57,14 +58,16 @@ export class CardViewComponent implements OnInit, AfterViewInit, OnDestroy, Filt
public element: ElementRef,
public issueService: IssueService,
public groupingContextService: GroupingContextService,
private filtersService: FiltersService
private filtersService: FiltersService,
private milestoneService: MilestoneService
) {}

ngOnInit() {
this.issues = new IssuesDataTable(
this.issueService,
this.groupingContextService,
this.filtersService,
this.milestoneService,
this.paginator,
this.headers,
this.group,
Expand Down
4 changes: 3 additions & 1 deletion src/app/shared/issue-tables/IssuesDataTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Issue } from '../../core/models/issue.model';
import { Filter, FiltersService } from '../../core/services/filters.service';
import { GroupingContextService } from '../../core/services/grouping/grouping-context.service';
import { IssueService } from '../../core/services/issue.service';
import { MilestoneService } from '../../core/services/milestone.service';
import { applyDropdownFilter } from './dropdownfilter';
import { FilterableSource } from './filterableTypes';
import { paginateData } from './issue-paginator';
Expand All @@ -25,6 +26,7 @@ export class IssuesDataTable extends DataSource<Issue> implements FilterableSour
private issueService: IssueService,
private groupingContextService: GroupingContextService,
private filtersService: FiltersService,
private milestoneService: MilestoneService,
private paginator: MatPaginator,
private displayedColumn: string[],
private group?: Group,
Expand Down Expand Up @@ -67,7 +69,7 @@ export class IssuesDataTable extends DataSource<Issue> implements FilterableSour
data = this.groupingContextService.getDataForGroup(data, this.group);

// Apply Filters
data = applyDropdownFilter(this.filter, data);
data = applyDropdownFilter(this.filter, data, !this.milestoneService.hasNoMilestones);

data = applySearchFilter(this.filter.title, this.displayedColumn, this.issueService, data);
this.count = data.length;
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/issue-tables/dropdownfilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const infoFromStatus = (statusString: string): StatusInfo => {
* This module exports a single function applyDropDownFilter which is called by IssueList.
* This functions returns the data passed in after all the filters of dropdownFilters are applied
*/
export function applyDropdownFilter(filter: Filter, data: Issue[]): Issue[] {
export function applyDropdownFilter(filter: Filter, data: Issue[], isFilteringByMilestone: boolean): Issue[] {
const filteredData: Issue[] = data.filter((issue) => {
let ret = true;

Expand All @@ -38,7 +38,7 @@ export function applyDropdownFilter(filter: Filter, data: Issue[]): Issue[] {
ret = ret && issue.issueOrPr === 'PullRequest';
}

ret = ret && filter.milestones.some((milestone) => issue.milestone.title === milestone);
ret = ret && (!isFilteringByMilestone || filter.milestones.some((milestone) => issue.milestone.title === milestone));
ret = ret && issue.labels.every((label) => !filter.deselectedLabels.has(label));
return ret && filter.labels.every((label) => issue.labels.includes(label));
});
Expand Down
7 changes: 4 additions & 3 deletions tests/model/issue.model.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as moment from 'moment';
import { Issue } from '../../src/app/core/models/issue.model';
import { Milestone } from '../../src/app/core/models/milestone.model';
import { USER_ANUBHAV } from '../constants/data.constants';
Expand All @@ -22,10 +23,10 @@ describe('Issue model class', () => {

expect(issue.globalId).toEqual(ISSUE_WITH_EMPTY_DESCRIPTION.id);
expect(issue.id).toEqual(ISSUE_WITH_EMPTY_DESCRIPTION.number);
expect(issue.created_at).toEqual('Mar 3, 2020 12:19 AM');
expect(issue.created_at).toEqual(moment(ISSUE_WITH_EMPTY_DESCRIPTION.created_at).format('lll'));
expect(issue.title).toEqual(ISSUE_WITH_EMPTY_DESCRIPTION.title);
expect(issue.description).toEqual('No details provided by bug reporter.');
expect(issue.updated_at).toEqual('Mar 13, 2020 9:37 PM');
expect(issue.updated_at).toEqual(moment(ISSUE_WITH_EMPTY_DESCRIPTION.updated_at).format('lll'));
expect(issue.closed_at).toEqual('Invalid date');
expect(issue.milestone).toEqual(new Milestone(MILESTONE_ONE));
expect(issue.state).toEqual(ISSUE_WITH_EMPTY_DESCRIPTION.state);
Expand All @@ -46,7 +47,7 @@ describe('Issue model class', () => {
it('should set close date correctly for closed issue', () => {
const issue = Issue.createPhaseBugReportingIssue(CLOSED_ISSUE_WITH_EMPTY_DESCRIPTION);

expect(issue.closed_at).toEqual('Mar 22, 2020 11:37 PM');
expect(issue.closed_at).toEqual(moment(CLOSED_ISSUE_WITH_EMPTY_DESCRIPTION.closed_at).format('lll'));
});

it('should set milestone to default milestone for issue without milestone', () => {
Expand Down
3 changes: 1 addition & 2 deletions tests/services/view.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ let activatedRouteSpy: jasmine.SpyObj<ActivatedRoute>;
describe('ViewService', () => {
beforeEach(() => {
githubServiceSpy = jasmine.createSpyObj('GithubService', ['isRepositoryPresent', 'storeViewDetails']);
activatedRouteSpy = jasmine.createSpyObj('ActivatedRoute', ['snapshot']);
routerSpy = jasmine.createSpyObj('Router', ['navigate']);
repoUrlCacheServiceSpy = jasmine.createSpyObj('RepoUrlCacheService', ['cache']);
loggingServiceSpy = jasmine.createSpyObj('LoggingService', ['info']);
activatedRouteSpy = jasmine.createSpyObj('ActivatedRoute', ['snapshot']);

viewService = new ViewService(githubServiceSpy, repoUrlCacheServiceSpy, loggingServiceSpy, activatedRouteSpy, routerSpy);
});

Expand Down

0 comments on commit 97a7128

Please sign in to comment.