Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
admin-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
admin-fe
Commits
88ea2a03
Commit
88ea2a03
authored
5 years ago
by
Angelina Filippova
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for wrapping settings with type keyword
parent
27cb6b3b
No related branches found
Branches containing commit
No related tags found
1 merge request
!77
Ability to remove settings from db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/views/settings/components/inputComponents/EditableKeywordInput.vue
+1
-1
1 addition, 1 deletion
...tings/components/inputComponents/EditableKeywordInput.vue
test/modules/normalizers/wrapUpdatedSettings.test.js
+110
-0
110 additions, 0 deletions
test/modules/normalizers/wrapUpdatedSettings.test.js
with
111 additions
and
1 deletion
src/views/settings/components/inputComponents/EditableKeywordInput.vue
+
1
−
1
View file @
88ea2a03
...
...
@@ -95,7 +95,7 @@ export default {
updateSetting
(
value
,
group
,
key
,
input
,
type
)
{
const
updatedSettings
=
type
!==
'
map
'
?
value
.
reduce
((
acc
,
element
)
=>
{
return
{
...
acc
,
[
Object
.
keys
(
element
)[
0
]]:
[
[
'
list
'
]
,
Object
.
values
(
element
)[
0
].
value
]
}
return
{
...
acc
,
[
Object
.
keys
(
element
)[
0
]]:
[
'
list
'
,
Object
.
values
(
element
)[
0
].
value
]
}
},
{})
:
value
.
reduce
((
acc
,
element
)
=>
{
return
{
...
acc
,
[
Object
.
keys
(
element
)[
0
]]:
Object
.
values
(
element
)[
0
].
value
}
...
...
This diff is collapsed.
Click to expand it.
test/modules/normalizers/wrapUpdatedSettings.test.js
+
110
−
0
View file @
88ea2a03
...
...
@@ -58,4 +58,114 @@ describe('Wrap settings', () => {
}]
expect
(
_
.
isEqual
(
result
,
expectedResult
)).
toBeTruthy
()
})
it
(
'
wraps settings with type keyword
'
,
()
=>
{
const
settings1
=
{
'
Pleroma.Upload
'
:
{
'
:proxy_opts
'
:
[
"
keyword
"
,
{
'
:redirect_on_failure
'
:
[
"
boolean
"
,
true
],
'
:http
'
:
[
"
keyword
"
,
{
'
:proxy_url
'
:
[[
"
string
"
,
"
tuple
"
],
"
localhost:3090
"
]}]
}]
}}
const
state1
=
{
'
:pleroma
'
:
{
'
Pleroma.Upload
'
:
{}}}
const
result1
=
wrapUpdatedSettings
(
'
:pleroma
'
,
settings1
,
state1
)
const
expectedResult1
=
[{
group
:
'
:pleroma
'
,
key
:
"
Pleroma.Upload
"
,
value
:
[{
tuple
:
[
"
:proxy_opts
"
,
[
{
tuple
:
[
"
:redirect_on_failure
"
,
true
]
},
{
tuple
:
[
"
:http
"
,
[{
tuple
:
[
"
:proxy_url
"
,
"
localhost:3090
"
]
}]]
}
]]}]
}]
const
settings2
=
{
'
:media_proxy
'
:
{
'
:proxy_opts
'
:
[
"
keyword
"
,
{
'
:max_body_length
'
:
[
"
integer
"
,
26210000
],
'
:http
'
:
[
"
keyword
"
,
{
'
:proxy_url
'
:
[[
"
string
"
,
"
tuple
"
],
[
"
:socks5
"
,
"
127.0.0.1
"
,
"
9020
"
]],
'
:adapter
'
:
[
"
keyword
"
,
{
'
:ssl_options
'
:
[
"
keyword
"
,
{
'
:versions
'
:
[[
"
list
"
,
"
atom
"
],
[
"
:tlsv1
"
,
"
:tlsv1.1
"
]]
}]
}]
}]
}]
}}
const
state2
=
{
'
:pleroma
'
:
{
'
:media_proxy
'
:
{}}}
const
result2
=
wrapUpdatedSettings
(
'
:pleroma
'
,
settings2
,
state2
)
const
expectedResult2
=
[{
group
:
'
:pleroma
'
,
key
:
"
:media_proxy
"
,
value
:
[{
tuple
:
[
"
:proxy_opts
"
,
[
{
tuple
:
[
"
:max_body_length
"
,
26210000
]
},
{
tuple
:
[
"
:http
"
,
[{
tuple
:
[
'
:proxy_url
'
,
{
tuple
:
[
'
:socks5
'
,
'
127.0.0.1
'
,
'
9020
'
]
}]},
{
tuple
:
[
"
:adapter
"
,
[{
tuple
:
[
"
:ssl_options
"
,
[{
tuple
:
[
"
:versions
"
,
[
"
:tlsv1
"
,
"
:tlsv1.1
"
]]}]]}]
]}]
]}
]]}]
}]
expect
(
_
.
isEqual
(
result1
,
expectedResult1
)).
toBeTruthy
()
expect
(
_
.
isEqual
(
result2
,
expectedResult2
)).
toBeTruthy
()
})
it
(
'
wraps settings that includes keyword in type
'
,
()
=>
{
const
settings1
=
{
'
Oban
'
:
{
'
:queues
'
:
[
[
"
keyword
"
,
"
integer
"
],
{
'
:activity_expiration
'
:
[
"
integer
"
,
15
],
'
:background
'
:
[
"
integer
"
,
10
],
'
:federator_incoming
'
:
[
"
integer
"
,
30
]}
]}}
const
state1
=
{
'
:pleroma
'
:
{
'
Oban
'
:
{}}}
const
result1
=
wrapUpdatedSettings
(
'
:pleroma
'
,
settings1
,
state1
)
const
expectedResult1
=
[{
group
:
'
:pleroma
'
,
key
:
"
Oban
"
,
value
:
[{
tuple
:
[
"
:queues
"
,
[
{
tuple
:
[
"
:activity_expiration
"
,
15
]
},
{
tuple
:
[
"
:background
"
,
10
]
},
{
tuple
:
[
"
:federator_incoming
"
,
30
]}
]]}]
}]
const
settings2
=
{
'
:emoji
'
:
{
'
:groups
'
:
[
[
"
keyword
"
,
"
string
"
,
[
"
list
"
,
"
string
"
]],
{
'
:custom
'
:
[[
"
list
"
],
[
"
/emoji/*.png
"
,
"
/emoji/**/*.png
"
]],
'
:another_group
'
:
[
"
list
"
,
[
"
/custom_emoji/*.png
"
]]}
]}}
const
state2
=
{
'
:pleroma
'
:
{
'
:emoji
'
:
{}}}
const
result2
=
wrapUpdatedSettings
(
'
:pleroma
'
,
settings2
,
state2
)
const
expectedResult2
=
[{
group
:
'
:pleroma
'
,
key
:
"
:emoji
"
,
value
:
[{
tuple
:
[
"
:groups
"
,
[
{
tuple
:
[
"
:custom
"
,
[
"
/emoji/*.png
"
,
"
/emoji/**/*.png
"
]]},
{
tuple
:
[
"
:another_group
"
,
[
"
/custom_emoji/*.png
"
]]}
]]}]
}]
expect
(
_
.
isEqual
(
result1
,
expectedResult1
)).
toBeTruthy
()
expect
(
_
.
isEqual
(
result2
,
expectedResult2
)).
toBeTruthy
()
})
it
(
'
wraps :replace setting
'
,
()
=>
{
const
settings
=
{
'
:mrf_keyword
'
:
{
'
:replace
'
:
[
[[
"
tuple
"
,
"
string
"
,
"
string
"
],
[
"
tuple
"
,
"
regex
"
,
"
string
"
]],
{
'
pattern
'
:
[
"
list
"
,
"
replacement
"
],
'
/
\
w+/
'
:
[
"
list
"
,
"
test_replacement
"
]}
]}}
const
state
=
{
'
:pleroma
'
:
{
'
:mrf_keyword
'
:
{}}}
const
result
=
wrapUpdatedSettings
(
'
:pleroma
'
,
settings
,
state
)
const
expectedResult
=
[{
group
:
'
:pleroma
'
,
key
:
"
:mrf_keyword
"
,
value
:
[{
tuple
:
[
"
:replace
"
,
[
{
tuple
:
[
"
pattern
"
,
"
replacement
"
]
},
{
tuple
:
[
"
/
\
w+/
"
,
"
test_replacement
"
]
}
]]}]
}]
expect
(
_
.
isEqual
(
result
,
expectedResult
)).
toBeTruthy
()
})
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment