Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #297 from SCCapstone/final-test-milestone
Browse files Browse the repository at this point in the history
Small testing changes
  • Loading branch information
afrederiksen authored Apr 23, 2022
2 parents 2f4cfc6 + 8774a75 commit 1e17af1
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 23 deletions.
1 change: 1 addition & 0 deletions .idea/hackstreetboys.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified frontend/src/assets/minus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions frontend/src/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ export const LoginForm: React.FC = () => {
type="password"
/>
</IonItem>
<IonButton className="ion-margin-top" onClick={LogIn} expand="block">
<IonButton className="ion-margin-top" onClick={LogIn} expand="block" data-testid="login-button">
Log In
</IonButton>
<Link to='changepassword'><IonItem>Forgot Password?</IonItem></Link>
{error === true && <IonTitle color="danger">Username or Password Incorrect. Has the email been verified?</IonTitle>}
{error === true && <IonTitle color="danger" data-testid="incorrect-message">Username or Password Incorrect. Has the email been verified?</IonTitle>}
</form>
);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function Home() {
// If user context does not exist -- display login or add some
(context.currentUser !== undefined) ?
<p>You don't have any favorites yet! See our recipes and go <Link to="/favorites">add some!</Link></p>
:<p data-testid="favorite-link"><Link to="/login">Login</Link> to see your favorites!</p>}
:<p data-testid="favorite-link"><Link to="/login" data-testid="favorite-login">Login</Link> to see your favorites!</p>}
</IonContent>
</IonPage>
</IonApp>
Expand Down
42 changes: 33 additions & 9 deletions frontend/src/tests/Goal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,43 @@ import { BASE_URL, fetchUsers } from "./utils";
jest.mock("axios");

// app.test.js
test('goal app rendering/navigating', () => {
test('link goals login redirect', () => {
render(<App />)
//expect(screen.getByText(/You are on the home page/i)).toBeInTheDocument()

const goalshome = {button: 0}
userEvent.click(screen.getByTestId('loginGoals'), goalshome)

expect(screen.getByText(/LOGIN/i)).toBeInTheDocument()
// const goalshome = {button: 0}
// userEvent.click(screen.getByTestId('loginGoals'), goalshome)
//
// expect(screen.getByText(/LOGIN/i)).toBeInTheDocument()
//
// const goalsmenu = {button: 0}
// userEvent.click(screen.getByTestId('menuGoals'), goalsmenu)
//
// expect(screen.getByText(/LOGIN/i)).toBeInTheDocument()

userEvent.click(screen.getByTestId('loginGoals'))

expect(screen.getByTestId("login-button")).toBeInTheDocument()
})

const goalsmenu = {button: 0}
userEvent.click(screen.getByTestId('menuGoals'), goalsmenu)

expect(screen.getByText(/LOGIN/i)).toBeInTheDocument()
test('menu goals login redirect', () => {
render(<App />)
//expect(screen.getByText(/You are on the home page/i)).toBeInTheDocument()

// const goalshome = {button: 0}
// userEvent.click(screen.getByTestId('loginGoals'), goalshome)
//
// expect(screen.getByText(/LOGIN/i)).toBeInTheDocument()
//
// const goalsmenu = {button: 0}
// userEvent.click(screen.getByTestId('menuGoals'), goalsmenu)
//
// expect(screen.getByText(/LOGIN/i)).toBeInTheDocument()


userEvent.click(screen.getByTestId('menuGoals'))

expect(screen.getByTestId("login-button")).toBeInTheDocument()
})


Expand Down
18 changes: 7 additions & 11 deletions frontend/src/tests/Login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@ test('wrong login', () => {
render(<App />);

// Clicks through to registration
userEvent.click(screen.getByText("Register/Log In"));
userEvent.click(screen.getByTestId("favorite-login"));

// Clicks through to login
userEvent.click(screen.getByText("Log in"));

// Clicks through to login with unsatisfactory credentials
userEvent.click(screen.getByText("Log In"));

// console.log(screen.getAllByText(/log in/i))
userEvent.click(screen.getByTestId("login-button"));
userEvent.click(screen.getByTestId("login-button"));

// Checks for the login label at the top of the expected screen
expect(screen.getByText("Login")).toBeInTheDocument()
expect(screen.getByTestId("login-button")).toBeInTheDocument()

});

Expand All @@ -36,13 +32,13 @@ test('password reset', () => {
render(<App />);

// Clicks through to login
userEvent.click(screen.getByText('Log In'));
userEvent.click(screen.getByTestId("favorite-login"));
// Indicates that user wants to reset password
userEvent.click(screen.getByText('Forgot Password?'));
userEvent.click(screen.getByText(/forgot/i));

// console.log(screen.getAllByText(/password reset/i))

// Checks for the Password Reset label at the top of the expected screen
expect(screen.getByText("Password Reset")).toBeInTheDocument();
expect(screen.getByText(/request password reset/i)).toBeInTheDocument();

});

0 comments on commit 1e17af1

Please sign in to comment.