Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ ✨ Testing for UI #388

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b89ff2b
Update change-password.spec.js
RRduToit Sep 21, 2022
9d0bc32
Merge branch 'develop' into testing
RRduToit Sep 25, 2022
66eb905
Update change-email.spec.js
RRduToit Sep 26, 2022
8bcb058
Update change-email.spec.js
RRduToit Sep 26, 2022
20482cc
Update change-email.spec.js
RRduToit Sep 26, 2022
6fcb07b
Update change-email.spec.js
RRduToit Sep 27, 2022
91c0525
Update change-email.spec.js
RRduToit Sep 27, 2022
d9f30ca
Update change-email.spec.js
RRduToit Sep 27, 2022
3fd2f2d
Update tests
RRduToit Sep 27, 2022
c343f59
Update change-password.spec.js
RRduToit Sep 27, 2022
19efd78
:sparkles: update testing
RRduToit Sep 27, 2022
f1ea7cb
Update forgot-password.spec.js
RRduToit Sep 27, 2022
950094b
:sparkles: update testing
RRduToit Sep 27, 2022
83e1b1a
:sparkles: update testing
RRduToit Sep 27, 2022
8b5f4a7
Update login.spec.js
RRduToit Sep 27, 2022
b9699f3
Update register.spec.js
RRduToit Sep 27, 2022
e666562
Update colour-page.spec.js
RRduToit Sep 27, 2022
7842ed7
Update colour-page.spec.js
RRduToit Sep 27, 2022
276e8a5
Update view-all.spec.js
RRduToit Sep 27, 2022
c1c57a3
Update view-all.spec.js
RRduToit Sep 27, 2022
66a6344
Update view-all.spec.js
RRduToit Sep 27, 2022
c992b1d
Adding library to yarn for testing
RRduToit Sep 28, 2022
1a587ca
Update home.spec.js
RRduToit Sep 28, 2022
f1c0114
Update react native tests
RRduToit Sep 28, 2022
8e08809
Update home.spec.js
RRduToit Sep 28, 2022
8084ac8
Update settings.spec.js
RRduToit Sep 28, 2022
7db0f8f
Update settings.spec.js
RRduToit Sep 28, 2022
7f36884
Update colour-page.spec.js
RRduToit Sep 28, 2022
c706118
Update change-email.spec.js
RRduToit Sep 28, 2022
611887b
Update change-email.spec.js
RRduToit Sep 28, 2022
ffe5b81
Update change-password.spec.js
RRduToit Sep 28, 2022
2023904
:sparkles: Update login page testing
RRduToit Sep 28, 2022
e710fb1
:sparkles: adding to testing navigation to UI
RRduToit Sep 28, 2022
a3e74bb
:sparkles: adding to testing navigation to UI
RRduToit Sep 28, 2022
88d04fe
Merge branch 'develop' into testing
RRduToit Sep 28, 2022
59b5b16
Update yarn.lock
RRduToit Sep 30, 2022
79b56aa
Merge branch 'testing' of https://github.com/COS301-SE-2022/Conversat…
RRduToit Sep 30, 2022
3c3abe6
Merge branch 'develop' into testing
RRduToit Sep 30, 2022
c4b901d
Remove useless files
u20437863-James-Butler Sep 30, 2022
8f80133
Merge branch 'main' into testing
u20437863-James-Butler Sep 30, 2022
b8e8a1f
Create yarn.lock
u20437863-James-Butler Sep 30, 2022
c1386d2
Update main.yml
u20437863-James-Butler Sep 30, 2022
ea364d2
Update main.yml
u20437863-James-Butler Sep 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
run: |
nx affected --target=test --coverage
nx affected --target=lint
nx affected --target=build
nx affected --target=build --coverage
nx affected --target=e2e --coverage

- name: Upload coverage to Codecov
Expand Down
10 changes: 0 additions & 10 deletions apps/client/src/app/slices/group.slice.spec.ts

This file was deleted.

52 changes: 0 additions & 52 deletions apps/client/src/app/slices/group.slice.ts

This file was deleted.

54 changes: 48 additions & 6 deletions libs/client/ui/src/lib/change-email/change-email.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { render } from '@testing-library/react-native';
import { render, screen, fireEvent } from '@testing-library/react-native';
import ChangeEmail from './change-email';
import { configureStore } from '@reduxjs/toolkit';
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import reducer from '../../../../../../apps/client/src/app/slices/user.slice';
import { Provider } from 'react-redux';
// yarn nx run change-email:test

describe('ChangeEmail', () => {
describe('check if ChangeEmail renders correctly', () => {
const store = configureStore({
reducer: {
user:reducer
Expand All @@ -18,8 +18,50 @@ describe('ChangeEmail', () => {
</Provider>
);
it('should render successfully', () => {
// const { container } = render(<TestComponent />);
// expect(container).toBeTruthy();
expect(true).toEqual(true);
const { container } = render(TestComponent);
expect(container).toBeTruthy();
});
});

test('check changing of email works', () => {
const store = configureStore({
reducer: {
user:reducer
},
});
const TestComponent = () => (
<Provider store={store}>
<ChangeEmail />
</Provider>
);

render(TestComponent);

//new email
const newEmailInput = screen.getByPlaceholderText("[email protected]");
expect(newEmailInput).toBeTruthy();

const textToEnterNewEmail = '[email protected]';
fireEvent.changeText(newEmailInput, textToEnterNewEmail);

// setCheckEmail
const checkEmailInput = screen.getByPlaceholderText("[email protected]");
expect(checkEmailInput).toBeTruthy();

const textToEnterCheckEmail = '[email protected]';
fireEvent.changeText(newEmailInput, textToEnterCheckEmail);

// setPassword
const passwordInput = screen.getByPlaceholderText("*********");
expect(passwordInput).toBeTruthy();

const textToEnterPassword = '123qwe123#';
fireEvent.changeText(passwordInput, textToEnterPassword);

// Submit
fireEvent.press(screen.ByLabelText('Change email'));

const emailState = store.getState().email;

expect(emailState).toEqual('[email protected]');
});
54 changes: 48 additions & 6 deletions libs/client/ui/src/lib/change-password/change-password.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { render } from '@testing-library/react-native';
import { render, screen, fireEvent } from '@testing-library/react-native';
import ChangePassword from './change-password';
import { configureStore } from '@reduxjs/toolkit';
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import reducer from '../../../../../../apps/client/src/app/slices/user.slice';
import { Provider } from 'react-redux';
// yarn nx run change-password:test

describe('ChangePassword', () => {
describe('check that ChangePassword is rendered correctly', () => {
const store = configureStore({
reducer: {
user:reducer
Expand All @@ -18,8 +18,50 @@ describe('ChangePassword', () => {
</Provider>
)
it('should render successfully', () => {
// const { container } = render(<TestComponent />);
// expect(container).toBeTruthy();
expect(true).toEqual(true)
const { container } = render(TestComponent);
expect(container).toBeTruthy();
});
});

test('check that password is changed', () => {
const store = configureStore({
reducer: {
user:reducer
},
});
const TestComponent = () => (
<Provider store={store}>
<ChangePassword />
</Provider>
);

render(TestComponent);

//password
const passwordInput = screen.getByPlaceholderText("*****************");
expect(passwordInput).toBeTruthy();

const textToEnterPassword = '123qwe123#';
fireEvent.changeText(passwordInput, textToEnterPassword);

// setCheckPassword
const checkPasswordInput = screen.getByPlaceholderText("*****************");
expect(checkPasswordInput).toBeTruthy();

const textToEnterCheckPassword = '123qwe123#';
fireEvent.changeText(checkPasswordInput, textToEnterCheckPassword);

//password
const oldPasswordInput = screen.getByPlaceholderText("*****************");
expect(oldPasswordInput).toBeTruthy();

const textToEnterOldPassword = '123qwe123#';
fireEvent.changeText(oldPasswordInput, textToEnterOldPassword);

// Submit
fireEvent.press(screen.ByLabelText("Change password"));

const passwordState = store.getState().password;

expect(passwordState).toEqual('123qwe123#');
});
22 changes: 12 additions & 10 deletions libs/client/ui/src/lib/colour-page/colour-page.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { render } from '@testing-library/react-native';
import { render, screen, fireEvent } from '@testing-library/react-native';
import ColourPage from './colour-page';
import { Provider } from 'react-redux';
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
Expand All @@ -10,16 +9,19 @@ describe('ColourPage', () => {
const store = configureStore({
reducer: {
user:reducer
}
})
},
});
const TestComponent = () => (
<Provider store = { store }>
<ColourPage />
<Provider store={store}>
<ColourPage />
</Provider>
)
);
it('should render successfully', () => {
// const { container } = render(<TestComponent />);
// expect(container).toBeTruthy();
expect(true).toEqual(true);
const { container } = render(TestComponent);
expect(container).toBeTruthy();
});
});

// Submit
//fireEvent.press(screen.ByLabelText("Register"));
// TODO: figure out how to do this
54 changes: 41 additions & 13 deletions libs/client/ui/src/lib/forgot-password/forgot-password.spec.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,53 @@
import React from 'react';
import { render } from '@testing-library/react-native';
import { render, screen, fireEvent } from '@testing-library/react-native';
import ForgotPassword from './forgot-password';
import { configureStore } from '@reduxjs/toolkit';
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import reducer from '../../../../../../apps/client/src/app/slices/user.slice';
import { Provider } from 'react-redux';

// describe('ForgotPassword', () => {
// const store = configureStore({
// reducer: {
// user:reducer
// }
// })
// const TestComponent = () => (
// <Provider store = { store }>
// <ForgotPassword />
// </Provider>
// )
// it('should render successfully', () => {
// // const { container } = render(<TestComponent />);
// // expect(container).toBeTruthy();
// expect(true).toEqual(true);
// });
// });

describe('ForgotPassword', () => {
const store = configureStore({
reducer: {
user:reducer
}
})
},
});
const TestComponent = () => (
<Provider store = { store }>
<ForgotPassword />
<Provider store={store}>
<ForgotPassword />
</Provider>
)
it('should render successfully', () => {
// const { container } = render(<TestComponent />);
// expect(container).toBeTruthy();
expect(true).toEqual(true);
});
});
);

render(TestComponent);

//new email
const newEmailInput = screen.getByPlaceholderText("[email protected]");
expect(newEmailInput).toBeTruthy();

const textToEnterNewEmail = '[email protected]';
fireEvent.changeText(newEmailInput, textToEnterNewEmail);

// Submit
fireEvent.press(screen.ByLabelText("Send reset email"));

const emailState = store.getState().email;

expect(emailState).toEqual('[email protected]');
});
Loading