| 1 | 'use strict'; |
| 2 | |
| 3 | const { action, assert, utils } = require( 'api-testing' ); |
| 4 | |
| 5 | describe( 'Backlinks', () => { |
| 6 | const randomPage = utils.title( 'Esther' ); |
| 7 | |
| 8 | const linksToEsther1 = utils.title( 'LinksToEsther1' ); |
| 9 | const linksToEsther2 = utils.title( 'LinksToEsther2' ); |
| 10 | |
| 11 | let bob; |
| 12 | |
| 13 | before( async () => { |
| 14 | bob = await action.bob(); |
| 15 | |
| 16 | const randomPageText = `I'm guessing you came here from ${ linksToEsther1 } or ${ linksToEsther2 }.`; |
| 17 | |
| 18 | const text = `All I do is link to [[${ randomPage }|Page]]`; |
| 19 | |
| 20 | await bob.edit( linksToEsther1, { text } ); |
| 21 | await bob.edit( linksToEsther2, { text } ); |
| 22 | await bob.edit( randomPage, { text: randomPageText } ); |
| 23 | |
| 24 | } ); |
| 25 | |
| 26 | describe( 'referrers', () => { |
| 27 | it( 'can be listed', async () => { |
| 28 | const result = await bob.list( 'backlinks', { bltitle: randomPage } ); |
| 29 | const links = result.map( ( p ) => p.title ); |
| 30 | assert.sameMembers( links, [ linksToEsther1, linksToEsther2 ] ); |
| 31 | } ); |
| 32 | } ); |
| 33 | } ); |