- Overview
- Exploring the client
- Workflow and Continuous Integration
- The coding part of this lab
- Questions
Questions that you need to answer (as a team!) are indicated with question mark symbols (:question:). Write up your answers to these questions in a Google Doc and turn that in via Canvas on the assignment for this lab. Make sure that everyone in your group has edit privileges on the document. Make sure that the link you turn in gives the TA(s) and professor(s) at least comment privileges.
- 1. Start by exploring the newly introduced
clientfolder and its contents - 2. Familiarize yourself with the expectations about your workflow and process
- 3. Set up your project on GitHub Projects with your stories and estimates
- 4. Work through the coding part of the lab
- 5. Turn in the URL of your Google Doc with answers to the questions when your team has completed the lab and you are ready for us to grade it.
Definitely ask if you're ever confused about what you need to do for a given task.
This lab introduces the client side of our project. The client-side interface uses Angular to handle most of the creation of the elements of the user interface. Angular's template syntax extends HTML and JavaScript. The testing is handled in two new places:
- Angular spec files (e.g.,
user-list.component.spec.ts) for unit testing in Angular. These use Jasmine and Karma. This is also sometimes called component testing. - E2E (end-to-end) tests in
client/e2e. These use Cypress.
The starting code includes several
ways of using Angular components to display user data.
It includes two ways of organizing the user-list information:
a grid-like arrangement of cards and a list.
The grid approach to organizing the user-list information
leverages a user-card component.
The user-card component is also used (in a slightly different way) in the user-profile component.
Karma tests for each component are named
almost the same as the component but include .cy before the .ts,
and Cypress E2E tests for user-list
are located in client/cypress/e2e. There are supporting files for the E2E tests (called
page objects) in client/cypress/support. The page objects are named similarly to the Cypress E2E tests, but also have .po before the .ts. The purpose of the page objects files is to help separate aspects of accessing elements on a page (like exactly what kind of component you are using) separate from the tests. That way, when you decide to use a simple button with a custom button (for example), your test will still just find the button. Specific information goes in the page object.
❓ Answer questions 1 through 4 in QUESTIONS below.
You should organize your work into features, where each feature is a (small) story in GitHub Projects. Each feature should "slice the cake", including server implementation and testing, Angular implementation and testing, and end-to-end testing.
To maximize your learning, we strongly encourage you to implement features in Angular one at a time instead of copying over entire components from the previous lab that presumably support numerous features.
Make sure you do frequent commits with useful commit messages. If you're pair programming (which we definitely recommend!) make sure include a co-authorship line in the commit message so the person you're working with gets credit. These have the form:
Co-authored-by: Connie Stewart <conniestewart@ohmnet.com>
where you replace the name ("Connie Stewart") and email
(conniestewart@ohmnet.com) with the name and email of the
person you're pairing with.
- As you work, create a branch for each new feature.
- Write tests for the server actions for the feature you added. Run them to make sure they fail. Then write the server code that makes those tests pass.
- Write new end-to-end tests for the new views using Cypress. Run these to make sure they fail.
- Write unit tests for the new Angular components you are adding using Karma. Run them to make sure they also fail. Then write the Angular code that makes those unit and integration/e2e tests pass.
- Address failing builds.
- Perform code reviews, especially if you're not pair programming. Ask (your partner, the class, the instructor) about things you don't understand!
- Use pull requests to
merge things into
mainwhen a feature is working and is tested (with passing tests and decent coverage). - Move the tasks and issues through the GitHub Projects board to help you with your planning.
Now that we have a reliable way to request todo data from our server, we should write a nice client-side application to help us request and view this data.
- Your new functionality should be contained in a 'todos' view,
with a 'todo-list' component and probably a service.
Note: You do NOT need to have multiple views of your todos like we provided you for users, and you should feel free to try out a different kind of component that you think would work well to display todos. Think about what information you would want to actually see about the todo to help you manage your tasks.
- Display the todos in a reasonable way using at least two nifty Angular Material features!
- You should make some decisions about when to request data from the API,
and when to simply use Angular's filtering tools to change how
the data is displayed.
- You have to use Angular's filtering at least once
- You have to use the server's filtering at least once
- You have to be able to use combinations of filters (implement and test this)
- ❓ Make note of why you choose to do each of those two things the way you did
❓ Answer Question 5 about your filtering in QUESTIONS
For Lab 3, teams need to implement the following features. You can implement these in any order you like, but implement them one at a time and test each one as you go.
-
Use Angular to build a nice client-side interface which allows the user to:
- Limit the number of todos returned
- Filter todos by status
- Filter todos by contents of the body
- Add new todos. This requires:
- An Angular form/page that allows the user to enter the information for a new todo with reasonable controls and validation.
- A new endpoint on the server that allows clients to add new todos.
- Logic in the server to add that new todo to the database and return the new ID.
-
For the possibility of full credit, teams should also implement these features:
- Filter todos by owner
- Filter todos by category
- Sort by a todo field (status, owner, body contents, or category)
- Apply combinations of filters
- We have included an example of writing to the database with
addUserfunctionality. Add functionality to both the front-end and back-end to make it possible to add todos so that they appear both in your list and in the database.
You should use Angular to display todos in attractive, readable, and useful ways that are helpful for understanding the nature of a todo.
- Use the Angular Material Design tools you've learned about to build a nice interface for
accessing these APIs:
- You must use at least two nifty Angular Material features!
- There are many interesting tools - we encourage you to try several.
- Feel free to borrow ideas and (preferably small bits of) code from the previous labs, but make sure you understand it. Also feel free to use this as an opportunity to improve the UI, perhaps taking advantages of ideas you had earlier but weren't able to implement then.
Your project should have tests that help you meaningfully practice using continuous integration. You should expand on these tests as appropriate so that your GitHub Actions checks are telling you valuable things about the health of your project.
- As you work, create a branch for a new feature,
move the story from the
icebox(orbacklogornew) toin-progressin GitHub Projects, write unit tests (Karma) for the new Angular components and services you are adding and using, write new end-to-end tests (Cypress) for the new views, and address failing tests. - Use pull requests to review code and
merge things into
mainwhen a feature is working and is tested (with passing tests and decent coverage). Move your story todone.
In general you'll want to write unit tests (using Karma) for small, focused bits of logic, often in an Angular service, but sometimes in a component.
E2E tests, on the other hand, are typically used to capture the desired functional behavior of specific features or stories.
❓ Answer Questions 6 and 7 about your Karma and E2E tests in QUESTIONS
- ❓ How does the navigation menu (with Home and Users) work in this project? Compare
server/src/main/java/umm3601/Server.javaandclient/src/app/app-routing.module.ts. Both do a kind of routing that maps a "path" to something that "handles" that path.- What are the "paths" in each case? (Be specific.)
- Trace through an example of a path being handled by both Angular and Javalin.
- Where does the "path" come from? As a user, how might I enter or trigger a particular path?
- What kinds of things do Angular and Javalin map their paths to? (Be specific.)
- What do those targets "do" with that path?
- ❓ What does the
user.service.tsdo? Why is it not just done in theuser-list.component.ts? - Look over the the test for calling
getUsers()with anageparameters inclient/src/app/users/user.service.spec.ts.- ❓ Where do we tell the service that we want only users with age 25?
- ❓ Where do we tell the mock HTTP system how many requests to expect and what parameters those requests should have?
- ❓ Where do we specify the expected HTTP request type (PUT or GET or DELETE or whatever)?
- ❓ Where do we specify what value the mock HTTP system should return in response to the expected request.
- Look over the E2E test for testing the age filtering in
client/cypress/e2e/user-list.cy.ts.- ❓ What is the
pageobject? Where is that defined? - ❓ Where do we enter the value 27 in the age field?
- ❓ How does Cypress find the age field?
- ❓ How does Cypress update the value in the age field?
- ❓ How does Cypress get all the cards on this page? (Hint: Look at the definition of
getUserCards()inclient/cypress/support/user-list.po.ts.) - How does Cypress extract the user's names from the cards?
- ❓ What is the
- You need to use filtering in Angular and filtering on the server each at least one time. Our example filters users by company on the client side in Angular and filters users by role on the server side in Java. There is not just one right answer here, so think about the why.
- ❓ What is one thing you filtered in Angular and why did that approach make sense for that filter?
- ❓ What is one thing you filtered using the server and why did that approach make sense for that filter?
- ❓ What's one piece of "internal" functionality that you chose to
write a unit test (with Karma) for?
- ❓ Why did you choose to test that piece of functionality?
- ❓ What is the "it" for that test, i.e., what Angular tool/method are you testing?
- ❓ List the behaviors you tested via your E2E tests. For each behavior:
- ❓ Why did you test that particular behavior?
- ❓ What is the "it" for that test, i.e., what part of the web app are you testing? (You don't need to tell us how the test works since your code will do that.)
