DEV: Try fix flaky dismiss keyboard specs (#13452)
Also add extra logging for test failures
This commit is contained in:
parent
5222247746
commit
f9a1d2bb81
|
@ -85,17 +85,29 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
|
|||
});
|
||||
|
||||
test("dismiss unread from top and bottom button", async function (assert) {
|
||||
// visit root first so topic list starts fresh
|
||||
await visit("/");
|
||||
await visit("/unread");
|
||||
assert.ok(exists("#dismiss-topics-top"));
|
||||
assert.ok(
|
||||
exists("#dismiss-topics-top"),
|
||||
"dismiss unread top button is present"
|
||||
);
|
||||
await triggerKeyEvent(document, "keypress", "x".charCodeAt(0));
|
||||
await triggerKeyEvent(document, "keypress", "t".charCodeAt(0));
|
||||
assert.ok(exists("#dismiss-read-confirm"));
|
||||
assert.ok(
|
||||
exists("#dismiss-read-confirm"),
|
||||
"confirmation modal to dismiss unread is present"
|
||||
);
|
||||
assert.equal(
|
||||
query(".modal-body").innerText,
|
||||
I18n.t("topics.bulk.also_dismiss_topics")
|
||||
);
|
||||
await click("#dismiss-read-confirm");
|
||||
assert.equal(markReadCalled, 1);
|
||||
assert.equal(
|
||||
markReadCalled,
|
||||
1,
|
||||
"mark read has been called on the backend once"
|
||||
);
|
||||
|
||||
// we get rid of all but one topic so the top dismiss button doesn't
|
||||
// show up, as it only appears if there are too many topics pushing
|
||||
|
@ -106,24 +118,37 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
|
|||
// visit root first so topic list starts fresh
|
||||
await visit("/");
|
||||
await visit("/unread");
|
||||
assert.notOk(exists("#dismiss-topics-top"));
|
||||
assert.notOk(
|
||||
exists("#dismiss-topics-top"),
|
||||
"dismiss unread top button is hidden"
|
||||
);
|
||||
await triggerKeyEvent(document, "keypress", "x".charCodeAt(0));
|
||||
await triggerKeyEvent(document, "keypress", "t".charCodeAt(0));
|
||||
assert.ok(exists("#dismiss-read-confirm"));
|
||||
assert.ok(
|
||||
exists("#dismiss-read-confirm"),
|
||||
"confirmation modal to dismiss unread is present"
|
||||
);
|
||||
assert.equal(
|
||||
query(".modal-body").innerText,
|
||||
"Stop tracking these topics so they never show up as unread for me again"
|
||||
);
|
||||
|
||||
await click("#dismiss-read-confirm");
|
||||
assert.equal(markReadCalled, 2);
|
||||
assert.equal(
|
||||
markReadCalled,
|
||||
2,
|
||||
"mark read has been called on the backend twice"
|
||||
);
|
||||
|
||||
// restore the original topic list
|
||||
topicList.topic_list.topics = originalTopics;
|
||||
});
|
||||
|
||||
test("dismiss new from top and bottom button", async function (assert) {
|
||||
// visit root first so topic list starts fresh
|
||||
await visit("/");
|
||||
await visit("/new");
|
||||
assert.ok(exists("#dismiss-new-top"));
|
||||
assert.ok(exists("#dismiss-new-top"), "dismiss new top button is present");
|
||||
await triggerKeyEvent(document, "keypress", "x".charCodeAt(0));
|
||||
await triggerKeyEvent(document, "keypress", "r".charCodeAt(0));
|
||||
assert.equal(resetNewCalled, 1);
|
||||
|
@ -137,7 +162,10 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
|
|||
// visit root first so topic list starts fresh
|
||||
await visit("/");
|
||||
await visit("/new");
|
||||
assert.notOk(exists("#dismiss-new-top"));
|
||||
assert.notOk(
|
||||
exists("#dismiss-new-top"),
|
||||
"dismiss new top button has been hidden"
|
||||
);
|
||||
await triggerKeyEvent(document, "keypress", "x".charCodeAt(0));
|
||||
await triggerKeyEvent(document, "keypress", "r".charCodeAt(0));
|
||||
assert.equal(resetNewCalled, 2);
|
||||
|
@ -147,9 +175,14 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
|
|||
});
|
||||
|
||||
test("click event not fired twice when both dismiss buttons are present", async function (assert) {
|
||||
// visit root first so topic list starts fresh
|
||||
await visit("/");
|
||||
await visit("/new");
|
||||
assert.ok(exists("#dismiss-new-top"));
|
||||
assert.ok(exists("#dismiss-new-bottom"));
|
||||
assert.ok(exists("#dismiss-new-top"), "dismiss new top button is present");
|
||||
assert.ok(
|
||||
exists("#dismiss-new-bottom"),
|
||||
"dismiss new bottom button is present"
|
||||
);
|
||||
|
||||
await triggerKeyEvent(document, "keypress", "x".charCodeAt(0));
|
||||
await triggerKeyEvent(document, "keypress", "r".charCodeAt(0));
|
||||
|
|
Loading…
Reference in New Issue