Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions web/__test__/components/Onboarding/OnboardingSummaryStep.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -295,7 +295,7 @@ interface SummaryVm {
applyResultSeverity: 'success' | 'warning' | 'error';
handleBootDriveWarningConfirm: () => Promise<void>;
handleBootDriveWarningCancel: () => void;
handleApplyResultConfirm: () => void;
handleApplyResultConfirm: () => Promise<void>;
}

const getSummaryVm = (wrapper: ReturnType<typeof mountComponent>['wrapper']) =>
Expand DownExpand Up@@ -332,7 +332,7 @@ const clickButtonByText = async (
} else if (normalizedTarget === 'cancel') {
vm.handleBootDriveWarningCancel();
} else if (normalizedTarget === 'ok') {
vm.handleApplyResultConfirm();
await vm.handleApplyResultConfirm();
} else {
expect(button).toBeTruthy();
}
Expand DownExpand Up@@ -1015,6 +1015,28 @@ describe('OnboardingSummaryStep', () => {
expect(onComplete).not.toHaveBeenCalled();
});

it('advances to next steps before reloading after a successful server rename', async () => {
draftStore.serverName = 'Newtower';
const reloadSpy = vi.spyOn(window.location, 'reload').mockImplementation(() => undefined);
const { wrapper, onComplete } = mountComponent();

await clickApply(wrapper);

expect(updateServerIdentityMock).toHaveBeenCalledWith({
name: 'Newtower',
comment: '',
sysModel: undefined,
});
expect(onComplete).not.toHaveBeenCalled();

await clickButtonByText(wrapper, 'OK');

expect(onComplete).toHaveBeenCalledTimes(1);
expect(reloadSpy).toHaveBeenCalledTimes(1);

reloadSpy.mockRestore();
});

it('retries final identity update after transient network errors when SSH changed', async () => {
draftStore.useSsh = true;
draftStore.serverDescription = 'Primary host';
Expand Down
22 changes: 18 additions & 4 deletions web/src/components/Onboarding/steps/OnboardingSummaryStep.vue
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { storeToRefs } from 'pinia';
import { useMutation, useQuery } from '@vue/apollo-composable';
Expand DownExpand Up@@ -57,7 +57,7 @@ import {
} from '~/composables/gql/graphql';

export interface Props {
onComplete: () => void;
onComplete: () => void | Promise<void>;
onBack?: () => void;
showBack?: boolean;
}
Expand DownExpand Up@@ -227,6 +227,7 @@ const showBootDriveWarningDialog = ref(false);
const applyResultTitle = ref('');
const applyResultMessage = ref('');
const applyResultSeverity = ref<'success' | 'warning' | 'error'>('success');
const shouldReloadAfterApplyResult = ref(false);
const summaryT = (key: string, values?: Record<string, unknown>) =>
t(`onboarding.summaryStep.${key}`, values ?? {});

Expand DownExpand Up@@ -579,6 +580,7 @@ const handleComplete = async () => {
isProcessing.value = true;
error.value = null;
logs.value = []; // Clear logs
shouldReloadAfterApplyResult.value = false;

addLog(summaryT('logs.startingConfiguration'), 'info');
draftStore.setInternalBootApplySucceeded(false);
Expand DownExpand Up@@ -617,6 +619,7 @@ const handleComplete = async () => {
? Boolean(coreSettingsResult.value?.vars?.useSsh || false)
: TRUSTED_DEFAULT_PROFILE.useSsh;
const currentSysModel = baselineLoaded ? coreSettingsResult.value?.vars?.sysModel || '' : '';
const serverNameChanged = baselineLoaded ? targetCoreSettings.serverName !== currentName : false;
const shouldApplyPartnerSysModel = Boolean(
isFreshInstall.value &&
activationSystemModel.value &&
Expand DownExpand Up@@ -657,6 +660,9 @@ const handleComplete = async () => {
}),
shouldRetryNetworkMutations
);
if (serverNameChanged) {
shouldReloadAfterApplyResult.value = true;
}
addLog(summaryT('logs.serverIdentityUpdated'), 'success');
} catch (caughtError: unknown) {
hadNonOptimisticFailures = true;
Expand DownExpand Up@@ -1032,9 +1038,17 @@ const handleComplete = async () => {
}
};

const handleApplyResultConfirm = () => {
const handleApplyResultConfirm = async () => {
showApplyResultDialog.value = false;
props.onComplete();
await Promise.resolve(props.onComplete());

if (!shouldReloadAfterApplyResult.value) {
return;
}

shouldReloadAfterApplyResult.value = false;
await nextTick();
window.location.reload();
};

const handleApplyClick = async () => {
Expand Down
Loading