Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions web/__test__/store/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ const getStore = () => {
description: store.description,
deviceCount: store.deviceCount,
expireTime: store.expireTime,
flashGuid: store.flashGuid || undefined,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
flashProduct: store.flashProduct,
flashVendor: store.flashVendor,
guid: store.guid,
Expand All @@ -203,6 +204,7 @@ const getStore = () => {
regTy: store.regTy,
regUpdatesExpired: store.regUpdatesExpired,
state: store.state,
tpmGuid: store.tpmGuid || undefined,
wanFQDN: store.wanFQDN,
};

Expand All @@ -218,6 +220,7 @@ const getStore = () => {
deviceCount: store.deviceCount,
description: store.description,
expireTime: store.expireTime,
flashGuid: store.flashGuid || undefined,
flashProduct: store.flashProduct,
flashVendor: store.flashVendor,
guid: store.guid,
Expand All @@ -233,6 +236,7 @@ const getStore = () => {
regTy: store.regTy,
regUpdatesExpired: store.regUpdatesExpired,
state: store.state,
tpmGuid: store.tpmGuid || undefined,
wanFQDN: store.wanFQDN,
};

Expand Down Expand Up @@ -651,6 +655,7 @@ describe('useServerStore', () => {
deviceCount: 6,
description: 'Test Server',
expireTime: 123,
flashGuid: 'flash-guid-1',
flashProduct: 'TestFlash',
flashVendor: 'TestVendor',
guid: '123456',
Expand All @@ -675,6 +680,7 @@ describe('useServerStore', () => {
expect(payload.description).toBe('Test Server');
expect(payload.deviceCount).toBe(6);
expect(payload.expireTime).toBe(123);
expect(payload.flashGuid).toBe('flash-guid-1');
expect(payload.flashProduct).toBe('TestFlash');
expect(payload.flashVendor).toBe('TestVendor');
expect(payload.guid).toBe('123456');
Expand Down Expand Up @@ -767,6 +773,7 @@ describe('useServerStore', () => {
regGuid: 'reg-guid-1',
regTy: 'Plus',
state: 'PLUS' as ServerState,
tpmGuid: '01-TPM-GUID-1',
wanFQDN: 'test.myunraid.net',
});

Expand All @@ -777,6 +784,7 @@ describe('useServerStore', () => {
expect(payload.deviceCount).toBe(6);
expect(payload.description).toBe('Test Server');
expect(payload.expireTime).toBe(123);
expect(payload.flashGuid).toBe('flash-guid-1');
expect(payload.flashProduct).toBe('TestFlash');
expect(payload.flashVendor).toBe('TestVendor');
expect(payload.guid).toBe('123456');
Expand All @@ -792,6 +800,7 @@ describe('useServerStore', () => {
expect(payload.regTy).toBe('Plus');
expect(payload.regUpdatesExpired).toBe(true);
expect(payload.state).toBe('PLUS');
expect(payload.tpmGuid).toBe('01-TPM-GUID-1');
expect(payload.wanFQDN).toBe('test.myunraid.net');
});

Expand Down
16 changes: 11 additions & 5 deletions web/src/store/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import { useThemeStore } from '~/store/theme';
import { useUnraidApiStore } from '~/store/unraidApi';
import { getRegistrationDeviceLimit, normalizeRegistrationType } from '~/utils/registration';

type ServerCallbackPayload = ServerData & Pick<Server, 'flashGuid' | 'tpmGuid'>;

export const useServerStore = defineStore('server', () => {
const { t } = useI18n();
const accountStore = useAccountStore();
Expand Down Expand Up @@ -246,13 +248,16 @@ export const useServerStore = defineStore('server', () => {
}
};

const buildServerCallbackPayload = (overrides: Partial<ServerData> = {}): ServerData => {
const payload: ServerData = {
const buildServerCallbackPayload = (
overrides: Partial<ServerCallbackPayload> = {}
): ServerCallbackPayload => {
const payload: ServerCallbackPayload = {
connectPluginVersion: connectPluginVersion.value || undefined,
connectState: getConnectState(),
description: description.value,
deviceCount: deviceCount.value,
expireTime: expireTime.value,
flashGuid: flashGuid.value || undefined,
flashProduct: flashProduct.value,
flashVendor: flashVendor.value,
guid: guid.value,
Expand All @@ -268,6 +273,7 @@ export const useServerStore = defineStore('server', () => {
regTy: regTy.value,
regUpdatesExpired: regUpdatesExpired.value,
state: state.value,
tpmGuid: tpmGuid.value || undefined,
wanFQDN: wanFQDN.value,
...overrides,
};
Expand All @@ -294,12 +300,12 @@ export const useServerStore = defineStore('server', () => {
};
};

const serverPurchasePayload = computed((): ServerData => buildServerCallbackPayload());
const serverPurchasePayload = computed((): ServerCallbackPayload => buildServerCallbackPayload());

const serverAccountPayload = computed((): ServerData => buildServerCallbackPayload());
const serverAccountPayload = computed((): ServerCallbackPayload => buildServerCallbackPayload());

const serverReplacePayload = computed(
(): ServerData => ({
(): ServerCallbackPayload => ({
...buildServerCallbackPayload({
guid: replaceFlashGuid.value,
}),
Expand Down
Loading