2020-10-28 16:36:01 -04:00
|
|
|
|
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
|
2018-11-22 11:19:24 -05:00
|
|
|
|
|
2020-10-20 13:56:52 -04:00
|
|
|
|
acceptance("Local Dates - composer", function (needs) {
|
|
|
|
|
needs.user();
|
|
|
|
|
needs.settings({ discourse_local_dates_enabled: true });
|
2018-11-22 11:19:24 -05:00
|
|
|
|
|
2020-10-20 13:56:52 -04:00
|
|
|
|
test("composer bbcode", async (assert) => {
|
|
|
|
|
const getAttr = (attr) => {
|
2020-10-28 16:36:01 -04:00
|
|
|
|
return queryAll(
|
|
|
|
|
".d-editor-preview .discourse-local-date.cooked-date"
|
|
|
|
|
).attr(`data-${attr}`);
|
2020-10-20 13:56:52 -04:00
|
|
|
|
};
|
2018-11-22 11:19:24 -05:00
|
|
|
|
|
2020-10-20 13:56:52 -04:00
|
|
|
|
await visit("/");
|
|
|
|
|
await click("#create-topic");
|
2018-11-22 11:19:24 -05:00
|
|
|
|
|
2020-10-20 13:56:52 -04:00
|
|
|
|
await fillIn(
|
|
|
|
|
".d-editor-input",
|
|
|
|
|
'[date=2017-10-23 time=01:30:00 displayedTimezone="America/Chicago" format="LLLL" calendar="off" recurring="1.weeks" timezone="Asia/Calcutta" timezones="Europe/Paris|America/Los_Angeles"]'
|
|
|
|
|
);
|
2018-11-22 11:19:24 -05:00
|
|
|
|
|
2020-10-20 13:56:52 -04:00
|
|
|
|
assert.equal(getAttr("date"), "2017-10-23", "it has the correct date");
|
|
|
|
|
assert.equal(getAttr("time"), "01:30:00", "it has the correct time");
|
|
|
|
|
assert.equal(
|
|
|
|
|
getAttr("displayed-timezone"),
|
|
|
|
|
"America/Chicago",
|
|
|
|
|
"it has the correct displayed timezone"
|
|
|
|
|
);
|
|
|
|
|
assert.equal(getAttr("format"), "LLLL", "it has the correct format");
|
|
|
|
|
assert.equal(
|
|
|
|
|
getAttr("timezones"),
|
|
|
|
|
"Europe/Paris|America/Los_Angeles",
|
|
|
|
|
"it has the correct timezones"
|
|
|
|
|
);
|
|
|
|
|
assert.equal(
|
|
|
|
|
getAttr("recurring"),
|
|
|
|
|
"1.weeks",
|
|
|
|
|
"it has the correct recurring"
|
|
|
|
|
);
|
|
|
|
|
assert.equal(
|
|
|
|
|
getAttr("timezone"),
|
|
|
|
|
"Asia/Calcutta",
|
|
|
|
|
"it has the correct timezone"
|
|
|
|
|
);
|
2018-11-22 11:19:24 -05:00
|
|
|
|
|
2020-10-20 13:56:52 -04:00
|
|
|
|
await fillIn(
|
|
|
|
|
".d-editor-input",
|
|
|
|
|
'[date=2017-10-24 format="LL" timezone="Asia/Calcutta" timezones="Europe/Paris|America/Los_Angeles"]'
|
|
|
|
|
);
|
2018-11-22 11:19:24 -05:00
|
|
|
|
|
2020-10-20 13:56:52 -04:00
|
|
|
|
assert.equal(getAttr("date"), "2017-10-24", "it has the correct date");
|
|
|
|
|
assert.notOk(getAttr("time"), "it doesn’t have time");
|
|
|
|
|
});
|
2018-11-22 11:19:24 -05:00
|
|
|
|
});
|