Skip to content

Commit

Permalink
add locators
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedRaslan committed Dec 2, 2021
1 parent 92e8068 commit 554b79d
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/components/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export const Checkbox = ({ id, taskDesc }) => {
const archiveTask = () => {
updateTaskData(id, {
archived: true,
}).then(docRef => {
console.log("Task updated successfully , task id:", docRef.id)
}).then(() => {
console.log("Task updated successfully , task id:", id)
}).catch(e => console.log("Failed to update the task", e));
};

Expand Down
2 changes: 2 additions & 0 deletions src/components/IndividualProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const IndividualProject = ({ project }) => {
<button
type="button"
onClick={() => deleteProject(project.docId)}
data-testid="delete"
>
Delete
</button>
Expand All @@ -60,6 +61,7 @@ export const IndividualProject = ({ project }) => {
tabIndex={0}
role="button"
aria-label="Cancel adding project, do not delete"
data-testid="cancel"
>
Cancel
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/firestore-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const addTaskOnFB = async (payload) => {
}

export const updateTaskData = async (id, newData) => {
return await updateDoc(collection(db, "tasks", id), newData)
return await updateDoc(doc(db, "tasks", id), newData)
}

export const deleteProjectFromFB = async (id) => {
Expand Down
17 changes: 11 additions & 6 deletions src/pages/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,27 @@ export default function Dashboard() {
>
<div className="w-100" style={{ maxWidth: '400px' }}>
<Card>
<Card.Body>
<h2 className="text-center mb-4">Profile</h2>
{error && <Alert variant="danger">{error}</Alert>}
<strong>Email:</strong> {currentUser.email}
<Link to={ROUTES.HOME} className="btn btn-primary w-100 mt-3">
<Card.Body data-testid="profile">
<h2 className="text-center mb-4" data-testid="title">Profile</h2>
{error && <Alert data-testid="error-message" variant="danger">{error}</Alert>}
<strong data-testid="username">Email:</strong> {currentUser.email}
<Link
to={ROUTES.HOME}
className="btn btn-primary w-100 mt-3"
data-testid="go-home"
>
Go Home
</Link>
<Link
to={ROUTES.UPDATE_PROFILE}
className="btn btn-primary w-100 mt-3"
data-testid="update-profile"
>
Update Profile
</Link>
</Card.Body>
</Card>
<div className="w-100 text-center mt-2">
<div className="w-100 text-center mt-2" data-testid="logout">
<Button variant="link" onClick={handleLogout}>
Log Out
</Button>
Expand Down
22 changes: 11 additions & 11 deletions src/pages/ForgotPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@ export default function ForgotPassword() {
style={{ minHeight: "100vh" }}>
<div className="w-100" style={{ maxWidth: "400px" }}>
<Card>
<Card.Body>
<h2 className="text-center mb-4">Password Reset</h2>
{error && <Alert variant="danger">{error}</Alert>}
{message && <Alert variant="success">{message}</Alert>}
<Form onSubmit={handleSubmit}>
<Form.Group id="email">
<Form.Label>Email</Form.Label>
<Form.Control type="email" ref={emailRef} required />
<Card.Body data-testid="forgot-password">
<h2 className="text-center mb-4" data-testid="title">Password Reset</h2>
{error && <Alert variant="danger" data-testid="error-message">{error}</Alert>}
{message && <Alert variant="success" data-testid="success-message">{message}</Alert>}
<Form onSubmit={handleSubmit} data-testid="forgot-password-form">
<Form.Group id="email" data-testid="email">
<Form.Label data-testid="label">Email</Form.Label>
<Form.Control data-testid="input" type="email" ref={emailRef} required />
</Form.Group>
<Button disabled={loading} className="w-100" type="submit">
<Button disabled={loading} className="w-100" type="submit" data-testid="reset-password-btn">
Reset Password
</Button>
</Form>
<div className="w-100 text-center mt-3">
<div className="w-100 text-center mt-3" data-testid="login">
<Link to="/login">Login</Link>
</div>
</Card.Body>
</Card>
<div className="w-100 text-center mt-2">
<div className="w-100 text-center mt-2" data-testid="signup">
Need an account? <Link to={ROUTES.SIGN_UP}>Sign Up</Link>
</div>
</div></Container>
Expand Down
26 changes: 13 additions & 13 deletions src/pages/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,28 @@ export default function Login() {
style={{ minHeight: "100vh" }}>
<div className="w-100" style={{ maxWidth: "400px" }}>
<Card>
<Card.Body>
<h2 className="text-center mb-4">Log In</h2>
{error && <Alert variant="danger">{error}</Alert>}
<Form onSubmit={handleSubmit}>
<Form.Group id="email">
<Form.Label>Email</Form.Label>
<Form.Control type="email" ref={emailRef} required />
<Card.Body data-testid="login-card">
<h2 className="text-center mb-4" data-testid="title">Log In</h2>
{error && <Alert data-testid="error-message" variant="danger">{error}</Alert>}
<Form onSubmit={handleSubmit} data-testid="login-form">
<Form.Group id="email" data-testid="email">
<Form.Label data-testid="label">Email</Form.Label>
<Form.Control type="email" ref={emailRef} required data-testid="input" />
</Form.Group>
<Form.Group id="password">
<Form.Label>Password</Form.Label>
<Form.Control type="password" ref={passwordRef} required />
<Form.Group id="password" data-testid="password">
<Form.Label data-testid="label">Password</Form.Label>
<Form.Control type="password" ref={passwordRef} required data-testid="input" />
</Form.Group>
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }} >
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }} data-testid="loginbtn">
Log In
</Button>
</Form>
<div className="w-100 text-center mt-3">
<div className="w-100 text-center mt-3" data-testid="forgot-password">
<Link to={ROUTES.FORGOT_PASSWORD} style={{ color: "#0080c8" }}>Forgot Password?</Link>
</div>
</Card.Body>
</Card>
<div className="w-100 text-center mt-2">
<div className="w-100 text-center mt-2" data-testid="signup" >
Need an account? <Link to={ROUTES.SIGN_UP} style={{ color: "#0080c8" }}>Sign Up</Link>
</div>
</div></Container >
Expand Down
6 changes: 3 additions & 3 deletions src/pages/NotFound.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export default function NotFound() {
style={{ minHeight: "100vh" }}>
<div className="w-100" style={{ maxWidth: "400px" }}>
<Card>
<Card.Body>
<h2 className="text-center mb-4"> Page Not Found</h2>
<Link to={ROUTES.HOME} className="btn btn-primary w-100 mt-3">
<Card.Body data-testid="not-found-page">
<h2 className="text-center mb-4" data-testid="title"> Page Not Found</h2>
<Link to={ROUTES.HOME} className="btn btn-primary w-100 mt-3" data-testid="go-back">
Go Back To Home
</Link>
</Card.Body>
Expand Down
30 changes: 15 additions & 15 deletions src/pages/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,29 @@ export default function Signup() {
style={{ minHeight: "100vh" }}>
<div className="w-100" style={{ maxWidth: "400px" }}>
<Card>
<Card.Body>
<h2 className="text-center mb-4">Sign Up</h2>
{error && <Alert variant="danger">{error}</Alert>}
<Form onSubmit={handleSubmit}>
<Form.Group id="email">
<Form.Label>Email</Form.Label>
<Form.Control type="email" placeholder="[email protected]" ref={emailRef} required />
<Card.Body data-testid="signup-card">
<h2 className="text-center mb-4" data-testid="title">Sign Up</h2>
{error && <Alert variant="danger" data-testid="error-message">{error}</Alert>}
<Form onSubmit={handleSubmit} data-testid="signup-form">
<Form.Group id="email" data-testid="email">
<Form.Label data-testid="label">Email</Form.Label>
<Form.Control type="email" placeholder="[email protected]" ref={emailRef} required data-testid="input" />
</Form.Group>
<Form.Group id="password">
<Form.Label>Password</Form.Label>
<Form.Control type="password" ref={passwordRef} required />
<Form.Group id="password" data-testid="password">
<Form.Label data-testid="label">Password</Form.Label>
<Form.Control type="password" ref={passwordRef} required data-testid="input" />
</Form.Group>
<Form.Group id="password-confirm">
<Form.Label>Password Confirmation</Form.Label>
<Form.Control type="password" ref={passwordConfirmRef} required />
<Form.Group id="password-confirm" data-testid="confirm-password">
<Form.Label data-testid="label">Password Confirmation</Form.Label>
<Form.Control type="password" ref={passwordConfirmRef} required data-testid="input" />
</Form.Group>
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }}>
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }} data-testid="signup-btn">
Sign Up
</Button>
</Form>
</Card.Body>
</Card>
<div className="w-100 text-center mt-2">
<div className="w-100 text-center mt-2" data-testid="login">
Already have an account? <Link to="/login" style={{ color: "#0080c8" }}>Log In</Link>
</div>
</div>
Expand Down
31 changes: 17 additions & 14 deletions src/pages/UpdateProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,42 +49,45 @@ export default function UpdateProfile() {
style={{ minHeight: "100vh" }}>
<div className="w-100" style={{ maxWidth: "400px" }}>
<Card>
<Card.Body>
<h2 className="text-center mb-4">Update Profile</h2>
{error && <Alert variant="danger">{error}</Alert>}
<Form onSubmit={handleSubmit}>
<Form.Group id="email">
<Form.Label>Email</Form.Label>
<Card.Body data-testid="update-card">
<h2 className="text-center mb-4" data-testid="title">Update Profile</h2>
{error && <Alert variant="danger" data-testid="error-message">{error}</Alert>}
<Form onSubmit={handleSubmit} data-testid="ypdate-form">
<Form.Group id="email" data-testid="email">
<Form.Label data-testid="label">Email</Form.Label>
<Form.Control
type="email"
ref={emailRef}
required
defaultValue={currentUser.email}
data-testid="input"
/>
</Form.Group>
<Form.Group id="password">
<Form.Label>Password</Form.Label>
<Form.Group id="password" data-testid="password">
<Form.Label data-testid="label">Password</Form.Label>
<Form.Control
type="password"
ref={passwordRef}
placeholder="Leave blank to keep the same"
placeholder="Enter you password"
data-testid="input"
/>
</Form.Group>
<Form.Group id="password-confirm">
<Form.Label>Password Confirmation</Form.Label>
<Form.Group id="password-confirm" data-testid="confirm-password">
<Form.Label data-testid="label" >Password Confirmation</Form.Label>
<Form.Control
type="password"
ref={passwordConfirmRef}
placeholder="Leave blank to keep the same"
placeholder="Re-enter your password"
data-testid="input"
/>
</Form.Group>
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }} >
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }} data-testid="update-btn">
Update
</Button>
</Form>
</Card.Body>
</Card>
<div className="w-100 text-center mt-2">
<div className="w-100 text-center mt-2" data-testid="cancel">
<Link to="/" style={{ color: "#0080c8" }} > Cancel</Link>
</div>
</div ></Container >
Expand Down

0 comments on commit 554b79d

Please sign in to comment.