Files
api/web/components/DowngradeOs.ce.vue
Michael Datelle 32c6fe6295 test: create tests for components batch 2 (#1365)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Improved component tests by integrating Pinia's testing utilities for
more reliable store mocking and state management.
- Updated test setup to streamline plugin usage and remove unnecessary
configuration.
- Enhanced test clarity by relying on store state changes and Vue's
reactivity instead of manual mock updates.
- Simplified test cases by focusing on passed props and standardized
store mocking.
- **Chores**
  - Updated test directory structure for better organization.
  - Added additional test mocks for dependencies.
- **New Features**
- Added comprehensive tests for the ColorSwitcher component, verifying
UI elements and theme store interactions.
- Introduced tests for the DevSettings component, confirming UI
rendering and interaction behavior.
- Added detailed tests for the DowngradeOs component covering store
interactions and conditional UI rendering.
- Added new test suites for DummyServerSwitcher component, ensuring
correct rendering and reactive state updates.
- Added new test suites for HeaderOsVersion component, validating
version badge rendering and error state handling.
- Added new test suite for the I18nHost component, validating
internationalization context provisioning and error handling.
- Added a comprehensive test suite for the Modal component, covering UI
behavior, styling, and event handling.
- Added new test suite for the Registration component, verifying
rendering based on server state.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mdatelle <mike@datelle.net>
2025-04-29 12:44:31 -04:00

81 lines
2.5 KiB
Vue

<script lang="ts" setup>
/**
* @todo how are we going to update test, beta, and stable releases for internal testing?
* @todo after install / downgrade detect if third-party drivers are installed and tell users to wait for a user to wait for a new notification
*
* run exec("ps aux | grep -E "inotifywait -q /boot/changes.txt -e move_self,delete_self" | grep -v "grep -E inotifywait" | awk '{print $2}'");
* if this returns are value assume we have third-party drivers installed and tell the user to wait for a new notification
*
* view https://s3.amazonaws.com/dnld.lime-technology.com/stable/unRAIDServer.plg to see how the update is handled
# ensure writes to USB flash boot device have completed
sync -f /boot
if [ -z "${plg_update_helper}" ]; then
echo "Update successful - PLEASE REBOOT YOUR SERVER"
else
echo "Third party plugins found - PLEASE CHECK YOUR UNRAID NOTIFICATIONS AND WAIT FOR THE MESSAGE THAT IT IS SAFE TO REBOOT!"
fi
*/
import { computed, onBeforeMount } from 'vue';
import { useI18n } from 'vue-i18n';
import { storeToRefs } from 'pinia';
import { PageContainer } from '@unraid/ui';
import { useServerStore } from '~/store/server';
const { t } = useI18n();
export interface Props {
rebootVersion?: string;
restoreReleaseDate?: string;
restoreVersion?: string;
}
const props = withDefaults(defineProps<Props>(), {
rebootVersion: '',
restoreReleaseDate: '',
restoreVersion: '',
});
const serverStore = useServerStore();
const { rebootType, osVersionBranch } = storeToRefs(serverStore);
const subtitle = computed(() => {
if (rebootType.value === 'update') {
return t('Please finish the initiated update to enable a downgrade.');
}
return '';
});
const showExternalDowngrade = computed(() => osVersionBranch.value !== 'stable');
onBeforeMount(() => {
serverStore.setRebootVersion(props.rebootVersion);
});
</script>
<template>
<PageContainer>
<UpdateOsStatus
:title="t('Downgrade Unraid OS')"
:subtitle="subtitle"
:downgrade-not-available="restoreVersion === '' && rebootType === ''"
:show-external-downgrade="showExternalDowngrade"
:t="t"
/>
<UpdateOsDowngrade
v-if="restoreVersion && rebootType === ''"
:release-date="restoreReleaseDate"
:version="restoreVersion"
:t="t"
/>
<UpdateOsThirdPartyDrivers v-if="rebootType === 'thirdPartyDriversDownloading'" :t="t" />
</PageContainer>
</template>
<style lang="postcss">
/* Import unraid-ui globals first */
@import '@unraid/ui/styles';
@import '~/assets/main.css';
</style>