Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions final/client/src/components/launch-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const LaunchTile: React.FC<LaunchTileProps> = ({ launch }) => {
const { id, mission, rocket } = launch;
return (
<StyledLink
id={`tile${id}`}
to={`/launch/${id}`}
style={{
backgroundImage: getBackgroundImage(id),
Expand Down
88 changes: 88 additions & 0 deletions final/node_testing/profile_tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
const {Builder, By, Key, until, WebDriver} = require('selenium-webdriver');
const assert = require('assert');
const testEmail = 'SeleniumTest@Gmail.Test'
let driver = new Builder().forBrowser('chrome').build();


runTests();
//checks to see if the profile successfully displays a booked trip
//then checks to see if the profile successfully shows no booked trips

async function runTests(){
await openApp();
await verifyNoPermissionRedirectTest();
await login();
await refreshPage();
await userVerificationTest();
await selectFirstTile();
await clickActionButton();
await navigateToCart();
await userVerificationTest();
await clickBookButton();
await navigateToProfile();
await userVerificationTest();
await selectFirstTile();
await clickActionButton();
await navigateToProfile();
await userVerificationTest();
await navigateToLogout();
await verifyNoPermissionRedirectTest();
await closeApp();
}

async function openApp() {
//Make sure both client and server are running prior to exectuing this script.
await driver.get('http://localhost:3000/');
//driver.manage().setTimeouts({ implicit: 1000});
}

async function verifyNoPermissionRedirectTest() {
var userFormField = await driver.findElement(By.name('email'));
assert.ok(userFormField)
console.log('Pass: user is not logged in.')
}

async function login() {
await driver.findElement(By.name('email')).sendKeys(testEmail, Key.ENTER);
}

async function refreshPage() {
await driver.navigate().refresh();
}

async function userVerificationTest() {
//Verify that the SeleniumTest user is logged in.
let actualUsername = await driver.wait(until.elementLocated(By.id('username')), 5000).getText();

//the css puts this in upper case.
assert.equal(actualUsername, testEmail.toUpperCase());
console.log('Pass: User authenticated on page.')
}

async function selectFirstTile() {
await driver.wait(until.elementLocated(By.id('tile109')), 5000).click();
}

async function clickActionButton() {
await driver.wait(until.elementLocated(By.xpath("//button[@data-testid='action-button']")), 5000).click();
}

async function navigateToCart() {
await driver.wait(until.elementLocated(By.id('cart')), 5000).click();
}

async function clickBookButton() {
await driver.wait(until.elementLocated(By.xpath("//button[@data-testid='book-button']")), 5000).click();
}

async function navigateToProfile() {
await driver.wait(until.elementLocated(By.id('profile'), 5000)).click();
}

async function navigateToLogout() {
await driver.wait(until.elementLocated(By.id('logout-button')), 5000).click();
}

async function closeApp() {
await driver.quit();
}