-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tr/making the tests great #50
Changes from 6 commits
22a2b90
f1674d8
fe19ff8
db5794e
0ecd162
20f81a0
7113252
f632217
8be285f
0e0565e
b0a95a8
3ea5afa
b6674c9
0f9463e
66ba974
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -160,14 +160,14 @@ def main(): | |||||
logger.info(f"Desired Coverage: {test_gen.desired_coverage}%") | ||||||
|
||||||
# Generate tests by making a call to the LLM | ||||||
generated_tests = test_gen.generate_tests(max_tokens=4096) | ||||||
generated_tests_dict = test_gen.generate_tests(max_tokens=4096) | ||||||
|
||||||
# Write test_gen.prompt to a debug markdown file | ||||||
write_prompt_to_file(GENERATED_PROMPT_NAME, test_gen.prompt) | ||||||
|
||||||
# Validate each test and append the results to the test results list | ||||||
for generated_test in generated_tests: | ||||||
test_result = test_gen.validate_test(generated_test) | ||||||
for generated_test in generated_tests_dict['tests']: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion from PR Agent
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
test_result = test_gen.validate_test(generated_test, generated_tests_dict) | ||||||
test_results_list.append(test_result) | ||||||
|
||||||
# Increment the iteration counter | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
package-lock.json | ||
coverage/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# js-vanilla-example | ||
|
||
A simple vanilla js project to find github users and their repositories. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// search input | ||
const github = new Github(); | ||
const ui = new UI(); | ||
const searchUser = document.getElementById('userName'); | ||
|
||
searchUser.addEventListener('keyup', (e) => { | ||
const userText = e.target.value; | ||
if (userText !== '') { | ||
github.getUser(userText).then((data) => { | ||
if (data.profile.message === 'Not Found') { | ||
//show alert | ||
ui.showAlert('Profile Not Found', 'alert alert-danger'); | ||
} else { | ||
ui.showProfile(data.profile); | ||
ui.showRepos(data.repos); | ||
} | ||
}); | ||
} else { | ||
// clear profile | ||
ui.clearProfile(); | ||
} | ||
}); |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class Github { | ||
constructor() { | ||
this.client_id = 'ab7e3c6ac10d3714249a'; | ||
this.client_secret = 'f315c3cc4bca8b4b922fc04af1b31b02cb1d143d'; | ||
mrT23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.repos_count = 5; | ||
this.repos_sort = 'created: asc'; | ||
} | ||
|
||
async getUser(user) { | ||
const profileResponse = await fetch( | ||
`https://api.github.com/users/${user}?client_id=${this.client_id}&client_secret=${this.client_secret}` | ||
); | ||
const reposResponse = await fetch( | ||
`https://api.github.com/users/${user}/repos?per_page=${this.repos_count}&sort=${this.repos_sort}&client_id=${this.client_id}&client_secret=${this.client_secret}` | ||
); | ||
|
||
const profile = await profileResponse.json(); | ||
const repos = await reposResponse.json(); | ||
|
||
return { | ||
profile: profile, | ||
repos: repos, | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>GitHub User Finder</title> | ||
<link rel="stylesheet" href="bootstrap.min.css"> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-dark bg-primary mb-3"> | ||
<div class="container"> | ||
<a href="" class="navbar-brand">Github User Finder</a> | ||
</div> | ||
</nav> | ||
<div class="container searchContainer"> | ||
<div class="search card card-body"> | ||
<h2>Search github user</h2> | ||
<p class="lead">Enter username to see user profile and reps </p> | ||
<input type="text" id="userName" class="form-control" placeholder="Enter Github username"> | ||
</div> | ||
<br> | ||
<div id="profile"> | ||
<footer class="mt-5 p-3 text-center bg-light"> | ||
Github user finder © | ||
</footer> | ||
</div> | ||
|
||
<script src="github.js"></script> | ||
<script src="ui.js"></script> | ||
<script src="app.js"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "js-vanilla-example", | ||
"version": "1.0.0", | ||
"description": "A simple vanilla js project to find github users and their repositories.", | ||
"main": "app.js", | ||
"type": "module", | ||
"scripts": { | ||
"test": "vitest", | ||
"test:coverage": "vitest run --coverage" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@vitest/coverage-v8": "^1.6.0", | ||
"vitest": "^1.6.0" | ||
}, | ||
"dependencies": { | ||
"jsdom": "^24.1.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
export default class UI { | ||
constructor() { | ||
this.profile = document.getElementById('profile'); | ||
} | ||
showProfile(user) { | ||
this.profile.innerHTML = ` | ||
<div class="card card-body mb-3"> | ||
<div class="row"> | ||
<div class="col-md-3"> | ||
<img src="${user.avatar_url}" alt="" class="img-fluid mb-2"> | ||
<a href="${user.html_url}" target="_blank" class="btn btn-primary btn-block"> View Profile</a> | ||
</div> | ||
<div class="col-md-9"> | ||
<span class="badge badge-primary"> Public Repos: ${user.public_repos}</span> | ||
<span class="badge badge-secondary"> Public Gists: ${user.public_gists}</span> | ||
<span class="badge badge-success"> Followers: ${user.followers}</span> | ||
<span class="badge badge-info"> Following: ${user.following}</span> | ||
<br> <br> | ||
<ul class="list-group"> | ||
<li class="list-group-item">Company : ${user.company}</li> | ||
<li class="list-group-item">Website : ${user.blog}</li> | ||
<li class="list-group-item">Location : ${user.location}</li> | ||
<li class="list-group-item">Member Since : ${user.created_at}</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
<h3 class="page-heading mb-3"> Latest Repos</h3> | ||
<div id="repos"></div> | ||
</div> | ||
`; | ||
} | ||
|
||
showRepos(repos) { | ||
let output = ''; | ||
|
||
repos.forEach(function (repo) { | ||
output += ` | ||
<div class="card card-body mb-2"> | ||
<div class="row"> | ||
<div class="col-sm-6"> | ||
<a href="${repo.html_url}" target="_blank">${repo.name}</a> | ||
<p class="pt-2">${repo.description}</p> | ||
</div> | ||
<div class="col-sm-6"> | ||
<span class="badge badge-primary"> Starts: ${repo.stargazers_count}</span> | ||
<span class="badge badge-info"> Watchers: ${repo.watchers_count}</span> | ||
<span class="badge badge-light"> Forks: ${repo.forms_count}</span> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
}); | ||
|
||
document.getElementById('repos').innerHTML = output; | ||
} | ||
|
||
showAlert(message, className) { | ||
this.clearAlert(); | ||
const div = document.createElement('div'); | ||
div.className = className; | ||
div.appendChild(document.createTextNode(message)); | ||
const container = document.querySelector('.searchContainer'); | ||
const search = document.querySelector('.search'); | ||
container.insertBefore(div, search); | ||
|
||
setTimeout(() => { | ||
this.clearAlert(); | ||
}, 2000); | ||
} | ||
|
||
clearAlert() { | ||
const currentAlert = document.querySelector('.alert'); | ||
if (currentAlert) { | ||
currentAlert.remove(); | ||
} | ||
} | ||
|
||
clearProfile() { | ||
this.profile.innerHTML = ''; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// ui.test.js | ||
import { describe, it, expect, beforeEach, vi } from 'vitest'; | ||
import { JSDOM } from 'jsdom'; | ||
import UI from './ui'; | ||
|
||
describe('UI Class', () => { | ||
let ui; | ||
let document; | ||
let profileElement; | ||
|
||
beforeEach(() => { | ||
const dom = new JSDOM(` | ||
<div id="profile"></div> | ||
<div class="searchContainer"> | ||
<div class="search"></div> | ||
</div> | ||
`); | ||
document = dom.window.document; | ||
global.document = document; | ||
global.window = dom.window; | ||
|
||
profileElement = document.getElementById('profile'); | ||
ui = new UI(); | ||
}); | ||
|
||
it('should instantiate the UI class', () => { | ||
expect(ui).toBeDefined(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { defineConfig } from 'vite'; | ||
|
||
export default defineConfig({ | ||
test: { | ||
globals: true, | ||
environment: 'jsdom', | ||
coverage: { | ||
provider: 'v8', | ||
reporter: ['text', 'html', 'cobertura'], | ||
// Add any other coverage options here | ||
}, | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error:
fule
but should befile
. Need to refactor.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed