Skip to content

Commit 554b79d

Browse files
committed
add locators
1 parent 92e8068 commit 554b79d

9 files changed

Lines changed: 75 additions & 65 deletions

File tree

src/components/Checkbox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export const Checkbox = ({ id, taskDesc }) => {
66
const archiveTask = () => {
77
updateTaskData(id, {
88
archived: true,
9-
}).then(docRef => {
10-
console.log("Task updated successfully , task id:", docRef.id)
9+
}).then(() => {
10+
console.log("Task updated successfully , task id:", id)
1111
}).catch(e => console.log("Failed to update the task", e));
1212
};
1313

src/components/IndividualProject.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const IndividualProject = ({ project }) => {
4949
<button
5050
type="button"
5151
onClick={() => deleteProject(project.docId)}
52+
data-testid="delete"
5253
>
5354
Delete
5455
</button>
@@ -60,6 +61,7 @@ export const IndividualProject = ({ project }) => {
6061
tabIndex={0}
6162
role="button"
6263
aria-label="Cancel adding project, do not delete"
64+
data-testid="cancel"
6365
>
6466
Cancel
6567
</span>

src/helpers/firestore-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const addTaskOnFB = async (payload) => {
2525
}
2626

2727
export const updateTaskData = async (id, newData) => {
28-
return await updateDoc(collection(db, "tasks", id), newData)
28+
return await updateDoc(doc(db, "tasks", id), newData)
2929
}
3030

3131
export const deleteProjectFromFB = async (id) => {

src/pages/Dashboard.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,27 @@ export default function Dashboard() {
2828
>
2929
<div className="w-100" style={{ maxWidth: '400px' }}>
3030
<Card>
31-
<Card.Body>
32-
<h2 className="text-center mb-4">Profile</h2>
33-
{error && <Alert variant="danger">{error}</Alert>}
34-
<strong>Email:</strong> {currentUser.email}
35-
<Link to={ROUTES.HOME} className="btn btn-primary w-100 mt-3">
31+
<Card.Body data-testid="profile">
32+
<h2 className="text-center mb-4" data-testid="title">Profile</h2>
33+
{error && <Alert data-testid="error-message" variant="danger">{error}</Alert>}
34+
<strong data-testid="username">Email:</strong> {currentUser.email}
35+
<Link
36+
to={ROUTES.HOME}
37+
className="btn btn-primary w-100 mt-3"
38+
data-testid="go-home"
39+
>
3640
Go Home
3741
</Link>
3842
<Link
3943
to={ROUTES.UPDATE_PROFILE}
4044
className="btn btn-primary w-100 mt-3"
45+
data-testid="update-profile"
4146
>
4247
Update Profile
4348
</Link>
4449
</Card.Body>
4550
</Card>
46-
<div className="w-100 text-center mt-2">
51+
<div className="w-100 text-center mt-2" data-testid="logout">
4752
<Button variant="link" onClick={handleLogout}>
4853
Log Out
4954
</Button>

src/pages/ForgotPassword.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,25 @@ export default function ForgotPassword() {
3333
style={{ minHeight: "100vh" }}>
3434
<div className="w-100" style={{ maxWidth: "400px" }}>
3535
<Card>
36-
<Card.Body>
37-
<h2 className="text-center mb-4">Password Reset</h2>
38-
{error && <Alert variant="danger">{error}</Alert>}
39-
{message && <Alert variant="success">{message}</Alert>}
40-
<Form onSubmit={handleSubmit}>
41-
<Form.Group id="email">
42-
<Form.Label>Email</Form.Label>
43-
<Form.Control type="email" ref={emailRef} required />
36+
<Card.Body data-testid="forgot-password">
37+
<h2 className="text-center mb-4" data-testid="title">Password Reset</h2>
38+
{error && <Alert variant="danger" data-testid="error-message">{error}</Alert>}
39+
{message && <Alert variant="success" data-testid="success-message">{message}</Alert>}
40+
<Form onSubmit={handleSubmit} data-testid="forgot-password-form">
41+
<Form.Group id="email" data-testid="email">
42+
<Form.Label data-testid="label">Email</Form.Label>
43+
<Form.Control data-testid="input" type="email" ref={emailRef} required />
4444
</Form.Group>
45-
<Button disabled={loading} className="w-100" type="submit">
45+
<Button disabled={loading} className="w-100" type="submit" data-testid="reset-password-btn">
4646
Reset Password
4747
</Button>
4848
</Form>
49-
<div className="w-100 text-center mt-3">
49+
<div className="w-100 text-center mt-3" data-testid="login">
5050
<Link to="/login">Login</Link>
5151
</div>
5252
</Card.Body>
5353
</Card>
54-
<div className="w-100 text-center mt-2">
54+
<div className="w-100 text-center mt-2" data-testid="signup">
5555
Need an account? <Link to={ROUTES.SIGN_UP}>Sign Up</Link>
5656
</div>
5757
</div></Container>

src/pages/Login.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,28 @@ export default function Login() {
3535
style={{ minHeight: "100vh" }}>
3636
<div className="w-100" style={{ maxWidth: "400px" }}>
3737
<Card>
38-
<Card.Body>
39-
<h2 className="text-center mb-4">Log In</h2>
40-
{error && <Alert variant="danger">{error}</Alert>}
41-
<Form onSubmit={handleSubmit}>
42-
<Form.Group id="email">
43-
<Form.Label>Email</Form.Label>
44-
<Form.Control type="email" ref={emailRef} required />
38+
<Card.Body data-testid="login-card">
39+
<h2 className="text-center mb-4" data-testid="title">Log In</h2>
40+
{error && <Alert data-testid="error-message" variant="danger">{error}</Alert>}
41+
<Form onSubmit={handleSubmit} data-testid="login-form">
42+
<Form.Group id="email" data-testid="email">
43+
<Form.Label data-testid="label">Email</Form.Label>
44+
<Form.Control type="email" ref={emailRef} required data-testid="input" />
4545
</Form.Group>
46-
<Form.Group id="password">
47-
<Form.Label>Password</Form.Label>
48-
<Form.Control type="password" ref={passwordRef} required />
46+
<Form.Group id="password" data-testid="password">
47+
<Form.Label data-testid="label">Password</Form.Label>
48+
<Form.Control type="password" ref={passwordRef} required data-testid="input" />
4949
</Form.Group>
50-
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }} >
50+
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }} data-testid="loginbtn">
5151
Log In
5252
</Button>
5353
</Form>
54-
<div className="w-100 text-center mt-3">
54+
<div className="w-100 text-center mt-3" data-testid="forgot-password">
5555
<Link to={ROUTES.FORGOT_PASSWORD} style={{ color: "#0080c8" }}>Forgot Password?</Link>
5656
</div>
5757
</Card.Body>
5858
</Card>
59-
<div className="w-100 text-center mt-2">
59+
<div className="w-100 text-center mt-2" data-testid="signup" >
6060
Need an account? <Link to={ROUTES.SIGN_UP} style={{ color: "#0080c8" }}>Sign Up</Link>
6161
</div>
6262
</div></Container >

src/pages/NotFound.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export default function NotFound() {
1313
style={{ minHeight: "100vh" }}>
1414
<div className="w-100" style={{ maxWidth: "400px" }}>
1515
<Card>
16-
<Card.Body>
17-
<h2 className="text-center mb-4"> Page Not Found</h2>
18-
<Link to={ROUTES.HOME} className="btn btn-primary w-100 mt-3">
16+
<Card.Body data-testid="not-found-page">
17+
<h2 className="text-center mb-4" data-testid="title"> Page Not Found</h2>
18+
<Link to={ROUTES.HOME} className="btn btn-primary w-100 mt-3" data-testid="go-back">
1919
Go Back To Home
2020
</Link>
2121
</Card.Body>

src/pages/Signup.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,29 @@ export default function Signup() {
4242
style={{ minHeight: "100vh" }}>
4343
<div className="w-100" style={{ maxWidth: "400px" }}>
4444
<Card>
45-
<Card.Body>
46-
<h2 className="text-center mb-4">Sign Up</h2>
47-
{error && <Alert variant="danger">{error}</Alert>}
48-
<Form onSubmit={handleSubmit}>
49-
<Form.Group id="email">
50-
<Form.Label>Email</Form.Label>
51-
<Form.Control type="email" placeholder="member@utasks.com" ref={emailRef} required />
45+
<Card.Body data-testid="signup-card">
46+
<h2 className="text-center mb-4" data-testid="title">Sign Up</h2>
47+
{error && <Alert variant="danger" data-testid="error-message">{error}</Alert>}
48+
<Form onSubmit={handleSubmit} data-testid="signup-form">
49+
<Form.Group id="email" data-testid="email">
50+
<Form.Label data-testid="label">Email</Form.Label>
51+
<Form.Control type="email" placeholder="member@utasks.com" ref={emailRef} required data-testid="input" />
5252
</Form.Group>
53-
<Form.Group id="password">
54-
<Form.Label>Password</Form.Label>
55-
<Form.Control type="password" ref={passwordRef} required />
53+
<Form.Group id="password" data-testid="password">
54+
<Form.Label data-testid="label">Password</Form.Label>
55+
<Form.Control type="password" ref={passwordRef} required data-testid="input" />
5656
</Form.Group>
57-
<Form.Group id="password-confirm">
58-
<Form.Label>Password Confirmation</Form.Label>
59-
<Form.Control type="password" ref={passwordConfirmRef} required />
57+
<Form.Group id="password-confirm" data-testid="confirm-password">
58+
<Form.Label data-testid="label">Password Confirmation</Form.Label>
59+
<Form.Control type="password" ref={passwordConfirmRef} required data-testid="input" />
6060
</Form.Group>
61-
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }}>
61+
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }} data-testid="signup-btn">
6262
Sign Up
6363
</Button>
6464
</Form>
6565
</Card.Body>
6666
</Card>
67-
<div className="w-100 text-center mt-2">
67+
<div className="w-100 text-center mt-2" data-testid="login">
6868
Already have an account? <Link to="/login" style={{ color: "#0080c8" }}>Log In</Link>
6969
</div>
7070
</div>

src/pages/UpdateProfile.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,42 +49,45 @@ export default function UpdateProfile() {
4949
style={{ minHeight: "100vh" }}>
5050
<div className="w-100" style={{ maxWidth: "400px" }}>
5151
<Card>
52-
<Card.Body>
53-
<h2 className="text-center mb-4">Update Profile</h2>
54-
{error && <Alert variant="danger">{error}</Alert>}
55-
<Form onSubmit={handleSubmit}>
56-
<Form.Group id="email">
57-
<Form.Label>Email</Form.Label>
52+
<Card.Body data-testid="update-card">
53+
<h2 className="text-center mb-4" data-testid="title">Update Profile</h2>
54+
{error && <Alert variant="danger" data-testid="error-message">{error}</Alert>}
55+
<Form onSubmit={handleSubmit} data-testid="ypdate-form">
56+
<Form.Group id="email" data-testid="email">
57+
<Form.Label data-testid="label">Email</Form.Label>
5858
<Form.Control
5959
type="email"
6060
ref={emailRef}
6161
required
6262
defaultValue={currentUser.email}
63+
data-testid="input"
6364
/>
6465
</Form.Group>
65-
<Form.Group id="password">
66-
<Form.Label>Password</Form.Label>
66+
<Form.Group id="password" data-testid="password">
67+
<Form.Label data-testid="label">Password</Form.Label>
6768
<Form.Control
6869
type="password"
6970
ref={passwordRef}
70-
placeholder="Leave blank to keep the same"
71+
placeholder="Enter you password"
72+
data-testid="input"
7173
/>
7274
</Form.Group>
73-
<Form.Group id="password-confirm">
74-
<Form.Label>Password Confirmation</Form.Label>
75+
<Form.Group id="password-confirm" data-testid="confirm-password">
76+
<Form.Label data-testid="label" >Password Confirmation</Form.Label>
7577
<Form.Control
7678
type="password"
7779
ref={passwordConfirmRef}
78-
placeholder="Leave blank to keep the same"
80+
placeholder="Re-enter your password"
81+
data-testid="input"
7982
/>
8083
</Form.Group>
81-
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }} >
84+
<Button disabled={loading} className="w-100" type="submit" style={{ background: "#0080c8", borderColor: "#0080c8" }} data-testid="update-btn">
8285
Update
8386
</Button>
8487
</Form>
8588
</Card.Body>
8689
</Card>
87-
<div className="w-100 text-center mt-2">
90+
<div className="w-100 text-center mt-2" data-testid="cancel">
8891
<Link to="/" style={{ color: "#0080c8" }} > Cancel</Link>
8992
</div>
9093
</div ></Container >

0 commit comments

Comments
 (0)