-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(editor): Render the current first in CollaborationPane (no-change…
…log) (#10799)
- Loading branch information
Showing
2 changed files
with
25 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,29 @@ | ||
import { merge } from 'lodash-es'; | ||
import { SETTINGS_STORE_DEFAULT_STATE, waitAllPromises } from '@/__tests__/utils'; | ||
import { ROLE, STORES } from '@/constants'; | ||
import { createTestingPinia } from '@pinia/testing'; | ||
import CollaborationPane from '@/components//MainHeader/CollaborationPane.vue'; | ||
import { mock } from 'vitest-mock-extended'; | ||
|
||
import { STORES } from '@/constants'; | ||
import CollaborationPane from '@/components/MainHeader/CollaborationPane.vue'; | ||
import type { IUser } from '@/Interface'; | ||
|
||
import type { RenderOptions } from '@/__tests__/render'; | ||
import { createComponentRenderer } from '@/__tests__/render'; | ||
import { waitAllPromises } from '@/__tests__/utils'; | ||
|
||
const OWNER_USER = { | ||
createdAt: '2023-11-22T10:17:12.246Z', | ||
id: 'aaaaaa', | ||
email: '[email protected]', | ||
firstName: 'Owner', | ||
lastName: 'User', | ||
role: ROLE.Owner, | ||
disabled: false, | ||
isPending: false, | ||
fullName: 'Owner User', | ||
}; | ||
|
||
const MEMBER_USER = { | ||
createdAt: '2023-11-22T10:17:12.246Z', | ||
id: 'aaabbb', | ||
email: '[email protected]', | ||
firstName: 'Member', | ||
lastName: 'User', | ||
role: ROLE.Member, | ||
disabled: false, | ||
isPending: false, | ||
fullName: 'Member User', | ||
}; | ||
|
||
const MEMBER_USER_2 = { | ||
createdAt: '2023-11-22T10:17:12.246Z', | ||
id: 'aaaccc', | ||
email: '[email protected]', | ||
firstName: 'Another Member', | ||
lastName: 'User', | ||
role: ROLE.Member, | ||
disabled: false, | ||
isPending: false, | ||
fullName: 'Another Member User', | ||
}; | ||
const OWNER_USER = mock<IUser>({ id: 'owner-id' }); | ||
const MEMBER_USER = mock<IUser>({ id: 'member-id' }); | ||
const MEMBER_USER_2 = mock<IUser>({ id: 'member-id-2' }); | ||
|
||
const initialState = { | ||
[STORES.SETTINGS]: { | ||
settings: merge({}, SETTINGS_STORE_DEFAULT_STATE.settings), | ||
}, | ||
[STORES.WORKFLOWS]: { | ||
workflow: { | ||
id: 'w1', | ||
}, | ||
}, | ||
[STORES.USERS]: { | ||
currentUserId: 'aaaaaa', | ||
users: { | ||
aaaaaa: OWNER_USER, | ||
aaabbb: MEMBER_USER, | ||
aaaccc: MEMBER_USER_2, | ||
currentUserId: OWNER_USER.id, | ||
usersById: { | ||
[OWNER_USER.id]: OWNER_USER, | ||
[MEMBER_USER.id]: MEMBER_USER, | ||
[MEMBER_USER_2.id]: MEMBER_USER_2, | ||
}, | ||
}, | ||
[STORES.COLLABORATION]: { | ||
collaborators: [ | ||
{ lastSeen: '2023-11-22T10:17:12.246Z', user: MEMBER_USER }, | ||
{ lastSeen: '2023-11-22T10:17:12.246Z', user: OWNER_USER }, | ||
], | ||
collaborators: [{ user: MEMBER_USER }, { user: OWNER_USER }], | ||
}, | ||
}; | ||
|
||
|
@@ -89,9 +49,10 @@ describe('CollaborationPane', () => { | |
expect(queryByTestId(`user-stack-avatar-${MEMBER_USER_2.id}`)).toBeNull(); | ||
}); | ||
|
||
it('should always render owner first in the list', async () => { | ||
it('should always render the current user first in the list', async () => { | ||
const { getByTestId } = renderComponent(); | ||
await waitAllPromises(); | ||
|
||
const firstAvatar = getByTestId('user-stack-avatars').querySelector('.n8n-avatar'); | ||
// Owner is second in the store but should be rendered first | ||
expect(firstAvatar).toHaveAttribute('data-test-id', `user-stack-avatar-${OWNER_USER.id}`); | ||
|
@@ -103,7 +64,7 @@ describe('CollaborationPane', () => { | |
initialState: { | ||
...initialState, | ||
[STORES.COLLABORATION]: { | ||
collaborators: [{ lastSeen: '2023-11-22T10:17:12.246Z', user: OWNER_USER }], | ||
collaborators: [{ user: OWNER_USER }], | ||
}, | ||
}, | ||
}), | ||
|