Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions cypress/component/ERACommons/era_commons_utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import * as ERACommonsUtils from 'src/components/era_commons/ERACommonsUtils'
import EnvironmentUtils from 'src/utils/EnvironmentUtils'
import { DuosUser } from 'src/types/model'

describe('ERACommonsUtils Tests', () => {
describe('Test environment-enabled cases', () => {
beforeEach(() => {
cy.stub(EnvironmentUtils, 'checkEnv').returns(true)
})
describe('Verify RAS is enabled', () => {
it('rasEnabled', () => {
const result = ERACommonsUtils.rasEnabled()
expect(result).to.eq(true)
Expand All @@ -21,24 +17,6 @@ describe('ERACommonsUtils Tests', () => {
})
})

describe('Test environment-disabled cases', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RAS is enabled in all environments, so these tests no longer make sense.

beforeEach(() => {
cy.stub(EnvironmentUtils, 'checkEnv').returns(false)
})
it('rasEnabled', () => {
const result = ERACommonsUtils.rasEnabled()
expect(result).to.eq(false)
})
it('nihAccountLabel', () => {
const result = ERACommonsUtils.nihAccountLabel()
expect(result).to.eq('eRA Commons')
})
it('nihAccountInstructions', () => {
const result = ERACommonsUtils.nihAccountInstructions()
expect(result).to.eq('https://www.era.nih.gov/register-accounts/understanding-era-commons-accounts.htm')
})
})

describe('extractEraAuthenticationState', () => {
const futureDate = new Date()
futureDate.setDate(futureDate.getDate() + 30)
Expand Down
2 changes: 1 addition & 1 deletion cypress/component/UserProfile/researcher_status.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('ResearcherStatus', () => {

mount(<ResearcherStatus user={userWithCard} pageProps={pageProps} />)
cy.contains('Researcher Status')
cy.contains('eRA Commons Account')
cy.contains('RAS Account')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Profile page will always point to RAS account

cy.contains('Library Card issued to you')
cy.contains('Issued on: ' + userWithCard.libraryCard?.createDate.toISOString().slice(0, 10))
cy.contains('Issued by: ' + signingOfficialUser.displayName)
Expand Down
3 changes: 1 addition & 2 deletions cypress/component/app.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import App from 'src/App'
import ReactGA from 'react-ga4'
import StackdriverReporter from 'src/libs/stackdriverReporter'
import { Config } from 'src/libs/config'
import { MemoryRouter, Route } from 'react-router-dom'
import { MemoryRouter, Route, Router } from 'react-router-dom'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Router should be imported from react-router-dom in v5

import { AuthenticateNIH } from 'src/libs/ajax/AuthenticateNIH'
import { Storage } from 'src/libs/storage'
import { createMemoryHistory } from 'history'
import { Router } from 'react-router'
import { ServiceStatus } from 'src/libs/ajax/ServiceStatus'

const user = {
Expand Down
4 changes: 3 additions & 1 deletion src/components/era_commons/ERACommons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ export default function ERACommons({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
catch (error: never) {
displayError('Error from Authentication Provider: ' + error?.response?.data?.message + ': ' + currentUser.email)
const userEmail = currentUser?.email || 'unknown user'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible that the email is empty in tests.

const errorMessage = 'Error from Authentication Provider: ' + error?.response?.data?.message + ': ' + userEmail
displayError(errorMessage)
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/components/era_commons/ERACommonsUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import EnvironmentUtils, { envGroups } from 'src/utils/EnvironmentUtils'
import { DuosUser } from 'src/types/model'

export const rasEnabled = (): boolean => {
return EnvironmentUtils.checkEnv(envGroups.NON_PROD)
return true
}

export const nihAccountLabel = () => {
Expand Down
Loading