Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue rewrite #748

Merged
merged 135 commits into from
Oct 24, 2023
Merged
Changes from 1 commit
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
b036d30
Vue Rewrite
May 15, 2022
40d9c35
[Vue Rewrite] Fix CI Jobs (#1816)
devlinjunker Jun 9, 2022
f1668df
[Vue Rewrite] Enable Typescript Vue Components (#1831)
devlinjunker Jul 4, 2022
42e9b47
change linting rule from spaces to tabs to match typical vue linting
devlinjunker Jul 1, 2022
a59f0fd
remove unecessary eslint rule
devlinjunker Jul 1, 2022
56ffba7
revert feeds.en.json
devlinjunker Sep 30, 2022
a71fc67
fix editor config and spaces inside of quotes
devlinjunker Oct 3, 2022
d248289
move all components to typescript 'Vue.extend({ ... ' syntax
devlinjunker Jul 1, 2022
fe62ff2
move types to separate files
devlinjunker Jul 1, 2022
08d12e5
running single test
devlinjunker Sep 30, 2022
a81cd40
clean up linting errors
devlinjunker Oct 3, 2022
902ff04
outline Sidebar specs
devlinjunker Oct 3, 2022
6557bb2
test file for each component
devlinjunker Oct 7, 2022
2be4f28
use newer libraries and clean up eslint
devlinjunker Oct 27, 2022
182897b
clean up dependencies
devlinjunker Oct 27, 2022
431236b
more package cleanup and some basic tests for Sidebar
devlinjunker Oct 27, 2022
3bf3bc1
fix tests with proper mocking
devlinjunker Oct 27, 2022
3138412
import -> require
devlinjunker Oct 27, 2022
d7aa5e1
fix linting
devlinjunker Oct 27, 2022
0fe2d49
update changelog
devlinjunker Oct 27, 2022
760c442
remove unecessary lines
devlinjunker Nov 1, 2022
c6b4bcc
upmerging master into vue-rewrite
devlinjunker Nov 10, 2022
7753837
ensure admin settings page is working
devlinjunker Nov 10, 2022
e4ada33
run npm install with node 18
devlinjunker Nov 10, 2022
234b975
fix linting
devlinjunker Nov 11, 2022
095176f
fix extraneous import error
devlinjunker Nov 11, 2022
167e7b6
Merge branch 'master' into vue-rewrite
Grotax Nov 21, 2022
8351293
update language files from master
Grotax Nov 21, 2022
01d15ae
fix admin page getRequestToken() call
devlinjunker Nov 17, 2022
a12e334
add unit tests for admin settings
devlinjunker Nov 21, 2022
208cfa8
add unit tests for admin settings
devlinjunker Nov 22, 2022
5bf6407
add back translate to admin main js file
devlinjunker Nov 22, 2022
c61d4bb
use single quotes
devlinjunker Nov 22, 2022
b77284d
clean
devlinjunker Nov 22, 2022
db8b4af
move to dev dependencies
devlinjunker Nov 23, 2022
604e4e0
moved store to separate file and started using constants for action/m…
devlinjunker Nov 28, 2022
83fe713
split store into multiple files
devlinjunker Nov 29, 2022
c522bac
cleanup and renaming
devlinjunker Nov 29, 2022
c0bc5ec
clean
devlinjunker Nov 29, 2022
28ead9d
modularize store files and fix unit tests
devlinjunker Nov 29, 2022
f657698
working unit test for local computed state
devlinjunker Nov 29, 2022
8131604
lint the .ts and spec.ts files also
devlinjunker Dec 1, 2022
4899be3
add more tests
devlinjunker Dec 3, 2022
2c32ea0
start on state/store tests
devlinjunker Dec 3, 2022
e61fb48
basic tests for store
devlinjunker Dec 4, 2022
404b636
clean
devlinjunker Dec 4, 2022
4fb5426
clean up linting warnings
devlinjunker Dec 4, 2022
c975b93
clean
devlinjunker Dec 4, 2022
d9532e3
clean up commented out lines
devlinjunker Dec 4, 2022
05ad544
lint
devlinjunker Dec 4, 2022
cec1827
fix admin tests
devlinjunker Dec 4, 2022
f517bc3
split out routing and add another route
devlinjunker Dec 4, 2022
450047e
rename to typescript file
devlinjunker Dec 15, 2022
923f986
upmerged from master
devlinjunker Aug 6, 2023
eeb0638
fix unit test and linting errors
devlinjunker Aug 6, 2023
b9a5887
resolve build issues
devlinjunker Aug 7, 2023
9a047cb
minimum nextcloud version supported is 27
devlinjunker Aug 8, 2023
10c8917
add feed pretty much works
devlinjunker Aug 6, 2023
67d687c
cleanup of angular directives
devlinjunker Aug 7, 2023
9b11141
clean up
devlinjunker Aug 7, 2023
0b4232c
fix formatting
devlinjunker Aug 7, 2023
9377e89
finished unit tests
devlinjunker Aug 8, 2023
8fe0bb2
fix indentation
devlinjunker Aug 8, 2023
770720a
clean up comments
devlinjunker Aug 8, 2023
da782c0
fix indentation
devlinjunker Aug 8, 2023
2287835
use eslint --fix to clean up linting errors
devlinjunker Aug 8, 2023
3f1fb5b
fix add + create folder
devlinjunker Aug 8, 2023
790701a
fix wrong property
devlinjunker Aug 9, 2023
e559cb3
fix linting errors
devlinjunker Aug 9, 2023
9c79d64
fix php unit test
devlinjunker Aug 9, 2023
0dd27dd
started on fetching starred items from backend and displaying with fo…
devlinjunker Aug 9, 2023
6693681
basic starred items list with VirtualScroll component
devlinjunker Aug 15, 2023
05e2e73
some cleanup and improvements
devlinjunker Aug 15, 2023
41213ad
css effects
devlinjunker Aug 15, 2023
d14dbe3
match style from current app
devlinjunker Aug 15, 2023
99a08b3
start on user actions and some more cleanup
devlinjunker Aug 16, 2023
4fa0a87
connect actions to backend
devlinjunker Aug 16, 2023
0bfb616
cleanup unused stuff
devlinjunker Aug 16, 2023
efb1ac2
basic unit tests
devlinjunker Aug 16, 2023
9272190
add unread route and component
devlinjunker Aug 21, 2023
726c157
cleanup and rename FeedItemRow component
devlinjunker Aug 21, 2023
fd72a20
add logic to fetch more starred
devlinjunker Aug 21, 2023
26488e8
Add FeedItemDisplayList component
devlinjunker Aug 22, 2023
3f34e3d
css tweaks
devlinjunker Aug 23, 2023
8183510
More cleanup and started on unit tests
devlinjunker Aug 24, 2023
d4d20e9
Add more unit tests and all passing
devlinjunker Aug 25, 2023
bb154d0
add Feed component and filtering in FeedItemDisplayList
devlinjunker Aug 25, 2023
83f99de
basic unit tests
devlinjunker Aug 27, 2023
a3077f1
fix loading bug and move to feed-display directory
devlinjunker Aug 31, 2023
6111aca
add comments and remove start parameter
devlinjunker Aug 31, 2023
e2e8ae5
move backend call details to services
devlinjunker Sep 1, 2023
5caefba
add routes for folder items and all items
devlinjunker Sep 1, 2023
7e21dc8
cleanup sidebar and translations
devlinjunker Sep 3, 2023
dce0701
add unit tests and little more cleanup of uncessary lines
devlinjunker Sep 4, 2023
fe03478
start hooking up actions to backend
devlinjunker Sep 7, 2023
9d629b9
adding pinned feeds
devlinjunker Sep 14, 2023
4b24d05
3 more feed actions
devlinjunker Sep 14, 2023
ac33e7c
remaining feed actions
devlinjunker Sep 14, 2023
4f5004e
all sidebar actions working
devlinjunker Sep 15, 2023
eb9dd0a
confirm mark all read and feed counter inside folder
devlinjunker Sep 15, 2023
b234f33
start on tests
devlinjunker Sep 15, 2023
6aa282d
store tests
devlinjunker Sep 16, 2023
84e891b
finish unit tests
devlinjunker Sep 16, 2023
a2ad3df
add all icons
devlinjunker Sep 16, 2023
2ebd898
ignore vue files for stylelint (probably need to remove old css files…
devlinjunker Sep 18, 2023
b7179b5
working share component
devlinjunker Sep 26, 2023
816ef83
reuse ShareItem component in FeedItemDisplay
devlinjunker Sep 26, 2023
74eb315
use translation method params for relative timestamp
devlinjunker Sep 26, 2023
ba9d512
tests
devlinjunker Sep 26, 2023
e16ab4a
add warning message generated with PHP, also check for subcribe_to pa…
devlinjunker Sep 25, 2023
2c7ffa8
fix tests
devlinjunker Sep 27, 2023
e6f5edb
fix whitespace
devlinjunker Sep 28, 2023
0aa4b10
Merge branch 'vue-rewrite' into share-item
devlinjunker Oct 1, 2023
883b7b5
fix length of line
devlinjunker Oct 3, 2023
bcb3dcb
Merge pull request #2361 from devlinjunker/share-item
devlinjunker Oct 4, 2023
ed69499
tested with audio and video feeds
devlinjunker Sep 28, 2023
b6a4293
add unit tests
devlinjunker Sep 28, 2023
06e373b
start on mobile view
devlinjunker Oct 5, 2023
2ed0df3
add box-shadow and other cleanups
devlinjunker Oct 5, 2023
2309c80
remove unecessary class
devlinjunker Oct 5, 2023
e737236
smaller date font size
devlinjunker Oct 5, 2023
00d1d65
display vue errors and axios errors in top right popover
devlinjunker Oct 4, 2023
498c001
cleanup
devlinjunker Oct 4, 2023
991facf
tests and some cleanup
devlinjunker Oct 5, 2023
60f319f
make ActionParams generic to make it clear what is available in each …
devlinjunker Oct 5, 2023
f576eb4
fix flex properties to avoid media queries
devlinjunker Oct 10, 2023
dff06a4
Merge branch 'vue-rewrite' into mobile-friendly-styles
devlinjunker Oct 10, 2023
ed62d3e
cleaning up explore page
devlinjunker Oct 4, 2023
30e4e9b
copy files from explore.scss file
devlinjunker Oct 10, 2023
0a2ecc2
Merge pull request #2371 from devlinjunker/mobile-friendly-styles
devlinjunker Oct 16, 2023
ab4f941
start documentation rewrite
devlinjunker Oct 16, 2023
9cab235
fix bug using php template for warning message
devlinjunker Oct 16, 2023
94f04d4
cleanup old cron stuff and make cron-warning.js part of build so it c…
devlinjunker Oct 16, 2023
3e35d78
Merge remote-tracking branch 'nextcloud/master' into master-merge
devlinjunker Oct 22, 2023
02c9fff
Merge pull request #2385 from devlinjunker/master-merge
Grotax Oct 24, 2023
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
Prev Previous commit
Next Next commit
store tests
Signed-off-by: Devlin Junker <devlin.junker@gmail.com>
  • Loading branch information
devlinjunker authored and Grotax committed Sep 20, 2023
commit 6aa282d2af464e9ee76dd0264d66ac54ef2fedea
10 changes: 1 addition & 9 deletions src/store/folder.ts
Original file line number Diff line number Diff line change
@@ -41,12 +41,6 @@ export const actions = {
{ commit }: ActionParams,
{ folder }: { folder: Folder },
) {
/**
* TODO: look into reversiblyDelete?
this.getByFolderId(folderId).forEach(function (feed) {
promises.push(self.reversiblyDelete(feed.id, false, true));
});
*/
await FolderService.deleteFolder({ id: folder.id })
commit(FOLDER_MUTATION_TYPES.DELETE_FOLDER, folder)
},
@@ -127,9 +121,7 @@ export const mutations = {
state: AppState,
feed: Feed,
) {
const folder = state.folders.find((folder: Folder) => {
return folder.id === feed.folderId
})
const folder = state.folders.find((folder: Folder) => { return folder.id === feed.folderId })

if (folder) {
folder.feedCount -= feed.unreadCount
150 changes: 148 additions & 2 deletions tests/javascript/unit/store/feed.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Feed } from '../../../../src/types/Feed'
import { AppState } from '../../../../src/store'
import { FEED_ACTION_TYPES, mutations, actions } from '../../../../src/store/feed'
import { FeedService } from '../../../../src/dataservices/feed.service'
import { FEED_ORDER, FEED_UPDATE_MODE, FeedService } from '../../../../src/dataservices/feed.service'

import { FEED_ITEM_MUTATION_TYPES, FEED_MUTATION_TYPES } from '../../../../src/types/MutationTypes'
import { FEED_ITEM_MUTATION_TYPES, FEED_MUTATION_TYPES, FOLDER_MUTATION_TYPES } from '../../../../src/types/MutationTypes'
import { ItemService } from '../../../../src/dataservices/item.service'

describe('feed.ts', () => {
'use strict'
@@ -42,6 +43,113 @@ describe('feed.ts', () => {
})
})

describe('FEED_MARK_READ', () => {
it('should call FeedService.markRead and commit all items read to state', async () => {
ItemService.fetchFeedItems = jest.fn();
(ItemService.fetchFeedItems as any).mockResolvedValue({ data: { items: [{ id: 123 }] } })
FeedService.markRead = jest.fn()
const commit = jest.fn()
const feed = { id: 1, title: 'feed' }

await (actions[FEED_ACTION_TYPES.FEED_MARK_READ] as any)({ commit }, { feed })
expect(FeedService.markRead).toBeCalled()
expect(commit).toBeCalledWith(FEED_MUTATION_TYPES.SET_FEED_ALL_READ, feed)
})

it('should commit MODIFY_FOLDER_UNREAD_COUNT with feed unreadCount if folderId exists on feed ', async () => {
ItemService.fetchFeedItems = jest.fn();
(ItemService.fetchFeedItems as any).mockResolvedValue({ data: { items: [{ id: 123 }] } })
FeedService.markRead = jest.fn()
const commit = jest.fn()
const feed = { id: 1, title: 'feed', folderId: 234, unreadCount: 2 }

await (actions[FEED_ACTION_TYPES.FEED_MARK_READ] as any)({ commit }, { feed })
expect(FeedService.markRead).toBeCalled()
expect(commit).toBeCalledWith(FEED_MUTATION_TYPES.SET_FEED_ALL_READ, feed)
expect(commit).toBeCalledWith(FOLDER_MUTATION_TYPES.MODIFY_FOLDER_UNREAD_COUNT, { folderId: 234, delta: -2 })
})
})

describe('FEED_SET_PINNED', () => {
it('should call FeedService.updateFeed and commit updated `pinned` property to state', async () => {
FeedService.updateFeed = jest.fn()
const commit = jest.fn()
await (actions[FEED_ACTION_TYPES.FEED_SET_PINNED] as any)({ commit }, { feed: { id: 1 }, pinned: true })
expect(FeedService.updateFeed).toBeCalledWith({ feedId: 1, pinned: true })
expect(commit).toBeCalledWith(FEED_MUTATION_TYPES.UPDATE_FEED, { id: 1, pinned: true })
})
})

describe('FEED_SET_ORDERING', () => {
it('should call FeedService.updateFeed and commit updated `ordering` property to state', async () => {
FeedService.updateFeed = jest.fn()
const commit = jest.fn()
await (actions[FEED_ACTION_TYPES.FEED_SET_ORDERING] as any)({ commit }, { feed: { id: 1 }, ordering: FEED_ORDER.DEFAULT })
expect(FeedService.updateFeed).toBeCalledWith({ feedId: 1, ordering: FEED_ORDER.DEFAULT })
expect(commit).toBeCalledWith(FEED_MUTATION_TYPES.UPDATE_FEED, { id: 1, ordering: FEED_ORDER.DEFAULT })
})
})

describe('FEED_SET_FULL_TEXT', () => {
it('should call FeedService.updateFeed and commit updated `fullTextEnabled` property to state', async () => {
FeedService.updateFeed = jest.fn()
const commit = jest.fn()
await (actions[FEED_ACTION_TYPES.FEED_SET_FULL_TEXT] as any)({ commit }, { feed: { id: 1 }, fullTextEnabled: true })
expect(FeedService.updateFeed).toBeCalledWith({ feedId: 1, fullTextEnabled: true })
expect(commit).toBeCalledWith(FEED_MUTATION_TYPES.UPDATE_FEED, { id: 1, fullTextEnabled: true })
})
})

describe('FEED_SET_UPDATE_MODE', () => {
it('should call FeedService.updateFeed and commit updated `updateMode` property to state', async () => {
FeedService.updateFeed = jest.fn()
const commit = jest.fn()
await (actions[FEED_ACTION_TYPES.FEED_SET_UPDATE_MODE] as any)({ commit }, { feed: { id: 1 }, updateMode: FEED_UPDATE_MODE.IGNORE })
expect(FeedService.updateFeed).toBeCalledWith({ feedId: 1, updateMode: FEED_UPDATE_MODE.IGNORE })
expect(commit).toBeCalledWith(FEED_MUTATION_TYPES.UPDATE_FEED, { id: 1, updateMode: FEED_UPDATE_MODE.IGNORE })
})
})

describe('FEED_SET_TITLE', () => {
it('should call FeedService.updateFeed and commit updated `title` property to state', async () => {
FeedService.updateFeed = jest.fn()
const commit = jest.fn()
await (actions[FEED_ACTION_TYPES.FEED_SET_TITLE] as any)({ commit }, { feed: { id: 1 }, title: 'newTitle' })
expect(FeedService.updateFeed).toBeCalledWith({ feedId: 1, title: 'newTitle' })
expect(commit).toBeCalledWith(FEED_MUTATION_TYPES.UPDATE_FEED, { id: 1, title: 'newTitle' })
})
})

describe('FEED_DELETE', () => {
it('should call FeedService.deleteFeed and commit to state', async () => {
FeedService.deleteFeed = jest.fn()
const commit = jest.fn()
await (actions[FEED_ACTION_TYPES.FEED_DELETE] as any)({ commit }, { feed: { id: 1 } })
expect(FeedService.deleteFeed).toBeCalledWith({ feedId: 1 })
expect(commit).toBeCalledWith(FEED_MUTATION_TYPES.FEED_DELETE, 1)
})
})

describe('MODIFY_FEED_UNREAD_COUNT', () => {
const state = {
feeds: [{ id: 1 }],
}
it('should commit to state', async () => {
const commit = jest.fn()
await (actions[FEED_ACTION_TYPES.MODIFY_FEED_UNREAD_COUNT] as any)({ commit, state }, { feedId: 1, delta: -2 })
expect(commit).toBeCalledWith(FEED_MUTATION_TYPES.MODIFY_FEED_UNREAD_COUNT, { feedId: 1, delta: -2 })
})

it('should commit folder to state if feed has folderId', async () => {
const state = {
feeds: [{ id: 1, folderId: 234 }],
}
const commit = jest.fn()
await (actions[FEED_ACTION_TYPES.MODIFY_FEED_UNREAD_COUNT] as any)({ commit, state }, { feedId: 1, delta: -2 })
expect(commit).toBeCalledWith(FEED_MUTATION_TYPES.MODIFY_FEED_UNREAD_COUNT, { feedId: 1, delta: -2 })
expect(commit).toBeCalledWith(FOLDER_MUTATION_TYPES.MODIFY_FOLDER_UNREAD_COUNT, { folderId: 234, delta: -2 })
})
})
})

describe('mutations', () => {
@@ -71,5 +179,43 @@ describe('feed.ts', () => {
expect(state.feeds[0]).toEqual(feed)
})
})

describe('UPDATE_FEED', () => {
it('should update a feed in the state', () => {
const state = { feeds: [{ title: 'oldName', id: 1 }] as Feed[], folders: [] as any[] } as AppState
const feed = { title: 'test', id: 1 } as any

mutations[FEED_MUTATION_TYPES.UPDATE_FEED](state, feed)
expect(state.feeds[0].title).toEqual('test')
})
})

describe('SET_FEED_ALL_READ', () => {
it('should update a feed unreadCount to 0 in the state', () => {
const state = { feeds: [{ title: 'oldName', id: 1, unreadCount: 4 }] as Feed[], folders: [] as any[] } as AppState
const feed = { title: 'test', id: 1 } as any

mutations[FEED_MUTATION_TYPES.SET_FEED_ALL_READ](state, feed)
expect(state.feeds[0].unreadCount).toEqual(0)
})
})

describe('MODIFY_FEED_UNREAD_COUNT', () => {
it('should update a feed unreadCount to 0 in the state', () => {
const state = { feeds: [{ title: 'oldName', id: 1, unreadCount: 4 }] as Feed[], folders: [] as any[] } as AppState

mutations[FEED_MUTATION_TYPES.MODIFY_FEED_UNREAD_COUNT](state, { feedId: 1, delta: -1 } as any)
expect(state.feeds[0].unreadCount).toEqual(3)
})
})

describe('FEED_DELETE', () => {
it('should update a feed unreadCount to 0 in the state', () => {
const state = { feeds: [{ title: 'oldName', id: 1, unreadCount: 4 }] as Feed[], folders: [] as any[] } as AppState

mutations[FEED_MUTATION_TYPES.FEED_DELETE](state, 1 as any)
expect(state.feeds.length).toEqual(0)
})
})
})
})
36 changes: 35 additions & 1 deletion tests/javascript/unit/store/folder.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Folder } from '../../../../src/types/Folder'
import { AppState } from '../../../../src/store'
import { FOLDER_ACTION_TYPES, mutations, actions } from '../../../../src/store/folder'
import { FOLDER_MUTATION_TYPES } from '../../../../src/types/MutationTypes'
import { FEED_MUTATION_TYPES, FOLDER_MUTATION_TYPES } from '../../../../src/types/MutationTypes'
import { FolderService } from '../../../../src/dataservices/folder.service'

jest.mock('@nextcloud/router')
@@ -44,6 +44,18 @@ describe('folder.ts', () => {
expect(FolderService.deleteFolder).toBeCalled()
expect(commit).toBeCalled()
})

it('FOLDER_SET_NAME should call FolderService.renameFolder and then commit deleted folder to state', async () => {
FolderService.renameFolder = jest.fn();
(FolderService.renameFolder as any).mockResolvedValue()

const folder = {} as Folder
const commit = jest.fn()

await actions[FOLDER_ACTION_TYPES.FOLDER_SET_NAME]({ commit } as any, { folder, name: 'newName' } as any)
expect(FolderService.renameFolder).toBeCalledWith({ id: folder.id, name: 'newName' })
expect(commit).toBeCalled()
})
})

describe('mutations', () => {
@@ -68,5 +80,27 @@ describe('folder.ts', () => {
(mutations[FOLDER_MUTATION_TYPES.DELETE_FOLDER] as any)(state, folders)
expect(state.folders.length).toEqual(0)
})

it('UPDATE_FOLDER should update the folder properties in the state', () => {
const state = { folders: [{ name: 'test', id: 123 }] as Folder[] } as AppState
const newFolder = { id: 123, name: 'newName' };

(mutations[FOLDER_MUTATION_TYPES.UPDATE_FOLDER] as any)(state, newFolder)
expect(state.folders[0].name).toEqual('newName')
})

it('MODIFY_FOLDER_UNREAD_COUNT should update the folder feedCount in the state based on the delta', () => {
const state = { folders: [{ name: 'test', id: 123, feedCount: 10 }] as Folder[] } as AppState

(mutations[FOLDER_MUTATION_TYPES.MODIFY_FOLDER_UNREAD_COUNT] as any)(state, { folderId: 123, delta: -3 })
expect(state.folders[0].feedCount).toEqual(7)
})

it('SET_FEED_ALL_READ should update the folder feedCount in the state based on the feed unreadCount', () => {
const state = { folders: [{ name: 'test', id: 123, feedCount: 10 }] as Folder[] } as AppState

(mutations[FEED_MUTATION_TYPES.SET_FEED_ALL_READ] as any)(state, { id: 1, folderId: 123, unreadCount: 2 })
expect(state.folders[0].feedCount).toEqual(8)
})
})
})