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
4 changes: 2 additions & 2 deletions final/client/src/components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export default function Footer() {
<HomeIcon />
Home
</MenuItem>
<MenuItem to="/cart">
<MenuItem id='cart' to="/cart">
<CartIcon />
Cart
</MenuItem>
<MenuItem to="/profile">
<MenuItem id='profile' to="/profile">
<ProfileIcon />
Profile
</MenuItem>
Expand Down
2 changes: 1 addition & 1 deletion final/client/src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Header: React.FC<HeaderProps> = ({ image, children = 'Space Explorer' }) =
<Image round={!image} src={avatar} alt="Space dog" />
<div>
<h2>{children}</h2>
<Subheading>{email}</Subheading>
<Subheading id='username'>{email}</Subheading>
</div>
</Container>
);
Expand Down
1 change: 1 addition & 0 deletions final/client/src/containers/logout-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const LogoutButton = () => {
const client = useApolloClient();
return (
<StyledButton
id="logout-button"
data-testid="logout-button"
onClick={() => {
// Since we're logging out, remove all traces of the current user
Expand Down
71 changes: 71 additions & 0 deletions final/node_testing/auth_tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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();

async function runTests(){
await openApp();
await verifyNoPermissionRedirectTest();
await login();
await loginTest();
await userVerificationTest();
await navigateToCart();
await userVerificationTest();
await naviageToProfile();
await userVerificationTest();
await naviageToLogout();
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 loginTest() {
//Verify the user got past the login screen
var actualHeading = await driver.wait(until.elementLocated(By.tagName('h2')), 5000).getText();

assert.equal(actualHeading, 'Space Explorer');
console.log('Pass: Testing user was successfully able to pass the login screen.')
}

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

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

async function navigateToCart() {
await driver.findElement(By.id('cart')).click();
}

async function naviageToProfile() {
await driver.findElement(By.id('profile')).click();
}

async function naviageToLogout() {
await driver.findElement(By.id('logout-button')).click();
}

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