-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AAE-13310: update and preserve column width preferences only on visib…
…le columns (#8488) * AAE-13310: update and preserve column width preferences only on visible columns * AAE-13310: Fixing lint issues
- Loading branch information
1 parent
98c0a3c
commit ee3f1cd
Showing
6 changed files
with
139 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,10 +39,11 @@ import { TranslateModule } from '@ngx-translate/core'; | |
import { TaskListCloudSortingModel } from '../../../models/task-list-sorting.model'; | ||
import { shareReplay, skip } from 'rxjs/operators'; | ||
import { TaskListCloudServiceInterface } from '../../../services/task-list-cloud.service.interface'; | ||
import { TASK_LIST_CLOUD_TOKEN } from '../../../services/cloud-token.service'; | ||
import { TASK_LIST_CLOUD_TOKEN, TASK_LIST_PREFERENCES_SERVICE_TOKEN } from '../../../services/cloud-token.service'; | ||
import { TaskListCloudModule } from '../task-list-cloud.module'; | ||
import { HttpClientModule } from '@angular/common/http'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface'; | ||
|
||
@Component({ | ||
template: ` | ||
|
@@ -96,6 +97,10 @@ describe('TaskListCloudComponent', () => { | |
let fixture: ComponentFixture<TaskListCloudComponent>; | ||
let appConfig: AppConfigService; | ||
let taskListCloudService: TaskListCloudServiceInterface; | ||
const preferencesService: PreferenceCloudServiceInterface = jasmine.createSpyObj('preferencesService', { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
getPreferences: of({}), | ||
updatePreference: of({}) | ||
}); | ||
|
||
setupTestBed({ | ||
imports: [ | ||
|
@@ -106,6 +111,10 @@ describe('TaskListCloudComponent', () => { | |
{ | ||
provide: TASK_LIST_CLOUD_TOKEN, | ||
useClass: TaskListCloudService | ||
}, | ||
{ | ||
provide: TASK_LIST_PREFERENCES_SERVICE_TOKEN, | ||
useValue: preferencesService | ||
} | ||
] | ||
}); | ||
|
@@ -304,6 +313,46 @@ describe('TaskListCloudComponent', () => { | |
expect(component.columns[0].width).toBe(120); | ||
}); | ||
|
||
it('should update columns widths when a column width gets changed', () => { | ||
component.appName = 'fake-app-name'; | ||
component.reload(); | ||
fixture.detectChanges(); | ||
|
||
const newColumns = [...component.columns]; | ||
newColumns[0].width = 120; | ||
component.onColumnsWidthChanged(newColumns); | ||
|
||
expect(component.columns[0].width).toBe(120); | ||
expect(preferencesService.updatePreference).toHaveBeenCalledWith('fake-app-name', 'tasks-list-cloud-columns-widths', { | ||
name: 120 | ||
}); | ||
}); | ||
|
||
it('should update columns widths while preserving previously saved widths when a column width gets changed', () => { | ||
component.appName = 'fake-app-name'; | ||
component.reload(); | ||
This comment has been minimized.
Sorry, something went wrong.
mauriziovitale
Contributor
|
||
fixture.detectChanges(); | ||
|
||
const newColumns = [...component.columns]; | ||
newColumns[0].width = 120; | ||
component.onColumnsWidthChanged(newColumns); | ||
|
||
expect(component.columns[0].width).toBe(120); | ||
expect(preferencesService.updatePreference).toHaveBeenCalledWith('fake-app-name', 'tasks-list-cloud-columns-widths', { | ||
name: 120 | ||
}); | ||
|
||
newColumns[1].width = 150; | ||
component.onColumnsWidthChanged(newColumns); | ||
|
||
expect(component.columns[0].width).toBe(120); | ||
expect(component.columns[1].width).toBe(150); | ||
expect(preferencesService.updatePreference).toHaveBeenCalledWith('fake-app-name', 'tasks-list-cloud-columns-widths', { | ||
name: 120, | ||
created: 150 | ||
}); | ||
}); | ||
|
||
it('should re-create columns when a column order gets changed', () => { | ||
component.reload(); | ||
fixture.detectChanges(); | ||
|
this strategy is not the best, you can easily have the mock and interface out of sync. i.e. if we rename getPreferences this unit won't complain ..