Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI
on:
push:
branches:
- "main"
- 'main'
pull_request:

permissions: {}
Expand All @@ -29,6 +29,9 @@ jobs:
build:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.fork == false
container:
image: mcr.microsoft.com/playwright:v1.61.0-noble
options: --user 1001
steps:
- name: Checkout sources
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
Expand All @@ -39,14 +42,40 @@ jobs:
with:
node-version: 24

- name: Install dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Run tests
run: npm run test:coverage

- name: Upload browser failure screenshots
if: failure() && !cancelled()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: browser-failure-screenshots-${{ github.run_id }}
retention-days: 7
if-no-files-found: ignore
path: |
packages/**/__screenshots__/**/*.png

- name: Licenses check
run: npm run licenses-check

- name: Build
run: |
npm ci
npm run build:all
npm run licenses-check
npm run lint
npm run test:coverage
run: npm run build:all

sonar:
name: SonarCloud Scan
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.fork == false
steps:
- name: Checkout sources
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@1a6d90ebcb0e6a6b1d87e37ba693fe453195ae25 #v5.3.1
env:
Expand Down
32 changes: 26 additions & 6 deletions .github/workflows/fork-build-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
build:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.fork == true
container:
image: mcr.microsoft.com/playwright:v1.61.0-noble
options: --user 1001
steps:
- name: Checkout sources
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
Expand All @@ -19,13 +22,30 @@ jobs:
with:
node-version: 24

- name: Install dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Run tests
run: npm run test:coverage

- name: Upload browser failure screenshots
if: failure() && !cancelled()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: browser-failure-screenshots-${{ github.event.pull_request.number }}
retention-days: 7
if-no-files-found: ignore
path: |
packages/**/__screenshots__/**/*.png

- name: Licenses check
run: npm run licenses-check

- name: Build
run: |
npm ci
npm run licenses-check
npm run lint
npm run test:coverage
npm run build:all
run: npm run build:all

- name: Save build artifacts and coverage report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@

# Vitest
/coverage
.vitest-attachments
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ To fix this, run this command from the app **after** running "npm install"

(Optional) [Test your package from library dependent directory](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages#testing-your-package)

## Testing

- Full test suite: `npm run test`
- Unit tests (fast): `npm run test:unit`
- Browser visual screenshots (Vitest browser mode): `npm run test:browser`
- Update screenshot baselines: `npm run test:browser -- -u`

According to PowSyBl [branching and release strategy](https://github.com/powsybl/.github/blob/main/BRANCHING_RELEASE_STRATEGY.md),
if you want to publish a new release of powsybl-network-viewer in the
[NPM package registry](https://www.npmjs.com/package/@powsybl/powsybl-network-viewer), you need to follow the steps below:
Expand Down
27 changes: 13 additions & 14 deletions demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
* SPDX-License-Identifier: MPL-2.0
*/

import { useEffect, useRef } from 'react';
import { createTheme, StyledEngineProvider, ThemeProvider } from '@mui/material/styles';
import { useEffect, useRef } from 'react';
import { IntlProvider } from 'react-intl';
import { DEFAULT_INTL_CONFIG } from 'react-intl/src/utils';
import { GeoData, type MapEquipment, MapEquipments, NetworkMap, type NetworkMapRef } from '../../src';
import { type MapEquipment, NetworkMap, type NetworkMapRef } from '../../src';

import {
createLargeGeoData,
createLargeNetwork,
} from '../../packages/network-map-layers/src/testUtils/network-fixtures.test.utils';

import sposdata from './map-viewer/data/spos.json';
import lposdata from './map-viewer/data/lpos.json';
import smapdata from './map-viewer/data/smap.json';
import lmapdata from './map-viewer/data/lmap.json';
Comment thread
NathanDissoubray marked this conversation as resolved.
const largeNetwork = createLargeNetwork();
const largeGeoData = createLargeGeoData();

// Called after a click (right mouse click) on some equipment (line or substation)
function showEquipmentMenu(equipment: MapEquipment, x: number, y: number, type: string) {
Expand All @@ -35,13 +38,9 @@ export default function App() {
});

//declare data to be displayed: coordinates and network data
const geoData = new GeoData(new Map(), new Map());
geoData.setSubstationPositions(sposdata);
geoData.setLinePositions(lposdata);
const geoData = largeGeoData;

const mapEquipments = new MapEquipments();
mapEquipments.updateSubstations(smapdata, true);
mapEquipments.updateLines(lmapdata, true);
const mapEquipments = largeNetwork;

useEffect(() => {
const handleContextmenu = (e: MouseEvent) => {
Expand All @@ -54,7 +53,7 @@ export default function App() {
}, []);

const networkMapRef = useRef<NetworkMapRef>(null);
const filteredNominalVoltages = [380.0, 225.0, 110.0];
const filteredNominalVoltages = [400.0, 380.0, 225.0, 150.0, 110.0, 90.0, 45.0];

return (
<div className="App">
Expand Down Expand Up @@ -99,7 +98,7 @@ export default function App() {
);
}}
mapLibrary={'cartonolabel'}
mapTheme={'dark'}
mapTheme={'light'}
filteredNominalVoltages={filteredNominalVoltages}
onDrawPolygonModeActive={(active) => {
console.log('polygon drawing mode active: ', active ? 'active' : 'inactive');
Expand Down
1 change: 1 addition & 0 deletions demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"rootDir": "..",
"outDir": "./dist",
"jsx": "react-jsx",
"paths": {
Expand Down
4 changes: 3 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export default defineConfig([
extends: tsEslint.configs.recommendedTypeChecked,
languageOptions: {
parserOptions: {
projectService: true,
projectService: {
allowDefaultProject: ['./setupBrowserTests.ts'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where is this file setupBrowserTests.ts ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's a leftover of intermediate work, but browser tests didn't need a setup. I will remove it.

},
tsconfigRootDir: import.meta.dirname,
},
},
Expand Down
Loading
Loading