| 1 | 'use strict'; |
| 2 | |
| 3 | const { action, assert, utils } = require( 'api-testing' ); |
| 4 | |
| 5 | describe( 'Prefix Search', () => { |
| 6 | const prefix = `R${ utils.title( utils.uniq() ) }`; |
| 7 | const firstPage = `${ prefix }_first`; |
| 8 | const secondPage = `${ prefix }_second`; |
| 9 | const thirdPage = `${ prefix }_third`; |
| 10 | |
| 11 | let alice; |
| 12 | |
| 13 | before( async () => { |
| 14 | alice = await action.alice(); |
| 15 | |
| 16 | const text = 'Random Text'; |
| 17 | |
| 18 | await alice.edit( firstPage, { text } ); |
| 19 | await alice.edit( secondPage, { text } ); |
| 20 | await alice.edit( thirdPage, { text } ); |
| 21 | } ); |
| 22 | |
| 23 | it( 'should search for pages with the `${prefix}` prefix', async () => { |
| 24 | const result = await alice.list( 'prefixsearch', { pssearch: `${ prefix }`, pslimit: 100 } ); |
| 25 | const pageTitles = result.map( ( p ) => utils.dbkey( p.title ) ); |
| 26 | assert.sameMembers( pageTitles, [ firstPage, secondPage, thirdPage ] ); |
| 27 | } ); |
| 28 | } ); |