Skip to content
Open
55 changes: 55 additions & 0 deletions web/__test__/components/CallbackFeedback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,61 @@ describe('CallbackFeedback.vue', () => {
expect(wrapper.find('.modal').attributes('data-success')).toBe('false');
});

describe('OS update confirmation', () => {
it('renders the update confirmation when a standalone update lands on a server with a state error', () => {
updateOsStatus.value = 'confirming';
callbackUpdateRelease.value = { name: 'Unraid 7.3.1' };
osVersion.value = '7.3.0';
// Server is in an error state (e.g. EGUID GUID mismatch) but no key was installed
stateDataError.value = true;
keyInstallStatus.value = 'ready';

const wrapper = mountComponent();

expect(wrapper.find('h1').text()).toBe('Update Unraid OS confirmation required');
expect(wrapper.text()).toContain('Current Version: Unraid 7.3.0');
expect(wrapper.text()).toContain('New Version: Unraid 7.3.1');
expect(wrapper.text()).toContain('Confirm and start update');
});

it('confirms the update when the confirm button is clicked', async () => {
updateOsStatus.value = 'confirming';
callbackUpdateRelease.value = { name: 'Unraid 7.3.1' };
stateDataError.value = true;
keyInstallStatus.value = 'ready';

const wrapper = mountComponent();

const confirmButton = wrapper
.findAll('button')
.find((button) => button.text() === 'Confirm and start update');
expect(confirmButton).toBeDefined();
await confirmButton!.trigger('click');

expect(mockInstallOsUpdate).toHaveBeenCalledTimes(1);
expect(mockSetCallbackStatus).toHaveBeenCalledWith('ready');
});

it('suppresses the update confirmation when a key install left the server in an error state', () => {
updateOsStatus.value = 'confirming';
callbackUpdateRelease.value = { name: 'Unraid 7.3.1' };
osVersion.value = '7.3.0';
// Combined key-install + update flow where the install errored
callbackStatus.value = 'success';
keyActionType.value = 'purchase';
keyInstallStatus.value = 'success';
keyType.value = 'Pro';
stateDataError.value = true;
callbackCallsCompleted.value = true;

const wrapper = mountComponent();

expect(wrapper.text()).not.toContain('New Version: Unraid 7.3.1');
expect(wrapper.text()).not.toContain('Confirm and start update');
expect(wrapper.text()).toContain('Post Install License Key Error');
});
});

it('reloads the page when the modal is dismissed after a callback action', async () => {
const mockReload = vi.fn();

Expand Down
4 changes: 2 additions & 2 deletions web/src/components/UserProfile/CallbackFeedback.vue
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ const showPostInstallKeyError = computed(() =>
/>
</div>

<template v-if="updateOsStatus === 'confirming' && !stateDataError">
<template v-if="updateOsStatus === 'confirming' && !showPostInstallKeyError">
<div class="my-4 flex flex-col gap-y-2">
<div class="flex flex-col gap-y-1">
<p class="text-center text-lg">
Expand Down Expand Up @@ -383,7 +383,7 @@ const showPostInstallKeyError = computed(() =>
</template>
</template>

<template v-if="updateOsStatus === 'confirming' && !stateDataError">
<template v-if="updateOsStatus === 'confirming' && !showPostInstallKeyError">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Block updates during pending key reconciliation

In a combined key-install + OS-update callback, actOnUpdateOsAction can put updateOsStatus into confirming before the delayed refreshServerState reconciliation has finished. If the server still has the pre-refresh stateDataError, showPostInstallKeyError is false while callbackCallsCompleted is false, so this predicate now exposes the confirm button and lets the user start the OS update before we know whether the key install actually cleared the license error. Keep state errors suppressing the update confirmation while a key-install reconciliation is still pending.

Useful? React with 👍 / 👎.

<BrandButton
variant="underline"
:icon="XMarkIcon"
Expand Down
Loading