Skip to content

A platform for community discussion. Free, open, simple.

DEV: Restore and update discourse-calendar tests (#39472)

Jarek Radosz2e694db17f66
diff --git a/plugins/discourse-calendar/test/javascripts/acceptance/topic-calendar-events-test.js b/plugins/discourse-calendar/test/javascripts/acceptance/topic-calendar-events-test.js
index 2bd47feec16..2be3ed2d27a 100644
--- a/plugins/discourse-calendar/test/javascripts/acceptance/topic-calendar-events-test.js
+++ b/plugins/discourse-calendar/test/javascripts/acceptance/topic-calendar-events-test.js
@@ -1,9 +1,21 @@
import { visit } from "@ember/test-helpers";
-import { skip } from "qunit";
+import { test } from "qunit";
+import { cloneJSON } from "discourse/lib/object";
+import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { acceptance, fakeTime } from "discourse/tests/helpers/qunit-helpers";
import eventTopicFixture from "../helpers/event-topic-fixture";
import getEventByText from "../helpers/get-event-by-text";
+function fixtureWithFullDay(fullDay) {
+ const fixture = cloneJSON(eventTopicFixture);
+ fixture.post_stream.posts[0].cooked =
+ fixture.post_stream.posts[0].cooked.replace(
+ /data-calendar-full-day="(true|false)"/,
+ `data-calendar-full-day="${fullDay}"`
+ );
+ return response(fixture);
+}
+
acceptance("Topic Calendar Events", function (needs) {
needs.hooks.beforeEach(function () {
this.clock = fakeTime("2023-09-10T00:00:00", "Europe/Lisbon", true);
@@ -13,17 +25,18 @@ acceptance("Topic Calendar Events", function (needs) {
this.clock.restore();
});
- needs.settings({
- calendar_enabled: true,
- });
+ needs.settings({ calendar_enabled: true });
+
+ test("renders calendar events with fullDay='true'", async function (assert) {
+ pretender.get("/t/252.json", () => fixtureWithFullDay("true"));
+ await visit("/t/-/252");
- needs.pretender((server, helper) => {
- server.get("/t/252.json", () => {
- return helper.response(eventTopicFixture);
- });
+ assert.dom(getEventByText("Event 1")).exists();
+ assert.dom(getEventByText("Event 2")).exists();
});
- skip("renders calendar events with fullDay='false'", async (assert) => {
+ test("renders calendar events with fullDay='false'", async function (assert) {
+ pretender.get("/t/252.json", () => fixtureWithFullDay("false"));
await visit("/t/-/252");
assert.dom(getEventByText("Event 1")).exists();
diff --git a/plugins/discourse-calendar/test/javascripts/integration/components/dates-test.gjs b/plugins/discourse-calendar/test/javascripts/integration/components/dates-test.gjs
index 18361d3633d..148387a20b6 100644
--- a/plugins/discourse-calendar/test/javascripts/integration/components/dates-test.gjs
+++ b/plugins/discourse-calendar/test/javascripts/integration/components/dates-test.gjs
@@ -1,5 +1,5 @@
import { render } from "@ember/test-helpers";
-import { module, skip, test } from "qunit";
+import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { fakeTime } from "discourse/tests/helpers/qunit-helpers";
import Dates from "../../discourse/components/discourse-post-event/dates";
@@ -186,8 +186,7 @@ module("Integration | Component | Dates", function (hooks) {
);
});
- // this test goest against the current implementation in local-dates
- skip("formats same day range", async function (assert) {
+ test("formats same day range", async function (assert) {
await render(
<template><Dates @event={{events.currentYear.endsSameDay}} /></template>
);
@@ -195,7 +194,7 @@ module("Integration | Component | Dates", function (hooks) {
assert
.dom(".event-dates")
.hasText(
- "Mon, Oct 6 12:00 AM → 1:00 AM",
+ "Mon, Oct 6 10:00 AM → 11:00 AM (Brisbane)",
"`endsAt` should show time only"
);
});