Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1427738
ExternalLinks.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ExternalLinks.js
View Options
'use strict'
;
const
{
action
,
assert
,
utils
}
=
require
(
'api-testing'
);
describe
(
'ExternalLinks'
,
()
=>
{
const
page
=
utils
.
title
(
'ExternalLinkTest_'
);
const
links
=
[
'http://example.org/search-me'
,
'http://www.example.org/some-page'
,
'ssh://example.org/'
];
let
alice
;
before
(
async
()
=>
{
alice
=
await
action
.
alice
();
const
text
=
links
.
reduce
(
(
currText
,
url
)
=>
`
${
currText
}
[
${
url
}
]`
,
''
);
await
alice
.
edit
(
page
,
{
text
}
);
}
);
it
(
'can be listed'
,
async
()
=>
{
const
result
=
await
alice
.
prop
(
'extlinks'
,
page
);
const
fetchedLinks
=
result
[
page
].
extlinks
.
map
(
(
p
)
=>
p
[
'*'
]
);
assert
.
sameMembers
(
fetchedLinks
,
links
);
}
);
it
(
'can be limited'
,
async
()
=>
{
const
result
=
await
alice
.
prop
(
'extlinks'
,
page
,
{
ellimit
:
1
}
);
const
fetchedLinks
=
result
[
page
].
extlinks
.
map
(
(
p
)
=>
p
[
'*'
]
);
assert
.
equal
(
fetchedLinks
.
length
,
1
);
}
);
it
(
'can be filtered by protocol'
,
async
()
=>
{
const
result
=
await
alice
.
prop
(
'extlinks'
,
page
,
{
elprotocol
:
'ssh'
}
);
const
fetchedLinks
=
result
[
page
].
extlinks
.
map
(
(
p
)
=>
p
[
'*'
]
);
assert
.
sameMembers
(
fetchedLinks
,
[
'ssh://example.org/'
]
);
}
);
it
(
'throws an error on invalid protocol'
,
async
()
=>
{
const
result
=
await
alice
.
actionError
(
'query'
,
{
prop
:
'extlinks'
,
titles
:
page
,
elprotocol
:
'uwu'
}
);
assert
.
deepNestedInclude
(
result
,
{
code
:
'badvalue'
}
);
}
);
it
(
'can be filtered by search string'
,
async
()
=>
{
const
result
=
await
alice
.
prop
(
'extlinks'
,
page
,
{
elquery
:
'example.org/search-me'
}
);
const
fetchedLinks
=
result
[
page
].
extlinks
.
map
(
(
p
)
=>
p
[
'*'
]
);
assert
.
sameMembers
(
fetchedLinks
,
[
'http://example.org/search-me'
]
);
}
);
it
(
'does not expand external urls'
,
async
()
=>
{
const
result
=
await
alice
.
prop
(
'extlinks'
,
page
,
{
elexpandurl
:
true
}
);
const
fetchedLinks
=
result
[
page
].
extlinks
.
map
(
(
p
)
=>
p
[
'*'
]
);
assert
.
sameMembers
(
fetchedLinks
,
links
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 16, 15:02 (22 h, 5 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d7/e1/0eddb08021d28c7580d474d57c56
Default Alt Text
ExternalLinks.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment