mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-09 07:45:00 -04:00
Search testing too
This commit is contained in:
parent
9b34626df9
commit
f60f80be0b
3 changed files with 29 additions and 27 deletions
|
@ -27,6 +27,7 @@ class HTMLOperation {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.title = name;
|
||||||
this.description = config.description;
|
this.description = config.description;
|
||||||
this.infoURL = config.infoURL;
|
this.infoURL = config.infoURL;
|
||||||
this.manualBake = config.manualBake || false;
|
this.manualBake = config.manualBake || false;
|
||||||
|
@ -46,7 +47,7 @@ class HTMLOperation {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
toStubHtml(removeIcon) {
|
toStubHtml(removeIcon) {
|
||||||
let html = `<li class='operation' data-opName="${this.name}"`;
|
let html = `<li class='operation' data-opname="${this.name}"`;
|
||||||
|
|
||||||
if (this.description) {
|
if (this.description) {
|
||||||
const infoLink = this.infoURL ? `<hr>${titleFromWikiLink(this.infoURL)}` : "";
|
const infoLink = this.infoURL ? `<hr>${titleFromWikiLink(this.infoURL)}` : "";
|
||||||
|
@ -56,24 +57,25 @@ class HTMLOperation {
|
||||||
data-boundary='viewport'`;
|
data-boundary='viewport'`;
|
||||||
}
|
}
|
||||||
|
|
||||||
html += ">" + this.name;
|
html += ">" + this.title;
|
||||||
|
|
||||||
|
// Ensure add button only appears in sidebar, not fav edit
|
||||||
|
if (removeIcon) {
|
||||||
|
// Remove button
|
||||||
|
html += "<i class='material-icons remove-icon op-icon'>delete</i>";
|
||||||
|
} else {
|
||||||
|
// Add buttob
|
||||||
html += `<span class='float-right'>
|
html += `<span class='float-right'>
|
||||||
<button type="button" class="btn btn-primary bmd-btn-icon accessibleUX" data-toggle="tooltip" data-original-title="Add to recipe">
|
<button type="button" class="btn btn-primary bmd-btn-icon accessibleUX" data-toggle="tooltip" data-original-title="Add to recipe">
|
||||||
<i class='material-icons'>add_box</i>
|
<i class='material-icons'>add_box</i>
|
||||||
</button>
|
</button>
|
||||||
</span>`;
|
</span>`;
|
||||||
|
|
||||||
if (removeIcon) {
|
|
||||||
html += "<i class='material-icons remove-icon op-icon'>delete</i>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
html += "</li>";
|
html += "</li>";
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the operation in HTML as a full operation with ingredients.
|
* Renders the operation in HTML as a full operation with ingredients.
|
||||||
*
|
*
|
||||||
|
@ -109,18 +111,18 @@ class HTMLOperation {
|
||||||
*/
|
*/
|
||||||
highlightSearchStrings(nameIdxs, descIdxs) {
|
highlightSearchStrings(nameIdxs, descIdxs) {
|
||||||
if (nameIdxs.length && typeof nameIdxs[0][0] === "number") {
|
if (nameIdxs.length && typeof nameIdxs[0][0] === "number") {
|
||||||
let opName = "",
|
let title = "",
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
|
||||||
nameIdxs.forEach(idxs => {
|
nameIdxs.forEach(idxs => {
|
||||||
const [start, length] = idxs;
|
const [start, length] = idxs;
|
||||||
if (typeof start !== "number") return;
|
if (typeof start !== "number") return;
|
||||||
opName += this.name.slice(pos, start) + "<b>" +
|
title += this.title.slice(pos, start) + "<b>" +
|
||||||
this.name.slice(start, start + length) + "</b>";
|
this.title.slice(start, start + length) + "</b>";
|
||||||
pos = start + length;
|
pos = start + length;
|
||||||
});
|
});
|
||||||
opName += this.name.slice(pos, this.name.length);
|
title += this.title.slice(pos, this.title.length);
|
||||||
this.name = opName;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.description && descIdxs.length && descIdxs[0][0] >= 0) {
|
if (this.description && descIdxs.length && descIdxs[0][0] >= 0) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ class OperationsWaiter {
|
||||||
if (ops.length) {
|
if (ops.length) {
|
||||||
selected = this.getSelectedOp(ops);
|
selected = this.getSelectedOp(ops);
|
||||||
if (selected > -1) {
|
if (selected > -1) {
|
||||||
this.manager.recipe.addOperation(ops[selected].innerHTML);
|
this.manager.recipe.addOperation($(ops[selected]).data("opname"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,6 @@ class OperationsWaiter {
|
||||||
* @param {event} e
|
* @param {event} e
|
||||||
*/
|
*/
|
||||||
operationAdd(e) {
|
operationAdd(e) {
|
||||||
log.info("add");
|
|
||||||
const li = e.target.parentNode.parentNode.parentNode;
|
const li = e.target.parentNode.parentNode.parentNode;
|
||||||
// get operation name from <li> data
|
// get operation name from <li> data
|
||||||
this.manager.recipe.addOperation($(li).data("opname"));
|
this.manager.recipe.addOperation($(li).data("opname"));
|
||||||
|
|
|
@ -59,8 +59,10 @@ module.exports = {
|
||||||
"Accessible user experience": browser => {
|
"Accessible user experience": browser => {
|
||||||
const addOp = "#catFavourites li.operation";
|
const addOp = "#catFavourites li.operation";
|
||||||
const recOp = "#rec-list li:nth-child(1)";
|
const recOp = "#rec-list li:nth-child(1)";
|
||||||
|
const searchOp = "#search-results";
|
||||||
const down = " i.move-down.accessibleUX";
|
const down = " i.move-down.accessibleUX";
|
||||||
const remove = " i.remove-icon.accessibleUX";
|
const remove = " i.remove-icon.accessibleUX";
|
||||||
|
const favCat = "#categories div:nth-child(1)"
|
||||||
|
|
||||||
// Switch UX on
|
// Switch UX on
|
||||||
browser
|
browser
|
||||||
|
@ -68,8 +70,7 @@ module.exports = {
|
||||||
.click("#options")
|
.click("#options")
|
||||||
.waitForElementVisible("#options-modal", 1000)
|
.waitForElementVisible("#options-modal", 1000)
|
||||||
.click("#reset-options")
|
.click("#reset-options")
|
||||||
.pause(500)
|
// Using label for checkbox click because nightwatch thinks #accessibleUX isn't visible
|
||||||
// Using label for checkbox click because nightwatch thinks #acessibleUX isn't visible
|
|
||||||
.click('label[for="accessibleUX"]')
|
.click('label[for="accessibleUX"]')
|
||||||
.click("#options-modal .modal-footer button:last-child")
|
.click("#options-modal .modal-footer button:last-child")
|
||||||
.waitForElementNotVisible("#options-modal")
|
.waitForElementNotVisible("#options-modal")
|
||||||
|
@ -88,6 +89,16 @@ module.exports = {
|
||||||
.click(recOp + remove)
|
.click(recOp + remove)
|
||||||
.click(recOp + remove)
|
.click(recOp + remove)
|
||||||
.waitForElementNotPresent(recOp);
|
.waitForElementNotPresent(recOp);
|
||||||
|
|
||||||
|
// Search for an op
|
||||||
|
browser
|
||||||
|
.useCss()
|
||||||
|
.clearValue("#search")
|
||||||
|
.setValue("#search", "md5")
|
||||||
|
.click(searchOp + " button")
|
||||||
|
.click(recOp + remove)
|
||||||
|
.click(favCat)
|
||||||
|
.expect.element(searchOp).text.to.contain("MD5");
|
||||||
},
|
},
|
||||||
|
|
||||||
"Recipe can be run": browser => {
|
"Recipe can be run": browser => {
|
||||||
|
@ -245,16 +256,6 @@ module.exports = {
|
||||||
browser.click("#clr-recipe");
|
browser.click("#clr-recipe");
|
||||||
},
|
},
|
||||||
|
|
||||||
"Search": browser => {
|
|
||||||
// Search for an op
|
|
||||||
browser
|
|
||||||
.useCss()
|
|
||||||
.clearValue("#search")
|
|
||||||
.setValue("#search", "md5")
|
|
||||||
.useXpath()
|
|
||||||
.waitForElementVisible("//ul[@id='search-results']//b[text()='MD5']", 1000);
|
|
||||||
},
|
|
||||||
|
|
||||||
after: browser => {
|
after: browser => {
|
||||||
browser.end();
|
browser.end();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue