Skip to content

Commit

Permalink
fix: api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisvisser committed Dec 20, 2024
1 parent 2be6d59 commit 6e8b953
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/integration/email/drought/email-uga-drought.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Should send an email for uga drought', () => {
// Get all span elements with data-testid="event-name" and their lower case text content
const eventNamesInEmail = Array.from(
document.querySelectorAll('[data-testid="event-name"]'),
(el) => (el as Element).textContent.toLowerCase(),
(el) => (el as Element).textContent?.toLowerCase() ?? '',
);

expect(eventNamesInEmail.length).toBe(nrOfEvents);
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/email/floods/test-flood-scenario.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function testFloodScenario(
params: TestFloodScenarioDto,
): Promise<boolean> {
const { events, countryCodeISO3, accessToken } = params;
const disasterTypeLabel = 'Floods';
const disasterTypeLabel = 'flood';
const mockResult = await mockFloods(scenario, countryCodeISO3, accessToken);
// Act
const response = await sendNotification(
Expand Down Expand Up @@ -60,9 +60,11 @@ export async function testFloodScenario(
// Check if there are elements with the desired text content
for (const event of events) {
const eventTitle = getEventTitle(disasterTypeLabel, event.eventName);
console.log('eventTitle: ', eventTitle);
const hasEvent = eventNamesInEmail.some((eventName) =>
eventName.includes(eventTitle),
);
console.log('hasEvent: ', hasEvent);
expect(hasEvent).toBe(true);
}

Expand Down

0 comments on commit 6e8b953

Please sign in to comment.