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
8 changes: 8 additions & 0 deletions src/pages/AccountList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ async function loadList(): Promise<void> {
if (savedKey !== null) {
account.applyServiceAccountOrderFromSavedCsv(configStore.get(savedKey))
}

// Auto-select the first enabled account after load — mirrors WPF
// which defaults SelectedIndex to 0 on `redrawSAccountList`.
if (!account.selectedSid && account.serviceAccounts.length > 0) {
const first = account.serviceAccounts.find((a) => a.is_enable)
if (first) account.selectedSid = first.sid
}

loadState.value = 'ready'
} catch (err) {
/*
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/pages/AccountList.EnterHotkey.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ describe('AccountList — Enter hotkey (B6 / WPF parity)', () => {
const wrapper = await buildHarness().mountIt()
await flushPromises()

// Clear auto-selected account to test the "no selection" guard.
useAccountStore().selectedSid = null

dispatchEnter()
await flushPromises()

Expand Down
21 changes: 11 additions & 10 deletions tests/unit/pages/AccountList.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ describe('AccountList page', () => {
await flushPromises()

const account = useAccountStore()
expect(account.selectedSid).toBeNull()
expect(account.selectedSid).toBe('sid-1')

await wrapper.get('[data-test="account-row-sid-2"]').trigger('click')

Expand All @@ -914,7 +914,7 @@ describe('AccountList page', () => {
const account = useAccountStore()
await wrapper.get('[data-test="account-row-sid-3"]').trigger('click')

expect(account.selectedSid).toBeNull()
expect(account.selectedSid).toBe('sid-1')
})

it('logout: confirm → auth.logout → account.clearSessionData → /login', async () => {
Expand Down Expand Up @@ -1062,12 +1062,12 @@ describe('AccountList page', () => {
await flushPromises()

const account = useAccountStore()
expect(account.selectedSid).toBeNull()
expect(account.selectedSid).toBe('sid-1')

await wrapper.get('[data-test="account-row-change-alias-sid-2"]').trigger('click')
await flushPromises()

expect(account.selectedSid).toBeNull()
expect(account.selectedSid).toBe('sid-1')
})

it('row context menu Account Info → opens dialog with the row account (D6 wiring)', async () => {
Expand Down Expand Up @@ -1127,12 +1127,12 @@ describe('AccountList page', () => {
await flushPromises()

const account = useAccountStore()
expect(account.selectedSid).toBeNull()
expect(account.selectedSid).toBe('sid-1')

await wrapper.get('[data-test="account-row-info-sid-2"]').trigger('click')
await flushPromises()

expect(account.selectedSid).toBeNull()
expect(account.selectedSid).toBe('sid-1')
})

/* ---------------------------------------------------------------- */
Expand Down Expand Up @@ -1307,9 +1307,10 @@ describe('AccountList page', () => {
const wrapper = await ctx.mountIt()
await flushPromises()

/* No row selected after the initial fetch. */
/* Auto-select picks the first enabled row; clear it to test the
* "no selection" guard. */
const account = useAccountStore()
expect(account.selectedSid).toBeNull()
account.selectedSid = null

await wrapper.get('[data-test="account-list-otp-get"]').trigger('click')
await flushPromises()
Expand Down Expand Up @@ -2066,8 +2067,8 @@ describe('AccountList page', () => {
expect(commands.setActiveService).toHaveBeenCalledWith('610099', 'T9')
/* (b) Account list reloaded for the new game. */
expect(commands.getAccounts).toHaveBeenCalledTimes(1)
/* (c) Stale selection cleared. */
expect(useAccountStore().selectedSid).toBeNull()
/* (c) Selection auto-picks first enabled account after reload. */
expect(useAccountStore().selectedSid).toBe('sid-1')
/* (d) Game switch reflected in the gameStore. */
expect(useGameStore().selectedGameCode).toBe('610099_T9')
/* Picker stays closed — the saved value resolved cleanly. */
Expand Down
Loading