standard user test fix

This commit is contained in:
Sean 2023-07-28 07:28:10 -04:00
parent 512f471ebe
commit c73e737c7d
3 changed files with 36 additions and 5 deletions

View File

@ -128,7 +128,14 @@ export default {
async mounted() {
const nodeId = this.pod.spec?.nodeName;
await this.$store.dispatch('cluster/find', { type: NODE, id: nodeId });
try {
const schema = this.$store.getters[`cluster/schemaFor`](NODE);
if (schema) {
await this.$store.dispatch('cluster/find', { type: NODE, id: nodeId });
}
} catch {}
await this.setupTerminal();
await this.connect();

View File

@ -18,6 +18,7 @@ jest.mock('@shell/utils/crypto', () => {
describe('component: ContainerShell', () => {
const action = jest.fn();
const translate = jest.fn();
const schemaFor = jest.fn();
const onData = jest.fn();
const loadAddon = jest.fn();
const open = jest.fn();
@ -66,7 +67,10 @@ describe('component: ContainerShell', () => {
mocks: {
$store: {
dispatch: action,
getters: { 'i18n/t': translate }
getters: {
'i18n/t': translate,
'cluster/schemaFor': schemaFor
}
}
}
};
@ -99,9 +103,23 @@ describe('component: ContainerShell', () => {
expect(windowElement.exists()).toBe(true);
});
it('the find action for the node is called', async() => {
it('the find action for the node is called if schemaFor finds a schema for NODE', async() => {
resetMocks();
await wrapperPostMounted(defaultContainerShellParams);
const testSchemaFindsSchemaParams = {
...defaultContainerShellParams,
mocks: {
...defaultContainerShellParams.mocks,
$store: {
...defaultContainerShellParams.mocks.$store,
getters: {
...defaultContainerShellParams.mocks.$store.getters,
'cluster/schemaFor': jest.fn().mockImplementation(() => true)
}
}
}
};
await wrapperPostMounted(testSchemaFindsSchemaParams);
const actionParams = action.mock.calls[0];

View File

@ -34,7 +34,13 @@ export default class Pod extends WorkloadService {
}
get node() {
this.$dispatch(`find`, { type: NODE, id: this.spec.nodeName });
try {
const schema = this.$store.getters[`cluster/schemaFor`](NODE);
if (schema) {
this.$dispatch(`find`, { type: NODE, id: this.spec.nodeName });
}
} catch {}
return this.$getters['byId'](NODE, this.spec.nodeName);
}