openvibers/openvibe.community Commits
Guide the community thread step (#371)
Changes
@@@ -360,7 +360,7 @@ function newThreadPage({ space, user, values = {}, error = null, categories = []${labelsUi.picker({ current: values.labels || [], id: 'new-labels' })}<label class="check"><input type="checkbox" name="members_only" value="1"${values.members_only ? ' checked' : ''}> Only my OpenVibe.VIP members can read and reply</label><div class="form-actions">-- <button class="btn btn-primary" type="submit"><i class="fa-solid fa-paper-plane" aria-hidden="true"></i> Post thread</button>++ <button class="btn btn-primary" type="submit" data-ov-guide="community.thread"><i class="fa-solid fa-paper-plane" aria-hidden="true"></i> Post thread</button><span class="muted small">Posting as <strong>${esc(user.display_name || user.username || 'you')}</strong>. By posting you agree to the <a href="/terms">rules</a>.</span></div></form>` : `<p class="alert"><a href="/auth/login?next=${encodeURIComponent(`/forum/${space.slug}/new`)}">Sign in with your OpenVibe account</a> to start a thread. Reading needs no account.</p>`;@@@ -73,6 +73,7 @@ const form = (obj) => ({ method: 'POST', body: new URLSearchParams(obj).toStringconst page = await t.get(target, as(alexJwt));assert.strictEqual(page.status, 200);++ has(page.text, 'data-ov-guide="community.thread"', 'the signed-in thread form has the guide target');has(page.text, `value="${esc(title)}"`, 'the title is escaped in the form value');has(page.text, `>${esc(body)}</textarea>`, 'the body is escaped in the textarea');assert.ok(!page.text.includes('<script>alert("title")</script>') && !page.text.includes('<script>alert("body")</script>'), 'no raw draft HTML');
@@ -360,7 +360,7 @@ function newThreadPage({ space, user, values = {}, error = null, categories = []
@@ -360,7 +360,7 @@ function newThreadPage({ space, user, values = {}, error = null, categories = []
${labelsUi.picker({ current: values.labels || [], id: 'new-labels' })}
${labelsUi.picker({ current: values.labels || [], id: 'new-labels' })}
<label class="check"><input type="checkbox" name="members_only" value="1"${values.members_only ? ' checked' : ''}> Only my OpenVibe.VIP members can read and reply</label>
<label class="check"><input type="checkbox" name="members_only" value="1"${values.members_only ? ' checked' : ''}> Only my OpenVibe.VIP members can read and reply</label>
<div class="form-actions">
<div class="form-actions">
- <button class="btn btn-primary" type="submit"><i class="fa-solid fa-paper-plane" aria-hidden="true"></i> Post thread</button>
+ <button class="btn btn-primary" type="submit" data-ov-guide="community.thread"><i class="fa-solid fa-paper-plane" aria-hidden="true"></i> Post thread</button>
<span class="muted small">Posting as <strong>${esc(user.display_name || user.username || 'you')}</strong>. By posting you agree to the <a href="/terms">rules</a>.</span>
<span class="muted small">Posting as <strong>${esc(user.display_name || user.username || 'you')}</strong>. By posting you agree to the <a href="/terms">rules</a>.</span>
</div>
</div>
</form>` : `<p class="alert"><a href="/auth/login?next=${encodeURIComponent(`/forum/${space.slug}/new`)}">Sign in with your OpenVibe account</a> to start a thread. Reading needs no account.</p>`;
</form>` : `<p class="alert"><a href="/auth/login?next=${encodeURIComponent(`/forum/${space.slug}/new`)}">Sign in with your OpenVibe account</a> to start a thread. Reading needs no account.</p>`;
@@ -73,6 +73,7 @@ const form = (obj) => ({ method: 'POST', body: new URLSearchParams(obj).toString
@@ -73,6 +73,7 @@ const form = (obj) => ({ method: 'POST', body: new URLSearchParams(obj).toString
const page = await t.get(target, as(alexJwt));
const page = await t.get(target, as(alexJwt));
assert.strictEqual(page.status, 200);
assert.strictEqual(page.status, 200);
+ has(page.text, 'data-ov-guide="community.thread"', 'the signed-in thread form has the guide target');
has(page.text, `value="${esc(title)}"`, 'the title is escaped in the form value');
has(page.text, `value="${esc(title)}"`, 'the title is escaped in the form value');
has(page.text, `>${esc(body)}</textarea>`, 'the body is escaped in the textarea');
has(page.text, `>${esc(body)}</textarea>`, 'the body is escaped in the textarea');
assert.ok(!page.text.includes('<script>alert("title")</script>') && !page.text.includes('<script>alert("body")</script>'), 'no raw draft HTML');
assert.ok(!page.text.includes('<script>alert("title")</script>') && !page.text.includes('<script>alert("body")</script>'), 'no raw draft HTML');