This commit is contained in:
Henry Jameson 2026-06-18 20:53:21 +03:00
commit fe1790f217
6 changed files with 67 additions and 70 deletions

View file

@ -339,14 +339,14 @@ export const fetchFavoritedByUsers = ({ id, credentials }) =>
url: MASTODON_STATUS_FAVORITEDBY_URL(id), url: MASTODON_STATUS_FAVORITEDBY_URL(id),
method: 'GET', method: 'GET',
credentials, credentials,
}).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) })) }).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) }))
export const fetchRebloggedByUsers = ({ id, credentials }) => export const fetchRebloggedByUsers = ({ id, credentials }) =>
promisedRequest({ promisedRequest({
url: MASTODON_STATUS_REBLOGGEDBY_URL(id), url: MASTODON_STATUS_REBLOGGEDBY_URL(id),
method: 'GET', method: 'GET',
credentials, credentials,
}).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) })) }).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) }))
export const fetchEmojiReactions = ({ id, credentials }) => export const fetchEmojiReactions = ({ id, credentials }) =>
promisedRequest({ promisedRequest({

View file

@ -44,7 +44,7 @@ const MASTODON_DENY_USER_URL = (id) => `/api/v1/follow_requests/${id}/reject`
const MASTODON_USER_RELATIONSHIPS_URL = ({ id, withSuspended }) => const MASTODON_USER_RELATIONSHIPS_URL = ({ id, withSuspended }) =>
`/api/v1/accounts/relationships/${paramsString({ id, withSuspended })}` `/api/v1/accounts/relationships/${paramsString({ id, withSuspended })}`
const MASTODON_USER_IN_LISTS = (id) => `/api/v1/accounts/${id}/lists` const MASTODON_USER_IN_LISTS = (id) => `/api/v1/accounts/${id}/lists`
export const MASTODON_LIST_URL = (id) => `/api/v1/lists/${id}` export const MASTODON_LIST_URL = (id = '') => `/api/v1/lists/${id}`
export const MASTODON_LIST_ACCOUNTS_URL = (id) => `/api/v1/lists/${id}/accounts` export const MASTODON_LIST_ACCOUNTS_URL = (id) => `/api/v1/lists/${id}/accounts`
const MASTODON_USER_BLOCKS_URL = ({ const MASTODON_USER_BLOCKS_URL = ({
maxId, maxId,

View file

@ -445,7 +445,7 @@ const conversation = {
fetchConversation({ fetchConversation({
id: this.statusId, id: this.statusId,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then(({ ancestors, descendants }) => { }).then(({ data: { ancestors, descendants } }) => {
this.$store.dispatch('addNewStatuses', { statuses: ancestors }) this.$store.dispatch('addNewStatuses', { statuses: ancestors })
this.$store.dispatch('addNewStatuses', { statuses: descendants }) this.$store.dispatch('addNewStatuses', { statuses: descendants })
this.setHighlight(this.originalStatusId) this.setHighlight(this.originalStatusId)
@ -456,7 +456,7 @@ const conversation = {
id: this.statusId, id: this.statusId,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}) })
.then((status) => { .then(({ data: status }) => {
this.$store.dispatch('addNewStatuses', { statuses: [status] }) this.$store.dispatch('addNewStatuses', { statuses: [status] })
this.fetchConversation() this.fetchConversation()
}) })

View file

@ -788,12 +788,12 @@ const statuses = {
fetchFavoritedByUsers({ fetchFavoritedByUsers({
id, id,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}), }).then(({ data }) => data),
fetchRebloggedByUsers({ fetchRebloggedByUsers({
id, id,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}), }).then(({ data }) => data),,
]).then(([{ data: favoritedByUsers }, { data: rebloggedByUsers }]) => { ]).then(([favoritedByUsers, rebloggedByUsers]) => {
commit('addFavs', { commit('addFavs', {
id, id,
favoritedByUsers, favoritedByUsers,

View file

@ -244,7 +244,6 @@ export const _mergeJournal = (...journals) => {
} }
}) })
.map((x) => x.data) .map((x) => x.data)
console.log(journal)
if (path.startsWith('collections')) { if (path.startsWith('collections')) {
const lastRemoveIndex = findLastIndex( const lastRemoveIndex = findLastIndex(

View file

@ -2,7 +2,7 @@ import { createTestingPinia } from '@pinia/testing'
import { HttpResponse, http } from 'msw' import { HttpResponse, http } from 'msw'
import { setActivePinia } from 'pinia' import { setActivePinia } from 'pinia'
import { test as mockedIt } from '/test/fixtures/mock_api.js' import { test as it } from '/test/fixtures/mock_api.js'
import { useListsStore } from 'src/stores/lists.js' import { useListsStore } from 'src/stores/lists.js'
@ -17,7 +17,7 @@ describe('The lists store', () => {
}) })
describe('actions', () => { describe('actions', () => {
mockedIt('updates array of all lists', () => { it('updates array of all lists', () => {
const list = { id: '1', title: 'testList' } const list = { id: '1', title: 'testList' }
store.setLists([list]) store.setLists([list])
@ -25,74 +25,72 @@ describe('The lists store', () => {
expect(store.allLists).to.eql([list]) expect(store.allLists).to.eql([list])
}) })
mockedIt( it('adds a new list with a title, updating the title for existing lists', async ({
'adds a new list with a title, updating the title for existing lists', worker,
async ({ worker }) => { }) => {
const list = { id: '1', title: 'testList' } const list = { id: '1', title: 'testList' }
const modList = { id: '1', title: 'anotherTestTitle' } const modList = { id: '1', title: 'anotherTestTitle' }
worker.use( worker.use(
http.put(MASTODON_LIST_URL(':id'), () => http.put(MASTODON_LIST_URL(':id'), () =>
HttpResponse.json({ ok: true }), HttpResponse.json({ ok: true }),
), ),
) )
console.log('1 =========', worker.listHandlers()) console.log('1 =========', worker.listHandlers())
await store.setList({ listId: list.id, title: list.title }) await store.setList({ listId: list.id, title: list.title })
expect(store.allListsObject[list.id]).to.eql({ expect(store.allListsObject[list.id]).to.eql({
title: list.title, title: list.title,
accountIds: [], accountIds: [],
}) })
expect(store.allLists).to.have.length(1) expect(store.allLists).to.have.length(1)
expect(store.allLists[0]).to.eql(list) expect(store.allLists[0]).to.eql(list)
console.log('2 =========', worker.listHandlers()) console.log('2 =========', worker.listHandlers())
await store.setList({ listId: modList.id, title: modList.title }) await store.setList({ listId: modList.id, title: modList.title })
expect(store.allListsObject[modList.id]).to.eql({ expect(store.allListsObject[modList.id]).to.eql({
title: modList.title, title: modList.title,
accountIds: [], accountIds: [],
}) })
expect(store.allLists).to.have.length(1) expect(store.allLists).to.have.length(1)
expect(store.allLists[0]).to.eql(modList) expect(store.allLists[0]).to.eql(modList)
console.log('3 =========', worker.listHandlers()) console.log('3 =========', worker.listHandlers())
}, })
)
mockedIt( it('adds a new list with an array of IDs, updating the IDs for existing lists', async ({
'adds a new list with an array of IDs, updating the IDs for existing lists', worker,
async ({ worker }) => { }) => {
const list = { id: '1', accountIds: ['1', '2', '3'] } const list = { id: '1', accountIds: ['1', '2', '3'] }
const modList = { id: '1', accountIds: ['3', '4', '5'] } const modList = { id: '1', accountIds: ['3', '4', '5'] }
worker.use( worker.use(
http.post(MASTODON_LIST_ACCOUNTS_URL(':id'), () => http.post(MASTODON_LIST_ACCOUNTS_URL(':id'), () =>
HttpResponse.json({ ok: true }), HttpResponse.json({ ok: true }),
), ),
http.delete(MASTODON_LIST_ACCOUNTS_URL(':id'), () => http.delete(MASTODON_LIST_ACCOUNTS_URL(':id'), () =>
HttpResponse.json({ ok: true }), HttpResponse.json({ ok: true }),
), ),
) )
await store.setListAccounts({ await store.setListAccounts({
listId: list.id, listId: list.id,
accountIds: list.accountIds, accountIds: list.accountIds,
}) })
expect(store.allListsObject[list.id].accountIds).to.eql(list.accountIds) expect(store.allListsObject[list.id].accountIds).to.eql(list.accountIds)
await store.setListAccounts({ await store.setListAccounts({
listId: modList.id, listId: modList.id,
accountIds: modList.accountIds, accountIds: modList.accountIds,
}) })
expect(store.allListsObject[modList.id].accountIds).to.eql( expect(store.allListsObject[modList.id].accountIds).to.eql(
modList.accountIds, modList.accountIds,
) )
}, })
)
mockedIt('deletes a list', async ({ worker }) => { it('deletes a list', async ({ worker }) => {
store.$patch({ store.$patch({
allLists: [{ id: '1', title: 'testList' }], allLists: [{ id: '1', title: 'testList' }],
allListsObject: { allListsObject: {
@ -114,7 +112,7 @@ describe('The lists store', () => {
}) })
describe('getters', () => { describe('getters', () => {
mockedIt('returns list title', () => { it('returns list title', () => {
store.$patch({ store.$patch({
allLists: [{ id: '1', title: 'testList' }], allLists: [{ id: '1', title: 'testList' }],
allListsObject: { allListsObject: {
@ -126,7 +124,7 @@ describe('The lists store', () => {
expect(store.findListTitle(id)).to.eql('testList') expect(store.findListTitle(id)).to.eql('testList')
}) })
mockedIt('returns list accounts', () => { it('returns list accounts', () => {
store.$patch({ store.$patch({
allLists: [{ id: '1', title: 'testList' }], allLists: [{ id: '1', title: 'testList' }],
allListsObject: { allListsObject: {