-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
4 changed files
with
78 additions
and
3 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
8 changes: 8 additions & 0 deletions
8
core/src/main/java/bio/terra/pearl/core/service/portal/exception/PortalConfigMissing.java
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,8 @@ | ||
package bio.terra.pearl.core.service.portal.exception; | ||
|
||
import java.util.function.Supplier; | ||
|
||
/** throw if the invariant that all portals must have a config object is violated */ | ||
public class PortalConfigMissing extends RuntimeException { | ||
public static final Supplier<PortalConfigMissing> SUPPLIER = PortalConfigMissing::new; | ||
} |
5 changes: 5 additions & 0 deletions
5
...src/main/java/bio/terra/pearl/core/service/portal/exception/PortalEnvironmentMissing.java
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,5 @@ | ||
package bio.terra.pearl.core.service.portal.exception; | ||
|
||
/** throw if the invariant that all portals must have the sandbox/irb/live environments is violated */ | ||
public class PortalEnvironmentMissing extends RuntimeException { | ||
} |
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,52 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import React from 'react' | ||
import { mockPortalEnvContext } from 'test-utils/mocking-utils' | ||
import { setupRouterTest } from 'test-utils/router-testing-utils' | ||
import userEvent from '@testing-library/user-event' | ||
import CreatePreRegSurveyModal from './CreatePreRegSurveyModal' | ||
|
||
describe('CreatePreRegSurveyModal', () => { | ||
test('disables Create button when survey name and stable ID are blank', () => { | ||
const portalEnvContext = mockPortalEnvContext('sandbox') | ||
const { RoutedComponent } = setupRouterTest(<CreatePreRegSurveyModal | ||
portalEnvContext={portalEnvContext} | ||
onDismiss={jest.fn()}/>) | ||
render(RoutedComponent) | ||
|
||
const createButton = screen.getByText('Create') | ||
expect(createButton).toBeDisabled() | ||
}) | ||
|
||
test('enables Create button when survey name and stable ID are filled out', async () => { | ||
const user = userEvent.setup() | ||
const portalEnvContext = mockPortalEnvContext('sandbox') | ||
const { RoutedComponent } = setupRouterTest(<CreatePreRegSurveyModal | ||
portalEnvContext={portalEnvContext} | ||
onDismiss={jest.fn()}/>) | ||
render(RoutedComponent) | ||
|
||
const surveyNameInput = screen.getByLabelText('Survey Name') | ||
const surveyStableIdInput = screen.getByLabelText('Survey Stable ID') | ||
await user.type(surveyNameInput, 'Test Survey') | ||
await user.type(surveyStableIdInput, 'test_survey_id') | ||
|
||
const createButton = screen.getByText('Create') | ||
expect(createButton).toBeEnabled() | ||
}) | ||
|
||
test('should autofill the stable ID as the user fills in the survey name', async () => { | ||
const user = userEvent.setup() | ||
const portalEnvContext = mockPortalEnvContext('sandbox') | ||
const { RoutedComponent } = setupRouterTest(<CreatePreRegSurveyModal | ||
portalEnvContext={portalEnvContext} | ||
onDismiss={jest.fn()}/>) | ||
render(RoutedComponent) | ||
|
||
const surveyNameInput = screen.getByLabelText('Survey Name') | ||
const surveyStableIdInput = screen.getByLabelText('Survey Stable ID') | ||
await user.type(surveyNameInput, 'Test Survey') | ||
|
||
//Confirm that auto-fill stable ID worked | ||
expect(surveyStableIdInput).toHaveValue('testSurvey') | ||
}) | ||
}) |