Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
42 changes: 22 additions & 20 deletions .github/workflows/frontend-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ on:
workflow_dispatch:
push:
branches: ["main"]
paths:
- "frontend/**"
pull_request:
branches: ["main"]
paths:
- "frontend/**"

concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

env:
FORCE_COLOR: "1"
FORCE_COLOR: "1"

jobs:
frontend_tests:
if: '! github.event.pull_request.draft'
if: "! github.event.pull_request.draft"
runs-on: ubuntu-latest
name: Frontend Tests
strategy:
Expand All @@ -23,34 +29,30 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
cache: "npm"
cache-dependency-path: frontend/package-lock.json

- name: Install dependencies
working-directory: ./frontend
run: npm ci
run: npm install
Comment thread
abhizipstack marked this conversation as resolved.

- name: Run tests with coverage
working-directory: ./frontend
run: CI=true npm run test -- --coverage .

- name: Git fetch unshallow
run: |
git fetch --unshallow
if: ${{ github.actor != 'dependabot[bot]' }}
run: git fetch --unshallow
Comment thread
greptile-apps[bot] marked this conversation as resolved.

- name: UI SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
uses: SonarSource/sonarcloud-github-action@v3
if: ${{ github.actor != 'dependabot[bot]' }}
continue-on-error: true
Comment thread
greptile-apps[bot] marked this conversation as resolved.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion frontend/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sonar.projectKey=zipstack_visitran_ui
sonar.projectKey=Zipstack_visitran
Comment thread
abhizipstack marked this conversation as resolved.
sonar.organization=zipstack
sonar.language=js
sonar.javascript.file.suffixes=.js,.jsx
Expand Down
34 changes: 28 additions & 6 deletions frontend/src/ide/explorer/__tests__/explorer.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import { ErrorBoundary } from "../../../widgets/error_boundary";

import "../../../setupTests";
import { App } from "../../../app.jsx";
describe("ErrorBoundary", () => {
test("renders children when no error occurs", () => {
render(
<ErrorBoundary onError={() => {}}>
<div>Test Content</div>
</ErrorBoundary>
);
expect(screen.getByText("Test Content")).toBeInTheDocument();
});

test("dummy test case to work with sonar", () => {
render(<App />);
const linkElement = screen.getByText(/Visitran/i);
expect(linkElement).toBeInTheDocument();
test("renders fallback when child throws", () => {
const ThrowError = () => {
throw new Error("Test error");
};
// Suppress console.error for expected error
const spy = jest.spyOn(console, "error").mockImplementation(() => {});
render(
<ErrorBoundary
onError={() => {}}
fallbackComponent={<div>Error occurred</div>}
>
<ThrowError />
</ErrorBoundary>
);
expect(screen.getByText("Error occurred")).toBeInTheDocument();
spy.mockRestore();
});
});
Loading