-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- narrow Ajax() usage within last of src/libs/ajax area modules to call Ajax().SubAreaX directly. - demoted Ajax() to no longer be exported from ajax.ts. It is now called AjaxTestingRoot and only a setupAjaxTestUtil method is exposed. - setupAjaxTestUtil is called from appLoader.js since it is no longer incedentally initalized through ajax.ts module load. - unit tests added for setupAjaxTestUtil. - improve mock types where possible
- Loading branch information
1 parent
5521b69
commit b5cdab3
Showing
13 changed files
with
154 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { asMockedFn, partial } from '@terra-ui-packages/test-utils'; | ||
|
||
import { AjaxTestingContract, setupAjaxTestUtil } from './ajax'; | ||
import { Apps, AppsAjaxContract } from './ajax/leonardo/Apps'; | ||
import { Runtimes, RuntimesAjaxContract } from './ajax/leonardo/Runtimes'; | ||
import { Workspaces, WorkspacesAjaxContract } from './ajax/workspaces/Workspaces'; | ||
|
||
jest.mock('src/libs/ajax/leonardo/Apps'); | ||
jest.mock('src/libs/ajax/leonardo/Runtimes'); | ||
jest.mock('src/libs/ajax/workspaces/Workspaces'); | ||
|
||
describe('setupAjaxTestUtil', () => { | ||
beforeEach(() => { | ||
asMockedFn(Apps).mockReturnValue(partial<AppsAjaxContract>({})); | ||
asMockedFn(Runtimes).mockReturnValue(partial<RuntimesAjaxContract>({})); | ||
asMockedFn(Workspaces).mockReturnValue(partial<WorkspacesAjaxContract>({})); | ||
}); | ||
|
||
it('sets up Ajax data-call testing root', () => { | ||
// Act | ||
setupAjaxTestUtil(); | ||
const ajaxTestingContract = (window as any).Ajax() as AjaxTestingContract; | ||
|
||
// Assert | ||
expect(ajaxTestingContract).toBeDefined(); | ||
expect(ajaxTestingContract.Apps).toBeDefined(); | ||
expect(ajaxTestingContract.Runtimes).toBeDefined(); | ||
expect(ajaxTestingContract.Workspaces).toBeDefined(); | ||
}); | ||
it('passes along signal arg to sub-areas', () => { | ||
// Arrange | ||
const signal = new AbortController().signal; | ||
|
||
// Act | ||
setupAjaxTestUtil(); | ||
const ajaxTestingContract = (window as any).Ajax(signal) as AjaxTestingContract; | ||
|
||
// Assert | ||
expect(ajaxTestingContract).toBeDefined(); | ||
expect(Apps).toBeCalledWith(signal); | ||
expect(Runtimes).toBeCalledWith(signal); | ||
expect(Workspaces).toBeCalledWith(signal); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,66 +1,18 @@ | ||
import { AzureStorage } from 'src/libs/ajax/AzureStorage'; | ||
import { Billing } from 'src/libs/ajax/billing/Billing'; | ||
import { Catalog } from 'src/libs/ajax/Catalog'; | ||
import { DataRepo } from 'src/libs/ajax/DataRepo'; | ||
import { Dockstore } from 'src/libs/ajax/Dockstore'; | ||
import { DrsUriResolver } from 'src/libs/ajax/drs/DrsUriResolver'; | ||
import { ExternalCredentials } from 'src/libs/ajax/ExternalCredentials'; | ||
import { FirecloudBucket } from 'src/libs/ajax/firecloud/FirecloudBucket'; | ||
import { GoogleStorage } from 'src/libs/ajax/GoogleStorage'; | ||
import { Groups } from 'src/libs/ajax/Groups'; | ||
import { Apps } from 'src/libs/ajax/leonardo/Apps'; | ||
import { Disks } from 'src/libs/ajax/leonardo/Disks'; | ||
import { Runtimes } from 'src/libs/ajax/leonardo/Runtimes'; | ||
import { Methods } from 'src/libs/ajax/methods/Methods'; | ||
import { Metrics } from 'src/libs/ajax/Metrics'; | ||
import { OAuth2 } from 'src/libs/ajax/OAuth2'; | ||
import { SamResources } from 'src/libs/ajax/SamResources'; | ||
import { Support } from 'src/libs/ajax/Support'; | ||
import { Surveys } from 'src/libs/ajax/surveys/Surveys'; | ||
import { TermsOfService } from 'src/libs/ajax/TermsOfService'; | ||
import { User } from 'src/libs/ajax/User'; | ||
import { Cbas } from 'src/libs/ajax/workflows-app/Cbas'; | ||
import { CromIAM } from 'src/libs/ajax/workflows-app/CromIAM'; | ||
import { CromwellApp } from 'src/libs/ajax/workflows-app/CromwellApp'; | ||
import { WorkflowScript } from 'src/libs/ajax/workflows-app/WorkflowScript'; | ||
import { WorkspaceData } from 'src/libs/ajax/WorkspaceDataService'; | ||
import { WorkspaceManagerResources } from 'src/libs/ajax/WorkspaceManagerResources'; | ||
import { Workspaces } from 'src/libs/ajax/workspaces/Workspaces'; | ||
|
||
export const Ajax = (signal?: AbortSignal) => { | ||
const AjaxTestingRoot = (signal?: AbortSignal) => { | ||
return { | ||
Apps: Apps(signal), // used for e2e testing | ||
AzureStorage: AzureStorage(signal), | ||
Billing: Billing(signal), | ||
Buckets: GoogleStorage(signal), // used for e2e testing | ||
Catalog: Catalog(signal), | ||
Cbas: Cbas(signal), | ||
CromIAM: CromIAM(signal), | ||
CromwellApp: CromwellApp(signal), | ||
DataRepo: DataRepo(signal), | ||
Disks: Disks(signal), | ||
Dockstore: Dockstore(signal), | ||
DrsUriResolver: DrsUriResolver(signal), | ||
ExternalCredentials: ExternalCredentials(signal), | ||
FirecloudBucket: FirecloudBucket(signal), | ||
Groups: Groups(signal), | ||
Methods: Methods(signal), | ||
Metrics: Metrics(signal), | ||
OAuth2: OAuth2(signal), | ||
Runtimes: Runtimes(signal), // used for e2e testing | ||
SamResources: SamResources(signal), | ||
Support: Support(signal), | ||
Surveys: Surveys(signal), | ||
TermsOfService: TermsOfService(signal), | ||
User: User(signal), | ||
WorkflowScript: WorkflowScript(signal), | ||
WorkspaceData: WorkspaceData(signal), | ||
WorkspaceManagerResources: WorkspaceManagerResources(signal), | ||
Workspaces: Workspaces(signal), // used for e2e testing | ||
}; | ||
}; | ||
|
||
export type AjaxContract = ReturnType<typeof Ajax>; | ||
export type AjaxTestingContract = ReturnType<typeof AjaxTestingRoot>; | ||
|
||
// Exposing Ajax for use by integration tests (and debugging, or whatever) | ||
(window as any).Ajax = Ajax; | ||
export const setupAjaxTestUtil = () => { | ||
// Exposing Ajax for use by integration tests (and debugging, or whatever) | ||
(window as any).Ajax = AjaxTestingRoot; | ||
}; |
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
Oops, something went wrong.