mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
DEV: Update moment-timezone-with-data (#22313)
`Africa/Cairo` timezone introduced DST so I replaced it in tests with `America/Lima`
This commit is contained in:
@ -1,8 +1,4 @@
|
||||
import {
|
||||
acceptance,
|
||||
exists,
|
||||
query,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import I18n from "I18n";
|
||||
import { test } from "qunit";
|
||||
@ -18,24 +14,25 @@ acceptance(
|
||||
needs.pretender((server, helper) => {
|
||||
const response = cloneJSON(fixturesByUrl["/t/281.json"]);
|
||||
const startDate = moment
|
||||
.tz("Africa/Cairo")
|
||||
.tz("America/Lima")
|
||||
.add(1, "days")
|
||||
.format("YYYY-MM-DD");
|
||||
response.post_stream.posts[0].cooked = `<p><span data-date=\"${startDate}\" data-time=\"13:00:00\" class=\"discourse-local-date\" data-timezone=\"Africa/Cairo\" data-email-preview=\"${startDate}T11:00:00Z UTC\">${startDate}T11:00:00Z</span></p>`;
|
||||
response.post_stream.posts[0].cooked = `<p><span data-date=\"${startDate}\" data-time=\"13:00:00\" class=\"discourse-local-date\" data-timezone=\"America/Lima\" data-email-preview=\"${startDate}T18:00:00Z UTC\">${startDate}T18:00:00Z</span></p>`;
|
||||
|
||||
server.get("/t/281.json", () => helper.response(response));
|
||||
});
|
||||
|
||||
test("Display pick calendar modal", async function (assert) {
|
||||
await visit("/t/local-dates/281");
|
||||
|
||||
await click(".discourse-local-date");
|
||||
await click(document.querySelector(".download-calendar"));
|
||||
assert.strictEqual(
|
||||
query("#discourse-modal-title").textContent.trim(),
|
||||
I18n.t("download_calendar.title"),
|
||||
"it should display modal to select calendar"
|
||||
);
|
||||
await click(".download-calendar");
|
||||
|
||||
assert
|
||||
.dom("#discourse-modal-title")
|
||||
.hasText(
|
||||
I18n.t("download_calendar.title"),
|
||||
"it should display modal to select calendar"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
@ -48,20 +45,20 @@ acceptance(
|
||||
needs.pretender((server, helper) => {
|
||||
const response = cloneJSON(fixturesByUrl["/t/281.json"]);
|
||||
const startDate = moment
|
||||
.tz("Africa/Cairo")
|
||||
.tz("America/Lima")
|
||||
.subtract(1, "days")
|
||||
.format("YYYY-MM-DD");
|
||||
|
||||
response.post_stream.posts[0].cooked = `<p><span data-date=\"${startDate}\" data-time=\"13:00:00\" class=\"discourse-local-date\" data-timezone=\"Africa/Cairo\" data-email-preview=\"${startDate}T11:00:00Z UTC\">${startDate}T11:00:00Z</span></p>`;
|
||||
response.post_stream.posts[0].cooked = `<p><span data-date=\"${startDate}\" data-time=\"13:00:00\" class=\"discourse-local-date\" data-timezone=\"America/Lima\" data-email-preview=\"${startDate}T18:00:00Z UTC\">${startDate}T18:00:00Z</span></p>`;
|
||||
|
||||
server.get("/t/281.json", () => helper.response(response));
|
||||
});
|
||||
|
||||
test("Does not show add to calendar button", async function (assert) {
|
||||
await visit("/t/local-dates/281");
|
||||
|
||||
await click(".discourse-local-date");
|
||||
assert.ok(!exists(document.querySelector(".download-calendar")));
|
||||
|
||||
assert.dom(".download-calendar").doesNotExist();
|
||||
});
|
||||
}
|
||||
);
|
||||
@ -74,38 +71,38 @@ acceptance(
|
||||
needs.pretender((server, helper) => {
|
||||
const response = cloneJSON(fixturesByUrl["/t/281.json"]);
|
||||
const startDate = moment
|
||||
.tz("Africa/Cairo")
|
||||
.tz("America/Lima")
|
||||
.add(1, "days")
|
||||
.format("YYYY-MM-DD");
|
||||
response.post_stream.posts[0].cooked = `<p><span data-date=\"${startDate}\" data-time=\"13:00:00\" class=\"discourse-local-date\" data-timezone=\"Africa/Cairo\" data-email-preview=\"${startDate}T11:00:00Z UTC\">${startDate}T11:00:00Z</span></p>`;
|
||||
response.post_stream.posts[0].cooked = `<p><span data-date=\"${startDate}\" data-time=\"13:00:00\" class=\"discourse-local-date\" data-timezone=\"America/Lima\" data-email-preview=\"${startDate}T18:00:00Z UTC\">${startDate}T18:00:00Z</span></p>`;
|
||||
response.title = " title to trim ";
|
||||
server.get("/t/281.json", () => helper.response(response));
|
||||
});
|
||||
|
||||
needs.hooks.beforeEach(function () {
|
||||
let win = { focus: function () {} };
|
||||
sinon.stub(window, "open").returns(win);
|
||||
sinon.stub(win, "focus");
|
||||
});
|
||||
|
||||
test("saves into default calendar", async function (assert) {
|
||||
const startDate = moment
|
||||
.tz("Africa/Cairo")
|
||||
.tz("America/Lima")
|
||||
.add(1, "days")
|
||||
.format("YYYYMMDD");
|
||||
await visit("/t/local-dates/281");
|
||||
|
||||
sinon.stub(window, "open").callsFake(function () {
|
||||
assert.deepEqual(
|
||||
[...arguments],
|
||||
[
|
||||
`https://www.google.com/calendar/event?action=TEMPLATE&text=title%20to%20trim&dates=${startDate}T180000Z/${startDate}T190000Z`,
|
||||
"_blank",
|
||||
"noopener",
|
||||
"noreferrer",
|
||||
]
|
||||
);
|
||||
return { focus() {} };
|
||||
});
|
||||
|
||||
await click(".discourse-local-date");
|
||||
await click(document.querySelector(".download-calendar"));
|
||||
assert.ok(!exists(document.querySelector("#discourse-modal-title")));
|
||||
assert.ok(
|
||||
window.open.calledWith(
|
||||
`https://www.google.com/calendar/event?action=TEMPLATE&text=title%20to%20trim&dates=${startDate}T110000Z/${startDate}T120000Z`,
|
||||
"_blank",
|
||||
"noopener",
|
||||
"noreferrer"
|
||||
)
|
||||
);
|
||||
await click(".download-calendar");
|
||||
|
||||
assert.dom("#discourse-modal-title").doesNotExist();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Reference in New Issue
Block a user