-
Notifications
You must be signed in to change notification settings - Fork 1
PER-10480: Enable re-import #957
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -52,10 +52,6 @@ p { | |
| visibility: hidden; | ||
| } | ||
|
|
||
| &.exists { | ||
| opacity: 0; | ||
| } | ||
|
|
||
| label { | ||
| display: block; | ||
| width: 100%; | ||
|
|
||
209 changes: 184 additions & 25 deletions
209
src/app/apps/components/family-search-import/family-search-import.component.spec.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -1,25 +1,184 @@ | ||
| // import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
|
||
| // import { FamilySearchImportComponent } from './family-search-import.component'; | ||
|
|
||
| // describe('FamilySearchImportComponent', () => { | ||
| // let component: FamilySearchImportComponent; | ||
| // let fixture: ComponentFixture<FamilySearchImportComponent>; | ||
|
|
||
| // beforeEach(async(() => { | ||
| // TestBed.configureTestingModule({ | ||
| // declarations: [ FamilySearchImportComponent ] | ||
| // }) | ||
| // .compileComponents(); | ||
| // })); | ||
|
|
||
| // beforeEach(() => { | ||
| // fixture = TestBed.createComponent(FamilySearchImportComponent); | ||
| // component = fixture.componentInstance; | ||
| // fixture.detectChanges(); | ||
| // }); | ||
|
|
||
| // it('should create', () => { | ||
| // expect(component).toBeTruthy(); | ||
| // }); | ||
| // }); | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
| import { FormsModule } from '@angular/forms'; | ||
| import { DIALOG_DATA, DialogRef } from '@angular/cdk/dialog'; | ||
| import { ApiService } from '@shared/services/api/api.service'; | ||
| import { MessageService } from '@shared/services/message/message.service'; | ||
| import { GuidedTourService } from '@shared/services/guided-tour/guided-tour.service'; | ||
| import { PromptService } from '@shared/services/prompt/prompt.service'; | ||
| import { FamilySearchImportComponent } from './family-search-import.component'; | ||
|
|
||
| describe('FamilySearchImportComponent', () => { | ||
| let component: FamilySearchImportComponent; | ||
| let fixture: ComponentFixture<FamilySearchImportComponent>; | ||
|
|
||
| const mockDialogRef = { close: jasmine.createSpy('close') }; | ||
|
|
||
| const mockApiService = { | ||
| archive: { create: jasmine.createSpy('create') }, | ||
| connector: { | ||
| familysearchFactImportRequest: jasmine.createSpy( | ||
| 'familysearchFactImportRequest', | ||
| ), | ||
| familysearchMemoryImportRequest: jasmine.createSpy( | ||
| 'familysearchMemoryImportRequest', | ||
| ), | ||
| }, | ||
| }; | ||
|
|
||
| const mockMessageService = { | ||
| showMessage: jasmine.createSpy('showMessage'), | ||
| showError: jasmine.createSpy('showError'), | ||
| }; | ||
|
|
||
| const mockGuidedTourService = { | ||
| isStepComplete: jasmine.createSpy('isStepComplete').and.returnValue(true), | ||
| startTour: jasmine.createSpy('startTour'), | ||
| emit: jasmine.createSpy('emit'), | ||
| markStepComplete: jasmine.createSpy('markStepComplete'), | ||
| }; | ||
|
|
||
| const mockPromptService = { | ||
| promptButtons: jasmine | ||
| .createSpy('promptButtons') | ||
| .and.returnValue(Promise.resolve('go-back')), | ||
| }; | ||
|
|
||
| const currentUserData = { | ||
| id: 'user-1', | ||
| display: { name: 'Test User', lifespan: '1900–1980', ascendancyNumber: 1 }, | ||
| }; | ||
|
|
||
| const makeDialogData = (treeData: object[]) => ({ | ||
| currentUserData, | ||
| treeData: treeData.map((member) => ({ ...member })), | ||
| }); | ||
|
|
||
| async function setup(treeData: object[]) { | ||
| await TestBed.configureTestingModule({ | ||
| declarations: [FamilySearchImportComponent], | ||
| imports: [FormsModule], | ||
| providers: [ | ||
| { provide: DialogRef, useValue: mockDialogRef }, | ||
| { provide: DIALOG_DATA, useValue: makeDialogData(treeData) }, | ||
| { provide: ApiService, useValue: mockApiService }, | ||
| { provide: MessageService, useValue: mockMessageService }, | ||
| { provide: GuidedTourService, useValue: mockGuidedTourService }, | ||
| { provide: PromptService, useValue: mockPromptService }, | ||
| ], | ||
| }).compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(FamilySearchImportComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| } | ||
|
|
||
| const newMember = { | ||
| id: 'person-2', | ||
| display: { name: 'Jane Doe', lifespan: '1930–2010', ascendancyNumber: 3 }, | ||
| permExists: false, | ||
| }; | ||
|
|
||
| const reimportMember = { | ||
| id: 'person-3', | ||
| display: { name: 'John Doe', lifespan: '1928–2005', ascendancyNumber: 2 }, | ||
| permExists: true, | ||
| }; | ||
|
|
||
| describe('goToNextFromPeople()', () => { | ||
| it('goes to memories stage when no selected member has permExists', async () => { | ||
| await setup([newMember]); | ||
| component.familyMembers[0].isSelected = true; | ||
|
|
||
| component.goToNextFromPeople(); | ||
|
|
||
| expect(component.stage).toBe('memories'); | ||
| }); | ||
|
|
||
| it('shows a confirmation prompt when a selected member has permExists', async () => { | ||
| await setup([reimportMember]); | ||
| component.familyMembers[0].isSelected = true; | ||
|
|
||
| await component.goToNextFromPeople(); | ||
|
|
||
| expect(mockPromptService.promptButtons).toHaveBeenCalledWith( | ||
| jasmine.arrayContaining([ | ||
| jasmine.objectContaining({ buttonName: 'go-back' }), | ||
| jasmine.objectContaining({ buttonName: 'continue' }), | ||
| ]), | ||
| 'Continue with re-import?', | ||
| undefined, | ||
| jasmine.stringContaining('John Doe'), | ||
| ); | ||
| }); | ||
|
|
||
| it('shows a confirmation prompt when selection includes both new and previously imported members', async () => { | ||
| await setup([newMember, reimportMember]); | ||
| component.familyMembers[0].isSelected = true; | ||
| component.familyMembers[1].isSelected = true; | ||
|
|
||
| await component.goToNextFromPeople(); | ||
|
|
||
| expect(mockPromptService.promptButtons).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('goes to memories stage when user confirms reimport', async () => { | ||
| await setup([reimportMember]); | ||
| component.familyMembers[0].isSelected = true; | ||
| mockPromptService.promptButtons.and.returnValue( | ||
| Promise.resolve('continue'), | ||
| ); | ||
|
|
||
| await component.goToNextFromPeople(); | ||
|
|
||
| expect(component.stage).toBe('memories'); | ||
| }); | ||
|
|
||
| it('stays on people stage when user dismisses reimport confirmation', async () => { | ||
| await setup([reimportMember]); | ||
| component.familyMembers[0].isSelected = true; | ||
| mockPromptService.promptButtons.and.returnValue( | ||
| Promise.resolve('go-back'), | ||
| ); | ||
|
|
||
| await component.goToNextFromPeople(); | ||
|
|
||
| expect(component.stage).toBe('people'); | ||
| }); | ||
|
|
||
| it('goes to memories stage when a member with permExists is not selected', async () => { | ||
| await setup([newMember, reimportMember]); | ||
| component.familyMembers[0].isSelected = true; | ||
| // reimportMember not selected | ||
|
|
||
| component.goToNextFromPeople(); | ||
|
|
||
| expect(component.stage).toBe('memories'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getSelectedMembers()', () => { | ||
| it('returns only selected members', async () => { | ||
| await setup([newMember, reimportMember]); | ||
| component.familyMembers[0].isSelected = true; | ||
|
|
||
| const selected = component.getSelectedMembers(); | ||
|
|
||
| expect(selected.length).toBe(1); | ||
| expect(selected[0].display.name).toBe('Jane Doe'); | ||
| }); | ||
|
|
||
| it('returns all members when all are selected', async () => { | ||
| await setup([newMember, reimportMember]); | ||
| component.familyMembers[0].isSelected = true; | ||
| component.familyMembers[1].isSelected = true; | ||
|
|
||
| expect(component.getSelectedMembers().length).toBe(2); | ||
| }); | ||
|
|
||
| it('returns empty array when no members are selected', async () => { | ||
| await setup([newMember, reimportMember]); | ||
|
|
||
| expect(component.getSelectedMembers().length).toBe(0); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.