This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js
Penar Musaraj 217274f2c1
A11Y: multiple fixes to user stream items (#18368)
- in group activity, allows avatars to be selectable by tabbing or screen readers
- in user activity > drafts, fixes a bug where for draft replies, the wrong avatar was being shown in the user card
- in both group and user activity, fixes the order of focusable items
2022-09-27 10:59:26 -04:00

74 lines
2.1 KiB
JavaScript

import {
acceptance,
count,
exists,
normalizeHtml,
query,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { IMAGE_VERSION } from "pretty-text/emoji/version";
acceptance("User Drafts", function (needs) {
needs.user();
test("Stream", async function (assert) {
await visit("/u/eviltrout/activity/drafts");
assert.strictEqual(count(".user-stream-item"), 3, "has drafts");
await click(".user-stream-item:first-child .remove-draft");
assert.ok(visible(".dialog-body"));
await click(".dialog-footer .btn-primary");
assert.strictEqual(
count(".user-stream-item"),
2,
"draft removed, list length diminished by one"
);
await visit("/");
assert.ok(visible("#create-topic"));
assert.ok(
!exists("#create-topic.open-draft"),
"Open Draft button is not present"
);
});
test("Stream - resume draft", async function (assert) {
await visit("/u/eviltrout/activity/drafts");
assert.ok(exists(".user-stream-item"), "has drafts");
await click(".user-stream-item .resume-draft");
assert.strictEqual(
query(".d-editor-input").value.trim(),
"A fun new topic for testing drafts."
);
});
test("Stream - has excerpt", async function (assert) {
await visit("/u/eviltrout/activity/drafts");
assert.ok(exists(".user-stream-item"), "has drafts");
assert.strictEqual(
query(".user-stream-item:nth-child(3) .category").textContent,
"meta"
);
assert.strictEqual(
normalizeHtml(
query(".user-stream-item:nth-child(3) .excerpt").innerHTML.trim()
),
normalizeHtml(
`here goes a reply to a PM <img src="/images/emoji/google_classic/slight_smile.png?v=${IMAGE_VERSION}" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;">`
),
"shows the excerpt"
);
assert.ok(
query(".user-stream-item:nth-child(2) a.avatar-link").href.endsWith(
"/u/eviltrout"
),
"has correct avatar link"
);
});
});