-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-128968: TrueCloud Backup shows non-Storj credentials
- Loading branch information
1 parent
706da7f
commit c804f4f
Showing
11 changed files
with
136 additions
and
78 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
121 changes: 121 additions & 0 deletions
121
...odules/custom-selects/cloud-credentials-select/cloud-credentials-select.component.spec.ts
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 |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { HarnessLoader, parallel } from '@angular/cdk/testing'; | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
import { | ||
FormGroup, FormControl, ReactiveFormsModule, FormsModule, | ||
} from '@angular/forms'; | ||
import { TooltipComponent } from '@angular/material/tooltip'; | ||
import { SpectatorHost } from '@ngneat/spectator'; | ||
import { createHostFactory, mockProvider } from '@ngneat/spectator/jest'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { MockComponent } from 'ng-mocks'; | ||
import { of } from 'rxjs'; | ||
import { CloudSyncProviderName } from 'app/enums/cloudsync-provider.enum'; | ||
import { CloudCredentialsSelectComponent } from 'app/modules/custom-selects/cloud-credentials-select/cloud-credentials-select.component'; | ||
import { IxErrorsComponent } from 'app/modules/ix-forms/components/ix-errors/ix-errors.component'; | ||
import { IxLabelComponent } from 'app/modules/ix-forms/components/ix-label/ix-label.component'; | ||
import { IxSelectComponent } from 'app/modules/ix-forms/components/ix-select/ix-select.component'; | ||
import { IxSelectHarness } from 'app/modules/ix-forms/components/ix-select/ix-select.harness'; | ||
import { IxFormsModule } from 'app/modules/ix-forms/ix-forms.module'; | ||
import { CloudCredentialService } from 'app/services/cloud-credential.service'; | ||
|
||
describe('CloudCredentialsSelectComponent', () => { | ||
let spectator: SpectatorHost<CloudCredentialsSelectComponent>; | ||
let loader: HarnessLoader; | ||
|
||
const host = ` | ||
<form [formGroup]="form"> | ||
<ix-cloud-credentials-select | ||
formControlName="credentials" | ||
[label]="label" | ||
[tooltip]="tooltip" | ||
[filterByProviders]="filterByProviders" | ||
[required]="required" | ||
></ix-cloud-credentials-select> | ||
</form> | ||
`; | ||
|
||
const defaultHostProps = { | ||
form: new FormGroup({ | ||
credentials: new FormControl(), | ||
}), | ||
label: '', | ||
required: false, | ||
tooltip: '', | ||
}; | ||
|
||
const mockCloudCredentialService = { | ||
getCloudSyncCredentials: jest.fn(() => of([ | ||
{ id: '1', name: 'AWS S3', provider: CloudSyncProviderName.AmazonS3 }, | ||
{ id: '2', name: 'Dropbox', provider: CloudSyncProviderName.Dropbox }, | ||
{ id: '2', name: 'Drive', provider: CloudSyncProviderName.GoogleDrive }, | ||
])), | ||
}; | ||
|
||
const createHost = createHostFactory({ | ||
component: CloudCredentialsSelectComponent, | ||
imports: [ | ||
TranslateModule.forRoot(), | ||
IxFormsModule, | ||
ReactiveFormsModule, | ||
FormsModule, | ||
], | ||
declarations: [ | ||
IxSelectComponent, | ||
MockComponent(IxErrorsComponent), | ||
MockComponent(IxLabelComponent), | ||
MockComponent(TooltipComponent), | ||
], | ||
providers: [ | ||
mockProvider(CloudCredentialService, mockCloudCredentialService), | ||
], | ||
}); | ||
|
||
describe('no filter by providers set', () => { | ||
beforeEach(() => { | ||
spectator = createHost(host, { | ||
hostProps: defaultHostProps, | ||
}); | ||
|
||
loader = TestbedHarnessEnvironment.loader(spectator.fixture); | ||
}); | ||
|
||
it('should populate ix-select with credentials when providers are set', async () => { | ||
const select = await (await loader.getHarness(IxSelectHarness)).getSelectHarness(); | ||
await select.open(); | ||
const options = await select.getOptions(); | ||
const optionLabels = await parallel(() => options.map((option) => option.getText())); | ||
expect(optionLabels).toEqual([ | ||
'--', | ||
'Add New', | ||
'AWS S3 (Amazon S3)', | ||
'Dropbox (Dropbox)', | ||
'Drive (Google Drive)', | ||
]); | ||
}); | ||
}); | ||
|
||
describe('filter by providers is set', () => { | ||
beforeEach(() => { | ||
spectator = createHost(host, { | ||
hostProps: { | ||
...defaultHostProps, | ||
filterByProviders: [CloudSyncProviderName.AmazonS3], | ||
}, | ||
}); | ||
|
||
loader = TestbedHarnessEnvironment.loader(spectator.fixture); | ||
}); | ||
|
||
it('should populate ix-select with credentials when providers are set', async () => { | ||
const select = await (await loader.getHarness(IxSelectHarness)).getSelectHarness(); | ||
await select.open(); | ||
const options = await select.getOptions(); | ||
const optionLabels = await parallel(() => options.map((option) => option.getText())); | ||
expect(optionLabels).toEqual([ | ||
'--', | ||
'Add New', | ||
'AWS S3 (Amazon S3)', | ||
]); | ||
}); | ||
}); | ||
}); |
69 changes: 0 additions & 69 deletions
69
src/app/modules/custom-selects/cloud-credentials-select/cloud-credentials-select.spec.ts
This file was deleted.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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