Merge branch 'api-refactor' into shigusegubu-themes3
This commit is contained in:
commit
635b58b7d6
6 changed files with 67 additions and 70 deletions
|
|
@ -339,14 +339,14 @@ export const fetchFavoritedByUsers = ({ id, credentials }) =>
|
|||
url: MASTODON_STATUS_FAVORITEDBY_URL(id),
|
||||
method: 'GET',
|
||||
credentials,
|
||||
}).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) }))
|
||||
}).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) }))
|
||||
|
||||
export const fetchRebloggedByUsers = ({ id, credentials }) =>
|
||||
promisedRequest({
|
||||
url: MASTODON_STATUS_REBLOGGEDBY_URL(id),
|
||||
method: 'GET',
|
||||
credentials,
|
||||
}).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) }))
|
||||
}).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) }))
|
||||
|
||||
export const fetchEmojiReactions = ({ id, credentials }) =>
|
||||
promisedRequest({
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ const MASTODON_DENY_USER_URL = (id) => `/api/v1/follow_requests/${id}/reject`
|
|||
const MASTODON_USER_RELATIONSHIPS_URL = ({ id, withSuspended }) =>
|
||||
`/api/v1/accounts/relationships/${paramsString({ id, withSuspended })}`
|
||||
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`
|
||||
const MASTODON_USER_BLOCKS_URL = ({
|
||||
maxId,
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ const conversation = {
|
|||
fetchConversation({
|
||||
id: this.statusId,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then(({ ancestors, descendants }) => {
|
||||
}).then(({ data: { ancestors, descendants } }) => {
|
||||
this.$store.dispatch('addNewStatuses', { statuses: ancestors })
|
||||
this.$store.dispatch('addNewStatuses', { statuses: descendants })
|
||||
this.setHighlight(this.originalStatusId)
|
||||
|
|
@ -456,7 +456,7 @@ const conversation = {
|
|||
id: this.statusId,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
.then((status) => {
|
||||
.then(({ data: status }) => {
|
||||
this.$store.dispatch('addNewStatuses', { statuses: [status] })
|
||||
this.fetchConversation()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -788,12 +788,12 @@ const statuses = {
|
|||
fetchFavoritedByUsers({
|
||||
id,
|
||||
credentials: useOAuthStore().token,
|
||||
}),
|
||||
}).then(({ data }) => data),
|
||||
fetchRebloggedByUsers({
|
||||
id,
|
||||
credentials: useOAuthStore().token,
|
||||
}),
|
||||
]).then(([{ data: favoritedByUsers }, { data: rebloggedByUsers }]) => {
|
||||
}).then(({ data }) => data),,
|
||||
]).then(([favoritedByUsers, rebloggedByUsers]) => {
|
||||
commit('addFavs', {
|
||||
id,
|
||||
favoritedByUsers,
|
||||
|
|
|
|||
|
|
@ -244,7 +244,6 @@ export const _mergeJournal = (...journals) => {
|
|||
}
|
||||
})
|
||||
.map((x) => x.data)
|
||||
console.log(journal)
|
||||
|
||||
if (path.startsWith('collections')) {
|
||||
const lastRemoveIndex = findLastIndex(
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { createTestingPinia } from '@pinia/testing'
|
|||
import { HttpResponse, http } from 'msw'
|
||||
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'
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ describe('The lists store', () => {
|
|||
})
|
||||
|
||||
describe('actions', () => {
|
||||
mockedIt('updates array of all lists', () => {
|
||||
it('updates array of all lists', () => {
|
||||
const list = { id: '1', title: 'testList' }
|
||||
|
||||
store.setLists([list])
|
||||
|
|
@ -25,74 +25,72 @@ describe('The lists store', () => {
|
|||
expect(store.allLists).to.eql([list])
|
||||
})
|
||||
|
||||
mockedIt(
|
||||
'adds a new list with a title, updating the title for existing lists',
|
||||
async ({ worker }) => {
|
||||
const list = { id: '1', title: 'testList' }
|
||||
const modList = { id: '1', title: 'anotherTestTitle' }
|
||||
it('adds a new list with a title, updating the title for existing lists', async ({
|
||||
worker,
|
||||
}) => {
|
||||
const list = { id: '1', title: 'testList' }
|
||||
const modList = { id: '1', title: 'anotherTestTitle' }
|
||||
|
||||
worker.use(
|
||||
http.put(MASTODON_LIST_URL(':id'), () =>
|
||||
HttpResponse.json({ ok: true }),
|
||||
),
|
||||
)
|
||||
console.log('1 =========', worker.listHandlers())
|
||||
worker.use(
|
||||
http.put(MASTODON_LIST_URL(':id'), () =>
|
||||
HttpResponse.json({ ok: true }),
|
||||
),
|
||||
)
|
||||
console.log('1 =========', worker.listHandlers())
|
||||
|
||||
await store.setList({ listId: list.id, title: list.title })
|
||||
expect(store.allListsObject[list.id]).to.eql({
|
||||
title: list.title,
|
||||
accountIds: [],
|
||||
})
|
||||
expect(store.allLists).to.have.length(1)
|
||||
expect(store.allLists[0]).to.eql(list)
|
||||
await store.setList({ listId: list.id, title: list.title })
|
||||
expect(store.allListsObject[list.id]).to.eql({
|
||||
title: list.title,
|
||||
accountIds: [],
|
||||
})
|
||||
expect(store.allLists).to.have.length(1)
|
||||
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 })
|
||||
expect(store.allListsObject[modList.id]).to.eql({
|
||||
title: modList.title,
|
||||
accountIds: [],
|
||||
})
|
||||
expect(store.allLists).to.have.length(1)
|
||||
expect(store.allLists[0]).to.eql(modList)
|
||||
await store.setList({ listId: modList.id, title: modList.title })
|
||||
expect(store.allListsObject[modList.id]).to.eql({
|
||||
title: modList.title,
|
||||
accountIds: [],
|
||||
})
|
||||
expect(store.allLists).to.have.length(1)
|
||||
expect(store.allLists[0]).to.eql(modList)
|
||||
|
||||
console.log('3 =========', worker.listHandlers())
|
||||
},
|
||||
)
|
||||
console.log('3 =========', worker.listHandlers())
|
||||
})
|
||||
|
||||
mockedIt(
|
||||
'adds a new list with an array of IDs, updating the IDs for existing lists',
|
||||
async ({ worker }) => {
|
||||
const list = { id: '1', accountIds: ['1', '2', '3'] }
|
||||
const modList = { id: '1', accountIds: ['3', '4', '5'] }
|
||||
it('adds a new list with an array of IDs, updating the IDs for existing lists', async ({
|
||||
worker,
|
||||
}) => {
|
||||
const list = { id: '1', accountIds: ['1', '2', '3'] }
|
||||
const modList = { id: '1', accountIds: ['3', '4', '5'] }
|
||||
|
||||
worker.use(
|
||||
http.post(MASTODON_LIST_ACCOUNTS_URL(':id'), () =>
|
||||
HttpResponse.json({ ok: true }),
|
||||
),
|
||||
http.delete(MASTODON_LIST_ACCOUNTS_URL(':id'), () =>
|
||||
HttpResponse.json({ ok: true }),
|
||||
),
|
||||
)
|
||||
worker.use(
|
||||
http.post(MASTODON_LIST_ACCOUNTS_URL(':id'), () =>
|
||||
HttpResponse.json({ ok: true }),
|
||||
),
|
||||
http.delete(MASTODON_LIST_ACCOUNTS_URL(':id'), () =>
|
||||
HttpResponse.json({ ok: true }),
|
||||
),
|
||||
)
|
||||
|
||||
await store.setListAccounts({
|
||||
listId: list.id,
|
||||
accountIds: list.accountIds,
|
||||
})
|
||||
expect(store.allListsObject[list.id].accountIds).to.eql(list.accountIds)
|
||||
await store.setListAccounts({
|
||||
listId: list.id,
|
||||
accountIds: list.accountIds,
|
||||
})
|
||||
expect(store.allListsObject[list.id].accountIds).to.eql(list.accountIds)
|
||||
|
||||
await store.setListAccounts({
|
||||
listId: modList.id,
|
||||
accountIds: modList.accountIds,
|
||||
})
|
||||
await store.setListAccounts({
|
||||
listId: modList.id,
|
||||
accountIds: modList.accountIds,
|
||||
})
|
||||
|
||||
expect(store.allListsObject[modList.id].accountIds).to.eql(
|
||||
modList.accountIds,
|
||||
)
|
||||
},
|
||||
)
|
||||
expect(store.allListsObject[modList.id].accountIds).to.eql(
|
||||
modList.accountIds,
|
||||
)
|
||||
})
|
||||
|
||||
mockedIt('deletes a list', async ({ worker }) => {
|
||||
it('deletes a list', async ({ worker }) => {
|
||||
store.$patch({
|
||||
allLists: [{ id: '1', title: 'testList' }],
|
||||
allListsObject: {
|
||||
|
|
@ -114,7 +112,7 @@ describe('The lists store', () => {
|
|||
})
|
||||
|
||||
describe('getters', () => {
|
||||
mockedIt('returns list title', () => {
|
||||
it('returns list title', () => {
|
||||
store.$patch({
|
||||
allLists: [{ id: '1', title: 'testList' }],
|
||||
allListsObject: {
|
||||
|
|
@ -126,7 +124,7 @@ describe('The lists store', () => {
|
|||
expect(store.findListTitle(id)).to.eql('testList')
|
||||
})
|
||||
|
||||
mockedIt('returns list accounts', () => {
|
||||
it('returns list accounts', () => {
|
||||
store.$patch({
|
||||
allLists: [{ id: '1', title: 'testList' }],
|
||||
allListsObject: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue