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
23 changes: 21 additions & 2 deletions Assets/Tests/Editor/OnionAssemblyDependencyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -884,9 +884,28 @@ public void SetupWizardStartup_WhenLoaded_SchedulesVersionCheckInsteadOfReadingS
// Tests that Setup Wizard settings reads run after the synchronous Editor startup hook.
string setupWizardSource = ReadProductionSource(
"Packages/src/Editor/Presentation/Setup/SetupWizardWindow.cs");
string setupWizardStartupFlowSource = ReadProductionSource(
"Packages/src/Editor/Presentation/Setup/SetupWizardStartupFlow.cs");

Assert.That(setupWizardSource, Does.Contain("EditorApplication.delayCall += TryShowOnVersionChange;"));
Assert.That(setupWizardSource, Does.Not.Contain("\n TryShowOnVersionChange();"));
Assert.That(
setupWizardSource,
Does.Contain("EditorApplication.delayCall += startupFlow.TryShowOnVersionChange;"));
Assert.That(
setupWizardStartupFlowSource,
Does.Contain("EditorApplication.delayCall += () => _showWindowOnVersionChange();"));
Assert.That(setupWizardSource, Does.Not.Contain("\n startupFlow.TryShowOnVersionChange();"));
}

[Test]
public void SetupWizardStartup_WhenMigrationAutoScanIsRequested_SchedulesAutoScanThroughDelayCall()
{
// Tests that startup migration auto-scan runs through a delayed Editor callback.
string setupWizardStartupFlowSource = ReadProductionSource(
"Packages/src/Editor/Presentation/Setup/SetupWizardStartupFlow.cs");

Assert.That(
setupWizardStartupFlowSource,
Does.Contain("EditorApplication.delayCall += () => _showThirdPartyMigrationAutoScan();"));
}

[Test]
Expand Down
45 changes: 32 additions & 13 deletions Assets/Tests/Editor/SetupWizardWindowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public void SetUp()
UnityCliLoopEditorSessionStateTestFactory.ClearAll();
SetupWizardWindow.InitializeEditorServices(
_editorSettingsPort,
_sessionFlagsRepository,
CreateCliSetupApplicationService(),
CreateSkillSetupUseCase());
_editorSettingsRepository.InvalidateCache();
Expand Down Expand Up @@ -85,7 +84,7 @@ public void ShouldAutoShowForVersion_ReturnsExpectedValue(
{
// Verifies that package and dispatcher requirement changes auto-show only for actionable updates.
bool shouldAutoShow =
SetupWizardWindow.ShouldAutoShowForVersion(
SetupWizardStartupFlow.ShouldAutoShowForVersion(
currentVersion,
lastSeenVersion,
currentMinimumDispatcherVersion,
Expand All @@ -108,7 +107,7 @@ public void HasSkillUpdateForSetupWizard_WhenOutdatedTargetHasSkillsDirectory_Re
installState: SkillInstallState.Outdated)
};

bool hasSkillUpdate = SetupWizardWindow.HasSkillUpdateForSetupWizard(targets);
bool hasSkillUpdate = SetupWizardStartupFlow.HasSkillUpdateForSetupWizard(targets);

Assert.That(hasSkillUpdate, Is.True);
}
Expand All @@ -127,7 +126,7 @@ public void HasSkillUpdateForSetupWizard_WhenTargetIsNotOutdated_ReturnsFalse(
installState)
};

bool hasSkillUpdate = SetupWizardWindow.HasSkillUpdateForSetupWizard(targets);
bool hasSkillUpdate = SetupWizardStartupFlow.HasSkillUpdateForSetupWizard(targets);

Assert.That(hasSkillUpdate, Is.False);
}
Expand All @@ -143,7 +142,7 @@ public void HasSkillUpdateForSetupWizard_WhenOutdatedTargetHasNoSkillsDirectory_
installState: SkillInstallState.Outdated)
};

bool hasSkillUpdate = SetupWizardWindow.HasSkillUpdateForSetupWizard(targets);
bool hasSkillUpdate = SetupWizardStartupFlow.HasSkillUpdateForSetupWizard(targets);

Assert.That(hasSkillUpdate, Is.False);
}
Expand All @@ -160,7 +159,7 @@ public void HasSkillUpdateForSetupWizard_WhenTargetHasDifferentLayoutSkills_Retu
hasDifferentLayoutSkills: true)
};

bool hasSkillUpdate = SetupWizardWindow.HasSkillUpdateForSetupWizard(targets);
bool hasSkillUpdate = SetupWizardStartupFlow.HasSkillUpdateForSetupWizard(targets);

Assert.That(hasSkillUpdate, Is.True);
}
Expand All @@ -179,7 +178,7 @@ public void ShouldAutoScanThirdPartyToolMigration_ReturnsExpectedValue(
{
// Verifies that V3 startup scans run for V2 upgrades or missing prior setup state.
bool shouldAutoScan =
SetupWizardWindow.ShouldAutoScanThirdPartyToolMigration(currentVersion, lastSeenVersion);
SetupWizardStartupFlow.ShouldAutoScanThirdPartyToolMigration(currentVersion, lastSeenVersion);

Assert.That(shouldAutoScan, Is.EqualTo(expected));
}
Expand All @@ -188,7 +187,7 @@ public void ShouldAutoScanThirdPartyToolMigration_ReturnsExpectedValue(
public void MaybeMarkThirdPartyToolMigrationAutoScan_WhenEnabled_SetsSessionFlag()
{
// Verifies that the V2-to-V3 upgrade signal is stored only in the current Editor session.
SetupWizardWindow.MaybeMarkThirdPartyToolMigrationAutoScan(true);
SetupWizardStartupFlow.MaybeMarkThirdPartyToolMigrationAutoScan(_sessionFlagsRepository, true);

Assert.That(_sessionFlagsRepository.GetShouldAutoScanThirdPartyToolMigration(), Is.True);
}
Expand All @@ -197,21 +196,26 @@ public void MaybeMarkThirdPartyToolMigrationAutoScan_WhenEnabled_SetsSessionFlag
public void MaybeMarkThirdPartyToolMigrationAutoScan_WhenDisabled_KeepsSessionFlagFalse()
{
// Verifies that non-upgrade version checks do not request migration scans.
SetupWizardWindow.MaybeMarkThirdPartyToolMigrationAutoScan(false);
SetupWizardStartupFlow.MaybeMarkThirdPartyToolMigrationAutoScan(_sessionFlagsRepository, false);

Assert.That(_sessionFlagsRepository.GetShouldAutoScanThirdPartyToolMigration(), Is.False);
}

[Test]
public void MaybeRecordLastSeenSetupWizardState_WhenAutoShow_UpdatesStoredState()
{
// Verifies that auto-show records the setup wizard version state.
_editorSettingsPort.SaveSettings(new UnityCliLoopEditorSettingsData
{
lastSeenSetupWizardVersion = "1.7.2",
lastSeenSetupWizardMinimumDispatcherVersion = "3.0.1"
});

SetupWizardWindow.MaybeRecordLastSeenSetupWizardState(true, "1.7.3", "3.0.2");
SetupWizardStartupFlow.MaybeRecordLastSeenSetupWizardState(
_editorSettingsPort,
true,
"1.7.3",
"3.0.2");

Assert.That(_editorSettingsPort.GetLastSeenSetupWizardVersion(), Is.EqualTo("1.7.3"));
Assert.That(
Expand All @@ -222,13 +226,18 @@ public void MaybeRecordLastSeenSetupWizardState_WhenAutoShow_UpdatesStoredState(
[Test]
public void MaybeRecordLastSeenSetupWizardState_WhenManualShow_KeepsStoredState()
{
// Verifies that manual opens do not update the setup wizard version state.
_editorSettingsPort.SaveSettings(new UnityCliLoopEditorSettingsData
{
lastSeenSetupWizardVersion = "1.7.2",
lastSeenSetupWizardMinimumDispatcherVersion = "3.0.1"
});

SetupWizardWindow.MaybeRecordLastSeenSetupWizardState(false, "1.7.3", "3.0.2");
SetupWizardStartupFlow.MaybeRecordLastSeenSetupWizardState(
_editorSettingsPort,
false,
"1.7.3",
"3.0.2");

Assert.That(_editorSettingsPort.GetLastSeenSetupWizardVersion(), Is.EqualTo("1.7.2"));
Assert.That(
Expand All @@ -239,13 +248,18 @@ public void MaybeRecordLastSeenSetupWizardState_WhenManualShow_KeepsStoredState(
[Test]
public void MaybeRecordSuppressedSetupWizardState_WhenAutoShowSuppressed_UpdatesStoredState()
{
// Verifies that suppressing auto-show records the current setup wizard state.
_editorSettingsPort.SaveSettings(new UnityCliLoopEditorSettingsData
{
lastSeenSetupWizardVersion = "1.7.2",
lastSeenSetupWizardMinimumDispatcherVersion = "3.0.1"
});

SetupWizardWindow.MaybeRecordSuppressedSetupWizardState(true, "1.7.3", "3.0.2");
SetupWizardStartupFlow.MaybeRecordSuppressedSetupWizardState(
_editorSettingsPort,
true,
"1.7.3",
"3.0.2");

Assert.That(_editorSettingsPort.GetLastSeenSetupWizardVersion(), Is.EqualTo("1.7.3"));
Assert.That(
Expand All @@ -256,13 +270,18 @@ public void MaybeRecordSuppressedSetupWizardState_WhenAutoShowSuppressed_Updates
[Test]
public void MaybeRecordSuppressedSetupWizardState_WhenAutoShowAllowed_KeepsStoredState()
{
// Verifies that allowing auto-show leaves the stored setup wizard state unchanged.
_editorSettingsPort.SaveSettings(new UnityCliLoopEditorSettingsData
{
lastSeenSetupWizardVersion = "1.7.2",
lastSeenSetupWizardMinimumDispatcherVersion = "3.0.1"
});

SetupWizardWindow.MaybeRecordSuppressedSetupWizardState(false, "1.7.3", "3.0.2");
SetupWizardStartupFlow.MaybeRecordSuppressedSetupWizardState(
_editorSettingsPort,
false,
"1.7.3",
"3.0.2");

Assert.That(_editorSettingsPort.GetLastSeenSetupWizardVersion(), Is.EqualTo("1.7.2"));
Assert.That(
Expand Down
Loading
Loading