Skip to content

Commit

Permalink
Merge pull request #494 from IQSS/fix-develop-merge
Browse files Browse the repository at this point in the history
fix: add missing import statement
  • Loading branch information
ekraffmiller authored Sep 19, 2024
2 parents c6c5144 + bd00e8f commit b6484bf
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/design-system/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default defineConfig({
},
env: {
codeCoverage: {
exclude: 'tests/**/*.*'
exclude: ['tests/**/*.*', '**/Tab.tsx']
}
}
})
18 changes: 18 additions & 0 deletions packages/design-system/tests/component/tabs/Tabs.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,22 @@ describe('Tabs', () => {
cy.findByText('Tab 2').should('have.class', 'active')
cy.findByText('Content 2').should('have.class', 'show').and('have.class', 'active')
})

it('renders with a disabled tab', () => {
cy.mount(
<Tabs defaultActiveKey="key-1">
<Tabs.Tab eventKey="key-1" title="Tab 1">
Content 1
</Tabs.Tab>
<Tabs.Tab eventKey="key-2" title="Tab 2" disabled>
Content 2
</Tabs.Tab>
<Tabs.Tab eventKey="key-3" title="Tab 3">
Content 3
</Tabs.Tab>
</Tabs>
)

cy.findByText('Tab 2').should('have.attr', 'disabled')
})
})
1 change: 1 addition & 0 deletions src/sections/account/api-token-section/ApiTokenSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import styles from './ApiTokenSection.module.scss'
export const ApiTokenSection = () => {
const { t } = useTranslation('account', { keyPrefix: 'apiToken' })

// TODO: When we have the use cases we need to mock stub to unit test this with or without token
const apiToken = '999fff-666rrr-this-is-not-a-real-token-123456'
const expirationDate = '2025-09-04'

Expand Down
2 changes: 1 addition & 1 deletion src/sections/layout/header/LoggedInHeaderActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Link, useNavigate } from 'react-router-dom'
import { Navbar } from '@iqss/dataverse-design-system'
import { useGetCollectionUserPermissions } from '../../../shared/hooks/useGetCollectionUserPermissions'
import { useSession } from '../../session/SessionContext'
import { RouteWithParams } from '../../Route.enum'
import { RouteWithParams, Route } from '../../Route.enum'
import { User } from '../../../users/domain/models/User'
import { CollectionRepository } from '../../../collection/domain/repositories/CollectionRepository'
import { ROOT_COLLECTION_ALIAS } from '../../../collection/domain/models/Collection'
Expand Down
25 changes: 25 additions & 0 deletions tests/component/sections/account/AccountHelper.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { AccountHelper } from '../../../../src/sections/account/AccountHelper'

describe('AccountHelper', () => {
describe('defineSelectedTabKey', () => {
it('should return the correct tab key when a tab query param is present in the URL', () => {
const searchParams = new URLSearchParams()
searchParams.set(
AccountHelper.ACCOUNT_PANEL_TAB_QUERY_KEY,
AccountHelper.ACCOUNT_PANEL_TABS_KEYS.notifications
)

const result = AccountHelper.defineSelectedTabKey(searchParams)

expect(result).to.equal(AccountHelper.ACCOUNT_PANEL_TABS_KEYS.notifications)
})

it('should return the my data tab key as default if the tab query param is not present in the URL', () => {
const searchParams = new URLSearchParams()

const result = AccountHelper.defineSelectedTabKey(searchParams)

expect(result).to.equal(AccountHelper.ACCOUNT_PANEL_TABS_KEYS.myData)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('FileThumbnail', () => {
cy.customMount(<FileThumbnail file={file} />)

cy.findByAltText(file.name).should('exist')
cy.findByAltText(file.name).trigger('mouseover')
cy.findByAltText(file.name).trigger('mouseover', { force: true })
cy.findByRole('tooltip').should('exist')

cy.findByText('Restricted File Icon').should('not.exist')
Expand Down
11 changes: 11 additions & 0 deletions tests/component/sections/homepage/SearchInput.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@ describe('SearchInput', () => {
cy.findByLabelText('Clear search').click()
cy.get('[aria-label="Search"]').should('have.value', '')
})

it('should be able to click the submit button when the user enters a value or not', () => {
cy.customMount(<SearchInput />)
cy.get('[aria-label="Search"]').type('test')
cy.get('[aria-label="Search"]').should('have.value', 'test')
cy.get('[aria-label="Submit Search"]').click()

cy.get('[aria-label="Search"]').clear()
cy.get('[aria-label="Search"]').should('have.value', '')
cy.get('[aria-label="Submit Search"]').click()
})
})
24 changes: 24 additions & 0 deletions tests/e2e-integration/e2e/sections/homepage/Homepage.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { QueryParamKey } from '../../../../../src/sections/Route.enum'

describe('Homepage', () => {
it('should navigate to the collections page with the search value encoded in the URL', () => {
const searchValue = 'John Doe'
cy.visit('/spa/')
cy.get('[aria-label="Search"]').type(searchValue)
cy.get('[aria-label="Submit Search"]').click()

const encodedSearchValue = encodeURIComponent(searchValue)

const searchParams = new URLSearchParams()
searchParams.set(QueryParamKey.QUERY, encodedSearchValue)

cy.url().should('include', `/collections?${searchParams.toString()}`)
})

it('navigates directly to the collection page when clicking the Browse Collections button', () => {
cy.visit('/spa/')
cy.findByRole('link', { name: 'Browse Collections' }).click()

cy.url().should('eq', `${Cypress.config().baseUrl as string}/spa/collections`)
})
})

0 comments on commit b6484bf

Please sign in to comment.