-
Notifications
You must be signed in to change notification settings - Fork 521
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
Create README.md #242
base: master
Are you sure you want to change the base?
Create README.md #242
Conversation
Uplevel your code reviews with CodeRabbit ProCodeRabbit ProIf you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. |
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.
Files selected (2)
- .eslintrc.json (1)
- .gitignore (1)
Files ignored due to filter (2)
- package-lock.json
- package.json
Review comments generated (2)
- Review: 2
- LGTM: 0
Tips
Chat with CodeRabbit Bot (@coderabbitai
)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitai
in a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignore
anywhere in the PR description to pause further reviews from the bot.
.gitignore
Outdated
/node_modules | ||
/dist No newline at end of file | ||
/dist | ||
.eslintcache |
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.
Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [3-4]
It's a good practice to always end your files with a newline. This is because some tools, especially those that are used in Unix environments, might not properly recognize or handle the last line if it doesn't end with a newline.
/node_modules | |
/dist | |
\ No newline at end of file | |
/dist | |
.eslintcache | |
/node_modules | |
/dist | |
.eslintcache |
.eslintrc.json
Outdated
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
} | ||
} |
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.
The ESLint configuration seems fine for a basic setup. However, it would be beneficial to add some specific rules that enforce code quality and consistency. Here's an example of how you might want to configure your rules:
"rules": {
+ "indent": ["error", 2],
+ "linebreak-style": ["error", "unix"],
+ "quotes": ["error", "single"],
+ "semi": ["error", "always"],
+ "no-console": "warn"
}
These rules enforce 2-space indentation, Unix line breaks, single quotes, semicolons at the end of lines, and warn when console
functions are used.
Remember, these are just examples and you should adjust the rules according to your project's style guide.
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.
Files selected (2)
- .husky/pre-commit (1)
- 6 (1)
Files ignored due to filter (2)
- package-lock.json
- package.json
Files skipped from review due to trivial changes (1)
- .husky/pre-commit
Review comments generated (4)
- Review: 3
- LGTM: 1
Tips
Chat with CodeRabbit Bot (@coderabbitai
)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitai
in a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignore
anywhere in the PR description to pause further reviews from the bot.
6
Outdated
|
||
56 packages are looking for funding | ||
run `npm fund` for details |
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.
6
Outdated
|
||
3 high severity vulnerabilities | ||
|
||
To address all issues, run: | ||
npm audit fix |
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.
The message "3 high severity vulnerabilities" is concerning. It's crucial to address these vulnerabilities as soon as possible to maintain the security of your application. Running npm audit fix
as suggested should automatically fix these issues in most cases. However, some fixes may introduce breaking changes, so it's important to thoroughly test your application after running this command.
6
Outdated
|
||
Run `npm audit` for details. |
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.
Added testing with jest and cypress.
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.
Files selected (7)
- .eslintrc.json (1)
- .gitignore (1)
- cypress/e2e/Frontpage.cy.js (1)
- cypress/support/commands.js (1)
- cypress/support/e2e.js (1)
- index.html (1)
- src/js/api/auth/login.test.js (1)
Files ignored due to filter (4)
- babel.config.json
- cypress/fixtures/example.json
- package-lock.json
- package.json
Files not summarized due to errors (1)
- index.html (diff tokens exceeds limit)
Files skipped from review due to trivial changes (5)
- .eslintrc.json
- .gitignore
- cypress/support/commands.js
- cypress/support/e2e.js
- index.html (diff too large)
Review comments generated (9)
- Review: 5
- LGTM: 4
Tips
Chat with CodeRabbit Bot (@coderabbitai
)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitai
in a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignore
anywhere in the PR description to pause further reviews from the bot.
it("allows the user to log in and access their profile", () => { | ||
cy.wait(1000); | ||
cy.get("#loginButton").click(); | ||
cy.wait(1000); | ||
|
||
cy.get("#loginEmail").type("sandersan@stud.noroff.no"); | ||
cy.get("#loginPassword").type("Sander124"); | ||
cy.get("#loginForm").submit(); | ||
|
||
cy.url().should("include", "/?view=profile"); |
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.
The test case for successful login seems to be hardcoding the user credentials. This could lead to maintenance issues if the credentials change in the future. Consider using environment variables or a configuration file to store these values.
- cy.get("#loginEmail").type("sandersan@stud.noroff.no");
- cy.get("#loginPassword").type("Sander124");
+ cy.get("#loginEmail").type(Cypress.env('username'));
+ cy.get("#loginPassword").type(Cypress.env('password'));
it("allows the user to log out with the logout button", () => { | ||
cy.get("#loginButton").click(); | ||
cy.wait(1000); | ||
cy.get("#loginEmail").type("sandersan@stud.noroff.no"); | ||
cy.get("#loginPassword").type("Sander124"); | ||
cy.get("#loginForm").submit(); | ||
|
||
cy.get('[data-auth="logout"]').click(); | ||
}); |
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.
Similar to the previous comment, consider using environment variables or a configuration file to store user credentials.
- cy.get("#loginEmail").type("sandersan@stud.noroff.no");
- cy.get("#loginPassword").type("Sander124");
+ cy.get("#loginEmail").type(Cypress.env('username'));
+ cy.get("#loginPassword").type(Cypress.env('password'));
import { login } from "./login"; | ||
import * as storage from "../../storage/index.js"; | ||
import "jest-localstorage-mock"; | ||
|
||
jest.mock("../../storage/index.js", () => ({ | ||
save: jest.fn(), | ||
load: jest.fn(), | ||
})); |
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("should fetch and store a token in browser storage", async () => { | ||
const mockEmail = "test@example.com"; | ||
const mockPassword = "password"; | ||
const mockAccessToken = "mockToken"; | ||
|
||
global.fetch = jest.fn().mockResolvedValue({ | ||
ok: true, | ||
json: jest.fn().mockResolvedValue({ token: mockAccessToken }), | ||
}); |
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.
The mocking of the fetch
function is done correctly. However, it's better to use jest.spyOn
instead of directly assigning global.fetch
. This way, you can easily restore the original function after the test using mockRestore
.
- global.fetch = jest.fn().mockResolvedValue({
+ const fetchMock = jest.spyOn(global, 'fetch').mockResolvedValue({
ok: true,
json: jest.fn().mockResolvedValue({ token: mockAccessToken }),
});
And then in afterEach
:
+ afterEach(() => {
+ fetchMock.mockRestore();
+ jest.restoreAllMocks();
+ });
|
||
await login(mockEmail, mockPassword); | ||
|
||
expect(fetch).toHaveBeenCalledWith( | ||
"https://nf-api.onrender.com/api/v1/social/auth/login", | ||
{ | ||
method: "post", | ||
body: JSON.stringify({ email: mockEmail, password: mockPassword }), | ||
headers: expect.any(Object), | ||
}, | ||
); | ||
|
||
expect(storage.save).toHaveBeenCalledWith( | ||
"profile", | ||
expect.objectContaining({ token: mockAccessToken }), | ||
); | ||
}); |
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.
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.
Files selected (1)
- README.md (1)
Files not summarized due to errors (1)
- README.md (nothing obtained from openai)
Files not reviewed due to errors (1)
- README.md (no response)
Review comments generated (0)
- Review: 0
- LGTM: 0
Tips
Chat with CodeRabbit Bot (@coderabbitai
)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitai
in a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignore
anywhere in the PR description to pause further reviews from the bot.
Fixed incorrect versioning.
Summary by CodeRabbit
Release Notes
.gitignore
to ignore.eslintcache
.login
function inauth
API.