Skip to content

Commit

Permalink
Merge branch 'main' into rafactor-volto-customization
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 authored Nov 7, 2024
2 parents d91612d + d256d89 commit 93bffda
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/mastering-plone/add-ons.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Running `make build` has three effects:
So an add-on can be enabled per Plone instance.

```{seealso}
Documentation {doc}`plone6docs:manage/backend`
Documentation {doc}`plone6docs:admin-guide/add-ons`
```

### Enabling add-ons in your Plone site
Expand Down
2 changes: 1 addition & 1 deletion docs/mastering-plone/case.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ myst:
"description": "Our training story"
"property=og:description": "Our training story"
"property=og:title": "The Case Study"
"keywords": ""
"keywords": "Plone, training"
---

(case-label)=
Expand Down
2 changes: 1 addition & 1 deletion docs/mastering-plone/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ While we're editing behaviors we can also add our own featured-behavior to News
Add {file}`profiles/default/types/News_Item.xml`:
```
```xml
<?xml version="1.0"?>
<object name="News Item" meta_type="Dexterity FTI" i18n:domain="plone"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
Expand Down
4 changes: 2 additions & 2 deletions docs/mastering-plone/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ myst:

This chapter provides instructions on how to install **Plone with the training code**.

For installation, deployment and hosting of Plone in general, see {ref}`Installation<plone6docs:install-index-label>` on `docs.plone.org`.
For installation, deployment and hosting of Plone in general, see {doc}`plone6docs:admin-guide/index` on `docs.plone.org`.


(installation-tools-label)=
Expand Down Expand Up @@ -83,7 +83,7 @@ By creating and working with a **Python virtual environment**, we are independen

The build generates a file structure to be prepared to install **Plone from packages** with `pip` and `mxdev`. The tool `mxdev` helps with configuration files to define which add-ons and which versions to install.
It also allows to override Plone core package versions or force a checkout from `github`.
The documentation {doc}`plone6docs:manage/backend` provides information on common tasks.
The documentation {doc}`plone6docs:admin-guide/add-ons` provides information on common tasks.

The build generates **Zope configuration** files with Cookiecutter `cookiecutter-zope-instance`.
The file we will modify to update our Zope / Plone configuration is `instance.yaml`.
Expand Down
67 changes: 43 additions & 24 deletions docs/mastering-plone/volto_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ make test

See the snapshot in folder `__snapshots__`.
If this is a rendering you expect, you are good to go.
For example you see that the heading is the talk title with preceding type.
For example you see that the heading is the talk title with preceding type of talk.

{file}`packages/volto-ploneconf/src/components/Views/__snapshots__/Talk.test.js.snap`

Expand Down Expand Up @@ -150,6 +150,10 @@ exports[`renders a talk view component with only required props 1`] = `
`;
```

```{seealso}
{doc}`plone6docs:volto/contributing/testing` in docs.plone.org.
```

(testing-cypress)=

## Testing permissions, features and user interface topics
Expand All @@ -160,22 +164,34 @@ The following simple test checks if an editor can add an instance of the custom

The test mimics the editor visiting her site and adding a talk via the appropriate menu action.

**Prerequisites**:

{ref}`Install docker<plone6docs:install-prerequisites-docker-label>`

Create a test file {file}`cypress/tests/content.cy.js`

```{code-block} js
:emphasize-lines: 3-4,8 , 25-28
:emphasize-lines: 4, 18, 23, 40
:linenos:
describe('talk tests', () => {
describe('content type tests', () => {
beforeEach(() => {
// Login as editor
cy.autologin();
cy.intercept('GET', `/**/*?expand*`).as('content');
cy.createUser({
username: 'editor',
fullname: 'Editor',
roles: ['Member', 'Reader', 'Contributor'],
});
cy.visit('/');
cy.wait('@content');
});
afterEach(() => {
cy.removeUser('editor', 'password');
});
it('As editor I can add a talk.', function () {
cy.autologin('editor', 'password');
cy.visit('/');
cy.wait('@content');
// when I add a talk with title, type and details
cy.get('#toolbar-add').click();
cy.get('#toolbar-add-talk').click();
Expand All @@ -201,14 +217,16 @@ describe('talk tests', () => {
});
```

With a simple test file you would be good to go with a frontend package that doesn't rely on a backend package.
You could proceed with {ref}`testing-cypress-run`.
With a frontend package NOT relying on a backend package, you could proceed with next step {ref}`testing-cypress-run`.

### Preparing acceptance backend with add-ons

For a test like this with talks, the acceptance backend needs the backend package with content type talk to be installed.
For a test like above, with talks, the acceptance backend needs the backend package with content type talk to be installed.

Have a look at the code and see `docker compose` used to assemble a backend with the package `ploneconf-site` installed.
The Dockerfile instructs docker to install the package from the main branch of its repository.
So you can proceed with development of the backend package while working on the frontend package.
Have a look at `/frontend/backend/`, where a backend with the add-on `ploneconf-site` is configured.
The configuration instructs to install the package from its repository and editable.
So you can proceed developing the backend package while working on the frontend package.
Necessary changes of the backend package while developing the couple of backend add-on and frontend add-on can be committed right out of `/frontend/backend/sources/ploneconf.site`.


(testing-cypress-run)=
Expand All @@ -224,33 +242,34 @@ All sessions should start from the `frontend` directory.
1. In the first session, start the backend server.

```shell
make backend-install
make acceptance-backend-start
```

2. In the second session, start the frontend server.
1. In the second session, start the frontend server.

```shell
make acceptance-frontend-dev-start
```

3. In the third session, start the Cypress tests runner.
1. In the third session, start the Cypress tests runner.

```shell
make acceptance-test
```

4. In the Cypress pop-up test style, choose `E2E Testing`, since Volto's tests are end-to-end tests.
1. In the Cypress pop-up test style, choose `E2E Testing`, since Volto's tests are end-to-end tests.
5. In the next section, select the browser you want Cypress to run in.
1. In the next section, select the browser you want Cypress to run in.
Although the core tests use `headless Electron` by default, you can choose your preferred browser for the tests development.
6. In the main Cypress runner section, you will see all test specs.
1. In the main Cypress runner section, you will see all test specs.
7. To run a test, interact with the file based tree that displays all possible tests to run, and click on the test spec you want to run.
1. To run a test, interact with the file based tree that displays all possible tests to run, and click on the test spec you want to run.
Have a look in the code of `volto-ploneconf` to see that the continuous integration includes these cypress tests: `.github/workflows/acceptance.yml`
Have a look in the code of `volto-ploneconf` to see that the continuous integration includes these cypress tests: `.github/workflows/acceptance.yml`.
Commits to pull requests trigger a run of the tests.
```{note}
Find helper functions for an auto login, create content, etc. from [Volto](https://github.com/plone/volto/tree/main/packages/volto/cypress/support).
```{seealso}
Helper functions for an auto login, creating content, etc. from [Volto](https://github.com/plone/volto/tree/main/packages/volto/cypress/support).
```
3 changes: 1 addition & 2 deletions docs/mastering-plone/voting-story/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ The jury votes for talks to be accepted or rejected.
---
name: toc-voting-story
maxdepth: 2
numbered: 1
---
behaviors_2
Expand Down Expand Up @@ -158,7 +157,7 @@ module.exports = {
};
```

Be sure keep the main package at the end of the array `addons`.
Be sure keep the main (project policy) package at the end of the array `addons`.
By this the main package can override add-ons configurations.

Check {file}`packages.json` to include the add-on in your app:
Expand Down

0 comments on commit 93bffda

Please sign in to comment.