Skip to content
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

Refactored theme components and added cypress test. #4843

Closed
wants to merge 8 commits into from

Conversation

Tishasoumya-02
Copy link
Contributor

Refactored Components

Used useSelector,useDispatch,useEffect,useState hooks instead of lifecycle methods and redux functions.

  1. Anontools
  2. Header
  3. Logout
  4. Contact-Form

Cypress Test-

  1. Header-Testing if the logo-img is visible
  2. Footer-Checks if the id-#footer itself is visible
  3. Contact-Form-Clicking on the Contact link in the footer and typing in the parameters
  4. Logout- Log in ,then logging out the application ,then log in again .

@netlify
Copy link

netlify bot commented Jun 4, 2023

Deploy Preview for volto canceled.

Name Link
🔨 Latest commit 0a12754
🔍 Latest deploy log https://app.netlify.com/sites/volto/deploys/647d8109897cec00070e0f96

@sneridagh
Copy link
Member

@Tishasoumya-02

Thanks for the PR!

I realised that you didn't have permissions on the Plone repo, so I added you in the "Contributors" Team. (/cc @fredvd)

This will allow you to work with branches in the Volto repo itself from now on. This is how we normally work, this way it's more handy and agile.

I'd like that for every refactored component you open a PR for it. So one PR, one refactored component. This will help us also to keep track of things.

I've completed this PR (I've mentioned you there too): #4767 I'd like you to proceed like this one for all the project's PRs.

  • Remove all cruft (useless comments, etc)
  • Remove React import (the build does not need that anymore)
  • Use the façade pattern (no Redux hooks in the components), we will create a façade hook trying to maintain the reducers folder naming, and creating a hook for every "useSelect" (data retrieval from the Redux store) using common sense in there, as the usage asks for. (Let's comment this out in our upcoming meeting)
  • We should maintain the resultant HTML. In the case that this is not true, we should have a good reason for it, and issue a breaking change with it.
  • Test the component in the most effective way if some components is enough using unit tests, lets do that. It's important the Cypress test in components that we are refactoring the lifecycle, to make sure we maintain the same behavior. But for components that does not have lifecycle, it's ok to have only unit tests (like the Header one).
  • StoryBook, of all the components refactored, showing the instantiation, and add docs for the props if makes sense and it's useful for other developers.

I'll review now the PR, so you can open a PR for every component in the Volto repo branch with the amendments already.

Thanks a lot!

Copy link
Member

@sneridagh sneridagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tishasoumya-02 I quickly reviewed the PR, please proceed as the previous comment, and then let's discuss further things when we meet.

It might seem a lot of amendments, but we are in the good path, good work so far!

@@ -4,7 +4,6 @@ about: Plone Improvement Proposal
title: ''
labels: ''
assignees: ''

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As rule of thumb, do not touch (an edit is present) a file that has nothing to do with the PR. The changes should contain only changes relevant to the current matter.

@@ -46,4 +46,3 @@ jobs:
# Required, set by GitHub actions automatically:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, probably you have a formatter that you don't need.

@@ -16,7 +16,7 @@ jobs:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
# remove workaround for 18.x once https://github.com/nodejs/node/issues/47563 is fixed
# remove workaround for 18.x once https://github.com/nodejs/node/issues/47563 is fixed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, probably you have a formatter that you don't need that is formatting .yml files.

@@ -48,80 +48,105 @@ const defaultRazzleOptions = {
staticCssInDev: false,
emitOnErrors: false,
disableWebpackbar: false,
browserslist: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie 11', 'not dead']
browserslist: [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the change seems legit, it would go to it's own PR. It seems that this file never was formatted properly, and the CI is not catching it.

@@ -1,4 +1,4 @@
const { defineConfig } = require('cypress');
const { defineConfig } = require('cypress')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, take a look at your Prettier extension, it seems something is off there. This one shouldn't be modified if the extension is reading the Prettier project config.

'@id': null,
},
};
shallowEqual,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is shallowEqual really necessary here? Since the value is not an object.

};
const pathname = useMemo(() => {
location.pathname;
}, [location]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESlint is complaining. You are returning nothing.

componentDidMount() {
this.setState({ isClient: true });
}
}, [loaded, loading]);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eslint.

@@ -3,10 +3,10 @@
* @module components/theme/Header/Header
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will merge the PR from #4767

content: PropTypes.shape({
'@id': PropTypes.string,
const Anontools = () => {
const { token, content } = useSelector(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's talk about how to make this using the façade, but ideally, we would use one hook for the token, other for the content.

Also, let's discuss if we always return a value or an object. Just to make sure that we are consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohkay ,understood

@Tishasoumya-02
Copy link
Contributor Author

Tishasoumya-02 commented Jun 6, 2023

Sure,I will look into these points and make the changes, closing this PR.

@Tishasoumya-02 Tishasoumya-02 deleted the TishaSoumya branch June 6, 2023 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants