Commit 2604376c authored by Rob Hulswit's avatar Rob Hulswit

Merge branch 'feature/testimages-for-external-use' into 'master'

Centralize test images, standardize some test images for external module tests

See merge request !230
parents aa91bc17 444c2717
......@@ -9,11 +9,11 @@ PUBLIC RECORD FUNCTION GetTestRTD(RECORD options DEFAULTSTO DEFAULT RECORD)
STRING inputfile := options.bigstructure ? "rte-structure-big.html" : "rte-structure.html";
RETURN [ htmltext := GetWebHareResource("mod::webhare_testsuite/data/test/" || inputfile)
, embedded := [ [ contentid := "SRCEMBED-4tE8e-B6Eig"
, data := GetWebhareResource("mod::webhare_testsuite/web/tests/pages/rte/header-logo.png")
, width:=27
, height:=26
, data := GetWebhareResource("mod::system/web/tests/webhare.png")
, width := 178
, height := 51
, mimetype:="image/png"
, filename := "header-logo.png"
, filename := "webhare.png"
]
]
, instances := [ [ instanceid := "_1ra7ve1TrCw-usGy9kO-g"
......
......@@ -195,7 +195,7 @@ PUBLIC MACRO SetupTheWRDTestSchema(OBJECT schemaobj, RECORD options DEFAULTSTO D
persontype->CreateAttribute("TEST_ARRAY.TEST_MULTIPLE", "DOMAINARRAY", [ title := "Array multiple domain attribute", domaintag := domain1_obj->tag ]);
persontype->CreateAttribute("TEST_ARRAY.TEST_EMAIL", "EMAIL", [ title := "Array email attribute" ]);
BLOB testimage_blob := GetWebhareResource("mod::webhare_testsuite/tests/wrd/testdata/goudvis.png");
BLOB testimage_blob := GetWebhareResource("mod::system/web/tests/goudvis.png");
RECORD testimage := WrapBlob(testimage_blob,"goudvis.png");
BLOB testfile_blob; //FIXME: Get from disk
......@@ -264,7 +264,7 @@ PUBLIC MACRO CreateWRDTestSchema(RECORD options DEFAULTSTO DEFAULT RECORD)
PUBLIC MACRO TestRichieEmbedded(RECORD testrec1)
{
TestEq(1, Length(testrec1.embedded));
TestEq(4157, Length(testrec1.embedded[0].data));
TestEq(4355, Length(testrec1.embedded[0].data));
TestEq(2, Length(testrec1.instances));
TestEq("<b>BOLD<\/b> HTML", testrec1.instances[0].data.html);
}
......
......@@ -210,7 +210,7 @@ PUBLIC MACRO CustomForm()
, link := "data:text/plain,someBODY"
]
, imgedit := [ filename := "goudvis.png"
, link := GetDataUrl(GetWebhareResource("mod::webhare_testsuite/tests/wrd/testdata/goudvis.png"), "image/png")
, link := GetDataUrl(GetWebhareResource("mod::system/web/tests/goudvis.png"), "image/png")
]
, checkboxes := ["copt1","copt3"]
, date := "2017-06-22"
......
......@@ -64,7 +64,7 @@ PUBLIC MACRO FillInForm()
, link := "data:text/plain,someBODY"
]
, imgedit := [ filename := "goudvis.png"
, link := GetDataUrl(GetWebhareResource("mod::webhare_testsuite/tests/wrd/testdata/goudvis.png"), "image/png")
, link := GetDataUrl(GetWebhareResource("mod::system/web/tests/goudvis.png"), "image/png")
]
, date := "2017-06-22"
, checkboxes := ["copt1","copt3"]
......
......@@ -86,8 +86,8 @@ test.registerTests(
test.eq("Dit bestandstype is niet toegestaan", filegroup.querySelector(".wh-form__error").textContent);
//uploading proper file should fix it
test.prepareUpload( [{ url: '/tollium_todd.res/webhare_testsuite/tollium/landscape_4.jpg'
, filename: 'landscape_4.jpg'
test.prepareUpload( [{ url: '/tests/flipped_and_180.jpg'
, filename: 'flipped_and_180.jpg'
}]);
test.click('[data-wh-form-group-for=file] .wh-form__uploadfieldselect');
......
......@@ -104,8 +104,8 @@ PUBLIC RECORD ARRAY restructuringtests :=
, [ structure := pages_rte_test_structure
, title := "Softenters, images at root level"
, input := `<h1>Kop</h1><p>paragraaf<br>metsoftenter</p><img height="50" width="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" />`
, expect := `<h1 class="heading1">Kop</h1><p class="normal">paragraaf<br>metsoftenter</p><p class="normal"><img class="wh-rtd__img" height="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" width="50" /></p>`
, input := `<h1>Kop</h1><p>paragraaf<br>metsoftenter</p><img height="50" width="50" src="/tests/webhare.png" />`
, expect := `<h1 class="heading1">Kop</h1><p class="normal">paragraaf<br>metsoftenter</p><p class="normal"><img class="wh-rtd__img" height="50" src="/tests/webhare.png" width="50" /></p>`
]
, [ structure := pages_rte_test_structure
, title := "Links with hash urls"
......@@ -114,13 +114,13 @@ PUBLIC RECORD ARRAY restructuringtests :=
]
, [ structure := pages_rte_test_structure
, title := "Link with image"
, input := `<p><a href="http://nu.nl/" target="_blank"><img alt="test" height="50" width="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" /></a></p>`
, expect := `<p class="normal"><a href="http://nu.nl/" target="_blank"><img alt="test" class="wh-rtd__img" height="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" width="50" /></a></p>`
, input := `<p><a href="http://nu.nl/" target="_blank"><img alt="test" height="50" width="50" src="/tests/webhare.png" /></a></p>`
, expect := `<p class="normal"><a href="http://nu.nl/" target="_blank"><img alt="test" class="wh-rtd__img" height="50" src="/tests/webhare.png" width="50" /></a></p>`
]
, [ structure := pages_rte_test_structure
, title := "Link with image and text"
, input := `<p><a href="http://nu.nl/"><img alt="test" height="50" width="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" />x</a></p>`
, expect := `<p class="normal"><a href="http://nu.nl/"><img alt="test" class="wh-rtd__img" height="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" width="50" />x</a></p>`
, input := `<p><a href="http://nu.nl/"><img alt="test" height="50" width="50" src="/tests/webhare.png" />x</a></p>`
, expect := `<p class="normal"><a href="http://nu.nl/"><img alt="test" class="wh-rtd__img" height="50" src="/tests/webhare.png" width="50" />x</a></p>`
]
, [ structure := pages_rte_test_structure
......
......@@ -171,7 +171,7 @@ MACRO WrappedTest()
testfw->BeginWork();
OBJECT testfolderobj := testfw->GetWHFSTestRoot();
RECORD goudvisfile := WrapBlob(GetWebhareResource("mod::webhare_testsuite/tests/wrd/testdata/goudvis.png"), "goudvis-name.png");
RECORD goudvisfile := WrapBlob(GetWebhareResource("mod::system/web/tests/goudvis.png"), "goudvis-name.png");
/* You *must* specify name explicitly, we're not going to take 'filename' from wrapped as that will be very confusing in
an UpdateMetadata call: if you give it a 'wrapped' with a different filename and don't explicitly set a name := to UpdateMetadata,
......
......@@ -140,8 +140,8 @@ test.registerTests(
, { name: 'testSelectAndUpload'
, test: async function(doc, win)
{
prepareUploadTest($t('myinput'),[ { url: '/tollium_todd.res/webhare_testsuite/designfiles/net/upload/header-logo.png'
, filename: 'header-logo.png'
prepareUploadTest($t('myinput'),[ { url: '/tests/webhare.png'
, filename: 'webhare.png'
} ]);
let uploadfiles = await compatupload.selectFiles();
......@@ -161,8 +161,8 @@ test.registerTests(
testEq([ 'loadstart', 'loadend' ], requestresult.events);
testEq(1, files.length);
testEq('header-logo.png', files[0].name);
testEq(4157, files[0].size);
testEq('webhare.png', files[0].name);
testEq(4355, files[0].size);
testEq('image/png', files[0].type);
}
}
......
......@@ -147,7 +147,7 @@ test.registerTests(
[ '<div>"a(*0*)(*2*)b(*1*)(*3*)c"</div>'
, '<div>"a"<b>"(*0*)(*2*)b(*1*)(*3*)"</b>"c"</div>'
, '<div>"a"<img></img>"test"<b>"(*0*)(*2*)b(*1*)(*3*)"</b>"c"</div>'
, '<p>"hmmm hmm"</p><img src="/.webhare_testsuite/tests/pages/rte/header-logo.png">"test"<b>"(*0*)(*2*)Bo ld!(*1*)(*3*)"</b>"en nog een "<a href="http://example.org/">"hyperlink"</a>"!"<p>"regel 2"</p><p>"image met "<a href="#link">"een hyperlink: "<img src="/.webhare_testsuite/tests/pages/rte/header-logo.png"></a></p>'
, '<p>"hmmm hmm"</p><img src="/tests/webhare.png">"test"<b>"(*0*)(*2*)Bo ld!(*1*)(*3*)"</b>"en nog een "<a href="http://example.org/">"hyperlink"</a>"!"<p>"regel 2"</p><p>"image met "<a href="#link">"een hyperlink: "<img src="/tests/webhare.png"></a></p>'
];
for (var i = 0; i < movetests.length; ++i)
......
......@@ -478,7 +478,7 @@ test.registerTests(
rtetest.testEqSelHTMLEx(win, '<ol class="ordered"><li>"(*0*)1"</li><li><br data-wh-rte="bogus"></li><li>"2(*1*)"</li></ol>');
// List to other list with disallowed <b> and <img> (remove <b> and <img>
rtetest.setStructuredContent(win, '<ol class="ordered"><li><i><b>"(*0*)1(*1*)"</b></i><img class="wh-rtd__img" height="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" width="50"></li></ol>');
rtetest.setStructuredContent(win, '<ol class="ordered"><li><i><b>"(*0*)1(*1*)"</b></i><img class="wh-rtd__img" height="50" src="/tests/webhare.png" width="50"></li></ol>');
prestate = rtetest.getPreActionState(rte);
rte._toggleBulletedList();
await rtetest.testUndoRedo(rte, prestate);
......@@ -774,14 +774,14 @@ test.registerTests(
rtetest.testEqHTMLEx(win, '<p class="normal">'+quotedloc01blockfill+'</p>', rte.getContentBodyNode(), [ range.start, range.end ]);
// End of block (with next block an image)
rte.setContentsHTML('<p class="normal">ab</p><p class="normal"><img src="/.webhare_testsuite/tests/pages/rte/header-logo.png" width="50" height="50"></p>');
rte.setContentsHTML('<p class="normal">ab</p><p class="normal"><img src="/tests/webhare.png" width="50" height="50"></p>');
locators = richdebug.getAllLocatorsInNode(rte.getContentBodyNode());
rtetest.testEqHTMLEx(win, '(*0*)<p class="normal">(*1*)"(*2*)a(*3*)b(*4*)"(*5*)</p>(*6*)<p class="normal">(*7*)<img class="wh-rtd__img" height="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" width="50">(*8*)</p>(*9*)', rte.getContentBodyNode(), locators);
rtetest.testEqHTMLEx(win, '(*0*)<p class="normal">(*1*)"(*2*)a(*3*)b(*4*)"(*5*)</p>(*6*)<p class="normal">(*7*)<img class="wh-rtd__img" height="50" src="/tests/webhare.png" width="50">(*8*)</p>(*9*)', rte.getContentBodyNode(), locators);
rte.selectRange(new Range(locators[4], locators[4]));
await rtetest.runWithUndo(rte, () => rte.executeHardEnter());
range = rte.getSelectionRange();
rtetest.testEqHTMLEx(win, '<p class="normal">"ab"</p><p class="normal">'+quotedloc01blockfill+'</p><p class="normal"><img class="wh-rtd__img" height="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" width="50"></p>', rte.getContentBodyNode(), [ range.start, range.end ]);
rtetest.testEqHTMLEx(win, '<p class="normal">"ab"</p><p class="normal">'+quotedloc01blockfill+'</p><p class="normal"><img class="wh-rtd__img" height="50" src="/tests/webhare.png" width="50"></p>', rte.getContentBodyNode(), [ range.start, range.end ]);
// End of filled nested li
rte.setContentsHTML('<ol class="ordered"><li>a<ol class="ordered"><li>b</li></ol></li></ol>');
......@@ -1044,7 +1044,7 @@ test.registerTests(
rtetest.testEqSelHTMLEx(win, '<p class="normal">"test"</p><p class="normal">(*0*)(*1*)'+blockfill+'</p>');
locators = rtetest.setStructuredContent(win, '<p class="normal">"test(*0*)"</p>');
topaste = dompack.create("div", { innerHTML: '<img class="wh-rtd__img" height="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" width="50" align="left">'});
topaste = dompack.create("div", { innerHTML: '<img class="wh-rtd__img" height="50" src="/tests/webhare.png" width="50" align="left">'});
//console.log(topaste.innerHTML);
await rtetest.runWithUndo(rte, () => rte._pasteContentAt(doc.importNode(topaste, true), locators[0]));
range = rte.getSelectionRange();
......@@ -1055,7 +1055,7 @@ test.registerTests(
test.true(range.isCollapsed());
locators = rtetest.setStructuredContent(win, '<p class="normal">"test(*0*)"</p>');
topaste = dompack.create("div", { innerHTML: '<img class="wh-rtd__img" height="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" width="50" class="pietje wh-rtd__img--floatleft">'});
topaste = dompack.create("div", { innerHTML: '<img class="wh-rtd__img" height="50" src="/tests/webhare.png" width="50" class="pietje wh-rtd__img--floatleft">'});
//console.log(topaste.innerHTML);
await rtetest.runWithUndo(rte, () => rte._pasteContentAt(doc.importNode(topaste, true), locators[0]));
range = rte.getSelectionRange();
......@@ -1108,14 +1108,14 @@ test.registerTests(
// Paste forbidden inline styles
locators = rtetest.setStructuredContent(win, '<h1 class="heading1">"test(*0*)ing"</h1>');
topaste = dompack.create("div", { innerHTML: '<ul><li><b>b</b></li></ul><h1 class="heading1"><img class="wh-rtd__img" height="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" width="50"></h1><ul><li>c</li></ul>' });
topaste = dompack.create("div", { innerHTML: '<ul><li><b>b</b></li></ul><h1 class="heading1"><img class="wh-rtd__img" height="50" src="/tests/webhare.png" width="50"></h1><ul><li>c</li></ul>' });
await rtetest.runWithUndo(rte, () => rte._pasteContentAt(doc.importNode(topaste, true), locators[0]));
let imgsrc = dompack.qS(rte.getContentBodyNode(), "img").getAttribute("src", 2);
rtetest.testEqSelHTMLEx(win, `<h1 class="heading1">"test"</h1><ul class="unordered"><li>"b"</li></ul><p class="normal"><img class="wh-rtd__img" height="50" src="${imgsrc}" width="50"></p><ul class="unordered"><li>"c"</li></ul><h1 class="heading1">"(*0*)(*1*)ing"</h1>`);
// Paste forbidden inline styles
locators = rtetest.setStructuredContent(win, '<h1 class="heading1">"test(*0*)ing"</h1>');
topaste = dompack.create("div", { innerHTML: '<b>b</b><img class="wh-rtd__img" height="50" src="/.webhare_testsuite/tests/pages/rte/header-logo.png" width="50">' });
topaste = dompack.create("div", { innerHTML: '<b>b</b><img class="wh-rtd__img" height="50" src="/tests/webhare.png" width="50">' });
await rtetest.runWithUndo(rte, () => rte._pasteContentAt(doc.importNode(topaste, true), locators[0]));
imgsrc = dompack.qS(rte.getContentBodyNode(), "img").getAttribute("src", 2);
rtetest.testEqSelHTMLEx(win, `<h1 class="heading1">"testb"</h1><p class="normal"><img class="wh-rtd__img" height="50" src="${imgsrc}" width="50">(*0*)(*1*)</p><h1 class="heading1">"ing"</h1>`);
......
......@@ -58,7 +58,7 @@ MACRO TestImageFileField(OBJECT persontype, INTEGER testpersonid, BOOLEAN curren
MACRO TestSchema()
{
BLOB testimage_blob := testfw->GetModuleTestBlob("webhare_testsuite","wrd/testdata/goudvis.png");
BLOB testimage_blob := GetWebhareResource("mod::system/web/tests/goudvis.png");
RECORD testimage := WrapBlob(testimage_blob,"goudvis.png");
OBJECT schemaobj := testfw->GetWRDSchema();
......@@ -285,7 +285,7 @@ MACRO ImageCache()
OBJECT wrdperson := schemaobj->^wrd_person;
STRING baseurl := OpenTestsuitesite()->webroot;
BLOB testimage_blob := testfw->GetModuleTestBlob("webhare_testsuite","wrd/testdata/goudvis.png");
BLOB testimage_blob := GetWebhareResource("mod::system/web/tests/goudvis.png");
INTEGER entityid1 := wrdperson->CreateEntity([ test_image := WrapBlob(testimage_blob,"")
] )->id;
INTEGER entityid2 := wrdperson->CreateEntity([ test_array := [ [ test_image := WrapBlob(testimage_blob,"") ], DEFAULT RECORD ]
......@@ -464,7 +464,7 @@ MACRO TestHSONAttr()
//verify that it's cleared in the database
TestEq(0, Length(SELECT FROM wrd.entity_settings WHERE entity = testperson->id AND attribute = extradata_attributeid));
BLOB goudvis := testfw->GetModuleTestBlob("webhare_testsuite","wrd/testdata/goudvis.png");
BLOB goudvis := GetWebhareResource("mod::system/web/tests/goudvis.png");
testperson->UpdateEntity([ extradata := [ goudvis := goudvis ]]); //overlong data
TestEq([ goudvis := goudvis ], testperson->GetField("extradata"));
......@@ -1166,7 +1166,7 @@ MACRO TestEnrichBulk()
OBJECT schemaobj:= testfw->GetWRDSchema();
OBJECT wrdperson := schemaobj->^wrd_person;
RECORD testimage := WrapBlob(testfw->GetModuleTestBlob("webhare_testsuite","wrd/testdata/goudvis.png"),"goudvis.png");
RECORD testimage := WrapBlob(GetWebhareResource("mod::system/web/tests/goudvis.png"),"goudvis.png");
INTEGER p2 := wrdperson->CreateEntity( [ test_email := "[email protected]", wrd_firstname := "Person 2", test_single_domain := "TEST_DOMAINVALUE_1_2", test_image := testimage ])->id;
INTEGER p1 := wrdperson->CreateEntity( [ test_email := "[email protected]", wrd_firstname := "Person 1", test_single_domain := 0 ])->id;
......@@ -2419,7 +2419,7 @@ MACRO TestUpdateFiltering()
myrichdoc->ImportFromMHTML(testfw->GetModuleTestBlob("webhare_testsuite","system/testdata/b-lex.mht"));
RECORD myrichexp := myrichdoc->ExportAsRecord();
BLOB testimage_blob := testfw->GetModuleTestBlob("webhare_testsuite","wrd/testdata/goudvis.png");
BLOB testimage_blob := GetWebhareResource("mod::system/web/tests/goudvis.png");
RECORD testimage := WrapBlob(testimage_blob,"goudvis.png", [ extractdominantcolor := TRUE ]);
OBJECT schemaobj := testfw->GetWRDSchema();
......
......@@ -7,6 +7,7 @@ LOADLIB "wh::xml/dom.whlib";
LOADLIB "wh::util/localization.whlib";
LOADLIB "mod::system/lib/resources.whlib";
LOADLIB "mod::system/lib/testframework.whlib";
LOADLIB "mod::webhare_testsuite/lib/system/tests.whlib";
......@@ -59,7 +60,7 @@ MACRO TestSchema()
TestEq(MakeDate(2006, 1, 1), testpersonrec.test_date);
// Test TEST_PASSWORD (FIXME => Create a password, test with login functions)
TestEq(SortArray([ INTEGER(domain2value3->id) ]), SortArray(testpersonrec.test_multiple_domain));
BLOB testimage_blob := testfw->GetModuleTestBlob("webhare_testsuite","wrd/testdata/goudvis.png");
BLOB testimage_blob := GetWebhareResource("mod::system/web/tests/goudvis.png");
TestEq(testimage_blob, testpersonrec.test_image.data);
TestEq(TRUE, CellExists(testpersonrec.test_image, "IMAGEID"));
TestEq(TRUE, CellExists(testpersonrec.test_file, "FILEID"));
......@@ -145,7 +146,7 @@ MACRO ImageCache()
OBJECT wrdperson := schemaobj->GetTypeByTag("WRD_PERSON");
STRING baseurl := OpenTestsuitesite()->webroot;
BLOB testimage_blob := testfw->GetModuleTestBlob("webhare_testsuite","wrd/testdata/goudvis.png");
BLOB testimage_blob := GetWebhareResource("mod::system/web/tests/goudvis.png");
INTEGER entityid1 := wrdperson->CreateEntity2([ test_image := WrapBlob(testimage_blob,"")
] )->id;
INTEGER entityid2 := wrdperson->CreateEntity2([ test_array := [ [ test_image := WrapBlob(testimage_blob,"") ], DEFAULT RECORD ]
......@@ -1417,7 +1418,7 @@ MACRO TestUpdateFiltering()
myrichdoc->ImportFromMHTML(testfw->GetModuleTestBlob("webhare_testsuite","system/testdata/b-lex.mht"));
RECORD myrichexp := myrichdoc->ExportAsRecord();
BLOB testimage_blob := testfw->GetModuleTestBlob("webhare_testsuite","wrd/testdata/goudvis.png");
BLOB testimage_blob := GetWebhareResource("mod::system/web/tests/goudvis.png");
RECORD testimage := WrapBlob(testimage_blob,"goudvis.png", [ extractdominantcolor := TRUE ]);
OBJECT schemaobj := OpenWRDSchema(testfw->GetWRDSchema()->id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment