2021-01-15 00:10:45 +00:00
import { GlLink , GlSprintf , GlAlert } from '@gitlab/ui' ;
2021-02-14 18:09:20 +00:00
import { shallowMount } from '@vue/test-utils' ;
2022-01-25 15:12:32 +00:00
import { nextTick } from 'vue' ;
2020-08-17 21:09:56 +00:00
import AncestorNotice from '~/clusters_list/components/ancestor_notice.vue' ;
import ClusterStore from '~/clusters_list/store' ;
2020-07-14 00:09:46 +00:00
describe ( 'ClustersAncestorNotice' , ( ) => {
let store ;
let wrapper ;
2022-01-25 15:12:32 +00:00
const createWrapper = async ( ) => {
2020-07-14 00:09:46 +00:00
store = ClusterStore ( { ancestorHelperPath : '/some/ancestor/path' } ) ;
2021-01-15 00:10:45 +00:00
wrapper = shallowMount ( AncestorNotice , { store , stubs : { GlSprintf , GlAlert } } ) ;
2022-01-25 15:12:32 +00:00
await nextTick ( ) ;
2020-07-14 00:09:46 +00:00
} ;
beforeEach ( ( ) => {
return createWrapper ( ) ;
} ) ;
afterEach ( ( ) => {
wrapper . destroy ( ) ;
} ) ;
describe ( 'when cluster does not have ancestors' , ( ) => {
2022-01-25 15:12:32 +00:00
beforeEach ( async ( ) => {
2020-07-14 00:09:46 +00:00
store . state . hasAncestorClusters = false ;
2022-01-25 15:12:32 +00:00
await nextTick ( ) ;
2020-07-14 00:09:46 +00:00
} ) ;
it ( 'displays no notice' , ( ) => {
2020-08-25 06:10:18 +00:00
expect ( wrapper . html ( ) ) . toBe ( '' ) ;
2020-07-14 00:09:46 +00:00
} ) ;
} ) ;
describe ( 'when cluster has ancestors' , ( ) => {
2022-01-25 15:12:32 +00:00
beforeEach ( async ( ) => {
2020-07-14 00:09:46 +00:00
store . state . hasAncestorClusters = true ;
2022-01-25 15:12:32 +00:00
await nextTick ( ) ;
2020-07-14 00:09:46 +00:00
} ) ;
it ( 'displays notice text' , ( ) => {
expect ( wrapper . text ( ) ) . toContain (
'Clusters are utilized by selecting the nearest ancestor with a matching environment scope. For example, project clusters will override group clusters.' ,
) ;
} ) ;
it ( 'displays link' , ( ) => {
2020-08-28 12:10:37 +00:00
expect ( wrapper . find ( GlLink ) . exists ( ) ) . toBe ( true ) ;
2020-07-14 00:09:46 +00:00
} ) ;
} ) ;
} ) ;