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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
import OnboardingNextStepsStep from '~/components/Onboarding/steps/OnboardingNextStepsStep.vue';
import { createTestI18n } from '../../utils/i18n';

const { draftStore, activationCodeDataStore, submitInternalBootRebootMock } = vi.hoisted(() => ({
const {
draftStore,
activationCodeDataStore,
submitInternalBootRebootMock,
cleanupOnboardingStorageMock,
} = vi.hoisted(() => ({
draftStore: {
internalBootApplySucceeded: false,
},
Expand All @@ -26,6 +31,7 @@ const { draftStore, activationCodeDataStore, submitInternalBootRebootMock } = vi
},
},
submitInternalBootRebootMock: vi.fn(),
cleanupOnboardingStorageMock: vi.fn(),
}));

vi.mock('@unraid/ui', () => ({
Expand Down Expand Up @@ -53,6 +59,10 @@ vi.mock('~/components/Onboarding/composables/internalBoot', () => ({
submitInternalBootReboot: submitInternalBootRebootMock,
}));

vi.mock('~/components/Onboarding/store/onboardingStorageCleanup', () => ({
cleanupOnboardingStorage: cleanupOnboardingStorageMock,
}));

describe('OnboardingNextStepsStep', () => {
beforeEach(() => {
vi.clearAllMocks();
Expand Down Expand Up @@ -105,6 +115,9 @@ describe('OnboardingNextStepsStep', () => {
await confirmButton!.trigger('click');
await flushPromises();

expect(cleanupOnboardingStorageMock).toHaveBeenCalledWith({
clearTemporaryBypassSessionState: true,
});
expect(submitInternalBootRebootMock).toHaveBeenCalledTimes(1);
expect(onComplete).not.toHaveBeenCalled();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { createTestI18n } from '../../utils/i18n';

const {
completeOnboardingMock,
cleanupOnboardingStorageMock,
refetchOnboardingMock,
partnerInfoRef,
isFreshInstallRef,
Expand All @@ -17,6 +18,7 @@ const {
themeRef,
} = vi.hoisted(() => ({
completeOnboardingMock: vi.fn().mockResolvedValue({}),
cleanupOnboardingStorageMock: vi.fn(),
refetchOnboardingMock: vi.fn().mockResolvedValue({}),
partnerInfoRef: {
value: {
Expand Down Expand Up @@ -90,7 +92,7 @@ vi.mock('@/store/theme', () => ({
}));

vi.mock('@/components/Onboarding/store/onboardingStorageCleanup', () => ({
cleanupOnboardingStorage: vi.fn(),
cleanupOnboardingStorage: cleanupOnboardingStorageMock,
}));

describe('OnboardingOverviewStep', () => {
Expand Down Expand Up @@ -140,4 +142,25 @@ describe('OnboardingOverviewStep', () => {
expect(updatedImg.attributes('src')).toBe(limitlessImage);
expect(updatedImg.attributes('alt')).toBe('Limitless Possibilities');
});

it('clears onboarding draft immediately when skipping setup', async () => {
const wrapper = mountComponent();

await wrapper.find('[data-testid="skip-setup-button"]').trigger('click');

Choose a reason for hiding this comment

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

P1 Badge Use semantic selector for skip button tests

/workspace/api/AGENTS.md (Vue Component Testing) says to use semantic queries like find('button') instead of data-test IDs, but this change introduces find('[data-testid="skip-setup-button"]') and requires a matching data-testid in production markup. Keeping this pattern will propagate test-only attributes and brittle selector conventions, so the test should target the skip action semantically and avoid the test-id dependency.

Useful? React with 👍 / 👎.


expect(cleanupOnboardingStorageMock).toHaveBeenCalledWith({
clearTemporaryBypassSessionState: true,
});
});

it('still clears onboarding draft when skip completion fails', async () => {
completeOnboardingMock.mockRejectedValueOnce(new Error('offline'));
const wrapper = mountComponent();

await wrapper.find('[data-testid="skip-setup-button"]').trigger('click');

expect(cleanupOnboardingStorageMock).toHaveBeenCalledWith({
clearTemporaryBypassSessionState: true,
});
});
});
16 changes: 16 additions & 0 deletions web/__test__/components/Onboarding/OnboardingSummaryStep.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const {
installLanguageMock,
installPluginMock,
submitInternalBootCreationMock,
cleanupOnboardingStorageMock,
useMutationMock,
useQueryMock,
} = vi.hoisted(() => ({
Expand Down Expand Up @@ -98,6 +99,7 @@ const {
installLanguageMock: vi.fn(),
installPluginMock: vi.fn(),
submitInternalBootCreationMock: vi.fn(),
cleanupOnboardingStorageMock: vi.fn(),
useMutationMock: vi.fn(),
useQueryMock: vi.fn(),
}));
Expand Down Expand Up @@ -170,6 +172,10 @@ vi.mock('@/components/Onboarding/store/onboardingStatus', () => ({
}),
}));

vi.mock('@/components/Onboarding/store/onboardingStorageCleanup', () => ({
cleanupOnboardingStorage: cleanupOnboardingStorageMock,
}));

vi.mock('@/components/Onboarding/composables/usePluginInstaller', () => ({
INSTALL_OPERATION_TIMEOUT_CODE: 'INSTALL_OPERATION_TIMEOUT',
default: () => ({
Expand Down Expand Up @@ -887,6 +893,7 @@ describe('OnboardingSummaryStep', () => {
assertExpected: (wrapper: ReturnType<typeof mountComponent>['wrapper']) => {
expect(completeOnboardingMock).toHaveBeenCalledTimes(1);
expect(refetchOnboardingMock).not.toHaveBeenCalled();
expect(cleanupOnboardingStorageMock).not.toHaveBeenCalled();
expect(wrapper.text()).toContain(
'Could not mark onboarding complete right now (API may be offline): offline'
);
Expand All @@ -902,6 +909,15 @@ describe('OnboardingSummaryStep', () => {
scenario.assertExpected(wrapper);
});

it('does not clear onboarding draft after a successful apply while still in the flow', async () => {
const { wrapper } = mountComponent();

await clickApply(wrapper);

expect(completeOnboardingMock).toHaveBeenCalledTimes(1);
expect(cleanupOnboardingStorageMock).not.toHaveBeenCalled();
});

it('retries completeOnboarding after transient network errors when SSH changed', async () => {
draftStore.useSsh = true;
updateSshSettingsMock.mockResolvedValue({
Expand Down
6 changes: 0 additions & 6 deletions web/src/components/Onboarding/OnboardingModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,6 @@ const currentStepProps = computed<Record<string, unknown>>(() => {
showActivationCodeHint: hasActivationCode.value,
};

case 'SUMMARY':
case 'NEXT_STEPS':
return {
...baseProps,
};

default:
return baseProps;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import UnraidIconSvg from '@/assets/partners/simple-icons-unraid.svg?raw';
import { submitInternalBootReboot } from '@/components/Onboarding/composables/internalBoot';
import { useActivationCodeDataStore } from '@/components/Onboarding/store/activationCodeData';
import { useOnboardingDraftStore } from '@/components/Onboarding/store/onboardingDraft';
import { cleanupOnboardingStorage } from '@/components/Onboarding/store/onboardingStorageCleanup';

export interface Props {
onComplete: () => void;
Expand Down Expand Up @@ -94,6 +95,7 @@ const handlePrimaryAction = () => {

const handleConfirmReboot = () => {
showRebootWarningDialog.value = false;
cleanupOnboardingStorage({ clearTemporaryBypassSessionState: true });
submitInternalBootReboot();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,12 @@ const handleSkipOnboarding = async () => {
}

isSkipping.value = true;
cleanupOnboardingStorage({ clearTemporaryBypassSessionState: true });

try {
await completeOnboarding();
await new Promise((r) => setTimeout(r, 500));
await refetchOnboarding();
cleanupOnboardingStorage({ clearTemporaryBypassSessionState: true });
window.location.reload();
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -314,6 +315,7 @@ const openDocs = () => {
<div class="flex items-center gap-6">
<button
@click="handleSkipOnboarding"
data-testid="skip-setup-button"
class="text-muted hover:text-toned text-sm font-medium transition-colors"
:disabled="isBusy"
>
Expand Down
2 changes: 0 additions & 2 deletions web/src/components/Onboarding/steps/OnboardingSummaryStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import { INSTALLED_UNRAID_PLUGINS_QUERY } from '@/components/Onboarding/graphql/
import { UPDATE_SYSTEM_TIME_MUTATION } from '@/components/Onboarding/graphql/updateSystemTime.mutation';
import { useOnboardingModalStore } from '@/components/Onboarding/store/onboardingModalVisibility';
import { useOnboardingStore } from '@/components/Onboarding/store/onboardingStatus';
import { cleanupOnboardingStorage } from '@/components/Onboarding/store/onboardingStorageCleanup';
import { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue';
import type { LogEntry } from '@/components/Onboarding/components/OnboardingConsole.vue';
Expand Down Expand Up @@ -1106,7 +1105,6 @@ const handleComplete = async () => {
try {
await runWithTransientNetworkRetry(() => completeOnboarding(), shouldRetryNetworkMutations);
completionMarked = true;
cleanupOnboardingStorage({ clearTemporaryBypassSessionState: true });
} catch (caughtError: unknown) {
hadWarnings = true;
addErrorLog(summaryT('logs.completeOnboardingFailed'), caughtError, {
Expand Down
Loading