Skip to content

Commit

Permalink
🧪 Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lvillen committed Nov 15, 2024
1 parent 675d3a3 commit fb62a23
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@ Feature: Account Settings > Users > SSO Integrations > New

Scenario: Navigation
Given they go to the users sso integrations page
When they follow "Create a new SSO integration"
When they follow "Add a SSO integration"
Then the current page is the new sso integration page

Scenario: Navigation when there is an integration
Given a red hat single sign-on integration
And they go to the users sso integrations page
Then there should be a link to "Create a new SSO integration"

Scenario: Empty state
Given they go to the users sso integrations page
Then they should see "No SSO integrations"
And there should be a link to "Add a SSO integration"

Scenario: Create RH SSO new integration
Given they go to the new sso integration page
When the form is submitted with:
Expand Down
7 changes: 3 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,9 @@ module.exports = {
},

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],
transformIgnorePatterns: [
'node_modules/(?!(?:@patternfly/react-icons)/)', // Transform @patternfly/react-icons
],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AccountAuthenticationProviders } from 'AuthenticationProviders/componen
import { mockLocation, waitForPromises } from 'utilities/test-utils'
import { EnforceSSOSwitch } from 'AuthenticationProviders/components/EnforceSSOSwitch'
import { AuthenticationProvidersTable } from 'AuthenticationProviders/components/AuthenticationProvidersTable'
import { AuthenticationProvidersEmptyState } from 'AuthenticationProviders/components/AuthenticationProvidersEmptyState'

import type { Props } from 'AuthenticationProviders/components/AccountAuthenticationProviders'

Expand Down Expand Up @@ -43,20 +44,20 @@ afterAll(() => {
describe('when SSO toggle is hidden', () => {
const props = { showToggle: false }

it('should only render a table', () => {
it('should render empty state', () => {
const wrapper = shallowWrapper(props)
expect(wrapper.exists(EnforceSSOSwitch)).toEqual(false)
expect(wrapper.exists(AuthenticationProvidersTable)).toEqual(true)
expect(wrapper.exists(AuthenticationProvidersEmptyState)).toEqual(true)
})
})

describe('when SSO toggle is visible', () => {
const props = { showToggle: true }

it('should render both a switch and a table', () => {
it('should render both a switch and empty state', () => {
const wrapper = shallowWrapper(props)
expect(wrapper.exists(EnforceSSOSwitch)).toEqual(true)
expect(wrapper.exists(AuthenticationProvidersTable)).toEqual(true)
expect(wrapper.exists(AuthenticationProvidersEmptyState)).toEqual(true)
})

it('should confirm before disabling password-based authentication', async () => {
Expand Down Expand Up @@ -147,3 +148,12 @@ describe('when SSO toggle is visible', () => {
expect(notice).not.toHaveBeenCalled()
})
})

describe('when there is an integration', () => {
const props = { table: { ...defaultProps.table, count: 1 } }

it('should render empty state', () => {
const wrapper = shallowWrapper(props)
expect(wrapper.exists(AuthenticationProvidersTable)).toEqual(true)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { mount } from 'enzyme'

import { AuthenticationProvidersEmptyState } from 'AuthenticationProviders/components/AuthenticationProvidersEmptyState'

import type { Props } from 'AuthenticationProviders/components/AuthenticationProvidersEmptyState'

const defaultProps = {
newHref: '/new'
}

const mountWrapper = (props: Partial<Props> = {}) => mount(<AuthenticationProvidersEmptyState {...{ ...defaultProps, ...props }} />)

it('should render itself', () => {
const wrapper = mountWrapper()

expect(wrapper.exists()).toEqual(true)
})

0 comments on commit fb62a23

Please sign in to comment.