feat: add max_ratio_act handling (#523) @giacomocerquone

This commit is contained in:
Giacomo Cerquone 2022-10-20 11:44:26 +02:00 committed by GitHub
parent 058766f617
commit b05dcd0569
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 274 additions and 91 deletions

View file

@ -170,6 +170,26 @@
</v-col>
</v-row>
</v-list-item>
<v-list-item>
<v-row dense>
<v-col>
<v-subheader>
{{ $t('then') }}
</v-subheader>
</v-col>
<v-col>
<v-select
v-model="settings.max_ratio_act"
class="mb-2"
outlined
:disabled="!settings.max_ratio_enabled && !settings.max_seeding_time_enabled"
dense
small-chips
:items="thenTypes"
/>
</v-col>
</v-row>
</v-list-item>
</v-card>
</template>
@ -178,6 +198,29 @@ import { SettingsTab, FullScreenModal } from '@/mixins'
export default {
name: 'BitTorrent',
mixins: [SettingsTab, FullScreenModal]
mixins: [SettingsTab, FullScreenModal],
data() {
return {
thenTypes: [
{
value: 0,
text: this.$i18n.t('modals.settings.pageBittorrent.maxRatioPauseTorrent')
},
{
value: 1,
text: this.$i18n.t('modals.settings.pageBittorrent.maxRatioRemoveTorrent')
},
{
value: 3,
text: this.$i18n.t('modals.settings.pageBittorrent.maxRatioRemoveTorrentAndFiles')
},
{
value: 2,
text: this.$i18n.t('modals.settings.pageBittorrent.maxRatioTorrentSuperseeding')
}
]
}
}
}
</script>

View file

@ -42,6 +42,7 @@ const locale = {
magnet: 'Magnet',
feed: 'feed',
rule: 'rule',
then: 'Then',
/** Torrent */
torrent: {
@ -207,7 +208,11 @@ const locale = {
torrentInactivityTimer: 'Torrent inactivity timer',
subHeaderSeedLimits: 'Seed Limits',
whenRatioReaches: 'When ratio reaches',
whenSeedingTimeReaches: 'When seeding time reaches'
whenSeedingTimeReaches: 'When seeding time reaches',
maxRatioPauseTorrent: 'Pause torrent',
maxRatioRemoveTorrent: 'Remove torrent',
maxRatioRemoveTorrentAndFiles: 'Remove torrent and files',
maxRatioTorrentSuperseeding: 'Enable torrent super seeding'
},
pageRss: {
tabName: {

View file

@ -22,25 +22,40 @@ const getSettingsMockRes = {
max_seeding_time: 1
}
const getCustomWrapper = (getSettingsRes)=> {
return shallowMount(BitTorrent,{ mocks: { $t: (x) => x , $store: {
const getCustomWrapper = getSettingsRes => {
return shallowMount(BitTorrent, {
mocks: {
$i18n: {
t: x => x
},
$t: x => x,
$store: {
getters: { getSettings: () => {
return getSettingsRes
} },
state: { }
}
} })
}
})
}
describe('BitTorrent', () => {
beforeEach(() => {
wrapper = shallowMount(BitTorrent,{ mocks: { $t: (x) => x , $store: {
wrapper = shallowMount(BitTorrent, {
mocks: {
$i18n: {
t: x => x
},
$t: x => x,
$store: {
getters: { getSettings: () => {
return getSettingsMockRes
} },
state: { }
}
} })
}
})
})
it('render correctly', () => {
@ -48,74 +63,74 @@ describe('BitTorrent', () => {
})
it('render correctly when anonymous_mode is false', () => {
const customerWarpper = getCustomWrapper({
const customWrapper = getCustomWrapper({
...getSettingsMockRes,
anonymous_mode: false
})
expect(customerWarpper.html()).toMatchSnapshot()
expect(customWrapper.html()).toMatchSnapshot()
})
it('render correctly when queueing_enabled is false', () => {
const customerWarpper = getCustomWrapper({
const customWrapper = getCustomWrapper({
...getSettingsMockRes,
queueing_enabled: false
})
expect(customerWarpper.html()).toMatchSnapshot()
expect(customWrapper.html()).toMatchSnapshot()
})
it('render correctly when dont_count_slow_torrents is false', () => {
const customerWarpper = getCustomWrapper({
const customWrapper = getCustomWrapper({
...getSettingsMockRes,
dont_count_slow_torrents: false
})
expect(customerWarpper.html()).toMatchSnapshot()
expect(customWrapper.html()).toMatchSnapshot()
})
it('render correctly when max_ratio_enabled is false', () => {
const customerWarpper = getCustomWrapper({
const customWrapper = getCustomWrapper({
...getSettingsMockRes,
max_ratio_enabled: false
})
expect(customerWarpper.html()).toMatchSnapshot()
expect(customWrapper.html()).toMatchSnapshot()
})
it('render correctly when max_seeding_time_enabled is false', () => {
const customerWarpper = getCustomWrapper({
const customWrapper = getCustomWrapper({
...getSettingsMockRes,
max_seeding_time_enabled: false
})
expect(customerWarpper.html()).toMatchSnapshot()
expect(customWrapper.html()).toMatchSnapshot()
})
it('render correctly when max_active_downloads is 2', () => {
const customerWarpper = getCustomWrapper({
const customWrapper = getCustomWrapper({
...getSettingsMockRes,
max_active_downloads: 2
})
expect(customerWarpper.html()).toMatchSnapshot()
expect(customWrapper.html()).toMatchSnapshot()
})
it('render correctly when max_active_torrents is 3', () => {
const customerWarpper = getCustomWrapper({
const customWrapper = getCustomWrapper({
...getSettingsMockRes,
max_active_torrents: 3
})
expect(customerWarpper.html()).toMatchSnapshot()
expect(customWrapper.html()).toMatchSnapshot()
})
it('render correctly when slow_torrent_dl_rate_threshold is 25', () => {
const customerWarpper = getCustomWrapper({
const customWrapper = getCustomWrapper({
...getSettingsMockRes,
slow_torrent_dl_rate_threshold: 25
})
expect(customerWarpper.html()).toMatchSnapshot()
expect(customWrapper.html()).toMatchSnapshot()
})
it('render correctly when slow_torrent_ul_rate_threshold is 24', () => {
const customerWarpper = getCustomWrapper({
const customWrapper = getCustomWrapper({
...getSettingsMockRes,
slow_torrent_ul_rate_threshold: 24
})
expect(customerWarpper.html()).toMatchSnapshot()
expect(customWrapper.html()).toMatchSnapshot()
})
})

View file

@ -62,6 +62,18 @@ exports[`BitTorrent render correctly 1`] = `
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub activeclass="" tag="div">
<v-row-stub tag="div" dense="true">
<v-col-stub tag="div">
<v-subheader-stub>
then
</v-subheader-stub>
</v-col-stub>
<v-col-stub tag="div">
<v-select-stub errorcount="1" errormessages="" messages="" rules="" successmessages="" appendicon="$dropdown" backgroundcolor="" dense="true" loaderheight="2" clearicon="$clear" outlined="true" type="text" valuecomparator="[Function]" nodatatext="$vuetify.noDataText" items="[object Object],[object Object],[object Object],[object Object]" itemcolor="primary" itemdisabled="disabled" itemtext="text" itemvalue="value" menuprops="[object Object]" smallchips="true" class="mb-2"></v-select-stub>
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
</v-card-stub>
`;
@ -127,6 +139,18 @@ exports[`BitTorrent render correctly when anonymous_mode is false 1`] = `
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub activeclass="" tag="div">
<v-row-stub tag="div" dense="true">
<v-col-stub tag="div">
<v-subheader-stub>
then
</v-subheader-stub>
</v-col-stub>
<v-col-stub tag="div">
<v-select-stub errorcount="1" errormessages="" messages="" rules="" successmessages="" appendicon="$dropdown" backgroundcolor="" dense="true" loaderheight="2" clearicon="$clear" outlined="true" type="text" valuecomparator="[Function]" nodatatext="$vuetify.noDataText" items="[object Object],[object Object],[object Object],[object Object]" itemcolor="primary" itemdisabled="disabled" itemtext="text" itemvalue="value" menuprops="[object Object]" smallchips="true" class="mb-2"></v-select-stub>
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
</v-card-stub>
`;
@ -192,6 +216,18 @@ exports[`BitTorrent render correctly when dont_count_slow_torrents is false 1`]
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub activeclass="" tag="div">
<v-row-stub tag="div" dense="true">
<v-col-stub tag="div">
<v-subheader-stub>
then
</v-subheader-stub>
</v-col-stub>
<v-col-stub tag="div">
<v-select-stub errorcount="1" errormessages="" messages="" rules="" successmessages="" appendicon="$dropdown" backgroundcolor="" dense="true" loaderheight="2" clearicon="$clear" outlined="true" type="text" valuecomparator="[Function]" nodatatext="$vuetify.noDataText" items="[object Object],[object Object],[object Object],[object Object]" itemcolor="primary" itemdisabled="disabled" itemtext="text" itemvalue="value" menuprops="[object Object]" smallchips="true" class="mb-2"></v-select-stub>
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
</v-card-stub>
`;
@ -257,6 +293,18 @@ exports[`BitTorrent render correctly when max_active_downloads is 2 1`] = `
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub activeclass="" tag="div">
<v-row-stub tag="div" dense="true">
<v-col-stub tag="div">
<v-subheader-stub>
then
</v-subheader-stub>
</v-col-stub>
<v-col-stub tag="div">
<v-select-stub errorcount="1" errormessages="" messages="" rules="" successmessages="" appendicon="$dropdown" backgroundcolor="" dense="true" loaderheight="2" clearicon="$clear" outlined="true" type="text" valuecomparator="[Function]" nodatatext="$vuetify.noDataText" items="[object Object],[object Object],[object Object],[object Object]" itemcolor="primary" itemdisabled="disabled" itemtext="text" itemvalue="value" menuprops="[object Object]" smallchips="true" class="mb-2"></v-select-stub>
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
</v-card-stub>
`;
@ -322,6 +370,18 @@ exports[`BitTorrent render correctly when max_active_torrents is 3 1`] = `
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub activeclass="" tag="div">
<v-row-stub tag="div" dense="true">
<v-col-stub tag="div">
<v-subheader-stub>
then
</v-subheader-stub>
</v-col-stub>
<v-col-stub tag="div">
<v-select-stub errorcount="1" errormessages="" messages="" rules="" successmessages="" appendicon="$dropdown" backgroundcolor="" dense="true" loaderheight="2" clearicon="$clear" outlined="true" type="text" valuecomparator="[Function]" nodatatext="$vuetify.noDataText" items="[object Object],[object Object],[object Object],[object Object]" itemcolor="primary" itemdisabled="disabled" itemtext="text" itemvalue="value" menuprops="[object Object]" smallchips="true" class="mb-2"></v-select-stub>
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
</v-card-stub>
`;
@ -387,6 +447,18 @@ exports[`BitTorrent render correctly when max_ratio_enabled is false 1`] = `
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub activeclass="" tag="div">
<v-row-stub tag="div" dense="true">
<v-col-stub tag="div">
<v-subheader-stub>
then
</v-subheader-stub>
</v-col-stub>
<v-col-stub tag="div">
<v-select-stub errorcount="1" errormessages="" messages="" rules="" successmessages="" appendicon="$dropdown" backgroundcolor="" dense="true" loaderheight="2" clearicon="$clear" outlined="true" type="text" valuecomparator="[Function]" nodatatext="$vuetify.noDataText" items="[object Object],[object Object],[object Object],[object Object]" itemcolor="primary" itemdisabled="disabled" itemtext="text" itemvalue="value" menuprops="[object Object]" smallchips="true" class="mb-2"></v-select-stub>
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
</v-card-stub>
`;
@ -452,6 +524,18 @@ exports[`BitTorrent render correctly when max_seeding_time_enabled is false 1`]
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub activeclass="" tag="div">
<v-row-stub tag="div" dense="true">
<v-col-stub tag="div">
<v-subheader-stub>
then
</v-subheader-stub>
</v-col-stub>
<v-col-stub tag="div">
<v-select-stub errorcount="1" errormessages="" messages="" rules="" successmessages="" appendicon="$dropdown" backgroundcolor="" dense="true" loaderheight="2" clearicon="$clear" outlined="true" type="text" valuecomparator="[Function]" nodatatext="$vuetify.noDataText" items="[object Object],[object Object],[object Object],[object Object]" itemcolor="primary" itemdisabled="disabled" itemtext="text" itemvalue="value" menuprops="[object Object]" smallchips="true" class="mb-2"></v-select-stub>
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
</v-card-stub>
`;
@ -517,6 +601,18 @@ exports[`BitTorrent render correctly when queueing_enabled is false 1`] = `
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub activeclass="" tag="div">
<v-row-stub tag="div" dense="true">
<v-col-stub tag="div">
<v-subheader-stub>
then
</v-subheader-stub>
</v-col-stub>
<v-col-stub tag="div">
<v-select-stub errorcount="1" errormessages="" messages="" rules="" successmessages="" appendicon="$dropdown" backgroundcolor="" dense="true" loaderheight="2" clearicon="$clear" outlined="true" type="text" valuecomparator="[Function]" nodatatext="$vuetify.noDataText" items="[object Object],[object Object],[object Object],[object Object]" itemcolor="primary" itemdisabled="disabled" itemtext="text" itemvalue="value" menuprops="[object Object]" smallchips="true" class="mb-2"></v-select-stub>
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
</v-card-stub>
`;
@ -582,6 +678,18 @@ exports[`BitTorrent render correctly when slow_torrent_dl_rate_threshold is 25 1
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub activeclass="" tag="div">
<v-row-stub tag="div" dense="true">
<v-col-stub tag="div">
<v-subheader-stub>
then
</v-subheader-stub>
</v-col-stub>
<v-col-stub tag="div">
<v-select-stub errorcount="1" errormessages="" messages="" rules="" successmessages="" appendicon="$dropdown" backgroundcolor="" dense="true" loaderheight="2" clearicon="$clear" outlined="true" type="text" valuecomparator="[Function]" nodatatext="$vuetify.noDataText" items="[object Object],[object Object],[object Object],[object Object]" itemcolor="primary" itemdisabled="disabled" itemtext="text" itemvalue="value" menuprops="[object Object]" smallchips="true" class="mb-2"></v-select-stub>
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
</v-card-stub>
`;
@ -647,5 +755,17 @@ exports[`BitTorrent render correctly when slow_torrent_ul_rate_threshold is 24 1
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub activeclass="" tag="div">
<v-row-stub tag="div" dense="true">
<v-col-stub tag="div">
<v-subheader-stub>
then
</v-subheader-stub>
</v-col-stub>
<v-col-stub tag="div">
<v-select-stub errorcount="1" errormessages="" messages="" rules="" successmessages="" appendicon="$dropdown" backgroundcolor="" dense="true" loaderheight="2" clearicon="$clear" outlined="true" type="text" valuecomparator="[Function]" nodatatext="$vuetify.noDataText" items="[object Object],[object Object],[object Object],[object Object]" itemcolor="primary" itemdisabled="disabled" itemtext="text" itemvalue="value" menuprops="[object Object]" smallchips="true" class="mb-2"></v-select-stub>
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
</v-card-stub>
`;