Skip to content

Commit

Permalink
Merge pull request #65 from slidr-app/test-error-page
Browse files Browse the repository at this point in the history
add error page test + error on presentation not found
  • Loading branch information
codyzu committed Feb 13, 2024
2 parents 844338b + 9f3b7ee commit af10e03
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/slides/use-presentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function usePresentation(): PresentationAndId {
return onSnapshot(
doc(firestore, 'presentations', presentationId),
(snapshot) => {
if (!snapshot.exists) {
if (!snapshot.exists()) {
setPageError(
new Error(`Presentation '${presentationId}' does not exist`),
);
Expand Down
33 changes: 33 additions & 0 deletions src/pages/error.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {test, expect} from '../test/coverage-fixture';

test('displays an error when the presentation does not exist', async ({
page,
}) => {
const errorLogs: string[] = [];
page.on('console', (message) => {
if (message.type() === 'error') {
errorLogs.push(message.text());
}
});

await page.goto(`/v/does-not-exist`);

await expect(
page.getByText('Something is not right. Try refreshing or going home.'),
).toBeVisible();

await expect(page.getByRole('link', {name: 'refreshing'})).toHaveAttribute(
'href',
/\/v\/does-not-exist/,
);

await expect(page.getByRole('link', {name: 'home'})).toHaveAttribute(
'href',
'/',
);

expect(errorLogs.length).toBeGreaterThanOrEqual(1);
expect(errorLogs[0]).toMatch(
"Error: Presentation 'does-not-exist' does not exist",
);
});

0 comments on commit af10e03

Please sign in to comment.