-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from rtjord/75-add-tests-to-frontend-using-se…
…lenium 75 add tests to frontend using selenium
- Loading branch information
Showing
8 changed files
with
169 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"require": "ts-node/register", | ||
"extension": ["ts"], | ||
"spec": "tests/**/*.test.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--require ts-node/register | ||
tests/**/*.test.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Builder, By, until, WebDriver, WebElement } from "selenium-webdriver"; | ||
import { expect } from "chai"; | ||
|
||
describe("Recommendation Feature Tests", function () { | ||
let driver: WebDriver; // Replace 'any' with 'WebDriver' | ||
|
||
before(async function () { | ||
driver = await new Builder().forBrowser("chrome").build(); | ||
}); | ||
|
||
after(async function () { | ||
await driver.quit(); | ||
}); | ||
|
||
it("should return package recommendations", async function () { | ||
await driver.get("https://www.teamfivepackages.com/recommend"); | ||
|
||
const inputField: WebElement = await driver.findElement(By.id("recommend-description-input")); | ||
await inputField.sendKeys("A tool for web development"); | ||
|
||
const recommendButton: WebElement = await driver.findElement(By.id("recommend-button")); | ||
await recommendButton.click(); | ||
|
||
const recommendations: WebElement = await driver.wait( | ||
until.elementLocated(By.id("recommend-results")), | ||
5000 | ||
); | ||
|
||
const items: WebElement[] = await recommendations.findElements(By.tagName("li")); | ||
expect(items.length).to.be.greaterThan(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Builder, By, until, WebDriver, WebElement } from "selenium-webdriver"; | ||
import { expect } from "chai"; | ||
|
||
describe("Search Package Tests", function () { | ||
let driver: WebDriver; | ||
|
||
before(async function () { | ||
driver = await new Builder().forBrowser("chrome").build(); | ||
}); | ||
|
||
after(async function () { | ||
await driver.quit(); | ||
}); | ||
|
||
it("should return results for a valid package search", async function () { | ||
await driver.get("https://www.teamfivepackages.com"); | ||
|
||
const searchBar: WebElement = await driver.findElement(By.id("express")); // Replace 'any' with 'WebElement' | ||
await searchBar.sendKeys("popular-package"); | ||
await searchBar.sendKeys("\n"); | ||
|
||
const results: WebElement = await driver.wait( | ||
until.elementLocated(By.id("search-results")), | ||
5000 | ||
); | ||
const text: string = await results.getText(); // Ensure 'text' is a string | ||
expect(text).to.include("popular-package"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Builder, By, until, WebDriver, WebElement } from "selenium-webdriver"; | ||
import { expect } from "chai"; | ||
|
||
describe("Submit Package Tests", function () { | ||
let driver: WebDriver; // Replace 'any' with 'WebDriver' | ||
|
||
before(async function () { | ||
driver = await new Builder().forBrowser("chrome").build(); | ||
}); | ||
|
||
after(async function () { | ||
await driver.quit(); | ||
}); | ||
|
||
it("should submit a package successfully", async function () { | ||
await driver.get("https://www.teamfivepackages.com/submit"); | ||
|
||
// Find and interact with elements | ||
await driver.findElement(By.id("package-name-input")).sendKeys("test-package"); | ||
await driver.findElement(By.id("package-description-input")).sendKeys("This is a test package."); | ||
await driver.findElement(By.id("package-tags-input")).sendKeys("test, selenium"); | ||
await driver.findElement(By.id("submit-button")).click(); | ||
|
||
// Wait for success message and get text | ||
const successMessage: WebElement = await driver.wait( | ||
until.elementLocated(By.id("success-message")), | ||
5000 | ||
); | ||
const text: string = await successMessage.getText(); // Ensure 'text' is a string | ||
expect(text).to.include("Package submitted successfully"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Builder, By, until, WebDriver } from 'selenium-webdriver'; | ||
import { expect } from 'chai'; | ||
import 'mocha'; | ||
|
||
describe('Team Five Packages Website', function () { | ||
let driver: WebDriver; | ||
|
||
// Initialize WebDriver | ||
before(async function () { | ||
driver = await new Builder().forBrowser('chrome').build(); | ||
}); | ||
|
||
|
||
it('should load the homepage with correct title', async function () { | ||
await driver.get('https://www.teamfivepackages.com'); | ||
const title = await driver.getTitle(); | ||
expect(title).to.include('Team Five Packages'); // Replace with expected title | ||
}); | ||
|
||
|
||
it('should navigate to the Packages page', async function () { | ||
const packagesLink = await driver.findElement(By.linkText('Packages')); | ||
await packagesLink.click(); | ||
|
||
await driver.wait(until.urlContains('/packages'), 5000); // Adjust timeout as needed | ||
const currentUrl = await driver.getCurrentUrl(); | ||
expect(currentUrl).to.include('/packages'); | ||
}); | ||
|
||
|
||
it('should search for a package and display results', async function () { | ||
const searchBox = await driver.findElement(By.name('search')); // Adjust selector | ||
await searchBox.sendKeys('example-package'); | ||
|
||
const searchButton = await driver.findElement(By.css('button[type="submit"]')); | ||
await searchButton.click(); | ||
|
||
await driver.wait(until.elementLocated(By.css('.package-result')), 5000); // Adjust selector | ||
const results = await driver.findElements(By.css('.package-result')); | ||
expect(results.length).to.be.greaterThan(0); // Ensure results are displayed | ||
}); | ||
|
||
|
||
// Quit WebDriver after tests | ||
after(async function () { | ||
await driver.quit(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters