it('should allow a user make edits on a page passing the timestamp from the previous edit on the same page the basetimetamp',async()=>{
constpage=utils.title('Page_');
consteditContent='An edit from Clark';
constrev1=awaitalice.edit(page,{
text:'An edit from Alice'
});
awaitClark.edit(page,{
text:editContent,
basetimestamp:rev1.timestamp
});
constpageContent=awaitClark.getHtml(page);
assert.include(pageContent,editContent);
});
it('should throw an error when a user tries to set the basetimestamp to a date/time different from the timestamp of the previous edit',async()=>{
constpage=utils.title('Page_');
constrev1=awaitalice.edit(page,{
text:'An edit from Alice'
});
awaitClark.edit(page,{
text:'An edit from Clark',
basetimestamp:rev1.timestamp
});
consterror=awaitalice.actionError('edit',{
title:page,
text:'Another edit by Alice',
token:awaitalice.token('csrf'),
basetimestamp:'2001-01-01T00:00:00Z'
},'POST');
assert.equal(error.code,'editconflict');
});
it('should throw an error when a wrong value is passed to md5',async()=>{
constpage=utils.title('Page');
consterror=awaitClark.actionError('edit',{
title:page,
token:awaitClark.token('csrf'),
text:'Some Text',
summary:'Bad md5',
md5:'sometext'
},'POST');
assert.equal(error.code,'badmd5');
});
it('should edit the page when the correct md5 hash of the text parameter is passed to it',async()=>{
constpage=utils.title('Page_');
consttext='An edit with the correct md5';
awaitClark.edit(page,{
text:text,
md5:'d19dc30a12f31ec3684743bc010ef148'
});
constpageContent=awaitClark.getHtml(page);
assert.include(pageContent,text);
});
it('should edit the page when the correct md5 hash of the appendtext is passed to the md5 parameter as the appendtext parameter should override the text parameter',async()=>{
constpage=utils.title('Page_');
consttext='An edit containing text and appendtext parameters with the correct md5';
constbottom='An edit just for the bottom';
awaitClark.edit(page,{
text:text,
appendtext:bottom,
md5:'83edcea6d422ba921d0442ca29abce1d'
});
constpageContent=awaitClark.getHtml(page);
assert.notInclude(pageContent,text);
assert.include(pageContent,bottom);
});
it('should edit the page when the correct md5 hash of the prependtext is passed to the md5 parameter as the prependtext parameter should override the text parameter',async()=>{
constpage=utils.title('Page_');
consttext='An edit containing text and appendtext parameters with the correct md5';
consttop='An edit just for the top';
awaitClark.edit(page,{
text:text,
prependtext:top,
md5:'0f5f08a431409bc0c504c090fe4f2f11'
});
constpageContent=awaitClark.getHtml(page);
assert.notInclude(pageContent,text);
assert.include(pageContent,top);
});
it('should edit the page when the correct md5 hash of the prependtext and appendtext concatenated is passed to the md5 parameter',async()=>{
constpage=utils.title('Page_');
consttext='An edit containing text and appendtext parameters with the correct md5';
consttop='An edit just for the top';
constbottom='An edit just for the bottom';
awaitClark.edit(page,{
text:text,
prependtext:top,
appendtext:bottom,
md5:'b1df72139fc1202b6d817d9b1459e2d5'
});
constpageContent=awaitClark.getHtml(page);
assert.notInclude(pageContent,text);
assert.include(pageContent,top+bottom);
});
it('should throw an error when the wrong md5 hash of the prependtext and appendtext concatenated is passed to the md5 parameter',async()=>{
constpage=utils.title('Page_');
consttext='An edit containing text and appendtext parameters with the correct md5';
consttop='An edit just for the top';
constbottom='An edit just for the bottom';
consterror=awaitClark.actionError('edit',{
title:page,
token:awaitClark.token('csrf'),
text:text,
prependtext:top,
appendtext:bottom,
summary:'Bad md5',
md5:'badmd5139fc1202b6d817d9b1459e2d5'
},'POST');
assert.equal(error.code,'badmd5');
});
it('should override the text parameter with the appendtext parameter',async()=>{
constpage=utils.title('Page_');
consttext='A text that is to be overriden';
constbottom='This text should override the text parameter';
awaitClark.edit(page,{
text:text,
appendtext:bottom
});
constpageContent=awaitClark.getHtml(page);
assert.notInclude(pageContent,text);
assert.include(pageContent,bottom);
});
it('should override the text parameter with the prependtext parameter',async()=>{
constpage=utils.title('Page_');
consttext='A text that is to be overriden';
consttop='This text should override the text parameter';
awaitClark.edit(page,{
text:text,
prependtext:top
});
constpageContent=awaitClark.getHtml(page);
assert.notInclude(pageContent,text);
assert.include(pageContent,top);
});
it('should override the text parameter with the appendtext and prependtext parameters',async()=>{
constpage=utils.title('Page_');
consttext='A text that is to be overriden';
consttop='This text should override the text parameter on top';
constbottom='This text should override the text parameter at the end';