Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4128641
ext.ipinfo.infobox.widget.test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ext.ipinfo.infobox.widget.test.js
View Options
'use strict'
;
const
addSpecialGlobalContributionsLink
=
require
(
'../../../modules/ext.checkUser.ipInfo.hooks/infobox.js'
);
QUnit
.
module
(
'ext.checkUser.ipInfo.hooks'
,
QUnit
.
newMwEnvironment
(
{
beforeEach
:
function
()
{
// simulate setting wgAutoCreateTempUser to { enabled: true, matchPattern: '~$1' }
// (setting it in mw.config has no effect, so we need to
// overwrite mw.util.isTemporaryUser())
this
.
realIsTemporaryUser
=
mw
.
util
.
isTemporaryUser
;
mw
.
util
.
isTemporaryUser
=
function
(
username
)
{
return
username
.
startsWith
(
'~'
);
};
},
afterEach
:
function
()
{
mw
.
util
.
isTemporaryUser
=
this
.
realIsTemporaryUser
;
}
}
)
);
function
setUpDocumentForTest
()
{
// Stub out the attribute container from IPInfo box for the function under test to act on
const
$el
=
$
(
'<div>'
).
append
(
$
(
'<div>'
).
attr
(
'data-property'
,
'edits'
)
);
return
$el
;
}
QUnit
.
test
(
'Special:GC link not added if conditions not met when hook is fired'
,
(
assert
)
=>
{
let
$body
=
setUpDocumentForTest
();
addSpecialGlobalContributionsLink
(
$body
,
'Registered User'
,
'Contributions'
);
assert
.
strictEqual
(
$body
.
find
(
'.ext-ipinfo-global-contribution-link'
).
length
,
0
,
'No Special:GC link added to page with invalid conditions'
);
$body
=
setUpDocumentForTest
();
addSpecialGlobalContributionsLink
(
$body
,
'1.2.3.4'
,
'Contributions'
);
assert
.
strictEqual
(
$body
.
find
(
'.ext-ipinfo-global-contribution-link'
).
length
,
0
,
'No Special:GC link added to page with invalid conditions'
);
}
);
QUnit
.
test
(
'Test Special:GC link added on ext.ipinfo.infobox.widget hook'
,
(
assert
)
=>
{
let
$body
=
setUpDocumentForTest
(
'~1'
,
'Contributions'
);
addSpecialGlobalContributionsLink
(
$body
,
'~1'
,
'Contributions'
);
assert
.
strictEqual
(
$body
.
find
(
'.ext-ipinfo-global-contribution-link'
).
length
,
1
,
'Special:GC link added to temporary account\'s contributions page'
);
$body
=
setUpDocumentForTest
(
'~1'
,
'DeletedContributions'
);
addSpecialGlobalContributionsLink
(
$body
,
'~1'
,
'Contributions'
);
assert
.
strictEqual
(
$body
.
find
(
'.ext-ipinfo-global-contribution-link'
).
length
,
1
,
'Special:GC link added to temporary account\'s contributions page'
);
$body
=
setUpDocumentForTest
(
'1.2.3.4'
,
'IPContributions'
);
addSpecialGlobalContributionsLink
(
$body
,
'1.2.3.4'
,
'IPContributions'
);
assert
.
strictEqual
(
$body
.
find
(
'.ext-ipinfo-global-contribution-link'
).
length
,
1
,
'Special:GC link added to temporary account\'s contributions page'
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 19, 09:21 (2 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
fb/c7/06167a988a0cfeb4223f7885da7d
Default Alt Text
ext.ipinfo.infobox.widget.test.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment