Hide form parts with the hidden attribute.
This commit is contained in:
+2
-2
@@ -21,8 +21,8 @@ const STORY_FORM = `
|
||||
<label for="story">Story:</label>
|
||||
<span id="texttab" class="tab active">Text:</span><span id="uploadtab" class="tab">Image:</span>
|
||||
<div id="textparent"><textarea id="story" name="story"></textarea></div>
|
||||
<div id="uploadparent" style="display: none;"><input type="file" id="upload" name="upload"></div>
|
||||
<span id="wordcounter" class="counter" style="display: none;">0 words</span>
|
||||
<div id="uploadparent" hidden><input type="file" id="upload" name="upload"></div>
|
||||
<span id="wordcounter" class="counter" hidden>0 words</span>
|
||||
</form>`;
|
||||
|
||||
function load(scripts, body, story) {
|
||||
|
||||
@@ -82,11 +82,9 @@ test("showHide switches between the text and the image tabs", () => {
|
||||
let focused = 0;
|
||||
w.storyEditor = { focus: () => focused++ };
|
||||
assert.equal(w.showHide("upload"), true);
|
||||
assert.deepEqual([$("textparent").style.display, $("uploadparent").style.display, $("wordcounter").style.display],
|
||||
["none", "block", "none"]);
|
||||
assert.deepEqual([$("textparent").hidden, $("uploadparent").hidden, $("wordcounter").hidden], [true, false, true]);
|
||||
assert.equal(w.showHide("text"), true);
|
||||
assert.deepEqual([$("textparent").style.display, $("uploadparent").style.display, $("wordcounter").style.display],
|
||||
["block", "none", "block"]);
|
||||
assert.deepEqual([$("textparent").hidden, $("uploadparent").hidden, $("wordcounter").hidden], [false, true, false]);
|
||||
assert.equal(focused, 1);
|
||||
assert.equal(w.showHide("other"), false);
|
||||
});
|
||||
|
||||
@@ -30,6 +30,14 @@ class SubmitTest extends PageTestCase {
|
||||
$this->assertStringContainsString('<script type="text/javascript" src="../publish/editor.js"></script>', $page['body']);
|
||||
}
|
||||
|
||||
public function testTheFormHidesWithTheHiddenAttribute(): void {
|
||||
$body = $this->get('/publish')['body'];
|
||||
$this->assertStringNotContainsString('display: none', $body);
|
||||
$this->assertStringContainsString('<span id="wordcounter" class="counter" hidden>', $body);
|
||||
$this->assertStringContainsString('<div id="uploadparent" hidden>', $body);
|
||||
$this->assertStringContainsString('wordcounter.hidden = false;', $body);
|
||||
}
|
||||
|
||||
public function testTheImageTabKeepsTheSpaceOfTheNote(): void {
|
||||
$html = new \DOMDocument();
|
||||
$html->loadHTML($this->get('/publish')['body'], LIBXML_NOERROR);
|
||||
|
||||
Reference in New Issue
Block a user