Skip to content

Commit c8d48e7

Browse files
committed
fix(embed): don't claim an event is online when attendanceMode is unset
rawLocationText() fell through to the "Online" location label whenever attendanceMode wasn't "online", "in-person", or "hybrid" — i.e. whenever it was absent entirely. An event that declares no attendance mode at all now falls back to "Venue not specified" instead, same as an in-person event with no venue. Bumps to 0.6.0 (minor) to also release the already-queued playground restructure (#53) and <ote-subscribe> badge redesign sitting under Unreleased. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 716ab2d commit c8d48e7

15 files changed

Lines changed: 3693 additions & 7 deletions

apps/embed/CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# @opentechevents/embed changelog
22

3-
## Unreleased
3+
## 0.6.0
4+
5+
### Fixed
6+
7+
- An event with no `attendanceMode` declared at all (neither `"online"`,
8+
`"in-person"`, nor `"hybrid"`) and no `location` no longer shows an
9+
"Online" location label — it now shows "Venue not specified", the same
10+
fallback an in-person event with no venue already used. `rawLocationText()`
11+
(`apps/embed/src/render.ts`) previously fell through to the "Online"
12+
default whenever `attendanceMode` wasn't one of the two handled cases,
13+
wrongly asserting online attendance for an event that never declared any
14+
attendance mode.
415

516
### Changed
617

apps/embed/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,15 @@ <h2 id="versioning-heading">Versioning</h2>
527527
<a href="https://tools.opentechevents.org/embed/v__EMBED_VERSION__/ote-events.js" target="_blank" rel="noopener">script</a>
528528
</td>
529529
</tr>
530+
<tr>
531+
<td><code>v0.5.0</code></td>
532+
<td><a href="https://opentechevents.org/schema/v0.3/event.schema.json" target="_blank" rel="noopener">v0.3.0</a></td>
533+
<td>
534+
<a href="https://github.com/OpenTechEvents/ote-tools/releases/tag/embed-v0.5.0" target="_blank" rel="noopener">release</a>
535+
<span aria-hidden="true"> · </span>
536+
<a href="https://tools.opentechevents.org/embed/v0.5.0/ote-events.js" target="_blank" rel="noopener">script</a>
537+
</td>
538+
</tr>
530539
<tr>
531540
<td><code>v0.4.0</code></td>
532541
<td><a href="https://opentechevents.org/schema/v0.3/event.schema.json" target="_blank" rel="noopener">v0.3.0</a></td>

apps/embed/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opentechevents/embed",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"oteSpecVersion": "0.3.0",
55
"description": "Embeddable <ote-events> web component: drop an OTE feed into any website",
66
"license": "MIT",

apps/embed/src/render.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,18 @@ function isOnlineLinkUnpublished(event: PreviewEvent): boolean {
399399
* `@opentechevents/preview-feed` whenever the source gave no venue and no
400400
* online URL — a data-agnostic fallback that doesn't know the event's
401401
* `attendanceMode`. Resolving that sentinel here, where `attendanceMode` is
402-
* available, avoids two bugs: an in-person event with no venue silently
403-
* claiming to be "Online" (wrong, not just noisy), and an online event
404-
* repeating the same "Online" text the attendance badge already shows.
402+
* available, avoids three bugs: an in-person event with no venue silently
403+
* claiming to be "Online" (wrong, not just noisy); an online event repeating
404+
* the same "Online" text the attendance badge already shows; and an event
405+
* with no `attendanceMode` at all (nothing declared either way) asserting
406+
* "Online" as if that were known — same wrongness as the in-person case,
407+
* just with attendance unspecified instead of specified-but-no-venue, so it
408+
* shares that case's fallback rather than defaulting to "Online".
405409
*/
406410
function rawLocationText(event: PreviewEvent, strings: Strings): string {
407411
if (event.location && event.location !== "online") return event.location;
408412
if (event.attendanceMode === "online") return strings.onlineLinkUnknown;
409-
if (event.attendanceMode === "in-person" || event.attendanceMode === "hybrid") return strings.locationUnknown;
410-
return strings.online;
413+
return strings.locationUnknown;
411414
}
412415

413416
function locationText(event: PreviewEvent, strings: Strings): string {

apps/embed/test/element.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,25 @@ describe("<ote-events>", () => {
612612
expect(location?.textContent).not.toContain("Online");
613613
});
614614

615+
it("doesn't claim an event with no attendanceMode declared is online", async () => {
616+
fetchMock.mockResolvedValue({
617+
ok: true,
618+
status: 200,
619+
text: async () =>
620+
JSON.stringify({
621+
events: [{ name: "Attendance unspecified", startDate: "2999-01-01" }],
622+
}),
623+
});
624+
const el = createCardsElement();
625+
el.setAttribute("feed", "https://example.org/no-attendance-mode.json");
626+
document.body.append(el);
627+
await flush();
628+
629+
const location = el.shadowRoot!.querySelector(".event-location");
630+
expect(location?.textContent).toBe("Venue not specified");
631+
expect(location?.textContent).not.toContain("Online");
632+
});
633+
615634
it("defensively hides raw URL locations in cards", () => {
616635
const container = document.createElement("div");
617636
renderWidget(container, rawLocationState("cards"));

apps/embed/versions/v0.6.0/calendar-layout.js

Lines changed: 874 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/embed/versions/v0.6.0/calendar-layout.js.map

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/embed/versions/v0.6.0/index.html

Lines changed: 727 additions & 0 deletions
Large diffs are not rendered by default.

apps/embed/versions/v0.6.0/ote-events.js

Lines changed: 1014 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/embed/versions/v0.6.0/ote-events.js.map

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)