2020-06-02 21:24:59 +00:00
|
|
|
'use strict';
|
2020-05-12 18:28:43 +00:00
|
|
|
const { REST, assert, action, utils, clientFactory } = require( 'api-testing' );
|
2020-06-02 21:24:59 +00:00
|
|
|
|
2020-06-16 13:52:40 +00:00
|
|
|
describe( 'GET contributions', () => {
|
2020-06-02 21:24:59 +00:00
|
|
|
const basePath = 'rest.php/coredev/v0';
|
|
|
|
|
const anon = new REST( basePath );
|
2020-06-03 19:20:35 +00:00
|
|
|
const limit = 2;
|
2020-05-12 18:28:43 +00:00
|
|
|
const arnoldsRevisions = [];
|
|
|
|
|
const arnoldsEdits = [];
|
2020-05-12 18:28:43 +00:00
|
|
|
const arnoldsTags = [];
|
2020-06-16 13:52:40 +00:00
|
|
|
let arnold, beth, mindy;
|
|
|
|
|
let arnoldAction, samAction, mindyAction;
|
2020-06-05 08:20:05 +00:00
|
|
|
const revisionText = { 0: '12345678', 1: 'A', 2: 'ABCD', 3: 'AB', 4: 'ABCDEFGH', 5: 'A' };
|
|
|
|
|
const expectedRevisionDeltas = { 1: 1, 2: -4, 3: 1, 4: 4, 5: -1 };
|
2020-06-16 13:52:40 +00:00
|
|
|
let editToDelete;
|
2020-06-03 19:20:35 +00:00
|
|
|
|
|
|
|
|
before( async () => {
|
2020-06-16 12:05:50 +00:00
|
|
|
// Sam will be the same Sam for all tests, even in other files
|
|
|
|
|
samAction = await action.user( 'Sam', [ 'suppress' ] );
|
|
|
|
|
|
|
|
|
|
// Arnold will be a different Arnold every time
|
|
|
|
|
arnoldAction = await action.getAnon();
|
|
|
|
|
await arnoldAction.account( 'Arnold_' );
|
2020-06-16 13:52:40 +00:00
|
|
|
|
|
|
|
|
// Beth will be a different Beth every time
|
|
|
|
|
const bethAction = await action.getAnon();
|
|
|
|
|
await bethAction.account( 'Beth_' );
|
|
|
|
|
|
2020-05-12 18:28:43 +00:00
|
|
|
arnold = clientFactory.getRESTClient( basePath, arnoldAction );
|
2020-06-16 13:52:40 +00:00
|
|
|
mindy = clientFactory.getRESTClient( basePath, mindyAction );
|
|
|
|
|
beth = clientFactory.getRESTClient( basePath, bethAction );
|
2020-06-03 19:20:35 +00:00
|
|
|
|
2020-06-05 08:20:05 +00:00
|
|
|
const oddEditsPage = utils.title( 'UserContribution_' );
|
|
|
|
|
const evenEditsPage = utils.title( 'UserContribution_' );
|
2020-06-03 19:20:35 +00:00
|
|
|
|
2020-06-05 08:20:05 +00:00
|
|
|
// Create a tag.
|
2020-05-12 18:28:43 +00:00
|
|
|
await action.makeTag( 'api-test' );
|
|
|
|
|
|
2020-06-16 13:52:40 +00:00
|
|
|
// Beth makes 2 edits, the first one is later suppressed
|
|
|
|
|
const pageToDelete = utils.title( 'UserContribution_' );
|
|
|
|
|
editToDelete = await bethAction.edit( pageToDelete, [ { text: 'Beth edit 1' } ] );
|
|
|
|
|
await bethAction.edit( pageToDelete, [ { text: 'Beth edit 2' } ] );
|
2020-06-03 19:20:35 +00:00
|
|
|
|
2020-06-05 08:20:05 +00:00
|
|
|
// arnold makes 5 edits
|
|
|
|
|
let page;
|
2020-05-12 18:28:43 +00:00
|
|
|
for ( let i = 1; i <= 5; i++ ) {
|
2020-06-05 08:20:05 +00:00
|
|
|
const oddEdit = i % 2;
|
|
|
|
|
const tags = oddEdit ? 'api-test' : null;
|
|
|
|
|
page = oddEdit ? oddEditsPage : evenEditsPage;
|
2020-05-12 18:28:43 +00:00
|
|
|
arnoldsTags[ i ] = tags ? tags.split( '|' ) : [];
|
|
|
|
|
|
2020-06-05 08:20:05 +00:00
|
|
|
const revData = await arnoldAction.edit( page, { text: revisionText[ i ], tags } );
|
2020-06-03 19:20:35 +00:00
|
|
|
await utils.sleep();
|
2020-05-12 18:28:43 +00:00
|
|
|
arnoldsRevisions[ revData.newrevid ] = revData;
|
|
|
|
|
arnoldsEdits[ i ] = revData;
|
2020-06-03 19:20:35 +00:00
|
|
|
}
|
|
|
|
|
} );
|
2020-06-02 21:24:59 +00:00
|
|
|
|
2020-06-16 13:52:40 +00:00
|
|
|
const testGetEdits = async ( client, endpoint ) => {
|
|
|
|
|
const { status, body } = await client.get( endpoint, { limit } );
|
2020-06-03 19:20:35 +00:00
|
|
|
assert.equal( status, 200 );
|
|
|
|
|
|
|
|
|
|
// assert body has property revisions
|
|
|
|
|
assert.property( body, 'revisions' );
|
|
|
|
|
const { revisions } = body;
|
|
|
|
|
|
|
|
|
|
// assert body.revisions is array
|
|
|
|
|
assert.isArray( revisions );
|
|
|
|
|
|
|
|
|
|
// assert body.revisions length is limit
|
|
|
|
|
assert.lengthOf( revisions, limit );
|
|
|
|
|
|
2020-05-12 18:28:43 +00:00
|
|
|
const lastRevision = arnoldsRevisions[ arnoldsRevisions.length - 1 ];
|
2020-06-03 19:20:35 +00:00
|
|
|
|
|
|
|
|
// assert body.revisions object schema is correct
|
|
|
|
|
assert.hasAllDeepKeys( revisions[ 0 ], [
|
2020-06-05 08:20:05 +00:00
|
|
|
'id', 'comment', 'timestamp', 'delta', 'size', 'page', 'tags'
|
2020-06-03 19:20:35 +00:00
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
assert.equal( revisions[ 0 ].page.key, utils.dbkey( lastRevision.title ) );
|
|
|
|
|
assert.equal( revisions[ 0 ].page.title, lastRevision.title );
|
|
|
|
|
assert.equal( revisions[ 0 ].comment, lastRevision.param_summary );
|
|
|
|
|
assert.equal( revisions[ 0 ].timestamp, lastRevision.newtimestamp );
|
2020-06-05 08:20:05 +00:00
|
|
|
assert.equal( revisions[ 0 ].size, revisionText[ 5 ].length );
|
|
|
|
|
assert.equal( revisions[ 0 ].delta, expectedRevisionDeltas[ 5 ] );
|
2020-06-03 19:20:35 +00:00
|
|
|
assert.isOk( Date.parse( revisions[ 0 ].timestamp ) );
|
|
|
|
|
assert.isNotOk( Date.parse( 'xyz' ) );
|
2020-05-12 18:28:43 +00:00
|
|
|
assert.isArray( revisions[ 0 ].tags );
|
|
|
|
|
|
2020-05-12 18:28:43 +00:00
|
|
|
assert.isAbove( Date.parse( revisions[ 0 ].timestamp ),
|
|
|
|
|
Date.parse( revisions[ 1 ].timestamp ) );
|
|
|
|
|
|
2020-06-05 08:20:05 +00:00
|
|
|
assert.equal( revisions[ 1 ].size, revisionText[ 4 ].length );
|
|
|
|
|
assert.equal( revisions[ 1 ].delta, expectedRevisionDeltas[ 4 ] );
|
|
|
|
|
|
2020-06-03 19:20:35 +00:00
|
|
|
// assert body.revisions contains edits only by one user
|
|
|
|
|
revisions.forEach( ( rev ) => {
|
2020-05-12 18:28:43 +00:00
|
|
|
assert.property( arnoldsRevisions, rev.id );
|
2020-06-03 19:20:35 +00:00
|
|
|
} );
|
2020-06-16 13:52:40 +00:00
|
|
|
};
|
2020-06-03 19:20:35 +00:00
|
|
|
|
2020-06-16 13:52:40 +00:00
|
|
|
const testGetEditsByTag = async ( client, endpoint ) => {
|
2020-06-15 21:29:21 +00:00
|
|
|
const taggedRevisions = [ arnoldsEdits[ 1 ], arnoldsEdits[ 3 ], arnoldsEdits[ 5 ] ];
|
|
|
|
|
|
2020-06-16 13:52:40 +00:00
|
|
|
const { status, body } = await client.get( endpoint, { tag: 'api-test' } );
|
2020-06-15 21:29:21 +00:00
|
|
|
assert.equal( status, 200 );
|
|
|
|
|
|
|
|
|
|
// assert body has property revisions
|
|
|
|
|
assert.property( body, 'revisions' );
|
|
|
|
|
const { revisions } = body;
|
|
|
|
|
|
|
|
|
|
// assert body.revisions length
|
|
|
|
|
assert.lengthOf( revisions, taggedRevisions.length );
|
|
|
|
|
|
|
|
|
|
// assert that there are no more revisions found
|
|
|
|
|
assert.propertyVal( body, 'older', null );
|
|
|
|
|
|
|
|
|
|
// assert body.revisions has the correct content
|
|
|
|
|
assert.equal( revisions[ 0 ].id, arnoldsEdits[ 5 ].newrevid );
|
|
|
|
|
assert.equal( revisions[ 1 ].id, arnoldsEdits[ 3 ].newrevid );
|
|
|
|
|
assert.equal( revisions[ 2 ].id, arnoldsEdits[ 1 ].newrevid );
|
2020-06-16 13:52:40 +00:00
|
|
|
};
|
2020-06-15 21:29:21 +00:00
|
|
|
|
2020-06-16 13:52:40 +00:00
|
|
|
const testPagingForward = async ( client, endpoint ) => {
|
2020-05-12 18:28:43 +00:00
|
|
|
// get latest segment
|
2020-06-16 13:52:40 +00:00
|
|
|
const { body: latestSegment } = await client.get( endpoint, { limit } );
|
2020-05-12 18:28:43 +00:00
|
|
|
assert.property( latestSegment, 'older' );
|
|
|
|
|
assert.property( latestSegment, 'revisions' );
|
|
|
|
|
assert.isArray( latestSegment.revisions );
|
|
|
|
|
assert.lengthOf( latestSegment.revisions, 2 );
|
|
|
|
|
|
|
|
|
|
// assert body.revisions has the correct content
|
|
|
|
|
assert.equal( latestSegment.revisions[ 0 ].id, arnoldsEdits[ 5 ].newrevid );
|
|
|
|
|
assert.equal( latestSegment.revisions[ 1 ].id, arnoldsEdits[ 4 ].newrevid );
|
|
|
|
|
|
2020-05-12 18:28:43 +00:00
|
|
|
assert.deepEqual( latestSegment.revisions[ 0 ].tags, arnoldsTags[ 5 ] );
|
|
|
|
|
assert.deepEqual( latestSegment.revisions[ 1 ].tags, arnoldsTags[ 4 ] );
|
|
|
|
|
|
2020-05-12 18:28:43 +00:00
|
|
|
// get older segment, using full url
|
2020-06-16 13:52:40 +00:00
|
|
|
const req = clientFactory.getHttpClient( client );
|
2020-05-12 18:28:43 +00:00
|
|
|
|
|
|
|
|
const { body: olderSegment } = await req.get( latestSegment.older );
|
|
|
|
|
assert.property( olderSegment, 'older' );
|
|
|
|
|
assert.property( olderSegment, 'revisions' );
|
|
|
|
|
assert.isArray( olderSegment.revisions );
|
|
|
|
|
assert.lengthOf( olderSegment.revisions, 2 );
|
|
|
|
|
|
|
|
|
|
// assert body.revisions has the correct content
|
|
|
|
|
assert.equal( olderSegment.revisions[ 0 ].id, arnoldsEdits[ 3 ].newrevid );
|
|
|
|
|
assert.equal( olderSegment.revisions[ 1 ].id, arnoldsEdits[ 2 ].newrevid );
|
|
|
|
|
|
2020-05-12 18:28:43 +00:00
|
|
|
assert.deepEqual( olderSegment.revisions[ 0 ].tags, arnoldsTags[ 3 ] );
|
|
|
|
|
assert.deepEqual( olderSegment.revisions[ 1 ].tags, arnoldsTags[ 2 ] );
|
|
|
|
|
|
2020-05-12 18:28:43 +00:00
|
|
|
// get the next older segment
|
|
|
|
|
const { body: finalSegment } = await req.get( olderSegment.older );
|
|
|
|
|
assert.propertyVal( finalSegment, 'older', null );
|
|
|
|
|
assert.property( finalSegment, 'revisions' );
|
|
|
|
|
assert.isArray( finalSegment.revisions );
|
|
|
|
|
assert.lengthOf( finalSegment.revisions, 1 );
|
|
|
|
|
|
|
|
|
|
// assert body.revisions has the correct content
|
|
|
|
|
assert.equal( finalSegment.revisions[ 0 ].id, arnoldsEdits[ 1 ].newrevid );
|
2020-05-12 18:28:43 +00:00
|
|
|
|
|
|
|
|
assert.deepEqual( finalSegment.revisions[ 0 ].tags, arnoldsTags[ 1 ] );
|
2020-06-16 13:52:40 +00:00
|
|
|
};
|
2020-05-12 18:28:43 +00:00
|
|
|
|
2020-06-16 13:52:40 +00:00
|
|
|
const testPagingBackwards = async ( client, endpoint ) => {
|
|
|
|
|
const req = clientFactory.getHttpClient( client );
|
2020-06-05 08:14:21 +00:00
|
|
|
|
|
|
|
|
// get latest segment
|
2020-06-16 13:52:40 +00:00
|
|
|
const { body: latestSegment } = await client.get( endpoint, { limit } );
|
2020-06-05 08:14:21 +00:00
|
|
|
assert.property( latestSegment, 'newer' );
|
|
|
|
|
|
|
|
|
|
// get next older segment
|
|
|
|
|
const { body: olderSegment } = await req.get( latestSegment.older );
|
|
|
|
|
assert.property( olderSegment, 'newer' );
|
|
|
|
|
|
|
|
|
|
// get the final segment
|
|
|
|
|
const { body: finalSegment } = await req.get( olderSegment.older );
|
|
|
|
|
assert.property( finalSegment, 'newer' );
|
|
|
|
|
|
|
|
|
|
// Follow the chain of "newer" links back to the latest segment
|
|
|
|
|
const { body: olderSegment2 } = await req.get( finalSegment.newer );
|
|
|
|
|
assert.deepEqual( olderSegment, olderSegment2 );
|
|
|
|
|
|
|
|
|
|
const { body: latestSegment2 } = await req.get( olderSegment.newer );
|
|
|
|
|
assert.deepEqual( latestSegment, latestSegment2 );
|
2020-06-16 13:52:40 +00:00
|
|
|
};
|
2020-06-05 08:14:21 +00:00
|
|
|
|
2020-06-16 13:52:40 +00:00
|
|
|
const testHasLatest = async ( client, endpoint ) => {
|
|
|
|
|
const req = clientFactory.getHttpClient( client );
|
2020-06-05 08:14:21 +00:00
|
|
|
|
|
|
|
|
// get latest segment
|
2020-06-16 13:52:40 +00:00
|
|
|
const { body: latestSegment } = await client.get( endpoint, { limit } );
|
2020-06-05 08:14:21 +00:00
|
|
|
assert.property( latestSegment, 'latest' );
|
|
|
|
|
|
|
|
|
|
// get next older segment
|
|
|
|
|
const { body: olderSegment } = await req.get( latestSegment.older );
|
|
|
|
|
assert.property( olderSegment, 'latest' );
|
|
|
|
|
|
|
|
|
|
// get the final segment
|
|
|
|
|
const { body: finalSegment } = await req.get( olderSegment.older );
|
|
|
|
|
assert.property( finalSegment, 'latest' );
|
|
|
|
|
|
|
|
|
|
// Follow all the "newer" links
|
2020-06-15 21:29:21 +00:00
|
|
|
const { body: latestSegment2 } = await req.get( latestSegment.latest );
|
|
|
|
|
assert.deepEqual( latestSegment, latestSegment2 );
|
|
|
|
|
|
|
|
|
|
assert.deepEqual( latestSegment.latest, finalSegment.latest );
|
|
|
|
|
assert.deepEqual( latestSegment.latest, olderSegment.latest );
|
|
|
|
|
|
2020-06-16 13:52:40 +00:00
|
|
|
};
|
2020-06-15 21:29:21 +00:00
|
|
|
|
2020-06-16 13:52:40 +00:00
|
|
|
const testPreserveTagFilter = async ( client, endpoint ) => {
|
|
|
|
|
const req = clientFactory.getHttpClient( client );
|
2020-06-15 21:29:21 +00:00
|
|
|
|
|
|
|
|
// get latest segment
|
2020-06-16 13:52:40 +00:00
|
|
|
const { body: latestSegment } = await client.get( endpoint, { limit: 2, tag: 'api-test' } );
|
2020-06-15 21:29:21 +00:00
|
|
|
|
|
|
|
|
// assert body.revisions has the latest revisions that have the "api-test" tag (odd edits)
|
|
|
|
|
assert.equal( latestSegment.revisions[ 0 ].id, arnoldsEdits[ 5 ].newrevid );
|
|
|
|
|
assert.equal( latestSegment.revisions[ 1 ].id, arnoldsEdits[ 3 ].newrevid );
|
|
|
|
|
|
|
|
|
|
// get the final segment
|
|
|
|
|
const { body: finalSegment } = await req.get( latestSegment.older );
|
|
|
|
|
|
|
|
|
|
// assert body.revisions has the oldest revisions that have the "api-test" tag (odd edits)
|
|
|
|
|
assert.equal( finalSegment.revisions[ 0 ].id, arnoldsEdits[ 1 ].newrevid );
|
|
|
|
|
|
|
|
|
|
const { body: latestSegment2 } = await req.get( finalSegment.newer );
|
2020-06-05 08:14:21 +00:00
|
|
|
assert.deepEqual( latestSegment, latestSegment2 );
|
|
|
|
|
|
2020-06-15 21:29:21 +00:00
|
|
|
const { body: latestSegment3 } = await req.get( latestSegment.latest );
|
2020-06-05 08:14:21 +00:00
|
|
|
assert.deepEqual( latestSegment, latestSegment3 );
|
|
|
|
|
|
2020-06-15 21:29:21 +00:00
|
|
|
// assert that the "latest" links also preserve the "tag" parameter
|
|
|
|
|
assert.deepEqual( finalSegment.latest, latestSegment.latest );
|
2020-06-16 13:52:40 +00:00
|
|
|
};
|
2020-06-09 09:33:22 +00:00
|
|
|
|
2020-06-16 13:52:40 +00:00
|
|
|
const testSuppressedRevisions = async ( client, endpoint ) => {
|
2020-06-09 09:33:22 +00:00
|
|
|
await samAction.action( 'revisiondelete',
|
|
|
|
|
{
|
|
|
|
|
type: 'revision',
|
|
|
|
|
token: await samAction.token(),
|
|
|
|
|
target: editToDelete.title,
|
|
|
|
|
hide: 'content|comment|user',
|
|
|
|
|
ids: editToDelete.newrevid
|
|
|
|
|
},
|
|
|
|
|
'POST'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Users without appropriate permissions cannot see suppressed revisions (even their own)
|
2020-06-16 13:52:40 +00:00
|
|
|
const { body: clientGetBody } = await client.get( endpoint );
|
|
|
|
|
assert.lengthOf( clientGetBody.revisions, 1 );
|
2020-06-09 09:33:22 +00:00
|
|
|
|
|
|
|
|
await samAction.action( 'revisiondelete',
|
|
|
|
|
{
|
|
|
|
|
type: 'revision',
|
|
|
|
|
token: await samAction.token(),
|
|
|
|
|
target: editToDelete.title,
|
|
|
|
|
show: 'content|comment|user',
|
|
|
|
|
ids: editToDelete.newrevid
|
|
|
|
|
},
|
|
|
|
|
'POST'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Users with appropriate permissions can see suppressed revisions
|
2020-06-16 13:52:40 +00:00
|
|
|
const { body: clientGetBody2 } = await client.get( endpoint );
|
|
|
|
|
assert.lengthOf( clientGetBody2.revisions, 2 );
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
describe( 'GET /me/contributions', () => {
|
|
|
|
|
const endpoint = '/me/contributions';
|
|
|
|
|
|
|
|
|
|
it( 'Returns status 401 for anon', async () => {
|
|
|
|
|
const response = await anon.get( endpoint );
|
|
|
|
|
assert.equal( response.status, 401 );
|
|
|
|
|
assert.nestedProperty( response.body, 'messageTranslations' );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns status OK', async () => {
|
|
|
|
|
const response = await arnold.get( endpoint );
|
|
|
|
|
assert.equal( response.status, 200 );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns 400 if segment size is out of bounds', async () => {
|
|
|
|
|
const { status: minLimitStatus } = await arnold.get( endpoint, { limit: 0 } );
|
|
|
|
|
assert.equal( minLimitStatus, 400 );
|
|
|
|
|
|
|
|
|
|
const { status: maxLimitStatus } = await arnold.get( endpoint, { limit: 30 } );
|
|
|
|
|
assert.equal( maxLimitStatus, 400 );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns a list of the user\'s own edits', async () => {
|
|
|
|
|
await testGetEdits( arnold, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns edits filtered by tag', async () => {
|
|
|
|
|
await testGetEditsByTag( arnold, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Can fetch a chain of segments following the "older" field in the response', async () => {
|
|
|
|
|
await testPagingForward( arnold, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Can fetch a chain of segments following the "newer" field in the response', async () => {
|
|
|
|
|
await testPagingBackwards( arnold, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns a valid link to the latest segment', async () => {
|
|
|
|
|
await testHasLatest( arnold, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Does not return suppressed revisions when requesting user does not have appropriate permissions', async () => {
|
|
|
|
|
// Note that the suppressed revisions are Beth's contributions.
|
|
|
|
|
await testSuppressedRevisions( beth, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Segment link preserves tag filtering', async () => {
|
|
|
|
|
await testPreserveTagFilter( arnold, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
describe( 'GET /user/{name}/contributions', () => {
|
|
|
|
|
let endpoint;
|
|
|
|
|
|
|
|
|
|
before( () => {
|
|
|
|
|
endpoint = `/user/${arnold.username}/contributions`;
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns 400 if segment size is out of bounds', async () => {
|
|
|
|
|
const { status: minLimitStatus } = await arnold.get( endpoint, { limit: 0 } );
|
|
|
|
|
assert.equal( minLimitStatus, 400 );
|
|
|
|
|
|
|
|
|
|
const { status: maxLimitStatus } = await arnold.get( endpoint, { limit: 30 } );
|
|
|
|
|
assert.equal( maxLimitStatus, 400 );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns 400 if user name is invalid', async () => {
|
|
|
|
|
const xyzzy = '|||'; // an invalid user name
|
|
|
|
|
const xendpoint = `/user/${xyzzy}/contributions`;
|
|
|
|
|
const response = await anon.get( xendpoint );
|
|
|
|
|
assert.equal( response.status, 400 );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns 400 if user name is empty', async () => {
|
|
|
|
|
const xendpoint = '/user//contributions';
|
|
|
|
|
const response = await anon.get( xendpoint );
|
|
|
|
|
assert.equal( response.status, 400 );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns 404 if user is unknown', async () => {
|
|
|
|
|
const xyzzy = utils.uniq(); // a non-existing user name
|
|
|
|
|
const xendpoint = `/user/${xyzzy}/contributions`;
|
|
|
|
|
const response = await anon.get( xendpoint );
|
|
|
|
|
assert.equal( response.status, 404 );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns 200 if user is an IP address', async () => {
|
|
|
|
|
const xyzzy = '127.111.222.111';
|
|
|
|
|
const xendpoint = `/user/${xyzzy}/contributions`;
|
|
|
|
|
const response = await anon.get( xendpoint );
|
|
|
|
|
assert.equal( response.status, 200 );
|
|
|
|
|
|
|
|
|
|
assert.property( response.body, 'revisions' );
|
|
|
|
|
assert.deepEqual( response.body.revisions, [] );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Anon gets a list of arnold\'s edits', async () => {
|
|
|
|
|
await testGetEdits( anon, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns Arnold\'s edits filtered by tag', async () => {
|
|
|
|
|
await testGetEditsByTag( anon, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Arnold gets a list of arnold\'s edits', async () => {
|
|
|
|
|
await testGetEdits( arnold, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Mindy gets a list of arnold\'s edits', async () => {
|
|
|
|
|
await testGetEdits( mindy, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Can fetch a chain of segments following the "older" field in the response', async () => {
|
|
|
|
|
await testPagingForward( anon, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Can fetch a chain of segments following the "newer" field in the response', async () => {
|
|
|
|
|
await testPagingBackwards( anon, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Returns a valid link to the latest segment', async () => {
|
|
|
|
|
await testHasLatest( anon, endpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Does not return suppressed revisions when requesting user does not have appropriate permissions', async () => {
|
|
|
|
|
// Note that the suppressed revisions are Beth's contributions.
|
|
|
|
|
const bethsEndpoint = `/user/${beth.username}/contributions`;
|
|
|
|
|
await testSuppressedRevisions( anon, bethsEndpoint );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'Segment link preserves tag filtering', async () => {
|
|
|
|
|
await testPreserveTagFilter( anon, endpoint );
|
|
|
|
|
} );
|
2020-06-09 09:33:22 +00:00
|
|
|
} );
|
|
|
|
|
|
2020-06-02 21:24:59 +00:00
|
|
|
} );
|