Skip to content

Commit

Permalink
[frontend] feat: Adding github info (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
helloitsdave authored Jun 15, 2024
1 parent 570cbec commit 7786c14
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 21 deletions.
1 change: 1 addition & 0 deletions frontend/public/github-mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 23 additions & 5 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ body::before {
width: 260px;
height: 350px;
padding: 10px;
backdrop-filter: blur(5px);
backdrop-filter: blur(50px);

}

Expand Down Expand Up @@ -207,14 +207,32 @@ textarea {
flex-direction: column;
align-items: center;
justify-content: center;
margin: 0px 20px 20px 20px;
padding: 10px;
width: 300px;
height: 200px;
height: 320px;
border-radius: 20px;
border: 2px solid white;
margin: 10px;
backdrop-filter: blur(10px);
backdrop-filter: blur(80px);
text-align: center;
}

.registration-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

.github-info-container {
display: flex;
flex-direction: column;
align-items: center;
margin: 20px;
}

.github-image {
width: 40px;
}

.registration-link {
Expand Down Expand Up @@ -273,7 +291,7 @@ textarea {
border-radius: 20px;
border: 2px solid white;
padding: 30px;
backdrop-filter: blur(10px);
backdrop-filter: blur(80px);
}

.edit-buttons {
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ describe('App', () => {

expect(localStorage.getItem('token')).toBeNull();

waitFor(() => {
await waitFor(() => {
expect(screen.queryByTestId('note-app')).not.toBeInTheDocument();
}
);
});
expect(await screen.findByText('Login')).toBeInTheDocument();
});
});
10 changes: 5 additions & 5 deletions frontend/src/components/RegistrationForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('RegistrationForm', () => {
userEvent.type(screen.getByPlaceholderText('Confirm Password'), 'passwor');
userEvent.click(screen.getByText('Register'));
expect(
await screen.findByText('Error: Passwords do not match')
await screen.findByText('Error: Passwords do not match'),
).toBeInTheDocument();
});
it('should throw error message on failed registration', async () => {
Expand All @@ -34,26 +34,26 @@ describe('RegistrationForm', () => {

await waitFor(() => {
expect(
screen.getByText('Error: An error occurred. Please retry')
screen.getByText('Error: An error occurred. Please retry'),
).toBeInTheDocument();
});
});
it('should register new user', async () => {
render(<RegistrationForm {...props} />);
userEvent.type(
screen.getByPlaceholderText('Username'),
`test${Date.now()}`
`test${Date.now()}`,
);
userEvent.type(
screen.getByPlaceholderText('Email'),
`test${Date.now()}@email.com`
`test${Date.now()}@email.com`,
);
userEvent.type(screen.getByPlaceholderText('Password'), 'pass');
userEvent.type(screen.getByPlaceholderText('Confirm Password'), 'pass');
userEvent.click(screen.getByText('Register'));
await waitFor(() => {
expect(
screen.getByText('Account created successfully!')
screen.getByText('Account created successfully!'),
).toBeInTheDocument();
});
});
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/components/RegistrationLink.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ import RegistrationLink from './RegistrationLink';
describe('RegistrationLink', () => {
it('should render the registration link', () => {
render(<RegistrationLink onRegister={false} />);
expect(screen.getByText('Welcome to the e-notes app')).toBeInTheDocument();
expect(
screen.getByText('Sign up for your free account'),
screen.getByText(
'This is a simple app to demonstrate different automated testing techniques.',
),
).toBeInTheDocument();
expect(
screen.getByText('Sign up for your free e-notes account.'),
).toBeInTheDocument();
expect(screen.getByText('Sign up')).toBeInTheDocument();

expect(
screen.getByText('View the source code on GitHub.'),
).toBeInTheDocument();

expect(screen.getByAltText('Github link')).toBeInTheDocument();
});

it('should render the registration link with account created successfully message', () => {
Expand Down
29 changes: 23 additions & 6 deletions frontend/src/components/RegistrationLink.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
/* eslint-disable prettier/prettier */
const RegistrationLink = (props: { onRegister: boolean }) => {
return (
<div>
<div className="registration-link">
<h1>e-notes</h1>
</div>
<div className="registration-container">
{!props.onRegister ? (
<div className="registration-link-container">
<p>Welcome to the e-notes app</p>
<p>Sign up for your free account</p>
<div className="github-info-container">
<p>
This is a simple app to demonstrate different automated testing
techniques.
</p>
<p>
View the source code on GitHub.
</p>
<a
href="https://github.com/helloitsdave/notes-app-full-stack-testing"
target="_blank"
rel="noopener noreferrer"
>
<img
className="github-image"
src="github-mark.svg"
alt="Github link"
/>
</a>
</div>
<p>Sign up for your free e-notes account.</p>
<a className="nav-link" href="/register">
Sign up
</a>
Expand Down

1 comment on commit 7786c14

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

96.90%

Coverage Report
FileBranchesFuncsLinesUncovered Lines
src
   App.tsx87.50%75%96%30–31, 40–41
   NoteApp.tsx94.44%100%97.04%72–76
src/api
   apiService.ts87.50%85.71%87.76%38, 38–43, 92–98
src/components
   Header.tsx100%100%100%
   Login.tsx81.82%100%98.72%32, 32–33
   Note.tsx100%100%100%
   NoteForm.tsx100%100%100%
   NoteFormModal.tsx100%100%100%
   NoteGrid.tsx100%100%100%
   RegistrationForm.tsx86.67%100%97.04%57, 57–61
   RegistrationLink.tsx100%100%100%
   Spinner.tsx100%100%100%

Please sign in to comment.