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

Contribution dashboard admin change: Add overall item count to contributor dashboard admin stats table #20186

Merged
merged 62 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
6bea1a4
Changes to contributor-dashboard-admin to appear correctly, to reduce…
stevenjgodfrey Dec 21, 2023
a83ee38
Add a test to contributor-dashboard-admin unit tests to ensure coverage
stevenjgodfrey Dec 21, 2023
806ddca
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Jan 9, 2024
ea34f9b
increase coverage of contributor-admin-dashboard page tests
stevenjgodfrey Jan 9, 2024
771d86b
increase coverage of contributor-admin-dashboard page tests further
stevenjgodfrey Jan 9, 2024
151c599
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Jan 16, 2024
2f15db8
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Jan 17, 2024
2647812
fix e2e test error by reducing elements to 1, as unseen component rem…
stevenjgodfrey Jan 17, 2024
9d30da1
Merge branch 'develop' into cont-dash-admin-change
stevenjgodfrey Jan 18, 2024
e5e1363
remove browser debug
stevenjgodfrey Jan 18, 2024
163aad0
acl decorator changed to open access for classroom id to name
stevenjgodfrey Jan 18, 2024
3ef76b0
fixed classroom linting error
stevenjgodfrey Jan 18, 2024
c9825fa
fixed further linting error in classroom
stevenjgodfrey Jan 18, 2024
675ef92
fix typescipt check error in contributor-dashboard-admin-stats-backen…
stevenjgodfrey Jan 18, 2024
a792c43
fix typescript check failure in contributor-dashboard-admin-stats-bac…
stevenjgodfrey Jan 18, 2024
c5e1316
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Jan 19, 2024
d501132
fix code coverage failure
stevenjgodfrey Jan 19, 2024
0ae3a9a
removed unnecessary test, and export
stevenjgodfrey Jan 19, 2024
011bf36
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Jan 19, 2024
5d22759
add coverage to contributor dashboard admin test
stevenjgodfrey Jan 19, 2024
85c60c7
Merge branch 'cont-dash-admin-change' of https://github.com/stevenjgo…
stevenjgodfrey Jan 19, 2024
876eb5d
Merge branch 'develop' into cont-dash-admin-change
stevenjgodfrey Jan 22, 2024
18a7c40
Merge branch 'develop' into cont-dash-admin-change
stevenjgodfrey Jan 23, 2024
427b850
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Jan 30, 2024
f183cdf
Improve test files to make language used more meaningful
stevenjgodfrey Jan 30, 2024
9bddce1
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Jan 30, 2024
f20e55d
tidied up use of domain constants and expectations of tests
stevenjgodfrey Jan 30, 2024
b37414b
Merge branch 'cont-dash-admin-change' of https://github.com/stevenjgo…
stevenjgodfrey Jan 30, 2024
9646579
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Feb 5, 2024
80e7c46
fixed indentation issue
stevenjgodfrey Feb 5, 2024
4a379ad
merge with develop, includes manuial merge main.py and classroom.py
stevenjgodfrey Feb 13, 2024
f79b3ff
finish manual merge of main and classroom
stevenjgodfrey Feb 13, 2024
d8fe836
added tests for userContributionRights, and changed description
stevenjgodfrey Feb 13, 2024
5d56382
removed extra blank lines from classroom.py
stevenjgodfrey Feb 13, 2024
78fa1a9
Merge branch 'develop' into cont-dash-admin-change
stevenjgodfrey Feb 13, 2024
a665849
change headings, simplify html code and move into ts file for unit te…
stevenjgodfrey Feb 28, 2024
f3455d4
merge in changes from develop
stevenjgodfrey Feb 28, 2024
3019d33
Make the calls to contributorDashboardAdminBackendApiService async, a…
stevenjgodfrey Mar 4, 2024
0a31cf6
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Mar 4, 2024
8302bb8
merge with develop
stevenjgodfrey Mar 4, 2024
7db80a5
Call asynchronous method to update question rights from both places
stevenjgodfrey Mar 6, 2024
c014a69
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Mar 6, 2024
9b9804a
refactor contributor-admin-stats attributes methods
stevenjgodfrey Mar 11, 2024
fda8623
Move formatting of contribution attributes in stats table to a service
stevenjgodfrey Mar 12, 2024
acc08ab
merge conflicts and changes from prettier introduction
stevenjgodfrey Mar 13, 2024
1c46f46
Use generics to improve validation and type checking in format-contri…
stevenjgodfrey Mar 18, 2024
d4af099
Merge branch 'develop' into cont-dash-admin-change
stevenjgodfrey Mar 18, 2024
6d0776b
remove service as a parameter, and unnecessary [] in contributor-dash…
stevenjgodfrey Mar 20, 2024
f468c7d
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Mar 20, 2024
ac64126
Merge branch 'cont-dash-admin-change' of https://github.com/stevenjgo…
stevenjgodfrey Mar 20, 2024
656ee0d
Change ordering of parameters for removeContributionReviewerAsync
stevenjgodfrey Mar 21, 2024
8f27b41
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Mar 22, 2024
7ab2b19
Raise toast message when question-admin user tries to use new contrib…
stevenjgodfrey Mar 22, 2024
8eaa29a
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Apr 18, 2024
ffe4b08
Add total number of items to contributor-admin-stats-table
stevenjgodfrey Apr 19, 2024
1f25998
tidy up contribution admin stats for code review
stevenjgodfrey Apr 23, 2024
6aedfb6
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Apr 23, 2024
f712329
Refactor contributor dashboard admin for simplicity
stevenjgodfrey Apr 25, 2024
27faa9e
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey Apr 25, 2024
0043e88
Changed the naming of tests in contributor-dashboard-admin_stats
stevenjgodfrey Apr 25, 2024
c913657
Merge remote-tracking branch 'upstream/develop' into cont-dash-admin-…
stevenjgodfrey May 6, 2024
ce42ae2
tidy up test file for contributor-admin-stats-table
stevenjgodfrey May 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2>{{ noDataMessage }}</h2>
</div>
<div class="dashboard-list-header" *ngIf="!loadingMessage && !noDataMessage && isMobileView()">
<div class="dashboard-list-header-count">
<span>Displaying {{ statsPageNumber * itemsPerPage + 1 }} - {{ getUpperLimitValueForPagination() }} of many</span>
<span>Displaying {{ getDisplayedIndexOfFirstItemOnPage() }} - {{ getIndexOfLastItemOnPage() }} of {{getOverallItemCount()}}</span>
</div>
<div class="results-per-page-div">
<span>Results per page: </span>
Expand All @@ -27,7 +27,7 @@ <h2>{{ noDataMessage }}</h2>
</div>
</div>
<table mat-table
[dataSource]="dataSource"
[dataSource]="displayStatsForCurrentPage()"
multiTemplateDataRows
[class.isMobile]="true"
class="mat-elevation-z8 e2e-test-stats-table"
Expand Down Expand Up @@ -171,20 +171,20 @@ <h2>{{ noDataMessage }}</h2>
</table>
<div class="dashboard-list-footer" *ngIf="!loadingMessage && !noDataMessage && !isMobileView()">
<div class="dashboard-list-footer-count">
<span>Displaying {{ statsPageNumber * itemsPerPage + 1 }} - {{ getUpperLimitValueForPagination() }} of many</span>
<span>Displaying {{ getDisplayedIndexOfFirstItemOnPage() }} - {{ getIndexOfLastItemOnPage() }} of {{getOverallItemCount()}}</span>
</div>
<div class="dashboard-list-pagination">
<div>
<i class="fa fa-angle-left stats-pagination-arrow" (click)="navigatePage(MOVE_TO_PREV_PAGE)" *ngIf="statsPageNumber > 0"></i>
<span class="dashboard-list-pagination-value">
<span class="dashboard-list-pagination-active">{{ statsPageNumber + 1 }}</span>
</span>
<i class="fa fa-angle-right stats-pagination-arrow" (click)="navigatePage(MOVE_TO_NEXT_PAGE)" *ngIf="more"></i>
<i class="fa fa-angle-right stats-pagination-arrow" (click)="navigatePage(MOVE_TO_NEXT_PAGE)" *ngIf="tableCanShowMoreItems"></i>
</div>
<div>
<span>Results per page: </span>
<select [(ngModel)]="itemsPerPage" aria-label="Results Per Page" (change)="refreshPagination()">
<option *ngFor="let choice of itemsPerPageChoice" [value]="choice" >{{ choice }}</option>
<select [value]="itemsPerPage" aria-label="Results Per Page" (change)="onItemsPerPageChange($event.target.value); refreshPagination()">
<option *ngFor="let choice of itemsPerPageChoice" [value]="choice">{{ choice }}</option>
</select>
</div>
</div>
Expand All @@ -195,7 +195,7 @@ <h2>{{ noDataMessage }}</h2>
<span class="dashboard-list-pagination-value">
<span class="dashboard-list-pagination-active">{{ statsPageNumber + 1 }}</span>
</span>
<i class="fa fa-angle-right stats-pagination-arrow" (click)="navigatePage(MOVE_TO_NEXT_PAGE)" *ngIf="more"></i>
<i class="fa fa-angle-right stats-pagination-arrow" (click)="navigatePage(MOVE_TO_NEXT_PAGE)" *ngIf="tableCanShowMoreItems"></i>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ import {
} from '../contributor-dashboard-admin-summary.model';

describe('Contributor stats component', () => {
const createQuestionReviewerStats = function createQuestionReviewerStats(
numStats: number
): QuestionReviewerStats[] {
let stats: QuestionReviewerStats[] = [];
for (let i = 0; i < numStats; i++) {
stats.push(questionReviewerStats);
}
return stats;
};
let component: ContributorAdminStatsTable;
let fixture: ComponentFixture<ContributorAdminStatsTable>;
let $window: WindowRef;
Expand Down Expand Up @@ -192,7 +201,7 @@ describe('Contributor stats component', () => {
};
component.inputs.activeTab = component.TAB_NAME_TRANSLATION_SUBMITTER;
component.ngOnChanges(changes);
component.updateColumnsToDisplay();
component.displayContributorAdminStats();
tick();
expect(component.columnsToDisplay).toEqual([
'chevron',
Expand Down Expand Up @@ -226,7 +235,7 @@ describe('Contributor stats component', () => {
};
component.inputs.activeTab = component.TAB_NAME_TRANSLATION_REVIEWER;
component.ngOnChanges(changes);
component.updateColumnsToDisplay();
component.displayContributorAdminStats();
tick();
expect(component.columnsToDisplay).toEqual([
'chevron',
Expand Down Expand Up @@ -258,7 +267,7 @@ describe('Contributor stats component', () => {
};
component.inputs.activeTab = component.TAB_NAME_QUESTION_SUBMITTER;
component.ngOnChanges(changes);
component.updateColumnsToDisplay();
component.displayContributorAdminStats();
tick();
expect(component.columnsToDisplay).toEqual([
'chevron',
Expand All @@ -269,6 +278,7 @@ describe('Contributor stats component', () => {
'lastContributedInDays',
'role',
]);
expect(component.getOverallItemCount()).toEqual('1');
}));

it('should show question reviewer stats', fakeAsync(() => {
Expand All @@ -279,7 +289,7 @@ describe('Contributor stats component', () => {
Promise.resolve({
stats: [questionReviewerStats],
nextOffset: 1,
more: false,
more: true,
} as QuestionReviewerStatsData)
);
const changes: SimpleChanges = {
Expand All @@ -292,7 +302,7 @@ describe('Contributor stats component', () => {
};
component.inputs.activeTab = component.TAB_NAME_QUESTION_REVIEWER;
component.ngOnChanges(changes);
component.updateColumnsToDisplay();
component.displayContributorAdminStats();
tick();
expect(component.columnsToDisplay).toEqual([
'chevron',
Expand All @@ -301,16 +311,64 @@ describe('Contributor stats component', () => {
'lastContributedInDays',
'role',
]);
expect(component.getOverallItemCount()).toEqual('1+');
}));

it('should check for upperlimit for pagination', fakeAsync(() => {
component.dataSource = [];
component.statsPageNumber = 1;
it(
'should index last item on page as "overall item count" when ' +
'"current page\'s cumulative item count"' +
' exceeds "overall item count".',
fakeAsync(() => {
component.statsPageNumber = 1;
component.itemsPerPage = 4;
fixture.detectChanges();
component.allStats = createQuestionReviewerStats(3);
expect(component.getIndexOfLastItemOnPage()).toEqual(3);
})
);

it(
'should index last item on page as "current page\'s ' +
'cumulative item count" when "overall item count"' +
' exceeds "current page\'s cumulative item count".',
fakeAsync(() => {
component.statsPageNumber = 1;
component.itemsPerPage = 1;
fixture.detectChanges();
component.allStats = createQuestionReviewerStats(3);
expect(component.getIndexOfLastItemOnPage()).toEqual(2);
})
);

it('should retrieve the index of the first item on the page', fakeAsync(() => {
component.statsPageNumber = 2;
component.itemsPerPage = 3;
expect(component.getDisplayedIndexOfFirstItemOnPage()).toEqual(7);
}));

it('should show the overall item count from the number of items', fakeAsync(() => {
component.statsPageNumber = 1;
component.itemsPerPage = 1;
fixture.detectChanges();
expect(component.getUpperLimitValueForPagination()).toEqual(3);
component.allStats = createQuestionReviewerStats(3);
expect(component.getOverallItemCount()).toEqual(
component.allStats.length.toString()
);
}));

it(
'should show a "+" at the end of the overall item count when ' +
'the number of items exceeds max expected',
fakeAsync(() => {
component.statsPageNumber = 1;
component.itemsPerPage = 1;
component.tableHasMoreThanMaximumExpectedItems = true;
fixture.detectChanges();
component.allStats = createQuestionReviewerStats(1000);
expect(component.getOverallItemCount()).toEqual('1000+');
})
);

it('should navigate to next page', fakeAsync(() => {
const goToSpy = spyOn(component, 'goToPageNumber');
component.statsPageNumber = 1;
Expand Down Expand Up @@ -357,7 +415,7 @@ describe('Contributor stats component', () => {
};
component.inputs.activeTab = component.TAB_NAME_TRANSLATION_SUBMITTER;
component.ngOnChanges(changes);
component.updateColumnsToDisplay();
component.displayContributorAdminStats();
tick();
expect(component.columnsToDisplay).toEqual([
'contributorName',
Expand Down Expand Up @@ -391,7 +449,7 @@ describe('Contributor stats component', () => {
};
component.inputs.activeTab = component.TAB_NAME_TRANSLATION_REVIEWER;
component.ngOnChanges(changes);
component.updateColumnsToDisplay();
component.displayContributorAdminStats();
tick();
expect(component.columnsToDisplay).toEqual([
'contributorName',
Expand Down Expand Up @@ -423,7 +481,7 @@ describe('Contributor stats component', () => {
};
component.inputs.activeTab = component.TAB_NAME_QUESTION_SUBMITTER;
component.ngOnChanges(changes);
component.updateColumnsToDisplay();
component.displayContributorAdminStats();
tick();
expect(component.columnsToDisplay).toEqual([
'contributorName',
Expand Down Expand Up @@ -457,7 +515,7 @@ describe('Contributor stats component', () => {
};
component.inputs.activeTab = component.TAB_NAME_QUESTION_REVIEWER;
component.ngOnChanges(changes);
component.updateColumnsToDisplay();
component.displayContributorAdminStats();
tick();
expect(component.columnsToDisplay).toEqual([
'contributorName',
Expand Down Expand Up @@ -844,5 +902,47 @@ describe('Contributor stats component', () => {
activeTab = component.TAB_NAME_QUESTION_REVIEWER;
expect(component.getContributionCount(activeTab, 1, 2, 3, 4)).toEqual(4);
}));

it('should convert the items per page dropdown back into numbers', fakeAsync(() => {
component.onItemsPerPageChange('05');
expect(component.itemsPerPage).toEqual(5);
}));
});

describe('when more than one page of stats are returned', () => {
it('should show data on multiple pages', fakeAsync(() => {
let allQuestionReviewerStats: QuestionReviewerStats[] =
createQuestionReviewerStats(30);

spyOn(
contributorDashboardAdminStatsBackendApiService,
'fetchContributorAdminStats'
).and.returnValue(
Promise.resolve({
stats: allQuestionReviewerStats,
nextOffset: 1,
more: false,
} as QuestionReviewerStatsData)
);
const changes: SimpleChanges = {
activeTab: {
currentValue: component.TAB_NAME_QUESTION_REVIEWER,
previousValue: component.TAB_NAME_QUESTION_SUBMITTER,
firstChange: false,
isFirstChange: () => false,
},
};
component.inputs.activeTab = component.TAB_NAME_QUESTION_REVIEWER;
component.ngOnChanges(changes);

tick();
expect(component.getOverallItemCount()).toEqual('30');
expect(component.displayStatsForCurrentPage().length).toEqual(20);
expect(component.tableCanShowMoreItems).toEqual(true);

component.goToPageNumber(1);
expect(component.displayStatsForCurrentPage().length).toEqual(10);
expect(component.tableCanShowMoreItems).toEqual(false);
}));
});
});
Loading
Loading