Skip to content

Commit

Permalink
3 detox tests working
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepThePatel committed Apr 21, 2024
1 parent fb38ef0 commit 65b3575
Show file tree
Hide file tree
Showing 128 changed files with 79 additions and 25 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.
4 changes: 2 additions & 2 deletions components/AccountButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import getStyles from '../styles/HomeScreenStyles';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import { useTheme } from "../services/ThemeContext";

const AccountButton = ({ navigation }) => {
const AccountButton = ({ navigation, testID }) => {
const { theme } = useTheme();
const styles = getStyles(theme);
const onAccountPress = () => {
navigation.navigate("Settings");
};

return (
<View style={styles.accountContainer}>
<View style={styles.accountContainer} testID={testID}>
<TouchableOpacity onPress={onAccountPress}>
<MaterialIcons name="settings" size={24} color={'white'} />
</TouchableOpacity>
Expand Down
48 changes: 48 additions & 0 deletions e2e/addPaymentScreen.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const TIMEOUT = 10000;
import loginUser from "./loginUser";

async function tapVisibleButton(buttonId) {
await waitFor(element(by.id(buttonId))).toBeVisible().withTimeout(TIMEOUT);
await element(by.id(buttonId)).tap();
}

describe('Add payment test', () => {
beforeEach(async () => {
await device.launchApp({newInstance: true});
});

it('should go to add payment screen, add payment, and save', async () => {
await loginUser();
console.log("Logged in");
await waitFor(element(by.id('home-screen')))
.toBeVisible()
.withTimeout(10000)
.catch(e => {
console.error("Failed to find settings-button within timeout: ", e);
});
await tapVisibleButton('settings-button');
await tapVisibleButton('tab-account');
await tapVisibleButton('to-payment-methods');
await tapVisibleButton('add-payment-button');
await waitFor(element(by.id('input-nickname'))).toBeVisible().withTimeout(TIMEOUT);

await element(by.id('input-nickname')).typeText('My Debit Card');
await element(by.id('safe-area')).tap();
await element(by.id('input-credit-card')).typeText('1234567890123456');
await element(by.id('safe-area')).tap();
await element(by.id('input-cvc')).typeText('123');
await element(by.id('safe-area')).tap();
await element(by.id('input-exp-month')).typeText('12');
await element(by.id('safe-area')).tap();
await element(by.id('input-exp-year')).typeText('2025');
await element(by.id('safe-area')).tap();
await element(by.id('input-name')).typeText('John Doe');
await element(by.id('safe-area')).tap();
await element(by.id('input-zip')).typeText('12345');
await element(by.id('safe-area')).tap();

await tapVisibleButton('button-save-payment-method');
await element(by.text('OK')).tap();
//await expect(element(by.text('Your payment method was saved successfully!'))).toBeVisible().withTimeout(TIMEOUT);
});
});
23 changes: 4 additions & 19 deletions e2e/loginScreen.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
import loginUser from "./loginUser";

describe('Login Screen Tests', () => {
beforeEach(async () => {
await device.launchApp({newInstance: true});
});

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();

await element(by.text("OK")).tap();
it('should fill email and password inputs and log the user in', async () => {
loginUser();
});
});
19 changes: 19 additions & 0 deletions e2e/loginUser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
async function loginUser() {
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');

console.log('Tapping login button now...');
await device.disableSynchronization();
await element(by.id('login-submit-button')).tap();

await waitFor(element(by.text('Login Successful' || 'Logged in successfully.'))).toBeVisible().withTimeout(5000);

await element(by.text("OK")).tap();
}

export default loginUser;
2 changes: 1 addition & 1 deletion e2e/registerScreen.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('Login Screen Tests', () => {
describe('Register Test', () => {
beforeEach(async () => {
await device.launchApp({newInstance: true});
});
Expand Down
2 changes: 1 addition & 1 deletion screens/AddPaymentMethodsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const AddPaymentMethodsScreen = () => {
</View>

<View>
<Text style={styles.label}>Credit Card:</Text>
<Text style={styles.label} testID='safe-area'>Credit Card:</Text>
<TextInput style={[styles.input, {width: '43%'}]}
testID='input-credit-card'
onChangeText={handleCreditCardChange}
Expand Down
6 changes: 4 additions & 2 deletions screens/HomeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useTheme } from "../services/ThemeContext";
import getStyles from "../styles/HomeScreenStyles";
import eventEmitter from "../components/EventEmitter";
import { set } from "date-fns";
import { LogBox } from 'react-native';

const HomeScreen = ({ route }) => {
const navigation = useNavigation();
Expand All @@ -33,6 +34,7 @@ const HomeScreen = ({ route }) => {
const [work, setWork] = useState(0);
const [gym, setGym] = useState(0);
const [personal, setPersonal] = useState(0);
LogBox.ignoreAllLogs();

// Function to fetch tasks and calculate progress
const fetchAndCalculateTasks = async () => {
Expand Down Expand Up @@ -173,15 +175,15 @@ const HomeScreen = ({ route }) => {
return () => backHandler.remove();
}, []);
return (
<View style={{ flex: 1 }}>
<View style={{ flex: 1 }} testID='home-screen'>
<View style={styles.homeTextContainer}>
<View style={styles.headerContainer}>
<View style={{ flex: 1 }}>{/* Empty View as Spacer */}</View>
<View style={{ flex: 2, alignItems: "center" }}>
<Text style={styles.homeText}>Today</Text>
</View>
<View style={{ flex: 1, alignItems: "flex-end" }}>
<AccountButton navigation={navigation} testID="settings-button"/>
<AccountButton navigation={navigation} testID='settings-button'/>
</View>
</View>
<View style={{ width: 24 }} />
Expand Down

0 comments on commit 65b3575

Please sign in to comment.