-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
92 additions
and
97 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,52 @@ | ||
import { mount } from '@vue/test-utils' | ||
import { QsAccessBtn } from '@/components/common' | ||
import Vuetify from 'vuetify' | ||
import { createPinia, setActivePinia } from 'pinia' | ||
import { useStore } from '@/store/store' | ||
import { axe } from 'jest-axe' | ||
const vuetify = new Vuetify({}) | ||
setActivePinia(createPinia()) | ||
import { axe } from 'vitest-axe' | ||
import { createComponent } from './utils' | ||
import { ProductCode, ProductStatus, ProductType } from '@/enums' | ||
import { UserProductSubscriptionIF } from '@/interfaces' | ||
|
||
const store = useStore() | ||
|
||
const mockedProductSubscription: UserProductSubscriptionIF[] = [{ | ||
premiumOnly: true, | ||
type: ProductType.INTERNAL, | ||
code: ProductCode.MANUFACTURER, | ||
url: '', | ||
hidden: false, | ||
needReview: false, | ||
description: '', | ||
subscriptionStatus: ProductStatus.ACTIVE | ||
}] | ||
|
||
describe('QsAccessBtn', () => { | ||
const wrapper = mount(QsAccessBtn, { | ||
data () { | ||
return { | ||
hasActiveQsAccess: true | ||
} | ||
}, | ||
store, | ||
vuetify | ||
let wrapper | ||
|
||
afterEach(async () => { | ||
await store.setUserProductSubscriptions([]) | ||
}) | ||
|
||
it('should have no accessibility violations', async () => { | ||
// Run the axe-core accessibility check on the component's HTML | ||
await store.setUserProductSubscriptions(mockedProductSubscription) | ||
wrapper = await createComponent(QsAccessBtn) | ||
|
||
// Run the axe accessibility check on the component's HTML | ||
const results = await axe(wrapper.html()) | ||
// Use the custom jest-axe matcher to check for violations | ||
expect(results).toHaveNoViolations() | ||
expect(results).toBeDefined(); | ||
expect(results.violations).toBeDefined(); | ||
expect(results.violations).toHaveLength(0); | ||
}) | ||
|
||
it('renders Approved Qualified Supplier link when isRoleQualifiedSupplier is true', () => { | ||
const wrapper = mount(QsAccessBtn, { | ||
data () { | ||
return { | ||
hasActiveQsAccess: true | ||
} | ||
}, | ||
store, | ||
vuetify | ||
}) | ||
|
||
it('renders Approved Qualified Supplier link when isRoleQualifiedSupplier is true', async () => { | ||
await store.setUserProductSubscriptions(mockedProductSubscription) | ||
wrapper = await createComponent(QsAccessBtn) | ||
expect(wrapper.find('.approved-qs-link').exists()).toBe(true) | ||
expect(wrapper.find('.request-qs-tooltip').exists()).toBe(false) | ||
}) | ||
|
||
it('renders Request MHR Qualified Supplier Access link when isRoleQualifiedSupplier is false', () => { | ||
const wrapper = mount(QsAccessBtn, { | ||
data () { | ||
return { | ||
hasActiveQsAccess: false | ||
} | ||
}, | ||
store, | ||
vuetify | ||
}) | ||
|
||
it('renders Request MHR Qualified Supplier Access link when isRoleQualifiedSupplier is false', async () => { | ||
wrapper = await createComponent(QsAccessBtn) | ||
// Product Subscriptions are not setup, therefore approved-qs-lik should not be shown | ||
expect(wrapper.find('.approved-qs-link').exists()).toBe(false) | ||
expect(wrapper.find('.request-qs-tooltip').exists()).toBe(true) | ||
expect(wrapper.find('.request-qs-link').exists()).toBe(true) | ||
}) | ||
}) |
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