mirror of
https://github.com/discourse/discourse.git
synced 2025-03-26 07:05:40 +08:00
DEV: Run tests in Firefox ESR (#14094)
This commit is contained in:
parent
d3be77a0d1
commit
9b30fbdbbd
.github/workflows
app/assets/javascripts/discourse
2
.github/workflows/ember.yml
vendored
2
.github/workflows/ember.yml
vendored
@ -43,5 +43,5 @@ jobs:
|
|||||||
|
|
||||||
- name: Core QUnit
|
- name: Core QUnit
|
||||||
working-directory: ./app/assets/javascripts/discourse
|
working-directory: ./app/assets/javascripts/discourse
|
||||||
run: yarn ember test
|
run: sudo -E -u discourse -H yarn ember test
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
test_page: "tests/index.html?hidepassed",
|
test_page: "tests/index.html?hidepassed",
|
||||||
disable_watching: true,
|
disable_watching: true,
|
||||||
launch_in_ci: ["Chrome"],
|
launch_in_ci: ["Chrome", "Firefox"],
|
||||||
launch_in_dev: ["Chrome"],
|
launch_in_dev: ["Chrome"],
|
||||||
|
parallel: -1, // run Firefox and Chrome in parallel
|
||||||
browser_args: {
|
browser_args: {
|
||||||
Chrome: [
|
Chrome: [
|
||||||
// --no-sandbox is needed when running Chrome inside a container
|
// --no-sandbox is needed when running Chrome inside a container
|
||||||
@ -14,5 +15,6 @@ module.exports = {
|
|||||||
"--remote-debugging-port=4201",
|
"--remote-debugging-port=4201",
|
||||||
"--window-size=1440,900",
|
"--window-size=1440,900",
|
||||||
].filter(Boolean),
|
].filter(Boolean),
|
||||||
|
Firefox: ["-headless", "--width=1440", "--height=900"],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
acceptance,
|
acceptance,
|
||||||
|
chromeTest,
|
||||||
count,
|
count,
|
||||||
exists,
|
exists,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { click, triggerEvent, visit } from "@ember/test-helpers";
|
import { click, triggerEvent, visit } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
|
||||||
|
|
||||||
async function triggerSwipeStart(touchTarget) {
|
async function triggerSwipeStart(touchTarget) {
|
||||||
// some tests are shown in a zoom viewport.
|
// some tests are shown in a zoom viewport.
|
||||||
@ -73,11 +73,12 @@ async function triggerSwipeEnd({ x, y, touchTarget }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// new Touch() isn't availiable in Firefox, so this is skipped there
|
||||||
acceptance("Mobile - menu swipes", function (needs) {
|
acceptance("Mobile - menu swipes", function (needs) {
|
||||||
needs.mobileView();
|
needs.mobileView();
|
||||||
needs.user();
|
needs.user();
|
||||||
|
|
||||||
test("swipe to close hamburger", async function (assert) {
|
chromeTest("swipe to close hamburger", async function (assert) {
|
||||||
await visit("/");
|
await visit("/");
|
||||||
await click(".hamburger-dropdown");
|
await click(".hamburger-dropdown");
|
||||||
|
|
||||||
@ -93,26 +94,29 @@ acceptance("Mobile - menu swipes", function (needs) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("swipe back and flick to re-open hamburger", async function (assert) {
|
chromeTest(
|
||||||
await visit("/");
|
"swipe back and flick to re-open hamburger",
|
||||||
await click(".hamburger-dropdown");
|
async function (assert) {
|
||||||
|
await visit("/");
|
||||||
|
await click(".hamburger-dropdown");
|
||||||
|
|
||||||
const touchTarget = document.querySelector(".panel-body");
|
const touchTarget = document.querySelector(".panel-body");
|
||||||
let swipe = await triggerSwipeStart(touchTarget);
|
let swipe = await triggerSwipeStart(touchTarget);
|
||||||
swipe.x -= 100;
|
swipe.x -= 100;
|
||||||
await triggerSwipeMove(swipe);
|
await triggerSwipeMove(swipe);
|
||||||
swipe.x += 20;
|
swipe.x += 20;
|
||||||
await triggerSwipeMove(swipe);
|
await triggerSwipeMove(swipe);
|
||||||
await triggerSwipeEnd(swipe);
|
await triggerSwipeEnd(swipe);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
count(".panel-body"),
|
count(".panel-body"),
|
||||||
1,
|
1,
|
||||||
"it should re-open hamburger on a right swipe"
|
"it should re-open hamburger on a right swipe"
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
test("swipe to user menu", async function (assert) {
|
chromeTest("swipe to user menu", async function (assert) {
|
||||||
await visit("/");
|
await visit("/");
|
||||||
await click("#current-user");
|
await click("#current-user");
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
acceptance,
|
acceptance,
|
||||||
|
chromeTest,
|
||||||
exists,
|
exists,
|
||||||
queryAll,
|
queryAll,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { test } from "qunit";
|
|
||||||
import { settled, visit } from "@ember/test-helpers";
|
import { settled, visit } from "@ember/test-helpers";
|
||||||
|
|
||||||
async function selectText(selector) {
|
async function selectText(selector) {
|
||||||
@ -18,6 +18,7 @@ async function selectText(selector) {
|
|||||||
await settled();
|
await settled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This tests are flaky on Firefox. Fails with `calling set on destroyed object`
|
||||||
acceptance("Topic - Quote button - logged in", function (needs) {
|
acceptance("Topic - Quote button - logged in", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
needs.settings({
|
needs.settings({
|
||||||
@ -25,41 +26,50 @@ acceptance("Topic - Quote button - logged in", function (needs) {
|
|||||||
share_quote_buttons: "twitter|email",
|
share_quote_buttons: "twitter|email",
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Does not show the quote share buttons by default", async function (assert) {
|
chromeTest(
|
||||||
await visit("/t/internationalization-localization/280");
|
"Does not show the quote share buttons by default",
|
||||||
await selectText("#post_5 blockquote");
|
async function (assert) {
|
||||||
assert.ok(exists(".insert-quote"), "it shows the quote button");
|
await visit("/t/internationalization-localization/280");
|
||||||
assert.ok(!exists(".quote-sharing"), "it does not show quote sharing");
|
await selectText("#post_5 blockquote");
|
||||||
});
|
assert.ok(exists(".insert-quote"), "it shows the quote button");
|
||||||
|
assert.ok(!exists(".quote-sharing"), "it does not show quote sharing");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
test("Shows quote share buttons with the right site settings", async function (assert) {
|
chromeTest(
|
||||||
this.siteSettings.share_quote_visibility = "all";
|
"Shows quote share buttons with the right site settings",
|
||||||
|
async function (assert) {
|
||||||
|
this.siteSettings.share_quote_visibility = "all";
|
||||||
|
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
await selectText("#post_5 blockquote");
|
await selectText("#post_5 blockquote");
|
||||||
|
|
||||||
assert.ok(exists(".quote-sharing"), "it shows the quote sharing options");
|
assert.ok(exists(".quote-sharing"), "it shows the quote sharing options");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`),
|
exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`),
|
||||||
"it includes the twitter share button"
|
"it includes the twitter share button"
|
||||||
);
|
);
|
||||||
assert.ok(
|
assert.ok(
|
||||||
exists(`.quote-sharing .btn[title='${I18n.t("share.email")}']`),
|
exists(`.quote-sharing .btn[title='${I18n.t("share.email")}']`),
|
||||||
"it includes the email share button"
|
"it includes the email share button"
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
test("Quoting a Onebox should not copy the formatting of the rendered Onebox", async function (assert) {
|
chromeTest(
|
||||||
await visit("/t/topic-for-group-moderators/2480");
|
"Quoting a Onebox should not copy the formatting of the rendered Onebox",
|
||||||
await selectText("#post_3 aside.onebox p");
|
async function (assert) {
|
||||||
await click(".insert-quote");
|
await visit("/t/topic-for-group-moderators/2480");
|
||||||
|
await selectText("#post_3 aside.onebox p");
|
||||||
|
await click(".insert-quote");
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
queryAll(".d-editor-input").val().trim(),
|
queryAll(".d-editor-input").val().trim(),
|
||||||
'[quote="group_moderator, post:3, topic:2480"]\nhttps://example.com/57350945\n[/quote]',
|
'[quote="group_moderator, post:3, topic:2480"]\nhttps://example.com/57350945\n[/quote]',
|
||||||
"quote only contains a link"
|
"quote only contains a link"
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
acceptance("Topic - Quote button - anonymous", function (needs) {
|
acceptance("Topic - Quote button - anonymous", function (needs) {
|
||||||
@ -68,46 +78,58 @@ acceptance("Topic - Quote button - anonymous", function (needs) {
|
|||||||
share_quote_buttons: "twitter|email",
|
share_quote_buttons: "twitter|email",
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Shows quote share buttons with the right site settings", async function (assert) {
|
chromeTest(
|
||||||
await visit("/t/internationalization-localization/280");
|
"Shows quote share buttons with the right site settings",
|
||||||
await selectText("#post_5 blockquote");
|
async function (assert) {
|
||||||
|
await visit("/t/internationalization-localization/280");
|
||||||
|
await selectText("#post_5 blockquote");
|
||||||
|
|
||||||
assert.ok(queryAll(".quote-sharing"), "it shows the quote sharing options");
|
assert.ok(
|
||||||
assert.ok(
|
queryAll(".quote-sharing"),
|
||||||
exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`),
|
"it shows the quote sharing options"
|
||||||
"it includes the twitter share button"
|
);
|
||||||
);
|
assert.ok(
|
||||||
assert.ok(
|
exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`),
|
||||||
exists(`.quote-sharing .btn[title='${I18n.t("share.email")}']`),
|
"it includes the twitter share button"
|
||||||
"it includes the email share button"
|
);
|
||||||
);
|
assert.ok(
|
||||||
assert.ok(!exists(".insert-quote"), "it does not show the quote button");
|
exists(`.quote-sharing .btn[title='${I18n.t("share.email")}']`),
|
||||||
});
|
"it includes the email share button"
|
||||||
|
);
|
||||||
|
assert.ok(!exists(".insert-quote"), "it does not show the quote button");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
test("Shows single share button when site setting only has one item", async function (assert) {
|
chromeTest(
|
||||||
this.siteSettings.share_quote_buttons = "twitter";
|
"Shows single share button when site setting only has one item",
|
||||||
|
async function (assert) {
|
||||||
|
this.siteSettings.share_quote_buttons = "twitter";
|
||||||
|
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
await selectText("#post_5 blockquote");
|
await selectText("#post_5 blockquote");
|
||||||
|
|
||||||
assert.ok(exists(".quote-sharing"), "it shows the quote sharing options");
|
assert.ok(exists(".quote-sharing"), "it shows the quote sharing options");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`),
|
exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`),
|
||||||
"it includes the twitter share button"
|
"it includes the twitter share button"
|
||||||
);
|
);
|
||||||
assert.ok(
|
assert.ok(
|
||||||
!exists(".quote-share-label"),
|
!exists(".quote-share-label"),
|
||||||
"it does not show the Share label"
|
"it does not show the Share label"
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
test("Shows nothing when visibility is disabled", async function (assert) {
|
chromeTest(
|
||||||
this.siteSettings.share_quote_visibility = "none";
|
"Shows nothing when visibility is disabled",
|
||||||
|
async function (assert) {
|
||||||
|
this.siteSettings.share_quote_visibility = "none";
|
||||||
|
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
await selectText("#post_5 blockquote");
|
await selectText("#post_5 blockquote");
|
||||||
|
|
||||||
assert.ok(!exists(".quote-sharing"), "it does not show quote sharing");
|
assert.ok(!exists(".quote-sharing"), "it does not show quote sharing");
|
||||||
assert.ok(!exists(".insert-quote"), "it does not show the quote button");
|
assert.ok(!exists(".insert-quote"), "it does not show the quote button");
|
||||||
});
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
acceptance,
|
acceptance,
|
||||||
|
chromeTest,
|
||||||
count,
|
count,
|
||||||
exists,
|
exists,
|
||||||
query,
|
query,
|
||||||
@ -400,18 +401,22 @@ acceptance("Topic featured links", function (needs) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Quoting a quote with replyAsNewTopic keeps the original poster name", async function (assert) {
|
// Using J/K on Firefox clean the text selection, so this won't work there
|
||||||
await visit("/t/internationalization-localization/280");
|
chromeTest(
|
||||||
await selectText("#post_5 blockquote");
|
"Quoting a quote with replyAsNewTopic keeps the original poster name",
|
||||||
await triggerKeyEvent(document, "keypress", "j".charCodeAt(0));
|
async function (assert) {
|
||||||
await triggerKeyEvent(document, "keypress", "t".charCodeAt(0));
|
await visit("/t/internationalization-localization/280");
|
||||||
|
await selectText("#post_5 blockquote");
|
||||||
|
await triggerKeyEvent(document, "keypress", "j".charCodeAt(0));
|
||||||
|
await triggerKeyEvent(document, "keypress", "t".charCodeAt(0));
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
queryAll(".d-editor-input")
|
queryAll(".d-editor-input")
|
||||||
.val()
|
.val()
|
||||||
.indexOf('quote="codinghorror said, post:3, topic:280"') !== -1
|
.indexOf('quote="codinghorror said, post:3, topic:280"') !== -1
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
test("Quoting by selecting text can mark the quote as full", async function (assert) {
|
test("Quoting by selecting text can mark the quote as full", async function (assert) {
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import QUnit, { module } from "qunit";
|
import QUnit, { module, skip, test } from "qunit";
|
||||||
import MessageBus from "message-bus-client";
|
import MessageBus from "message-bus-client";
|
||||||
import {
|
import {
|
||||||
clearCache as clearOutletCache,
|
clearCache as clearOutletCache,
|
||||||
@ -468,3 +468,19 @@ export function publishToMessageBus(channelPath, ...args) {
|
|||||||
.filterBy("channel", channelPath)
|
.filterBy("channel", channelPath)
|
||||||
.map((c) => c.func(...args));
|
.map((c) => c.func(...args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function conditionalTest(name, condition, testCase) {
|
||||||
|
if (condition) {
|
||||||
|
test(name, testCase);
|
||||||
|
} else {
|
||||||
|
skip(name, testCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function chromeTest(name, testCase) {
|
||||||
|
conditionalTest(name, navigator.userAgent.includes("Chrome"), testCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function firefoxTest(name, testCase) {
|
||||||
|
conditionalTest(name, navigator.userAgent.includes("Firefox"), testCase);
|
||||||
|
}
|
||||||
|
@ -85,6 +85,7 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
|
|||||||
const textarea = jumpEnd(query("textarea.d-editor-input"));
|
const textarea = jumpEnd(query("textarea.d-editor-input"));
|
||||||
testFunc.call(this, assert, textarea);
|
testFunc.call(this, assert, textarea);
|
||||||
},
|
},
|
||||||
|
skip: !navigator.userAgent.includes("Chrome"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user