Clear Career - Условиеuyu
Clear Career - Условиеuyu
Clear Career - Условиеuyu
You are assigned to implement a Web application (SPA) using JavaScript. The application should dynamically display
content, based on user interaction and support user-profiles and CRUD operations, using a REST service.
1. Overview
Implement a front-end app (SPA) for creating and managing offers. The application allows visitors to browse
through the offers catalog. Users may register with an email and password which allows them to create their own
offer. Offer authors can also edit or delete their own publications at any time.
2. Technical Details
You are provided with the following resources:
Project scaffold: A package.json file, containing a list of common dependencies. You may change the
included libraries to your preference. The sections devDependencies and scripts of the file are used by the
automated testing suite, altering them may result in incorrect test operation.
To initialize the project, execute the command npm install via the command-line terminal.
HTML and CSS files: All views (pages) of the application, including sample user-generated content, are
included in the file index.html, which links to CSS and other static files. Each view is in a separate section of
the file, which can be identified by a unique class name or id attribute. Your application may use any
preferred method (such as a templating library or manual visibility settings) to display only the selected
view and to navigate between views upon user interaction.
Local REST service: A special server, which contains sample data and supports user registration and CRUD
operations via REST requests is included with the project. Each section of this document (where applicable)
includes details about the necessary REST endpoints, to which requests must be sent, and the shape of the
expected request body.
For more information on how to use the included server, see Appendix A: Using the Local REST Service at
the end of this document.
Automated tests: A complete test suite is included, which can be used to test the correctness of your
solution. Your work will be assessed, based on these tests.
For more information on how to run the tests, see Appendix B: Running the Test Suite at the end of this
document.
Do not use CDN for loading the dependencies because it can affect the tests in a negative way!
Note: When creating HTML Elements and displaying them on the page, adhere as close as possible to the provided
HTML samples. Changing the structure of the document may prevent the tests from running correctly, which will
adversely affect your assessment grade. You may add attributes (such as class and dataset) to any HTML Element,
as well as change "href" attributes on links and add/change the method and action attributes of HTML Forms, to
facilitate the correct operation of a routing library or another method of abstraction. You may also add hidden
elements to help you implement certain parts of the application requirements.
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Navigation links should correctly change the current page (view). All users can see the site logo that should be a link
to the Home page as well as the Dashboard which should link to the Dashboard page. Guests (un-authenticated
visitors) can see the links to the Login and Register pages. The logged-in user navbar should contain the links to the
Create Offer page and a link for the Logout action.
The Login page contains a form for existing user authentication. By providing an email and password the app should
login a user in the system if there are no empty fields.
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Method: POST
URL: /users/login
Required headers are described in the documentation. The service expects a body with the following shape:
{
email,
password
}
Upon success, the REST service will return the newly created object with an automatically generated _id and a
property accessToken, which contains the session token for the user – you need to store this information using
sessionStorage or localStorage, in order to be able to perform authenticated requests.
If the login was successful, redirect the user to the Dashboard page. If there is an error, or the validations don’t
pass, display an appropriate error message, using a system dialog (window.alert).
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Method: POST
URL: /users/register
Required headers are described in the documentation. The service expects a body with the following shape:
{
email,
password
}
Upon success, the REST service will return the newly created object with an automatically generated _id and a
property accessToken, which contains the session token for the user – you need to store this information using
sessionStorage or localStorage, in order to be able to perform authenticated requests.
If the registration was successful, redirect the user to the Dashboard page. If there is an error, or the validations
don’t pass, display an appropriate error message, using a system dialog (window.alert).
Logout (5 pts)
The logout action is available to logged-in users. Send the following request to perform logout:
Method: GET
URL: /users/logout
Required headers are described in the documentation. Upon success, the REST service will return an empty
response. Clear any session information you’ve stored in browser storage.
If the logout was successful, redirect the user to the Dashboard page.
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Method: GET
URL: /data/offers?sortBy=_createdOn%20desc
Required headers are described in the documentation. Keep in mind that the server and tests returns the salary as a
string. The service will return an array of offers.
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Method: POST
URL: /data/offers
Required headers are described in the documentation. The service expects a body with the following shape:
{
title,
imageUrl,
category,
description,
requirements,
salary
}
Required headers are described in the documentation. The service will return the newly created record. Upon
success, redirect the user to the Dashboard page.
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Method: GET
URL: /data/offers/:id
Where :id is the id of the desired card. Required headers are described in the documentation. The service will return
a single object.
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Method: PUT
URL: /data/offers/:id
Where :id is the id of the desired card.
{
title,
imageUrl,
category,
description,
requirements,
salary
}
Required headers are described in the documentation. The service will return the modified record. Note that PUT
requests do not merge properties and will instead replace the entire record. Upon success, redirect the user to the
Details page for the current offer.
Method: DELETE
URL: /data/offers/:id
Where :id is the id of the desired offer. Required headers are described in the documentation. The service will
return an object, containing the deletion time. Upon success, redirect the user to the Dashboard page.
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
The view when the user did not press [Apply] button should look like:
When the
user Applied for the offer the [Apply] button should not be available and the counter should be increased by 1.
Creator should not be able to see the [Apply] button. The view should look like:
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Method: POST
URL: /data/applications
The service expects a body with the following shape:
{
offerId
}
Required headers are described in the documentation. The service will return the newly created record.
Send the following request to get total applications count for a offers:
Method: GET
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Where {offerId} is the id of the desired offer. Required headers are described in the documentation. The service
will return the total applications count.
Send the following request to get the number of the applications for an offer for specific user:
Method: GET
URL:/data/applications?where=offerId%3D%22{offerId}%22%20and%20_ownerId%3D%22{userId}
%22&count
Where {offerId} is the id of the desired offer and {userId} is the id of the currently logged-in user.
Required headers are described in the documentation. The service will return either 0 or 1. Depends on that result
the [Apply] button should be displayed or not.
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
node server.js
If everything initialized correctly, you should see a message about the host address and port on which the service
will respond to requests.
Sending Requests
To send a request, use the hostname and port, shown in the initialization log and resource address and method as
described in the application requirements. If data needs to be included in the request, it must be JSON-encoded,
and the appropriate Content-Type header must be added. Similarly, if the service is to return data, it will be JSON-
encoded. Note that some requests do not return a body and attempting to parse them will throw an exception.
Read requests, as well as login and register requests do not require authentication. All other requests must be
authenticated.
Required Headers
To send data to the server, include a Content-Type header and encode the body as a JSON-string:
Content-Type: application/json
{JSON-encoded request body as described in the application requirements}
To perform an authenticated request, include an X-Authorization header, set to the value of the session token,
returned by an earlier login or register request:
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
HTTP/1.1 200 OK
Access-Contrl-Allow-Origin: *
Content-Type: application/json
{JSON-encoded response data}
Empty response:
More Information
You can find more details on the GitHub repository of the service.
npm install
Note that if you changed the section devDependencies of the project, the tests may not initialize properly.
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
To execute the tests, open a new terminal (do not close the terminal, running the web server instance) in the folder
containing package.json and execute:
Test results will be displayed in the terminal, along with detailed information about encountered problems. You can
perform this operation as many times as it is necessary by re-running the above command.
This first step will not be necessary if you are using the included web server. Make sure the application host is set
correctly:
The value for host must be the address where your application is being served. Make sure that entering this
address in a regular internet browser shows your application.
To make just a single test run, instead of the full suite (useful when debugging a single failing test), find the test and
append .only after the it reference:
On slower machines, some of the tests may require more time to complete. You can instruct the tests to run more
slowly by slightly increasing the values for interval and timeout:
Note that interval values greater than 500 and timeout values greater than 10000 are not recommended.
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
If the actions are happening too fast, you can increase the value of slowMo. If the browser hangs, you can just close
it and abort any remaining tests by focusing the terminal window and pressing [Ctrl+C] followed by the letter "y"
and [Enter].
The final thing to look for is the exact row where the test fails:
© SoftUni – about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.