-
Notifications
You must be signed in to change notification settings - Fork 278
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
cleanup app-link for tests #4526
Changes from 4 commits
21caa76
2886218
ab8e534
ac325f1
d806089
e313e43
76d140a
2de7d08
e13d1af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,9 @@ | |
</component> | ||
</script> | ||
<script> | ||
Vue.component('app-link', { | ||
Vue.component({ | ||
name: 'app-link', | ||
template: '#app-link-template', | ||
store, | ||
props: { | ||
to: [String, Object], | ||
|
@@ -30,6 +31,17 @@ Vue.component('app-link', { | |
config() { | ||
return this.$store.state.config; | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that for future usage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for future usage. |
||
indexerName() { | ||
const { indexerId, config } = this; | ||
if (!indexerId) { | ||
return ''; | ||
} | ||
return Object.keys(config.indexers).filter(indexer => { | ||
if (config.indexers[indexer].id === parseInt(indexerId, 10)) { | ||
return config.indexers[indexer].name; | ||
} | ||
})[0]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
const { indexers } = config.indexers.config; // This is weird, I know...
// Returns `undefined` if not found.
return Object.keys(indexers).find(indexer => indexers[indexer].id === parseInt(indexerId, 10)); [1]{ store.state
"config": {
"indexers": {
"config": {
"indexers": {
"tvdb": {
"xemOrigin": "tvdb",
"apiParams": {
"useZip": true,
"language": "en"
},
"showUrl": "https://www.thetvdb.com/dereferrer/series/",
"id": 1,
"icon": "thetvdb16.png",
"name": "TVDBv2",
"scene_loc": "https://cdn.pymedusa.com/scene_exceptions/scene_exceptions_tvdb.json",
"enabled": true,
"baseUrl": "https://api.thetvdb.com/",
"mappedTo": "tvdb_id",
"identifier": "tvdb"
},
"tmdb": {
"xemOrigin": null,
"apiParams": {
"useZip": true,
"language": "en"
},
"showUrl": "https://www.themoviedb.org/tv/",
"id": 4,
"icon": "tmdb16.png",
"name": "TMDB",
"scene_loc": "https://cdn.pymedusa.com/scene_exceptions/scene_exceptions_tmdb.json",
"enabled": true,
"baseUrl": "https://www.themoviedb.org/",
"mappedTo": "tmdb_id",
"identifier": "tmdb"
},
"tvmaze": {
"xemOrigin": null,
"apiParams": {
"useZip": true,
"language": "en"
},
"showUrl": "http://www.tvmaze.com/shows/",
"id": 3,
"icon": "tvmaze16.png",
"name": "TVmaze",
"scene_loc": "https://cdn.pymedusa.com/scene_exceptions/scene_exceptions_tvmaze.json",
"enabled": true,
"baseUrl": "http://api.tvmaze.com/",
"mappedTo": "tvmaze_id",
"identifier": "tvmaze"
}
},
"main": {
"externalMappings": {<truncated>},
"statusMap": {<truncated>},
"traktIndexers": {<truncated>},
"validLanguages": [<truncated>],
"langabbvToId": {<truncated>}
}
}
}
}
} |
||
}, | ||
computedBase() { | ||
// Return prop before HTML element to allow tests to mock | ||
if (this.base) { | ||
|
@@ -39,11 +51,11 @@ Vue.component('app-link', { | |
return document.getElementsByTagName('base')[0].getAttribute('href'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any problem with doing this: const { base } = this;
// Return prop before HTML element to allow tests to mock
return this.base || document.getElementsByTagName('base')[0].getAttribute('href'); It's just a personal preference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to make sure document isn't ever called since it'll throw an error in the tests. I know how bad that sounds but I'll fix it once I move this to a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK, JavaScript logical statements are evaluated from left to right and not all at once. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not that. It's the testing framework seeing it in the AST that's the issue. |
||
}, | ||
computedHref() { | ||
const { indexerId, placeholder } = this; | ||
const { href, indexerId, placeholder, indexerName } = this; | ||
if (indexerId && placeholder) { | ||
return this.href.replace(placeholder, MEDUSA.config.indexers.indexerIdToName(indexerId)); | ||
return href.replace(placeholder, indexerName); | ||
} | ||
return this.href; | ||
return href; | ||
}, | ||
isIRC() { | ||
return this.computedHref.startsWith('irc://'); | ||
|
@@ -60,11 +72,6 @@ Vue.component('app-link', { | |
isHashPath() { | ||
return this.computedHref.startsWith('#'); | ||
}, | ||
isAnonymised() { | ||
const { anonRedirect } = this.config; | ||
const href = this.computedHref; | ||
return anonRedirect && href.startsWith(anonRedirect); | ||
}, | ||
anonymisedHref() { | ||
const { anonRedirect } = this.config; | ||
const href = this.computedHref; | ||
|
@@ -92,11 +99,6 @@ Vue.component('app-link', { | |
}; | ||
} | ||
|
||
// @TODO: Remove this once we move to vue only | ||
if (isAnonymised) { | ||
throw new Error('Still using anon_url in Python!'); | ||
} | ||
|
||
return { | ||
is: 'a', | ||
target: isAbsolute && isExternal ? '_blank' : '_self', | ||
|
@@ -124,8 +126,7 @@ Vue.component('app-link', { | |
rel: isAbsolute && isExternal ? 'noreferrer' : undefined | ||
}; | ||
} | ||
}, | ||
template: '#app-link-template' | ||
} | ||
}); | ||
</script> | ||
<style> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is redundant, please remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for future usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, then remove the one above it, which overrides the first argument to
Vue.component
.