Fix broken app container test

This commit is contained in:
mabashian
2021-05-25 08:06:06 -04:00
parent 82c3348b15
commit dd1bda3b67

View File

@@ -22,7 +22,7 @@ describe('<AppContainer />', () => {
RootAPI.readAssetVariables.mockResolvedValue({ RootAPI.readAssetVariables.mockResolvedValue({
data: { data: {
BRAND_NAME: 'AWX', BRAND_NAME: 'AWX',
PENDO_API_KEY: '', PENDO_API_KEY: 'some-pendo-key',
}, },
}); });
MeAPI.read.mockResolvedValue({ data: { results: [{}] } }); MeAPI.read.mockResolvedValue({ data: { results: [{}] } });
@@ -37,7 +37,7 @@ describe('<AppContainer />', () => {
test('expected content is rendered', async () => { test('expected content is rendered', async () => {
const routeConfig = [ const routeConfig = [
{ {
groupTitle: 'Group One', groupTitle: <span>Group One</span>,
groupId: 'group_one', groupId: 'group_one',
routes: [ routes: [
{ title: 'Foo', path: '/foo' }, { title: 'Foo', path: '/foo' },
@@ -45,7 +45,7 @@ describe('<AppContainer />', () => {
], ],
}, },
{ {
groupTitle: 'Group Two', groupTitle: <span>Group Two</span>,
groupId: 'group_two', groupId: 'group_two',
routes: [{ title: 'Fiz', path: '/fiz' }], routes: [{ title: 'Fiz', path: '/fiz' }],
}, },
@@ -95,7 +95,36 @@ describe('<AppContainer />', () => {
expect(global.pendo.initialize).toHaveBeenCalledTimes(1); expect(global.pendo.initialize).toHaveBeenCalledTimes(1);
}); });
test('expected content is rendered', async () => { test('Pendo not initialized when key is missing', async () => {
RootAPI.readAssetVariables.mockResolvedValue({
data: {
BRAND_NAME: 'AWX',
PENDO_API_KEY: '',
},
});
let wrapper;
await act(async () => {
wrapper = mountWithContexts(<AppContainer />, {
context: {
config: {
analytics_status: 'detailed',
ansible_version: null,
custom_virtualenvs: [],
version: '9000',
me: { is_superuser: true },
toJSON: () => '/config/',
license_info: {
valid_key: true,
},
},
},
});
});
wrapper.update();
expect(global.pendo.initialize).toHaveBeenCalledTimes(0);
});
test('Pendo not initialized when status is analytics off', async () => {
let wrapper; let wrapper;
await act(async () => { await act(async () => {
wrapper = mountWithContexts(<AppContainer />, { wrapper = mountWithContexts(<AppContainer />, {