parent
acba52f280
commit
e4d1e22a10
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { test } from "qunit";
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
|
|
@ -36,23 +36,19 @@ acceptance("Admin - Discourse Calendar - Holidays", function (needs) {
|
|||
await regions.expand();
|
||||
await regions.selectRowByValue("ca");
|
||||
|
||||
assert.ok(
|
||||
query(".holidays-list").innerText.includes("New Year's Day"),
|
||||
"it displays holiday names"
|
||||
);
|
||||
assert.ok(
|
||||
query(".holidays-list").innerText.includes("Good Friday"),
|
||||
"it displays holiday names"
|
||||
);
|
||||
assert
|
||||
.dom(".holidays-list")
|
||||
.includesText("New Year's Day", "it displays holiday names");
|
||||
assert
|
||||
.dom(".holidays-list")
|
||||
.includesText("Good Friday", "it displays holiday names");
|
||||
|
||||
assert.ok(
|
||||
query(".holidays-list").innerText.includes("2022-01-01"),
|
||||
"it displays holiday dates"
|
||||
);
|
||||
assert.ok(
|
||||
query(".holidays-list").innerText.includes("2022-04-15"),
|
||||
"it displays holiday dates"
|
||||
);
|
||||
assert
|
||||
.dom(".holidays-list")
|
||||
.includesText("2022-01-01", "it displays holiday dates");
|
||||
assert
|
||||
.dom(".holidays-list")
|
||||
.includesText("2022-04-15", "it displays holiday dates");
|
||||
});
|
||||
|
||||
test("disabling and enabling a holiday", async (assert) => {
|
||||
|
|
@ -62,16 +58,20 @@ acceptance("Admin - Discourse Calendar - Holidays", function (needs) {
|
|||
await regions.expand();
|
||||
await regions.selectRowByValue("ca");
|
||||
|
||||
await click("table tr:first-child button");
|
||||
assert.ok(
|
||||
query("table tr.disabled:first-child"),
|
||||
"after clicking the disable button, it adds a .disabled CSS class"
|
||||
);
|
||||
await click("table tbody tr button");
|
||||
assert
|
||||
.dom("table tbody tr")
|
||||
.hasClass(
|
||||
"disabled",
|
||||
"after clicking the disable button, it adds a .disabled CSS class"
|
||||
);
|
||||
|
||||
await click("table tr.disabled:first-child button");
|
||||
assert.ok(
|
||||
query("table tr:first-child"),
|
||||
"after clicking the enable button, it removes the .disabled CSS class"
|
||||
);
|
||||
await click("table tr.disabled button");
|
||||
assert
|
||||
.dom("table tbody tr")
|
||||
.doesNotHaveClass(
|
||||
"disabled",
|
||||
"after clicking the enable button, it removes the .disabled CSS class"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { test } from "qunit";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
|
||||
|
|
@ -70,10 +70,9 @@ acceptance("Discourse Calendar - Category Events Calendar", function (needs) {
|
|||
test("shows event calendar on category page", async (assert) => {
|
||||
await visit("/c/bug/1");
|
||||
|
||||
assert.ok(
|
||||
exists("#category-events-calendar"),
|
||||
"Events calendar div exists."
|
||||
);
|
||||
assert.ok(exists(".fc-view-container"), "FullCalendar is loaded.");
|
||||
assert
|
||||
.dom("#category-events-calendar")
|
||||
.exists("Events calendar div exists.");
|
||||
assert.dom(".fc-view-container").exists("FullCalendar is loaded.");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -122,14 +122,13 @@ acceptance("Discourse Calendar - Notifications", function (needs) {
|
|||
)} Monthly Hangout #3`,
|
||||
"before event reminder notification has the right content"
|
||||
);
|
||||
assert.ok(
|
||||
assert.true(
|
||||
notifications[0].href.endsWith("/t/monthly-hangout-3/993"),
|
||||
"before event reminder notification links to the event topic"
|
||||
);
|
||||
assert.ok(
|
||||
notifications[0].querySelector(".d-icon-calendar-day"),
|
||||
"before event reminder notification has the right icon"
|
||||
);
|
||||
assert
|
||||
.dom(".d-icon-calendar-day", notifications[0])
|
||||
.exists("before event reminder notification has the right icon");
|
||||
|
||||
assert.strictEqual(
|
||||
notifications[1].textContent.replaceAll(/\s+/g, " ").trim(),
|
||||
|
|
@ -138,14 +137,13 @@ acceptance("Discourse Calendar - Notifications", function (needs) {
|
|||
)} Fancy title and pants`,
|
||||
"ongoing event reminder notification has the right content"
|
||||
);
|
||||
assert.ok(
|
||||
assert.true(
|
||||
notifications[1].href.endsWith("/t/fancy-title-and-pants/339"),
|
||||
"ongoing event reminder notification links to the event topic"
|
||||
);
|
||||
assert.ok(
|
||||
notifications[1].querySelector(".d-icon-calendar-day"),
|
||||
"ongoing event reminder notification has the right icon"
|
||||
);
|
||||
assert
|
||||
.dom(".d-icon-calendar-day", notifications[1])
|
||||
.exists("ongoing event reminder notification has the right icon");
|
||||
|
||||
assert.strictEqual(
|
||||
notifications[2].textContent.replaceAll(/\s+/g, " ").trim(),
|
||||
|
|
@ -154,30 +152,28 @@ acceptance("Discourse Calendar - Notifications", function (needs) {
|
|||
)} Topic with event and after_event reminder`,
|
||||
"after event reminder notification has the right content"
|
||||
);
|
||||
assert.ok(
|
||||
assert.true(
|
||||
notifications[2].href.endsWith(
|
||||
"/t/topic-with-event-and-after_event-reminder/834"
|
||||
),
|
||||
"after event reminder notification links to the event topic"
|
||||
);
|
||||
assert.ok(
|
||||
notifications[2].querySelector(".d-icon-calendar-day"),
|
||||
"after event reminder notification has the right icon"
|
||||
);
|
||||
assert
|
||||
.dom(".d-icon-calendar-day", notifications[2])
|
||||
.exists("after event reminder notification has the right icon");
|
||||
|
||||
assert.strictEqual(
|
||||
notifications[3].textContent.replaceAll(/\s+/g, " ").trim(),
|
||||
"imposter Tuesdays are for Among Us",
|
||||
"event invitation notification has the right content"
|
||||
);
|
||||
assert.ok(
|
||||
assert.true(
|
||||
notifications[3].href.endsWith("/t/tuesdays-are-for-among-us/195"),
|
||||
"event invitation notification links to the event topic"
|
||||
);
|
||||
assert.ok(
|
||||
notifications[3].querySelector(".d-icon-calendar-day"),
|
||||
"event invitation notification has the right icon"
|
||||
);
|
||||
assert
|
||||
.dom(".d-icon-calendar-day", notifications[3])
|
||||
.exists("event invitation notification has the right icon");
|
||||
|
||||
assert.strictEqual(
|
||||
notifications[4].textContent.replaceAll(/\s+/g, " ").trim(),
|
||||
|
|
@ -187,13 +183,14 @@ acceptance("Discourse Calendar - Notifications", function (needs) {
|
|||
)} Asia Pacific team call`,
|
||||
"event invitation with predefined attendance notification has the right content"
|
||||
);
|
||||
assert.ok(
|
||||
assert.true(
|
||||
notifications[4].href.endsWith("/t/asia-pacific-team-call/348"),
|
||||
"event invitation with predefined attendance notification links to the event topic"
|
||||
);
|
||||
assert.ok(
|
||||
notifications[4].querySelector(".d-icon-calendar-day"),
|
||||
"event invitation with predefined attendance notification has the right icon"
|
||||
);
|
||||
assert
|
||||
.dom(".d-icon-calendar-day", notifications[4])
|
||||
.exists(
|
||||
"event invitation with predefined attendance notification has the right icon"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } 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";
|
||||
|
|
@ -36,15 +36,13 @@ acceptance("Post event - composer", function (needs) {
|
|||
"Timezone can be changed"
|
||||
);
|
||||
|
||||
const fromDate = query(`${modal} .from input[type=date]`);
|
||||
await fillIn(fromDate, "2022-07-01");
|
||||
await fillIn(`${modal} .from input[type=date]`, "2022-07-01");
|
||||
|
||||
const fromTime = selectKit(`${modal} .from .d-time-input .select-kit`);
|
||||
await fromTime.expand();
|
||||
await fromTime.selectRowByName("12:00");
|
||||
|
||||
const toDate = query(`${modal} .to input[type=date]`);
|
||||
await fillIn(toDate, "2022-07-01");
|
||||
await fillIn(`${modal} .to input[type=date]`, "2022-07-01");
|
||||
const toTime = selectKit(`${modal} .to .d-time-input .select-kit`);
|
||||
await toTime.expand();
|
||||
await toTime.selectRowByName("13:00");
|
||||
|
|
@ -57,11 +55,12 @@ acceptance("Post event - composer", function (needs) {
|
|||
|
||||
await click(`${modal} .modal-footer .btn-primary`);
|
||||
|
||||
assert.strictEqual(
|
||||
query(".d-editor-input").value,
|
||||
`[event start="2022-07-01 12:00" status="public" timezone="Europe/Paris" end="2022-07-01 13:00" allowedGroups="trust_level_0"]\n[/event]`,
|
||||
"bbcode is correct"
|
||||
);
|
||||
assert
|
||||
.dom(".d-editor-input")
|
||||
.hasValue(
|
||||
`[event start="2022-07-01 12:00" status="public" timezone="Europe/Paris" end="2022-07-01 13:00" allowedGroups="trust_level_0"]\n[/event]`,
|
||||
"bbcode is correct"
|
||||
);
|
||||
});
|
||||
|
||||
test("composer event builder - the timezone case", async function (assert) {
|
||||
|
|
@ -103,10 +102,7 @@ acceptance("Post event - composer", function (needs) {
|
|||
await timezoneInput.selectRowByValue("Europe/London");
|
||||
|
||||
// The date should be still the same?
|
||||
assert.strictEqual(
|
||||
query(`${modal} .from input[type=date]`).value,
|
||||
"2022-07-01"
|
||||
);
|
||||
assert.dom(`${modal} .from input[type=date]`).hasValue("2022-07-01");
|
||||
} finally {
|
||||
// Unfreeze time
|
||||
moment.tz.guess.returns(previousZone);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { test } from "qunit";
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
acceptance("Discourse Calendar - hamburger action shown", function (needs) {
|
||||
needs.user();
|
||||
|
|
@ -38,7 +38,7 @@ acceptance("Discourse Calendar - hamburger action hidden", function (needs) {
|
|||
test("upcoming events hamburger action hidden", async function (assert) {
|
||||
await visit("/");
|
||||
await click(".hamburger-dropdown");
|
||||
assert.notOk(exists(".widget-link[title='Upcoming events']"));
|
||||
assert.dom(".widget-link[title='Upcoming events']").doesNotExist();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -54,9 +54,9 @@ acceptance("Discourse Calendar - sidebar link shown", function (needs) {
|
|||
test("upcoming events sidebar section link shown", async function (assert) {
|
||||
await visit("/");
|
||||
await click(".sidebar-more-section-links-details-summary");
|
||||
assert.ok(
|
||||
exists(".sidebar-section-link[data-link-name='upcoming-events']")
|
||||
);
|
||||
assert
|
||||
.dom(".sidebar-section-link[data-link-name='upcoming-events']")
|
||||
.exists();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -72,8 +72,8 @@ acceptance("Discourse Calendar - sidebar link hidden", function (needs) {
|
|||
test("upcoming events sidebar section link hidden", async function (assert) {
|
||||
await visit("/");
|
||||
await click(".sidebar-more-section-links-details-summary");
|
||||
assert.notOk(
|
||||
exists(".sidebar-section-link[data-link-name='upcoming-events']")
|
||||
);
|
||||
assert
|
||||
.dom(".sidebar-section-link[data-link-name='upcoming-events']")
|
||||
.doesNotExist();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { test } from "qunit";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import Site from "discourse/models/site";
|
||||
|
|
@ -16,11 +16,12 @@ acceptance("Calendar - Disable sorting headers", function (needs) {
|
|||
site.categories[15].custom_fields = { disable_topic_resorting: true };
|
||||
|
||||
await visit("/c/bug");
|
||||
assert.ok(exists(".topic-list"), "The list of topics was rendered");
|
||||
assert.ok(
|
||||
exists(".topic-list .topic-list-data"),
|
||||
"The headers were rendered"
|
||||
);
|
||||
assert.ok(!exists(".topic-list .sortable"), "The headers are not sortable");
|
||||
assert.dom(".topic-list").exists("The list of topics was rendered");
|
||||
assert
|
||||
.dom(".topic-list .topic-list-data")
|
||||
.exists("The headers were rendered");
|
||||
assert
|
||||
.dom(".topic-list")
|
||||
.doesNotHaveClass("sortable", "The headers are not sortable");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,269 +1,20 @@
|
|||
import { acceptance, fakeTime } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
|
||||
const topicResponse = {
|
||||
post_stream: {
|
||||
posts: [
|
||||
{
|
||||
id: 375,
|
||||
name: null,
|
||||
username: "jan",
|
||||
avatar_template: "/letter_avatar_proxy/v4/letter/j/ce7236/{size}.png",
|
||||
created_at: "2023-09-08T16:50:07.638Z",
|
||||
raw: '[calendar weekends=true tzPicker="true" fullDay="true" showAddToCalendar="false" defaultTimezone="Europe/Lisbon"] [/calendar]',
|
||||
cooked:
|
||||
'\u003cdiv class="discourse-calendar-wrap"\u003e\n\u003cdiv class="discourse-calendar-header"\u003e\n\u003ch2 class="discourse-calendar-title"\u003e\u003c/h2\u003e\n\u003cspan class="discourse-calendar-timezone-wrap"\u003e\n\u003cselect class="discourse-calendar-timezone-picker"\u003e\u003c/select\u003e\n\u003c/span\u003e\n\u003c/div\u003e\n\u003cdiv class="calendar" data-calendar-type="dynamic" data-calendar-default-timezone="Europe/Lisbon" data-weekends="true" data-calendar-show-add-to-calendar="false" data-calendar-full-day="true"\u003e\u003c/div\u003e\n\u003c/div\u003e',
|
||||
post_number: 1,
|
||||
post_type: 1,
|
||||
updated_at: "2023-09-08T16:50:07.638Z",
|
||||
reply_count: 0,
|
||||
reply_to_post_number: null,
|
||||
quote_count: 0,
|
||||
incoming_link_count: 2,
|
||||
reads: 1,
|
||||
readers_count: 0,
|
||||
score: 10.2,
|
||||
yours: true,
|
||||
topic_id: 252,
|
||||
topic_slug: "awesome-calendar",
|
||||
display_username: null,
|
||||
primary_group_name: null,
|
||||
flair_name: null,
|
||||
flair_url: null,
|
||||
flair_bg_color: null,
|
||||
flair_color: null,
|
||||
flair_group_id: null,
|
||||
version: 1,
|
||||
can_edit: true,
|
||||
can_delete: false,
|
||||
can_recover: false,
|
||||
can_see_hidden_post: true,
|
||||
can_wiki: true,
|
||||
read: true,
|
||||
user_title: null,
|
||||
bookmarked: false,
|
||||
actions_summary: [
|
||||
{ id: 3, can_act: true },
|
||||
{ id: 4, can_act: true },
|
||||
{ id: 8, can_act: true },
|
||||
{ id: 7, can_act: true },
|
||||
],
|
||||
moderator: false,
|
||||
admin: true,
|
||||
staff: true,
|
||||
user_id: 1,
|
||||
hidden: false,
|
||||
trust_level: 1,
|
||||
deleted_at: null,
|
||||
user_deleted: false,
|
||||
edit_reason: null,
|
||||
can_view_edit_history: true,
|
||||
wiki: false,
|
||||
reviewable_id: 0,
|
||||
reviewable_score_count: 0,
|
||||
reviewable_score_pending_count: 0,
|
||||
mentioned_users: [],
|
||||
calendar_details: [
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 2,
|
||||
message: "Cordoba",
|
||||
from: "2023-09-14T00:00:00.000Z",
|
||||
to: "2023-09-14T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/2",
|
||||
timezone: "America/Cordoba",
|
||||
},
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 4,
|
||||
message: "Moscow",
|
||||
from: "2023-09-17T00:00:00.000Z",
|
||||
to: "2023-09-18T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/3",
|
||||
timezone: "Europe/Moscow",
|
||||
},
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 3,
|
||||
message: "Tokyo",
|
||||
from: "2023-09-20T00:00:00.000Z",
|
||||
to: "2023-09-21T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/4",
|
||||
timezone: "Asia/Tokyo",
|
||||
},
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 5,
|
||||
message: "Lisbon",
|
||||
from: "2023-09-28T00:00:00.000Z",
|
||||
to: "2023-09-28T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/5",
|
||||
timezone: "Europe/Lisbon",
|
||||
},
|
||||
{
|
||||
type: "grouped",
|
||||
from: "2023-09-04T05:00:00.000Z",
|
||||
name: "Labor Day",
|
||||
users: [
|
||||
{
|
||||
username: "gmt-5_user",
|
||||
timezone: "America/Chicago",
|
||||
},
|
||||
{
|
||||
username: "gmt-6_user",
|
||||
timezone: "America/Denver",
|
||||
},
|
||||
{
|
||||
username: "gmt-7_user",
|
||||
timezone: "America/Los_Angeles",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
timeline_lookup: [[1, 0]],
|
||||
tags: [],
|
||||
tags_descriptions: {},
|
||||
id: 252,
|
||||
title: "Awesome Calendar",
|
||||
fancy_title: "Awesome Calendar",
|
||||
posts_count: 5,
|
||||
created_at: "2023-09-08T16:50:07.371Z",
|
||||
views: 1,
|
||||
reply_count: 0,
|
||||
like_count: 0,
|
||||
last_posted_at: "2023-09-08T16:50:52.936Z",
|
||||
visible: true,
|
||||
closed: false,
|
||||
archived: false,
|
||||
has_summary: false,
|
||||
archetype: "regular",
|
||||
slug: "awesome-calendar",
|
||||
category_id: 5,
|
||||
word_count: 56,
|
||||
deleted_at: null,
|
||||
user_id: 1,
|
||||
featured_link: null,
|
||||
pinned_globally: false,
|
||||
pinned_at: null,
|
||||
pinned_until: null,
|
||||
image_url: null,
|
||||
slow_mode_seconds: 0,
|
||||
draft: null,
|
||||
draft_key: "topic_252",
|
||||
draft_sequence: 9,
|
||||
posted: true,
|
||||
unpinned: null,
|
||||
pinned: false,
|
||||
current_post_number: 1,
|
||||
highest_post_number: 4,
|
||||
last_read_post_number: 4,
|
||||
last_read_post_id: 378,
|
||||
deleted_by: null,
|
||||
has_deleted: false,
|
||||
actions_summary: [
|
||||
{ id: 4, count: 0, hidden: false, can_act: true },
|
||||
{ id: 8, count: 0, hidden: false, can_act: true },
|
||||
{ id: 7, count: 0, hidden: false, can_act: true },
|
||||
],
|
||||
chunk_size: 20,
|
||||
bookmarked: false,
|
||||
bookmarks: [],
|
||||
topic_timer: null,
|
||||
message_bus_last_id: 16,
|
||||
participant_count: 1,
|
||||
show_read_indicator: false,
|
||||
thumbnails: null,
|
||||
slow_mode_enabled_until: null,
|
||||
summarizable: false,
|
||||
details: {
|
||||
can_edit: true,
|
||||
notification_level: 3,
|
||||
notifications_reason_id: 1,
|
||||
can_move_posts: true,
|
||||
can_delete: true,
|
||||
can_remove_allowed_users: true,
|
||||
can_invite_to: true,
|
||||
can_invite_via_email: true,
|
||||
can_create_post: true,
|
||||
can_reply_as_new_topic: true,
|
||||
can_flag_topic: true,
|
||||
can_convert_topic: true,
|
||||
can_review_topic: true,
|
||||
can_close_topic: true,
|
||||
can_archive_topic: true,
|
||||
can_split_merge_topic: true,
|
||||
can_edit_staff_notes: true,
|
||||
can_toggle_topic_visibility: true,
|
||||
can_pin_unpin_topic: true,
|
||||
can_moderate_category: true,
|
||||
can_remove_self_id: 1,
|
||||
participants: [
|
||||
{
|
||||
id: 1,
|
||||
username: "jan",
|
||||
name: null,
|
||||
avatar_template: "/letter_avatar_proxy/v4/letter/j/ce7236/{size}.png",
|
||||
post_count: 4,
|
||||
primary_group_name: null,
|
||||
flair_name: null,
|
||||
flair_url: null,
|
||||
flair_color: null,
|
||||
flair_bg_color: null,
|
||||
flair_group_id: null,
|
||||
admin: true,
|
||||
trust_level: 1,
|
||||
},
|
||||
],
|
||||
created_by: {
|
||||
id: 1,
|
||||
username: "jan",
|
||||
name: null,
|
||||
avatar_template: "/letter_avatar_proxy/v4/letter/j/ce7236/{size}.png",
|
||||
},
|
||||
last_poster: {
|
||||
id: 1,
|
||||
username: "jan",
|
||||
name: null,
|
||||
avatar_template: "/letter_avatar_proxy/v4/letter/j/ce7236/{size}.png",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
function getEventByText(text) {
|
||||
const events = [...document.querySelectorAll(".fc-day-grid-event")].filter(
|
||||
(event) => event.textContent.includes(text)
|
||||
);
|
||||
if (!events.length) {
|
||||
return;
|
||||
}
|
||||
return events.length === 1 ? events[0] : events;
|
||||
}
|
||||
import getEventByText from "../helpers/get-event-by-text";
|
||||
import eventTopicFixture from "../helpers/event-topic-fixture";
|
||||
|
||||
function getRoundedPct(marginString) {
|
||||
return Math.round(marginString.match(/(\d+(\.\d+)?)%/)[1]);
|
||||
}
|
||||
|
||||
function setupClock(needs) {
|
||||
let clock;
|
||||
|
||||
needs.hooks.beforeEach(() => {
|
||||
clock = fakeTime("2023-09-10T00:00:00", "Australia/Brisbane", true);
|
||||
needs.hooks.beforeEach(function () {
|
||||
this.clock = fakeTime("2023-09-10T00:00:00", "Australia/Brisbane", true);
|
||||
});
|
||||
|
||||
needs.hooks.afterEach(() => {
|
||||
clock?.restore();
|
||||
needs.hooks.afterEach(function () {
|
||||
this.clock.restore();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -278,21 +29,21 @@ acceptance("Discourse Calendar - Timezone Offset", function (needs) {
|
|||
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/t/252.json", () => {
|
||||
return helper.response(topicResponse);
|
||||
return helper.response(eventTopicFixture);
|
||||
});
|
||||
});
|
||||
|
||||
test("doesn't apply an offset for events in the same timezone", async (assert) => {
|
||||
await visit("/t/252");
|
||||
await visit("/t/-/252");
|
||||
|
||||
const eventElement = getEventByText("Lisbon");
|
||||
|
||||
assert.notOk(eventElement.style.marginLeft);
|
||||
assert.notOk(eventElement.style.marginRight);
|
||||
assert.strictEqual(eventElement.style.marginLeft, "");
|
||||
assert.strictEqual(eventElement.style.marginRight, "");
|
||||
});
|
||||
|
||||
test("applies the correct offset for events that extend into the next day", async (assert) => {
|
||||
await visit("/t/252");
|
||||
await visit("/t/-/252");
|
||||
|
||||
const eventElement = getEventByText("Cordoba");
|
||||
|
||||
|
|
@ -301,7 +52,7 @@ acceptance("Discourse Calendar - Timezone Offset", function (needs) {
|
|||
});
|
||||
|
||||
test("applies the correct offset for events that start on the previous day", async (assert) => {
|
||||
await visit("/t/252");
|
||||
await visit("/t/-/252");
|
||||
|
||||
const eventElement = getEventByText("Tokyo");
|
||||
|
||||
|
|
@ -310,14 +61,14 @@ acceptance("Discourse Calendar - Timezone Offset", function (needs) {
|
|||
});
|
||||
|
||||
test("applies the correct offset for multiline events", async (assert) => {
|
||||
await visit("/t/252");
|
||||
await visit("/t/-/252");
|
||||
|
||||
const eventElement = getEventByText("Moscow");
|
||||
|
||||
assert.strictEqual(getRoundedPct(eventElement[0].style.marginLeft), 46); // ( ( 24 - ( 1 - (-1) ) ) / 24 ) * 50%
|
||||
assert.notOk(eventElement[0].style.marginRight);
|
||||
assert.strictEqual(eventElement[0].style.marginRight, "");
|
||||
|
||||
assert.notOk(eventElement[1].style.marginLeft);
|
||||
assert.strictEqual(eventElement[1].style.marginLeft, "");
|
||||
assert.strictEqual(getRoundedPct(eventElement[1].style.marginRight), 8); // ( ( 1 - (-1) ) / 24 ) * 100%
|
||||
});
|
||||
});
|
||||
|
|
@ -334,17 +85,17 @@ acceptance("Discourse Calendar - Splitted Grouped Events", function (needs) {
|
|||
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/t/252.json", () => {
|
||||
return helper.response(topicResponse);
|
||||
return helper.response(eventTopicFixture);
|
||||
});
|
||||
});
|
||||
|
||||
test("splits holidays events by timezone", async (assert) => {
|
||||
await visit("/t/252");
|
||||
await visit("/t/-/252");
|
||||
|
||||
const eventElement = document.querySelectorAll(
|
||||
".fc-day-grid-event.grouped-event"
|
||||
);
|
||||
assert.ok(eventElement.length === 3);
|
||||
assert.strictEqual(eventElement.length, 3);
|
||||
|
||||
assert.strictEqual(getRoundedPct(eventElement[0].style.marginLeft), 13); // ( ( 1 - (-5) ) / 24 ) * 50%
|
||||
assert.strictEqual(getRoundedPct(eventElement[0].style.marginRight), 38); // ( ( 24 - ( 1 - (-5) ) ) / 24 ) * 50%
|
||||
|
|
@ -369,17 +120,17 @@ acceptance("Discourse Calendar - Grouped Events", function (needs) {
|
|||
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/t/252.json", () => {
|
||||
return helper.response(topicResponse);
|
||||
return helper.response(eventTopicFixture);
|
||||
});
|
||||
});
|
||||
|
||||
test("groups holidays events according to threshold", async (assert) => {
|
||||
await visit("/t/252");
|
||||
await visit("/t/-/252");
|
||||
|
||||
const eventElement = document.querySelectorAll(
|
||||
".fc-day-grid-event.grouped-event"
|
||||
);
|
||||
assert.ok(eventElement.length === 1);
|
||||
assert.strictEqual(eventElement.length, 1);
|
||||
|
||||
assert.strictEqual(getRoundedPct(eventElement[0].style.marginLeft), 15); // ( ( 1 - (-6) ) / 24 ) * 50%
|
||||
assert.strictEqual(getRoundedPct(eventElement[0].style.marginRight), 35); // ( ( 24 - ( 1 - (-6) ) ) / 24 ) * 50%
|
||||
|
|
|
|||
|
|
@ -1,118 +1,16 @@
|
|||
import { acceptance, fakeTime } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
|
||||
const topicResponse = {
|
||||
post_stream: {
|
||||
posts: [
|
||||
{
|
||||
id: 375,
|
||||
name: null,
|
||||
username: "jan",
|
||||
avatar_template: "/letter_avatar_proxy/v4/letter/j/ce7236/{size}.png",
|
||||
created_at: "2023-09-08T16:50:07.638Z",
|
||||
raw: '[calendar fullDay="false"][/calendar]',
|
||||
cooked:
|
||||
'<div class="discourse-calendar-wrap"><div class="discourse-calendar-header"><h2 class="discourse-calendar-title"></h2><span class="discourse-calendar-timezone-wrap"></span></div><div class="calendar" data-calendar-type="dynamic" data-calendar-default-timezone="undefined" data-calendar-full-day="false"><p> </p></div></div>',
|
||||
post_number: 1,
|
||||
post_type: 1,
|
||||
updated_at: "2023-09-08T16:50:07.638Z",
|
||||
reply_count: 0,
|
||||
reply_to_post_number: null,
|
||||
quote_count: 0,
|
||||
incoming_link_count: 2,
|
||||
reads: 1,
|
||||
readers_count: 0,
|
||||
score: 10.2,
|
||||
yours: true,
|
||||
topic_id: 252,
|
||||
topic_slug: "awesome-calendar",
|
||||
display_username: null,
|
||||
primary_group_name: null,
|
||||
flair_name: null,
|
||||
flair_url: null,
|
||||
flair_bg_color: null,
|
||||
flair_color: null,
|
||||
flair_group_id: null,
|
||||
version: 1,
|
||||
can_edit: true,
|
||||
can_delete: false,
|
||||
can_recover: false,
|
||||
can_see_hidden_post: true,
|
||||
can_wiki: true,
|
||||
read: true,
|
||||
user_title: null,
|
||||
bookmarked: false,
|
||||
actions_summary: [
|
||||
{ id: 3, can_act: true },
|
||||
{ id: 4, can_act: true },
|
||||
{ id: 8, can_act: true },
|
||||
{ id: 7, can_act: true },
|
||||
],
|
||||
moderator: false,
|
||||
admin: true,
|
||||
staff: true,
|
||||
user_id: 1,
|
||||
hidden: false,
|
||||
trust_level: 1,
|
||||
deleted_at: null,
|
||||
user_deleted: false,
|
||||
edit_reason: null,
|
||||
can_view_edit_history: true,
|
||||
wiki: false,
|
||||
reviewable_id: 0,
|
||||
reviewable_score_count: 0,
|
||||
reviewable_score_pending_count: 0,
|
||||
mentioned_users: [],
|
||||
calendar_details: [
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 2,
|
||||
message: "Event 1",
|
||||
from: "2023-09-08T00:00:00.000Z",
|
||||
to: "2023-09-08T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/2",
|
||||
timezone: "America/Cordoba",
|
||||
},
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 5,
|
||||
message: "Event 2",
|
||||
from: "2023-09-20T00:00:00.000Z",
|
||||
to: "2023-09-20T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/5",
|
||||
timezone: "Europe/Lisbon",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
details: {},
|
||||
};
|
||||
|
||||
function getEventByText(text) {
|
||||
const events = [...document.querySelectorAll(".fc-day-grid-event")].filter(
|
||||
(event) => event.textContent.includes(text)
|
||||
);
|
||||
if (!events.length) {
|
||||
return;
|
||||
}
|
||||
return events.length === 1 ? events[0] : events;
|
||||
}
|
||||
import getEventByText from "../helpers/get-event-by-text";
|
||||
import eventTopicFixture from "../helpers/event-topic-fixture";
|
||||
|
||||
acceptance("Discourse Calendar - Topic Calendar Events", function (needs) {
|
||||
let clock;
|
||||
|
||||
needs.hooks.beforeEach(() => {
|
||||
clock = fakeTime("2023-09-10T00:00:00", "Europe/Lisbon", true);
|
||||
needs.hooks.beforeEach(function () {
|
||||
this.clock = fakeTime("2023-09-10T00:00:00", "Europe/Lisbon", true);
|
||||
});
|
||||
|
||||
needs.hooks.afterEach(() => {
|
||||
clock?.restore();
|
||||
needs.hooks.afterEach(function () {
|
||||
this.clock.restore();
|
||||
});
|
||||
|
||||
needs.settings({
|
||||
|
|
@ -121,14 +19,14 @@ acceptance("Discourse Calendar - Topic Calendar Events", function (needs) {
|
|||
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/t/252.json", () => {
|
||||
return helper.response(topicResponse);
|
||||
return helper.response(eventTopicFixture);
|
||||
});
|
||||
});
|
||||
|
||||
test("renders calendar events with fullDay='false'", async (assert) => {
|
||||
await visit("/t/252");
|
||||
await visit("/t/-/252");
|
||||
|
||||
assert.ok(getEventByText("Event 1"));
|
||||
assert.ok(getEventByText("Event 2"));
|
||||
assert.dom(getEventByText("Event 1")).exists();
|
||||
assert.dom(getEventByText("Event 2")).exists();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,14 +3,7 @@ import { test } from "qunit";
|
|||
import { visit } from "@ember/test-helpers";
|
||||
import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
|
||||
const topicList = cloneJSON(discoveryFixtures["/latest.json"]);
|
||||
|
||||
function latestResponse() {
|
||||
topicList.topic_list.topics[0].event_starts_at = "2022-01-10 19:00:00";
|
||||
topicList.topic_list.topics[0].event_ends_at = "2022-01-10 20:00:00";
|
||||
return topicList;
|
||||
}
|
||||
import sinon from "sinon";
|
||||
|
||||
acceptance("Discourse Calendar - Event Title Decorator", function (needs) {
|
||||
needs.user();
|
||||
|
|
@ -21,26 +14,30 @@ acceptance("Discourse Calendar - Event Title Decorator", function (needs) {
|
|||
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/latest.json", () => {
|
||||
return helper.response(latestResponse());
|
||||
const topicList = cloneJSON(discoveryFixtures["/latest.json"]);
|
||||
topicList.topic_list.topics[0].event_starts_at = "2022-01-10 19:00:00";
|
||||
topicList.topic_list.topics[0].event_ends_at = "2022-01-10 20:00:00";
|
||||
|
||||
return helper.response(topicList);
|
||||
});
|
||||
});
|
||||
|
||||
test("shows event date with attributes in topic list", async (assert) => {
|
||||
sinon.stub(moment.tz, "guess");
|
||||
moment.tz.guess.returns("UTC");
|
||||
moment.tz.setDefault("UTC");
|
||||
|
||||
await visit("/latest");
|
||||
|
||||
const firstTopic = query(".topic-list-item:first-child .raw-topic-link");
|
||||
assert.ok(firstTopic.querySelector(".event-date.past"));
|
||||
assert.ok(
|
||||
firstTopic.querySelector(".event-date").getAttribute("data-starts_at")
|
||||
);
|
||||
assert.ok(
|
||||
firstTopic.querySelector(".event-date").getAttribute("data-ends_at")
|
||||
);
|
||||
assert.ok(
|
||||
firstTopic
|
||||
.querySelector(".event-date")
|
||||
.getAttribute("title")
|
||||
.startsWith("January 10, 2022")
|
||||
);
|
||||
assert.dom(".event-date.past", firstTopic).exists();
|
||||
assert.dom(".event-date", firstTopic).hasAttribute("data-starts_at");
|
||||
assert.dom(".event-date", firstTopic).hasAttribute("data-ends_at");
|
||||
assert
|
||||
.dom(".event-date", firstTopic)
|
||||
.hasAttribute(
|
||||
"title",
|
||||
"January 10, 2022 7:00 PM → January 10, 2022 8:00 PM"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,262 @@
|
|||
const eventTopicFixture = {
|
||||
post_stream: {
|
||||
posts: [
|
||||
{
|
||||
id: 375,
|
||||
name: null,
|
||||
username: "jan",
|
||||
avatar_template: "/letter_avatar_proxy/v4/letter/j/ce7236/{size}.png",
|
||||
created_at: "2023-09-08T16:50:07.638Z",
|
||||
raw: '[calendar weekends=true tzPicker="true" fullDay="true" showAddToCalendar="false" defaultTimezone="Europe/Lisbon"] [/calendar]',
|
||||
cooked:
|
||||
'\u003cdiv class="discourse-calendar-wrap"\u003e\n\u003cdiv class="discourse-calendar-header"\u003e\n\u003ch2 class="discourse-calendar-title"\u003e\u003c/h2\u003e\n\u003cspan class="discourse-calendar-timezone-wrap"\u003e\n\u003cselect class="discourse-calendar-timezone-picker"\u003e\u003c/select\u003e\n\u003c/span\u003e\n\u003c/div\u003e\n\u003cdiv class="calendar" data-calendar-type="dynamic" data-calendar-default-timezone="Europe/Lisbon" data-weekends="true" data-calendar-show-add-to-calendar="false" data-calendar-full-day="true"\u003e\u003c/div\u003e\n\u003c/div\u003e',
|
||||
post_number: 1,
|
||||
post_type: 1,
|
||||
updated_at: "2023-09-08T16:50:07.638Z",
|
||||
reply_count: 0,
|
||||
reply_to_post_number: null,
|
||||
quote_count: 0,
|
||||
incoming_link_count: 2,
|
||||
reads: 1,
|
||||
readers_count: 0,
|
||||
score: 10.2,
|
||||
yours: true,
|
||||
topic_id: 252,
|
||||
topic_slug: "awesome-calendar",
|
||||
display_username: null,
|
||||
primary_group_name: null,
|
||||
flair_name: null,
|
||||
flair_url: null,
|
||||
flair_bg_color: null,
|
||||
flair_color: null,
|
||||
flair_group_id: null,
|
||||
version: 1,
|
||||
can_edit: true,
|
||||
can_delete: false,
|
||||
can_recover: false,
|
||||
can_see_hidden_post: true,
|
||||
can_wiki: true,
|
||||
read: true,
|
||||
user_title: null,
|
||||
bookmarked: false,
|
||||
actions_summary: [
|
||||
{ id: 3, can_act: true },
|
||||
{ id: 4, can_act: true },
|
||||
{ id: 8, can_act: true },
|
||||
{ id: 7, can_act: true },
|
||||
],
|
||||
moderator: false,
|
||||
admin: true,
|
||||
staff: true,
|
||||
user_id: 1,
|
||||
hidden: false,
|
||||
trust_level: 1,
|
||||
deleted_at: null,
|
||||
user_deleted: false,
|
||||
edit_reason: null,
|
||||
can_view_edit_history: true,
|
||||
wiki: false,
|
||||
reviewable_id: 0,
|
||||
reviewable_score_count: 0,
|
||||
reviewable_score_pending_count: 0,
|
||||
mentioned_users: [],
|
||||
calendar_details: [
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 2,
|
||||
message: "Event 1",
|
||||
from: "2023-09-08T00:00:00.000Z",
|
||||
to: "2023-09-08T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/2",
|
||||
timezone: "America/Cordoba",
|
||||
},
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 5,
|
||||
message: "Event 2",
|
||||
from: "2023-09-20T00:00:00.000Z",
|
||||
to: "2023-09-20T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/5",
|
||||
timezone: "Europe/Lisbon",
|
||||
},
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 2,
|
||||
message: "Cordoba",
|
||||
from: "2023-09-14T00:00:00.000Z",
|
||||
to: "2023-09-14T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/2",
|
||||
timezone: "America/Cordoba",
|
||||
},
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 4,
|
||||
message: "Moscow",
|
||||
from: "2023-09-17T00:00:00.000Z",
|
||||
to: "2023-09-18T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/3",
|
||||
timezone: "Europe/Moscow",
|
||||
},
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 3,
|
||||
message: "Tokyo",
|
||||
from: "2023-09-20T00:00:00.000Z",
|
||||
to: "2023-09-21T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/4",
|
||||
timezone: "Asia/Tokyo",
|
||||
},
|
||||
{
|
||||
type: "standalone",
|
||||
post_number: 5,
|
||||
message: "Lisbon",
|
||||
from: "2023-09-28T00:00:00.000Z",
|
||||
to: "2023-09-28T00:00:00.000Z",
|
||||
username: "jan",
|
||||
recurring: null,
|
||||
post_url: "/t/-/252/5",
|
||||
timezone: "Europe/Lisbon",
|
||||
},
|
||||
{
|
||||
type: "grouped",
|
||||
from: "2023-09-04T05:00:00.000Z",
|
||||
name: "Labor Day",
|
||||
users: [
|
||||
{
|
||||
username: "gmt-5_user",
|
||||
timezone: "America/Chicago",
|
||||
},
|
||||
{
|
||||
username: "gmt-6_user",
|
||||
timezone: "America/Denver",
|
||||
},
|
||||
{
|
||||
username: "gmt-7_user",
|
||||
timezone: "America/Los_Angeles",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
timeline_lookup: [[1, 0]],
|
||||
tags: [],
|
||||
tags_descriptions: {},
|
||||
id: 252,
|
||||
title: "Awesome Calendar",
|
||||
fancy_title: "Awesome Calendar",
|
||||
posts_count: 5,
|
||||
created_at: "2023-09-08T16:50:07.371Z",
|
||||
views: 1,
|
||||
reply_count: 0,
|
||||
like_count: 0,
|
||||
last_posted_at: "2023-09-08T16:50:52.936Z",
|
||||
visible: true,
|
||||
closed: false,
|
||||
archived: false,
|
||||
has_summary: false,
|
||||
archetype: "regular",
|
||||
slug: "awesome-calendar",
|
||||
category_id: 5,
|
||||
word_count: 56,
|
||||
deleted_at: null,
|
||||
user_id: 1,
|
||||
featured_link: null,
|
||||
pinned_globally: false,
|
||||
pinned_at: null,
|
||||
pinned_until: null,
|
||||
image_url: null,
|
||||
slow_mode_seconds: 0,
|
||||
draft: null,
|
||||
draft_key: "topic_252",
|
||||
draft_sequence: 9,
|
||||
posted: true,
|
||||
unpinned: null,
|
||||
pinned: false,
|
||||
current_post_number: 1,
|
||||
highest_post_number: 4,
|
||||
last_read_post_number: 4,
|
||||
last_read_post_id: 378,
|
||||
deleted_by: null,
|
||||
has_deleted: false,
|
||||
actions_summary: [
|
||||
{ id: 4, count: 0, hidden: false, can_act: true },
|
||||
{ id: 8, count: 0, hidden: false, can_act: true },
|
||||
{ id: 7, count: 0, hidden: false, can_act: true },
|
||||
],
|
||||
chunk_size: 20,
|
||||
bookmarked: false,
|
||||
bookmarks: [],
|
||||
topic_timer: null,
|
||||
message_bus_last_id: 16,
|
||||
participant_count: 1,
|
||||
show_read_indicator: false,
|
||||
thumbnails: null,
|
||||
slow_mode_enabled_until: null,
|
||||
summarizable: false,
|
||||
details: {
|
||||
can_edit: true,
|
||||
notification_level: 3,
|
||||
notifications_reason_id: 1,
|
||||
can_move_posts: true,
|
||||
can_delete: true,
|
||||
can_remove_allowed_users: true,
|
||||
can_invite_to: true,
|
||||
can_invite_via_email: true,
|
||||
can_create_post: true,
|
||||
can_reply_as_new_topic: true,
|
||||
can_flag_topic: true,
|
||||
can_convert_topic: true,
|
||||
can_review_topic: true,
|
||||
can_close_topic: true,
|
||||
can_archive_topic: true,
|
||||
can_split_merge_topic: true,
|
||||
can_edit_staff_notes: true,
|
||||
can_toggle_topic_visibility: true,
|
||||
can_pin_unpin_topic: true,
|
||||
can_moderate_category: true,
|
||||
can_remove_self_id: 1,
|
||||
participants: [
|
||||
{
|
||||
id: 1,
|
||||
username: "jan",
|
||||
name: null,
|
||||
avatar_template: "/letter_avatar_proxy/v4/letter/j/ce7236/{size}.png",
|
||||
post_count: 4,
|
||||
primary_group_name: null,
|
||||
flair_name: null,
|
||||
flair_url: null,
|
||||
flair_color: null,
|
||||
flair_bg_color: null,
|
||||
flair_group_id: null,
|
||||
admin: true,
|
||||
trust_level: 1,
|
||||
},
|
||||
],
|
||||
created_by: {
|
||||
id: 1,
|
||||
username: "jan",
|
||||
name: null,
|
||||
avatar_template: "/letter_avatar_proxy/v4/letter/j/ce7236/{size}.png",
|
||||
},
|
||||
last_poster: {
|
||||
id: 1,
|
||||
username: "jan",
|
||||
name: null,
|
||||
avatar_template: "/letter_avatar_proxy/v4/letter/j/ce7236/{size}.png",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default eventTopicFixture;
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
export default function getEventByText(text) {
|
||||
const events = [...document.querySelectorAll(".fc-day-grid-event")].filter(
|
||||
(event) => event.textContent.includes(text)
|
||||
);
|
||||
|
||||
switch (events.length) {
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
return events[0];
|
||||
default:
|
||||
return events;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue