Skip to content

Commit

Permalink
detox tests working
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepThePatel committed Apr 20, 2024
1 parent 1d768f8 commit fb38ef0
Show file tree
Hide file tree
Showing 49 changed files with 53 additions and 28 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion components/EmailInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import React from 'react';
import { TextInput, View } from 'react-native';
import styles from '../styles/LoginBoxesStyle';

const Email = ({ value, onChangeText }) => {
const Email = ({ value, onChangeText, testID }) => {
return (
<View style={styles.container}>
<TextInput
testID={testID}
style={styles.emailInput}
placeholder="Email"
value={value}
Expand Down
4 changes: 2 additions & 2 deletions components/LoginButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { TouchableOpacity, Text } from 'react-native';
import { FontAwesome5 } from '@expo/vector-icons';
import styles from '../styles/LoginButtonStyle';

const LoginButton = ({ onPress }) => {
const LoginButton = ({ onPress, testID }) => {
return (
<TouchableOpacity onPress={onPress}>
<TouchableOpacity onPress={onPress} testID={testID}>
<FontAwesome5 name="arrow-circle-right" size={45} color="#57BCBE" />
</TouchableOpacity>
);
Expand Down
3 changes: 2 additions & 1 deletion components/PasswordInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import React from 'react';
import { TextInput, View } from 'react-native';
import styles from '../styles/LoginBoxesStyle';

const PasswordInput = ({ value, onChangeText }) => {
const PasswordInput = ({ value, onChangeText, testID }) => {
return (
<View style={styles.container}>
<TextInput
testID={testID}
style={styles.passwordInput}
placeholder="Password"
value={value}
Expand Down
18 changes: 9 additions & 9 deletions e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
rootDir: '..',
testMatch: ['<rootDir>/e2e/**/*.test.js'],
testTimeout: 120000,
maxWorkers: 1,
globalSetup: 'detox/runners/jest/globalSetup',
globalTeardown: 'detox/runners/jest/globalTeardown',
reporters: ['detox/runners/jest/reporter'],
testEnvironment: 'detox/runners/jest/testEnvironment',
verbose: true,
rootDir: "..",
testMatch: ["<rootDir>/e2e/**/*.test.js"],
testTimeout: 120000,
maxWorkers: 1,
globalSetup: "detox/runners/jest/globalSetup",
globalTeardown: "detox/runners/jest/globalTeardown",
reporters: ["detox/runners/jest/reporter"],
testEnvironment: "detox/runners/jest/testEnvironment",
verbose: true,
};
31 changes: 20 additions & 11 deletions e2e/loginScreen.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
describe("Login Screen", () => {
describe('Login Screen Tests', () => {
beforeEach(async () => {
await device.launchApp();
await device.launchApp({newInstance: true});
});

it("Expect to see login button", async () => {
await waitFor(element(by.id('login-submit-button'))).toBeVisible().withTimeout(5000);
});
it('should fill email and password inputs and click the register button', async () => {
await waitFor(element(by.id('register-button')))
.toBeVisible()
.withTimeout(5000);
console.log('Login username input should now be visible');
await element(by.id('login-username-input')).typeText('[email protected]');

await element(by.id('login-password-input')).typeText('CWA843');

//await device.disableSynchronization();
console.log('Tapping login button now...');
await element(by.id('login-submit-button')).tap();
console.log('Button tapped, proceeding without waiting for network...');

await waitFor(element(by.text('Login Successful'))).toBeVisible().withTimeout(15000);

//await device.enableSynchronization();

it("Should login", async () => {
await waitFor(element(by.id('login-submit-button'))).toBeVisible().withTimeout(5000);
await element(by.id('login-username-input')).typeText('[email protected]');
await element(by.id('login-password-input')).typeText('CWA843');
await element(by.id('login-submit-button')).tap();
await waitFor(element(by.id('settings-button'))).toBeVisible().withTimeout(5000);
await element(by.text("OK")).tap();
});
});
14 changes: 14 additions & 0 deletions e2e/registerScreen.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
describe('Login Screen Tests', () => {
beforeEach(async () => {
await device.launchApp({newInstance: true});
});

it('should click register button and show register screen', async () => {
await waitFor(element(by.id('register-button')))
.toBeVisible()
.withTimeout(5000);
await element(by.id('register-button')).tap();

await expect(element(by.id('register-screen-id'))).toBeVisible();
});
});
8 changes: 4 additions & 4 deletions screens/LoginScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,22 @@ const LoginScreen = ({ navigation }) => {
</View>
<View style={styles.inputContainer}>
<View style={styles.passwordBox}>
<PasswordInput value={password} onChangeText={setPassword} testID="login-password-input"/>
<PasswordInput value={password} onChangeText={setPassword} testID='login-password-input'/>
</View>
<View style={styles.emailBox}>
<EmailInput
style={styles.emailBox}
value={email}
onChangeText={setEmail}
testID="login-username-input"
testID='login-username-input'
/>
</View>
<View style={styles.buttonBox}>
<LoginButton onPress={handleLogin} testID="login-submit-button"/>
<LoginButton onPress={handleLogin} testID='login-submit-button'/>
</View>
</View>
<View style={styles.textContainer}>
<TouchableOpacity onPress={() => navigation.navigate("Register")}>
<TouchableOpacity onPress={() => navigation.navigate("Register")} testID="register-button">
<Text style={styles.registerText}>
Don't have an account? Register
</Text>
Expand Down

0 comments on commit fb38ef0

Please sign in to comment.