Skip to content

Commit

Permalink
Got the Apple and Android Appium tests working with the cat API
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardKrupa-Cap committed Jun 28, 2023
1 parent 5a929ef commit b3a3740
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 33 deletions.
6 changes: 3 additions & 3 deletions __tests__/App.unit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ it('displays a random image when I select a tag', async () => {

await waitFor(() => expect(global.fetch).toHaveBeenCalledTimes(1));

const button = component.getByText('one >');
const button = component.getByTestId('test:id/one');
fireEvent.press(button);
expect(component.queryAllByTestId('taggedImage')).toHaveLength(1);
const image = component.getByTestId('taggedImage');
expect(component.queryAllByTestId('test:id/tagged-image')).toHaveLength(1);
const image = component.getByTestId('test:id/tagged-image');
expect(image.props.source.uri).toBe('https://cataas.com/c/one');
});
2 changes: 1 addition & 1 deletion components/TagList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function TagList({baseURL, onSelect}): JSX.Element {
message={`${item} >`}
onPress={() => onSelect(item)}
accessibilityLabel={`Select the tag named ${item}`}
testID={item}
testID={`test:id/${item}`}
/>
</View>
);
Expand Down
2 changes: 1 addition & 1 deletion components/TaggedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function TaggedItem({baseURL, tag}): JSX.Element {
const imageUrl = `${baseURL}c/${encodedTag}`;
return (
<Image
testID="taggedImage"
testID="test:id/tagged-image"
source={{uri: imageUrl}}
style={styles.taggedImage}
/>
Expand Down
2 changes: 1 addition & 1 deletion screens/Other.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function Other({route, navigation}): JSX.Element {
<FeatureButton
message="Go Home"
onPress={navigateAway}
testID="navigateHome"
testID="test:id/navigate-home"
accessibilityLabel="Click here to go back to the home screen"
/>

Expand Down
21 changes: 7 additions & 14 deletions src/test/java/AndroidEmulatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,19 @@ public void tearDown() {
}
}

@Test
public void theButtonChangesTheText() {
Assert.assertNotNull(driver.findElement(By.xpath("//*[@text='Nothing to see here']")));
WebElement button = driver.findElement(By.xpath("//*[@text='Do not click here']"));
button.click();
Assert.assertNotNull(driver.findElement(By.xpath("//*[@text='Still nothing to see here']")));
}

@Test
public void theButtonsNavigate() {
driver.findElement(By.xpath("//*[@text='Bye bye']")).click();
driver.findElement(By.xpath("//*[@text='Go Home']")).click();
Assert.assertNotNull(driver.findElement(By.xpath("//*[@text='Nothing to see here']")));
driver.findElement(By.id("test:id/Beer")).click();
Assert.assertNotNull(driver.findElement(By.id("test:id/tagged-image")));
driver.findElement(By.id("test:id/navigate-home")).click();
Assert.assertNotNull(driver.findElement(By.id("test:id/Beer")));
}

@Test
public void backGoesBackHome() {
driver.findElement(By.xpath("//*[@text='Bye bye']")).click();
Assert.assertNotNull(driver.findElement(By.xpath("//*[@text='Go Home']")));
driver.findElement(By.id("test:id/Beer")).click();
Assert.assertNotNull(driver.findElement(By.id("test:id/tagged-image")));
driver.navigate().back();
Assert.assertNotNull(driver.findElement(By.xpath("//*[@text='Nothing to see here']")));
Assert.assertNotNull(driver.findElement(By.id("test:id/Beer")));
}
}
20 changes: 7 additions & 13 deletions src/test/java/AppleSimulatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,19 @@ public void tearDown() {
}
}

@Test
public void theButtonChangesTheText() {
Assert.assertNotNull(driver.findElement(By.xpath("//*[@label='Nothing to see here']")));
driver.findElement(By.xpath("//*[@name='changeText']")).click();
Assert.assertNotNull(driver.findElement(By.xpath("//*[@label='Still nothing to see here']")));
}

@Test
public void theButtonsNavigate() {
driver.findElement(By.xpath("//*[@label='Bye bye']")).click();
driver.findElement(By.xpath("//*[@label='Go Home']")).click();
Assert.assertNotNull(driver.findElement(By.xpath("//*[@label='Nothing to see here']")));
driver.findElement(By.id("test:id/Beer")).click();
Assert.assertNotNull(driver.findElement(By.id("test:id/tagged-image")));
driver.findElement(By.id("test:id/navigate-home")).click();
Assert.assertNotNull(driver.findElement(By.id("test:id/Beer")));
}

@Test
public void backGoesBackHome() {
driver.findElement(By.xpath("//*[@label='Bye bye']")).click();
Assert.assertNotNull(driver.findElement(By.xpath("//*[@label='Go Home']")));
driver.findElement(By.id("test:id/Beer")).click();
Assert.assertNotNull(driver.findElement(By.id("test:id/tagged-image")));
driver.navigate().back();
Assert.assertNotNull(driver.findElement(By.xpath("//*[@label='Nothing to see here']")));
Assert.assertNotNull(driver.findElement(By.id("test:id/Beer")));
}
}

0 comments on commit b3a3740

Please sign in to comment.