-
Notifications
You must be signed in to change notification settings - Fork 1
Exercise 7 #13
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
base: main
Are you sure you want to change the base?
Exercise 7 #13
Conversation
RespectableRuessel
left a comment
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.
⭐For instructions in the README.md on how to build your webapp for production.
(I think it's still the default README but it worked for us)
⭐ For no changes in "Files Changed" tab of the refactoring from vue-cli to create-nuxt-app. (See #1 in instructions)
⭐ ⭐ For the API connection between your front- and backend.
⭐ For an upvote button that behaves according to the authentication state of your user
⭐ For a delete and edit button that is only visible to the author of the post.
🔴 We didn't find software tests for the login / logout.
Looks good so far!
| state.token = token; | ||
| if (token) { | ||
| let { userId } = jwt_decode(token); | ||
| state.currentUser = userId; | ||
| } else { | ||
| state.currentUser = null; | ||
| } |
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.
Maybe consider to only set the token if it is valid. Otherwise (if the token contains garbage) your state will be broken because your loggedIn method checks !!state.token. So it will show True even if the token is invalid.
| it("renders a message when the item list is empty", async () => { | ||
| createComponent({ | ||
| allPostsQueryHandler: jest.fn().mockResolvedValue({ data: { posts: [] } }), | ||
| }); | ||
| await wrapper.vm.$nextTick(); | ||
|
|
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.
⭐ Refactor looks good. We also used wrapper.vm.$nextTick() which is considered ugly but at least it works.
| <button v-if="loggedIn" @click="upvote">Upvote</button> | ||
| <button v-if="loggedIn" @click="downvote">Downvote</button> | ||
| <button v-if="isAuthor" @click="remove">Remove</button> | ||
| <button v-if="isAuthor" @click="edit">Edit</button> |
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.
⭐Implemented Upvote and Downvote in logged in state, Remove and Edit only if it's the author. Optional: Only show the upvote or downvote button if you didn't upvoted / downvoted before.
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.
➕ 1️⃣
jobegrabber
left a comment
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.
And
⭐ For no changes in "Files Changed" tab of the refactoring from vue-cli to create-nuxt-app. (See #1 in instructions)
⭐ ⭐ For the API connection between your front- and backend.
| ### build for production and launch server | ||
|
|
||
| ``` | ||
| npm run build | ||
| npm run start | ||
| ``` |
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.
Nice!
⭐ For instructions in the README.md on how to build your webapp for production.
| @@ -0,0 +1,75 @@ | |||
| import { createLocalVue, shallowMount } from "@vue/test-utils"; | |||
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.
Good job!
⭐ ⭐ For a login feature in your webapp including a Vue component and its software tests.
| @@ -0,0 +1,86 @@ | |||
| import { createLocalVue, shallowMount, RouterLinkStub } from "@vue/test-utils"; | |||
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.
Looks great,
⭐ ⭐ For a menu component which shows a login or logout button and its software tests.
| it("calls logout when logout button is clicked", () => { | ||
| const logoutBtn = wrapper.find("#logoutBtn"); | ||
| logoutBtn.trigger("click"); | ||
| expect(logout.mock.calls.length).toBe(1); |
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.
| expect(logout.mock.calls.length).toBe(1); | |
| expect(logout).toBeCalledTimes(1); |
is the idiomatic way I think
| <button v-if="loggedIn" @click="upvote">Upvote</button> | ||
| <button v-if="loggedIn" @click="downvote">Downvote</button> | ||
| <button v-if="isAuthor" @click="remove">Remove</button> | ||
| <button v-if="isAuthor" @click="edit">Edit</button> |
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.
➕ 1️⃣
| <button @click="upvote">Upvote</button> | ||
| <button @click="downvote">Downvote</button> | ||
| <button @click="remove">Remove</button> | ||
| <button v-if="loggedIn" @click="upvote">Upvote</button> |
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.
⭐ For an upvote button that behaves according to the authentication state of your user
|
Hi @Systems-Development-and-Frameworks/lichtow ! I got issues with building your app. It looks like at least one Same is happening with Could you help me out here? Do you have the It looks good so far. Not sure why the file is missing. Youri |
|
You're absolutely right, the file was missing. It was deleted accidentally in the last commit 😅 |
|
The import was also messed up. Not sure why we didn't realize this before. So sorry! |
roschaefer
left a comment
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.
Yay, you received all ⭐ in this exercise, 13 out of 13. Excellent work.
⭐ For instructions in the README.md on how to build your webapp for production.
⭐ For no changes in "Files Changed" tab of the refactoring from vue-cli to create-nuxt-app. (See #1 in instructions)
⭐ ⭐ For the API connection between your front- and backend.
⭐ For your previous frontend tests still passing. Requests to the backend are mocked.
⭐ ⭐ For a login feature in your webapp including a Vue component and its software tests.
⭐ ⭐ For a menu component which shows a login or logout button and its software tests.
⭐ For an upvote button that behaves according to the authentication state of your user
⭐ For a delete button that is only visible to the author of the post.
⭐ For Lighthouse reporting that your production website is installable as PWA (except HTTPS).
⭐ For requesting a review and reviewing another team's PR.
See a few suggestions below
| expect(submitBtn.exists()).toBe(true); | ||
| }); | ||
|
|
||
| describe("invalid credentials", () => { |
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.
valid credentials would be nice.
| @@ -0,0 +1,64 @@ | |||
| <template> | |||
| <div> | |||
| <form onsubmit="event.preventDefault();"> | |||
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.
| <form onsubmit="event.preventDefault();"> | |
| <form @submit.prevent="submit"> |
| type="submit" | ||
| aria-label="Login" | ||
| value="Login" | ||
| @click="submit" |
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.
If you have the submit on the <form> you can omit that. With the form submit, you could also submit by hitting enter.
| } | ||
| }, | ||
| }, | ||
| data: function () { |
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.
| data: function () { | |
| data() { |
| export default { | ||
| methods: { | ||
| ...mapActions(["login"]), | ||
| submit: async function () { |
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.
| submit: async function () { | |
| async submit() { |
| @@ -0,0 +1,8 @@ | |||
| fragment Post on Post { | |||
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.
Very nice, you discovered fragments.
| authenticationType: "Bearer", | ||
|
|
||
| // Token name for the cookie which will be set in case of authentication | ||
| tokenName: "apollo-token", |
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.
It's the default, no?
| tokenName: "apollo-token", |
| }, | ||
| }, | ||
| // Sets the authentication type for any authorized request. | ||
| authenticationType: "Bearer", |
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.
| authenticationType: "Bearer", |
Default?
| <style> | ||
| </style> No newline at end of file |
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.
| <style> | |
| </style> |
| <div> | ||
| <template v-if="loggedIn"> | ||
| <button id="logoutBtn" @click="logout">Logout</button> | ||
| </template> | ||
| <template v-else> | ||
| <NuxtLink to="/login">Login</NuxtLink> | ||
| </template> | ||
| </div> |
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.
| <div> | |
| <template v-if="loggedIn"> | |
| <button id="logoutBtn" @click="logout">Logout</button> | |
| </template> | |
| <template v-else> | |
| <NuxtLink to="/login">Login</NuxtLink> | |
| </template> | |
| </div> | |
| <div> | |
| <button v-if="loggedIn" id="logoutBtn" @click="logout">Logout</button> | |
| <NuxtLink v-else to="/login">Login</NuxtLink> | |
| </div> |
You could even remove the <div> if you want. An if-clause with an else is allowed as root node.
| background: "#ffffff", | ||
| theme_color: "#90EE90", | ||
| }, | ||
| }, |
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.


Review: Systems-Development-and-Frameworks/dojo#9 (review)