DEV: Add additional test for timezone switching during event creation
Test the case which has been resolved by core commit c9a6d9ac89
Co-authored-by: David Taylor <david@taylorhq.com>
This commit is contained in:
parent
2597f464b8
commit
0e4b49d292
|
|
@ -2,6 +2,7 @@ import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
|||
import { test } from "qunit";
|
||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import sinon from "sinon";
|
||||
|
||||
acceptance("Post event - composer", function (needs) {
|
||||
needs.user({ admin: true, can_create_discourse_post_event: true });
|
||||
|
|
@ -62,4 +63,55 @@ acceptance("Post event - composer", function (needs) {
|
|||
"bbcode is correct"
|
||||
);
|
||||
});
|
||||
|
||||
test("composer event builder - the timezone case", async function (assert) {
|
||||
await visit("/");
|
||||
|
||||
// Freeze time
|
||||
const newTimezone = "Europe/Paris";
|
||||
const previousZone = moment.tz.guess();
|
||||
const now = moment.tz("2022-04-04 23:15", newTimezone).valueOf();
|
||||
sinon.useFakeTimers({
|
||||
now,
|
||||
toFake: ["Date"],
|
||||
shouldAdvanceTime: true,
|
||||
shouldClearNativeTimers: true,
|
||||
});
|
||||
sinon.stub(moment.tz, "guess");
|
||||
moment.tz.guess.returns(newTimezone);
|
||||
moment.tz.setDefault(newTimezone);
|
||||
|
||||
try {
|
||||
await click("#create-topic");
|
||||
const categoryChooser = selectKit(".category-chooser");
|
||||
await categoryChooser.expand();
|
||||
await categoryChooser.selectRowByValue(2);
|
||||
|
||||
await click(".toolbar-popup-menu-options .dropdown-select-box-header");
|
||||
await click(".toolbar-popup-menu-options *[data-value='insertEvent']");
|
||||
|
||||
const modal = ".discourse-post-event-builder-modal";
|
||||
|
||||
// Select the date
|
||||
await fillIn(`${modal} .from input[type=date]`, "2022-07-01");
|
||||
|
||||
// Select the timezone
|
||||
const timezoneInput = selectKit(
|
||||
`${modal} .event-field.timezone .timezone-input`
|
||||
);
|
||||
await timezoneInput.expand();
|
||||
await timezoneInput.selectRowByValue("Europe/London");
|
||||
|
||||
// The date should be still the same?
|
||||
assert.strictEqual(
|
||||
query(`${modal} .from input[type=date]`).value,
|
||||
"2022-07-01"
|
||||
);
|
||||
} finally {
|
||||
// Unfreeze time
|
||||
moment.tz.guess.returns(previousZone);
|
||||
moment.tz.setDefault(previousZone);
|
||||
sinon.restore();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue