Skip to content

Commit 7459e5c

Browse files
committed
chore: fix tests
1 parent dbdce1d commit 7459e5c

3 files changed

Lines changed: 53 additions & 6 deletions

File tree

app/venue/[id]/page.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ export default async function VenuePage({
7777
const eventStatus = getEventStatus(city.date);
7878
const cfpUrl = resolveCfpUrl(city.cfp);
7979
const cfpDeadlinePassed = isCfpDeadlinePassed(city.cfpDate);
80+
const shouldShowCfpGuidelines = Boolean(
81+
city.agenda.length === 0 && cfpUrl && !cfpDeadlinePassed
82+
);
8083
const textColor: string =
8184
eventStatus === ConferenceStatus.ENDED ? 'text-gray-400' : 'text-white';
8285

@@ -180,7 +183,7 @@ export default async function VenuePage({
180183
<div className="w-[1130px] lg:w-full">
181184
<AgendaComponent city={city} />
182185
</div>
183-
) : cfpUrl ? (
186+
) : shouldShowCfpGuidelines && cfpUrl ? (
184187
<div className="w-[1090px] lg:w-full">
185188
<Guidelines
186189
talkDeadLine={city.cfpDate}
@@ -190,7 +193,11 @@ export default async function VenuePage({
190193
cfpDeadlinePassed={cfpDeadlinePassed}
191194
/>
192195
</div>
193-
) : null}
196+
) : (
197+
<div className="w-[1130px] lg:w-full">
198+
<AgendaComponent city={city} />
199+
</div>
200+
)}
194201
</div>
195202
<div id="recordings" className="flex justify-center">
196203
{eventStatus === ConferenceStatus.ENDED ? (

cypress/e2e/Venue.cy.ts

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,54 @@
1-
import { cities } from '../../config/conference-data';
1+
import { agenda, cities } from '../../config/conference-data';
22
import { City } from '../../types/types';
33
import { resolveCfpUrl } from '../../utils/pretalx';
44

5+
const monthIndexByName: Record<string, number> = {
6+
january: 0,
7+
february: 1,
8+
march: 2,
9+
april: 3,
10+
may: 4,
11+
june: 5,
12+
july: 6,
13+
august: 7,
14+
september: 8,
15+
october: 9,
16+
november: 10,
17+
december: 11,
18+
};
19+
20+
function isCfpDeadlinePassed(cfpDate: string): boolean {
21+
if (!cfpDate || cfpDate.toLowerCase() === 'not announced yet') {
22+
return false;
23+
}
24+
25+
const match = cfpDate.match(/^(\d{1,2})\s+([a-zA-Z]+),?\s+(\d{4})$/);
26+
27+
if (!match) {
28+
return false;
29+
}
30+
31+
const month = monthIndexByName[match[2].toLowerCase()];
32+
33+
if (month === undefined) {
34+
return false;
35+
}
36+
37+
const deadline = new Date(Number(match[3]), month, Number(match[1]), 23, 59);
38+
39+
return Date.now() > deadline.getTime();
40+
}
41+
542
it('should render guideline if cfp is open, and agenda otherwise', () => {
643
cy.wrap(cities).each((city: City) => {
7-
cy.visit(`http://localhost:3000/venue/${city.name}`);
44+
cy.visit(`/venue/${encodeURIComponent(city.name)}`);
845

946
cy.getTestData(`venue-${city.name}`).then((val) => {
10-
if (resolveCfpUrl(city.cfp)) {
47+
const hasAgenda = agenda.some((item) => item.city === city.name);
48+
49+
if (hasAgenda) {
50+
cy.getTestData('agenda-com').should('be.visible');
51+
} else if (resolveCfpUrl(city.cfp) && !isCfpDeadlinePassed(city.cfpDate)) {
1152
cy.getTestData('guideline-com').should('be.visible');
1253
} else {
1354
cy.getTestData('agenda-com').should('be.visible');

next-env.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
/// <reference types="next/navigation-types/compat/navigation" />
43
/// <reference path="./.next/types/routes.d.ts" />
54

65
// NOTE: This file should not be edited

0 commit comments

Comments
 (0)