Skip to content

Commit

Permalink
Merge pull request #615 from HSF/fix-master-main
Browse files Browse the repository at this point in the history
We migrated master to main - fix this in a few places
  • Loading branch information
9inpachi authored Aug 24, 2023
2 parents ea792f5 + 67e72ce commit cfbcd20
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[build-img]: https://github.com/HSF/phoenix/actions/workflows/main.yml/badge.svg?branch=master
[build-link]: https://github.com/HSF/phoenix/actions/workflows/main.yml?query=branch%3Amaster
[license-img]: https://img.shields.io/github/license/hsf/phoenix.svg
[license-url]: https://github.com/hsf/phoenix/blob/master/LICENSE
[license-url]: https://github.com/hsf/phoenix/blob/main/LICENSE

![Phoenix Logo](https://raw.github.com/HSF/phoenix/master/packages/phoenix-ng/projects/phoenix-app/src/assets/images/logo-text.svg)

Expand Down
2 changes: 1 addition & 1 deletion guides/developers/set-up-phoenix.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ After this, go to the `src/styles.scss` file of your app and import the global P

#### Set up assets

And lastly, download [these assets](https://github.com/HSF/phoenix/tree/master/packages/phoenix-ng/projects/phoenix-ui-components/lib/assets) (icons and images used by the Phoenix UI components) and put them in the `src/assets` directory of your app.
And lastly, download [these assets](https://github.com/HSF/phoenix/tree/main/packages/phoenix-ng/projects/phoenix-ui-components/lib/assets) (icons and images used by the Phoenix UI components) and put them in the `src/assets` directory of your app.

With this, the app is ready and we can move onto setting up the event display in this app.

Expand Down
12 changes: 6 additions & 6 deletions guides/developers/test-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

## Introduction

Phoenix has 2 types of tests: [unit tests](https://en.wikipedia.org/wiki/Unit_testing) and [end-to-end tests](https://www.browserstack.com/guide/end-to-end-testing). In essence, Unit tests are written to test individual components of the project which includes the [phoenix-event-display](https://github.com/HSF/phoenix/blob/master/packages/phoenix-event-display/README.md) library and the Angular components used by the Phoenix application inside [phoenix-ng](https://github.com/HSF/phoenix/tree/master/packages/phoenix-ng/) package, while the end-to-end tests are used to test user interactions with the [Phoenix application](https://github.com/HSF/phoenix/blob/master/packages/phoenix-ng/projects/phoenix-app/).
Phoenix has 2 types of tests: [unit tests](https://en.wikipedia.org/wiki/Unit_testing) and [end-to-end tests](https://www.browserstack.com/guide/end-to-end-testing). In essence, Unit tests are written to test individual components of the project which includes the [phoenix-event-display](https://github.com/HSF/phoenix/blob/main/packages/phoenix-event-display/README.md) library and the Angular components used by the Phoenix application inside [phoenix-ng](https://github.com/HSF/phoenix/tree/main/packages/phoenix-ng/) package, while the end-to-end tests are used to test user interactions with the [Phoenix application](https://github.com/HSF/phoenix/blob/main/packages/phoenix-ng/projects/phoenix-app/).

## Unit Tests in Phoenix

Expand All @@ -23,7 +23,7 @@ While writing unit tests, we make sure to follow these practices:
3. We try to keep the tests as simple as possible and you can find them ending with the extension `.test.ts`. We try to avoid using complex logic in the tests as it may be difficult to debug and maintain.
4. We try to keep the tests as readable as possible. We use the `it('<should work as expected>', () => {})` syntax to write the description of a test and make sure that it is clear enough as to what is being tested. Inside the test cases, you can use either the [AAA (Arrange, Act, Assert)](https://automationpanda.com/2020/07/07/arrange-act-assert-a-pattern-for-writing-good-tests/) or [GWT (Given, When, Then)](https://martinfowler.com/bliki/GivenWhenThen.html) pattern to clearly define the phases of your test case. We should test "what" the function does instead of "how" it does it.
5. We have to make sure that the tests are deterministic and not flaky. Flaky tests are tests that fail intermittently and are difficult to debug, i.e., the tests we write should always present the same behavior. For this, each test case has to be isolated and independent of the other test cases.
6. Since Phoenix uses `WebGLRenderer` extensively, we make sure to mock it whenever we are using it inside our tests. This is because [WebGLRenderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer) is not supported by [jsdom](https://jestjs.io/docs/configuration#testenvironment-string) due to non-availability of `WebGLContext` in Node.js and the browserless nature of `jsdom` and hence, we mock it using our custom helper [`webgl-mock.ts`](https://github.com/HSF/phoenix/blob/master/packages/phoenix-event-display/src/tests/helpers/webgl-mock.ts).
6. Since Phoenix uses `WebGLRenderer` extensively, we make sure to mock it whenever we are using it inside our tests. This is because [WebGLRenderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer) is not supported by [jsdom](https://jestjs.io/docs/configuration#testenvironment-string) due to non-availability of `WebGLContext` in Node.js and the browserless nature of `jsdom` and hence, we mock it using our custom helper [`webgl-mock.ts`](https://github.com/HSF/phoenix/blob/main/packages/phoenix-event-display/src/tests/helpers/webgl-mock.ts).
7. The code we are supposed to test should not be mocked. We should mock the code that is not supposed to be tested. For example, if we are testing the `EventDisplay` class, we should not mock the `EventDisplay` class, but we should mock the `WebGLRenderer` class as it is not supposed to be tested in this case.
8. `Constants` are not tested separately. Testing the code that uses those constants should be sufficient. `Types` are not tested as they don't contain any logic that has to be tested.
9. We should avoid having assertions that have nothing to do with the test case and the code to be tested. Proper usage of assertions is important to make sure that the test case is testing just the right thing. For example, if we are testing a function that returns a [Group](https://threejs.org/docs/#api/en/objects/Group), we can check if the correct objects exist inside it. And then we can check if the objects are instances of the correct class and have the correct properties, etc.
Expand All @@ -42,12 +42,12 @@ describe('ClassName', () => {
```

Some simple examples of unit tests written in TypeScript using Jest:
- [info-logger.test.ts](https://github.com/HSF/phoenix/blob/master/packages/phoenix-event-display/src/tests/helpers/info-logger.test.ts)
- [file-explorer.component.test.ts](https://github.com/HSF/phoenix/blob/master/packages/phoenix-ng/projects/phoenix-ui-components/lib/components/file-explorer/file-explorer.component.test.ts)
- [info-logger.test.ts](https://github.com/HSF/phoenix/blob/main/packages/phoenix-event-display/src/tests/helpers/info-logger.test.ts)
- [file-explorer.component.test.ts](https://github.com/HSF/phoenix/blob/main/packages/phoenix-ng/projects/phoenix-ui-components/lib/components/file-explorer/file-explorer.component.test.ts)

### Jest Configuration

The configuration file for Jest inside `phoenix-event-display` is [jest.conf.js](https://github.com/HSF/phoenix/blob/master/packages/phoenix-event-display/configs/jest.conf.js) and the configuration file for Jest inside `phoenix-ng` is [jest.conf.js](https://github.com/HSF/phoenix/blob/master/packages/phoenix-ng/jest.config.js). Both require slightly different configurations so we decided not to merge them.
The configuration file for Jest inside `phoenix-event-display` is [jest.conf.js](https://github.com/HSF/phoenix/blob/main/packages/phoenix-event-display/configs/jest.conf.js) and the configuration file for Jest inside `phoenix-ng` is [jest.conf.js](https://github.com/HSF/phoenix/blob/main/packages/phoenix-ng/jest.config.js). Both require slightly different configurations so we decided not to merge them.

To learn more about Jest and related documentation, we recommend you check out the following links:
- [Jest Docs](https://jestjs.io/docs/getting-started)
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('CMSComponent', () => {

### Cypress Configuration

The configuration file for e2e tests is [cypress.config.ts](https://github.com/HSF/phoenix/blob/master/packages/phoenix-ng/cypress.config.ts). More examples of e2e tests can be found inside the [phoenix-app/cypress](https://github.com/HSF/phoenix/tree/master/packages/phoenix-ng/projects/phoenix-app/cypress) folder and we recommend you to check out the [official Cypress documentation](https://docs.cypress.io/guides/overview/why-cypress) as it is quite fantastic and more than enough to get started with Cypress.
The configuration file for e2e tests is [cypress.config.ts](https://github.com/HSF/phoenix/blob/main/packages/phoenix-ng/cypress.config.ts). More examples of e2e tests can be found inside the [phoenix-app/cypress](https://github.com/HSF/phoenix/tree/main/packages/phoenix-ng/projects/phoenix-app/cypress) folder and we recommend you to check out the [official Cypress documentation](https://docs.cypress.io/guides/overview/why-cypress) as it is quite fantastic and more than enough to get started with Cypress.


# Running the tests locally
Expand Down
6 changes: 3 additions & 3 deletions packages/phoenix-event-display/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Version](https://img.shields.io/npm/v/phoenix-event-display.svg)](https://www.npmjs.com/package/phoenix-event-display)
[![Downloads](https://img.shields.io/npm/dt/phoenix-event-display.svg)](https://www.npmjs.com/package/phoenix-event-display)
[![Documentation Coverage](https://raw.github.com/HSF/phoenix/master/docs/api-docs/images/coverage-badge-documentation.svg)](https://hepsoftwarefoundation.org/phoenix/api-docs/coverage.html)
[![Documentation Coverage](https://raw.github.com/HSF/phoenix/main/docs/api-docs/images/coverage-badge-documentation.svg)](https://hepsoftwarefoundation.org/phoenix/api-docs/coverage.html)

A highly modular and API driven experiment independent event display that uses [three.js](https://threejs.org) for processing and presenting detector geometry and event data.

Expand Down Expand Up @@ -100,5 +100,5 @@ Without building, you can include the bundle directly from [CDN](https://cdn.jsd

### Examples

- [Usage in Angular (as a service)](https://github.com/HSF/phoenix/blob/master/packages/phoenix-ng/projects/phoenix-app/src/app/sections/lhcb/lhcb.component.ts)
- [Usage in React](https://github.com/9inpachi/phoenix-react/blob/master/src/App.js#L6-L31)
- [Usage in Angular (as a service)](https://github.com/HSF/phoenix/blob/main/packages/phoenix-ng/projects/phoenix-app/src/app/sections/lhcb/lhcb.component.ts)
- [Usage in React](https://github.com/9inpachi/phoenix-react/blob/main/src/App.js#L6-L31)
2 changes: 1 addition & 1 deletion packages/phoenix-event-display/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "dist/index",
"author": "Phoenix contributors (https://github.com/HSF/phoenix/graphs/contributors)",
"license": "Apache-2.0",
"homepage": "http://github.com/HSF/phoenix/tree/master/packages/phoenix-event-display#readme",
"homepage": "http://github.com/HSF/phoenix/tree/main/packages/phoenix-event-display#readme",
"repository": {
"type": "git",
"url": "git://github.com/HSF/phoenix.git"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ <h5 class="card-title">TrackML</h5>
</p>
<p>
<a href="https://github.com/HSF/phoenix"> Github </a> -
<a href="https://github.com/HSF/phoenix/blob/master/README.md">
<a href="https://github.com/HSF/phoenix/blob/main/README.md">
Documentation
</a>
</p>
Expand Down
4 changes: 2 additions & 2 deletions packages/phoenix-ng/projects/phoenix-ui-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ yarn add phoenix-ui-components

## Setup

You can see [phoenix-app](https://github.com/HSF/phoenix/tree/master/packages/phoenix-ng/projects/phoenix-app) as a reference app that uses this package.
You can see [phoenix-app](https://github.com/HSF/phoenix/tree/main/packages/phoenix-ng/projects/phoenix-app) as a reference app that uses this package.

Since the components use some icons and images, you will need to copy these assets to your application. Download these assets from [./src/assets](https://github.com/HSF/phoenix/tree/master/packages/phoenix-ng/projects/phoenix-ui-components/src/assets) and put them in the `src/assets` directory of your application. All assets should be served through `/assets`.
Since the components use some icons and images, you will need to copy these assets to your application. Download these assets from [./src/assets](https://github.com/HSF/phoenix/tree/main/packages/phoenix-ng/projects/phoenix-ui-components/src/assets) and put them in the `src/assets` directory of your application. All assets should be served through `/assets`.

Once you have the assets set up, import the `PhoenixUIModule` and `BrowserAnimationsModule` in your `NgModule`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Reusable Angular components of the Phoenix event display application.",
"author": "Phoenix contributors (https://github.com/HSF/phoenix/graphs/contributors)",
"license": "Apache-2.0",
"homepage": "http://github.com/HSF/phoenix/tree/master/packages/phoenix-ng/projects/phoenix-ui-components#readme",
"homepage": "http://github.com/HSF/phoenix/tree/main/packages/phoenix-ng/projects/phoenix-ui-components#readme",
"repository": {
"type": "git",
"url": "git://github.com/HSF/phoenix.git"
Expand Down

0 comments on commit cfbcd20

Please sign in to comment.