diff options
author | MusikAnimal <musikanimal@gmail.com> | 2025-03-19 13:39:26 -0400 |
---|---|---|
committer | MusikAnimal <musikanimal@gmail.com> | 2025-03-19 14:20:58 -0400 |
commit | 53820c92e3c9d788737c26bebb664c8e7bc9afdb (patch) | |
tree | 01228d87ad57072a7467e1080792fa2d65c85024 /tests | |
parent | af413e5ac4f5c7fd3ee57d72ae598351493316a9 (diff) | |
download | mediawikicore-53820c92e3c9d788737c26bebb664c8e7bc9afdb.tar.gz mediawikicore-53820c92e3c9d788737c26bebb664c8e7bc9afdb.zip |
BlockLog.vue: show non-relative expiry where applicable
Log entries now correctly show the timestamp instead of a relavtive
expiry if the date was entered as a timestamp. We aren't able to do the
same for active blocks without a larger refactor, so for now it will
continue to show computed relative expiries even for those entered as
exact timestamps.
Bug: T389275
Change-Id: Iae28dc9cfd6eb7193f7b5cfc7b34fd9537ae2079
Diffstat (limited to 'tests')
-rw-r--r-- | tests/jest/mediawiki.special.block/BlockLog.test.js | 25 | ||||
-rw-r--r-- | tests/jest/mediawiki.special.block/SpecialBlock.setup.js | 82 |
2 files changed, 86 insertions, 21 deletions
diff --git a/tests/jest/mediawiki.special.block/BlockLog.test.js b/tests/jest/mediawiki.special.block/BlockLog.test.js index 1e9b806de19c..4b547e5e8049 100644 --- a/tests/jest/mediawiki.special.block/BlockLog.test.js +++ b/tests/jest/mediawiki.special.block/BlockLog.test.js @@ -105,4 +105,29 @@ describe( 'BlockLog', () => { expect( rows ).toHaveLength( 1 ); expect( rows[ 0 ].find( 'ul' ).text() ).toContain( 'blocklist-editing blocklist-editing-page Foobar' ); } ); + + it( 'should show relative expiries where appropriate', async () => { + mockMwConfigGet( { blockTargetUser: 'BlockedALot' } ); + const wrapper = mount( BlockLog, { + propsData: { blockLogType: 'recent' }, + global: { plugins: [ createTestingPinia( { stubActions: false } ) ] } + } ); + await flushPromises(); + // First expiry (5 years) + expect( wrapper.find( + '.mw-block-log__type-recent tr:first-child .mw-block-log__parameters li:first-child' + ).text() ).toStrictEqual( '5 years' ); + // Second is an unblock event, so no expiry + expect( + wrapper.find( '.mw-block-log__type-recent tr:nth-child(2) .mw-block-log__parameters' ).text() + ).toStrictEqual( '' ); + // Third row is an indefinite block + expect( wrapper.find( + '.mw-block-log__type-recent tr:nth-child(3) .mw-block-log__parameters li:first-child' + ).text() ).toStrictEqual( 'infinite' ); + // Fourth is a block entered with an exact datetime, and so should not show a relative expiry. + expect( wrapper.find( + '.mw-block-log__type-recent tr:nth-child(4) .mw-block-log__parameters li:first-child' + ).text() ).toStrictEqual( 'Sep 20, 2029, 14:31 UTC' ); + } ); } ); diff --git a/tests/jest/mediawiki.special.block/SpecialBlock.setup.js b/tests/jest/mediawiki.special.block/SpecialBlock.setup.js index 2a6268463276..dec463d55d60 100644 --- a/tests/jest/mediawiki.special.block/SpecialBlock.setup.js +++ b/tests/jest/mediawiki.special.block/SpecialBlock.setup.js @@ -121,6 +121,7 @@ function mockMwApiGet( additionalMocks = [] ) { title: 'User:ExampleUser', params: { duration: '1 year', + 'duration-l10n': '1 year', flags: [ 'noautoblock' ], @@ -152,6 +153,7 @@ function mockMwApiGet( additionalMocks = [] ) { title: 'User:ActiveBlockedUser', params: { duration: '100 years', + 'duration-l10n': '100 years', flags: [ 'noautoblock' ], @@ -170,6 +172,7 @@ function mockMwApiGet( additionalMocks = [] ) { user: 'ActiveBlockedUser', timestamp: '2024-09-17T14:30:51Z', expiry: '2124-09-17T14:30:51Z', + 'duration-l10n': '100 years', by: 'Admin', anononly: false, nocreate: false, @@ -186,6 +189,7 @@ function mockMwApiGet( additionalMocks = [] ) { user: 'ActiveBlockedUser', timestamp: '2024-09-17T14:30:51Z', expiry: '2029-09-17T14:30:51Z', + 'duration-l10n': '5 years', by: 'Admin', anononly: false, nocreate: false, @@ -202,6 +206,7 @@ function mockMwApiGet( additionalMocks = [] ) { user: 'ActiveBlockedUser', timestamp: '2024-09-17T14:30:51Z', expiry: '2029-09-17T14:30:51Z', + 'duration-l10n': '5 years', by: 'Admin', anononly: false, nocreate: false, @@ -243,11 +248,13 @@ function mockMwApiGet( additionalMocks = [] ) { }, query: { logevents: [ + // 5-year block { logid: 980, title: 'User:BlockedALot', params: { - duration: '1 year', + duration: '5 years', + 'duration-l10n': '5 years', flags: [ 'noautoblock' ], @@ -255,31 +262,29 @@ function mockMwApiGet( additionalMocks = [] ) { expiry: '2029-09-17T14:30:51Z' }, type: 'block', + action: 'block', user: 'Admin', timestamp: '2024-09-17T14:30:51Z', parsedcomment: 'A reason' }, + // Unblock event { logid: 981, title: 'User:BlockedALot', - params: { - duration: '1 year', - flags: [ - 'noautoblock' - ], - sitewide: true, - expiry: '2029-09-18T14:30:51Z' - }, + params: { blockId: 999 }, type: 'block', + action: 'unblock', user: 'Admin', timestamp: '2024-09-18T14:30:51Z', parsedcomment: 'A reason' }, + // Indefinite block { logid: 982, title: 'User:BlockedALot', params: { - duration: '1 year', + duration: 'infinity', + 'duration-l10n': 'infinite', flags: [ 'noautoblock' ], @@ -287,31 +292,37 @@ function mockMwApiGet( additionalMocks = [] ) { expiry: '2029-09-19T14:30:51Z' }, type: 'block', + action: 'block', user: 'Admin', timestamp: '2024-09-19T14:30:51Z', parsedcomment: 'A reason' }, + // Block with datetime duration { logid: 983, title: 'User:BlockedALot', params: { - duration: '1 year', + duration: '2029-09-20T14:31:51Z', + 'duration-l10n': '5 years and 1 minute', flags: [ 'noautoblock' ], sitewide: true, - expiry: '2029-09-20T14:30:51Z' + expiry: '2029-09-20T14:31:51Z' }, type: 'block', + action: 'block', user: 'Admin', timestamp: '2024-09-20T14:30:51Z', parsedcomment: 'A reason' }, + // Reblock { logid: 984, title: 'User:BlockedALot', params: { - duration: '1 year', + duration: '5 years', + 'duration-l10n': '5 years', flags: [ 'noautoblock' ], @@ -319,15 +330,18 @@ function mockMwApiGet( additionalMocks = [] ) { expiry: '2029-09-21T14:30:51Z' }, type: 'block', + action: 'reblock', user: 'Admin', timestamp: '2024-09-21T14:30:51Z', parsedcomment: 'A reason' }, + // Other mock blocks { logid: 985, title: 'User:BlockedALot', params: { - duration: '1 year', + duration: '5 years', + 'duration-l10n': '5 years', flags: [ 'noautoblock' ], @@ -335,6 +349,7 @@ function mockMwApiGet( additionalMocks = [] ) { expiry: '2029-09-22T14:30:51Z' }, type: 'block', + action: 'block', user: 'Admin', timestamp: '2024-09-22T14:30:51Z', parsedcomment: 'A reason' @@ -343,7 +358,8 @@ function mockMwApiGet( additionalMocks = [] ) { logid: 986, title: 'User:BlockedALot', params: { - duration: '1 year', + duration: '5 years', + 'duration-l10n': '5 years', flags: [ 'noautoblock' ], @@ -351,6 +367,7 @@ function mockMwApiGet( additionalMocks = [] ) { expiry: '2029-09-23T14:30:51Z' }, type: 'block', + action: 'block', user: 'Admin', timestamp: '2024-09-23T14:30:51Z', parsedcomment: 'A reason' @@ -359,7 +376,8 @@ function mockMwApiGet( additionalMocks = [] ) { logid: 987, title: 'User:BlockedALot', params: { - duration: '1 year', + duration: '5 years', + 'duration-l10n': '5 years', flags: [ 'noautoblock' ], @@ -367,6 +385,7 @@ function mockMwApiGet( additionalMocks = [] ) { expiry: '2029-09-24T14:30:51Z' }, type: 'block', + action: 'block', user: 'Admin', timestamp: '2024-09-24T14:30:51Z', parsedcomment: 'A reason' @@ -375,7 +394,8 @@ function mockMwApiGet( additionalMocks = [] ) { logid: 988, title: 'User:BlockedALot', params: { - duration: '1 year', + duration: '5 years', + 'duration-l10n': '5 years', flags: [ 'noautoblock' ], @@ -383,6 +403,7 @@ function mockMwApiGet( additionalMocks = [] ) { expiry: '2029-09-25T14:30:51Z' }, type: 'block', + action: 'block', user: 'Admin', timestamp: '2024-09-25T14:30:51Z', parsedcomment: 'A reason' @@ -391,7 +412,8 @@ function mockMwApiGet( additionalMocks = [] ) { logid: 989, title: 'User:BlockedALot', params: { - duration: '1 year', + duration: '5 years', + 'duration-l10n': '5 years', flags: [ 'noautoblock' ], @@ -399,6 +421,7 @@ function mockMwApiGet( additionalMocks = [] ) { expiry: '2029-09-26T14:30:51Z' }, type: 'block', + action: 'block', user: 'Admin', timestamp: '2024-09-26T14:30:51Z', parsedcomment: 'A reason' @@ -449,7 +472,12 @@ function mockMwApiGet( additionalMocks = [] ) { title: 'User:BadNameBlocked', pageid: 583, logpage: 583, - params: { duration: 'infinity', flags: [ 'hiddenname' ], sitewide: true }, + params: { + duration: 'infinity', + 'duration-l10n': 'infinite', + flags: [ 'hiddenname' ], + sitewide: true + }, type: 'suppress', action: 'block', user: 'Admin', @@ -475,7 +503,12 @@ function mockMwApiGet( additionalMocks = [] ) { title: 'User:BadNameBlocked', pageid: 583, logpage: 583, - params: { duration: 'infinity', flags: [ 'hiddenname' ], sitewide: true }, + params: { + duration: 'infinity', + 'duration-l10n': 'infinite', + flags: [ 'hiddenname' ], + sitewide: true + }, type: 'suppress', action: 'block', user: 'Admin', @@ -488,7 +521,12 @@ function mockMwApiGet( additionalMocks = [] ) { title: 'User:BadNameBlocked', pageid: 583, logpage: 583, - params: { duration: 'infinity', flags: [ 'hiddenname' ], sitewide: true }, + params: { + duration: 'infinity', + 'duration-l10n': 'infinite', + flags: [ 'hiddenname' ], + sitewide: true + }, type: 'suppress', action: 'block', user: 'Admin', @@ -514,6 +552,7 @@ function mockMwApiGet( additionalMocks = [] ) { by: 'Admin', timestamp: '2024-09-17T14:30:51Z', expiry: '2094-09-17T14:30:51Z', + 'duration-l10n': '50 years', reason: 'Vandalizing on [[Project:Foobar]]', anononly: false, nocreate: false, @@ -538,6 +577,7 @@ function mockMwApiGet( additionalMocks = [] ) { title: 'User:PartiallyBlockedUser', params: { duration: '50 years', + 'duration-l10n': '50 years', flags: [], restrictions: { pages: [ { |