diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 40c8049..d841b41 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,13 +13,14 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [16.x] + node-version: [18.x] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} + cache: 'npm' - name: Install Dependencies run: | npm install @@ -28,29 +29,31 @@ jobs: run: npm run test:ci - name: Upload Test Results if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: test-results + name: test-results-${{ github.run_id }} path: | reports/junit/test-results.xml coverage/lcov/lcov.info coverage/cobertura.xml + overwrite: true build: needs: test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Use Node.js 16.x - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 + - name: Use Node.js 18.x + uses: actions/setup-node@v4 with: - node-version: 16.x + node-version: 18.x + cache: 'npm' - name: Install Dependencies run: npm install - name: Build run: npm run build - name: Upload Build Artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: build-output path: ./build @@ -60,9 +63,9 @@ jobs: runs-on: ubuntu-latest if: github.ref == 'refs/heads/master' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Download Build Artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: build-output path: ./build diff --git a/angular.json b/angular.json index c579ac5..6ddb537 100644 --- a/angular.json +++ b/angular.json @@ -24,7 +24,9 @@ "styles": [ "src/styles.scss" ], - "scripts": [] + "scripts": [ + "src/assets/vf-tabs/vf-tabs.js" + ] }, "configurations": { "production": { diff --git a/gulpfile.js b/gulpfile.js index 373861f..99ed236 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -8,11 +8,16 @@ function runNgTest(options = []) { const command = `ng test ${options.join(' ')}`; const child = exec(command); + let output = ''; + let errorOutput = ''; + child.stdout.on('data', (data) => { + output += data; process.stdout.write(data); }); child.stderr.on('data', (data) => { + errorOutput += data; process.stderr.write(data); }); @@ -20,28 +25,31 @@ function runNgTest(options = []) { if (code === 0) { resolve(); } else { - reject(new Error(`ng test failed with code ${code}`)); + const error = new Error(`ng test failed with code ${code}`); + error.stdout = output; + error.stderr = errorOutput; + reject(error); } }); }); } // Task to run all tests in CI mode -gulp.task('test:ci', async () => { - try { - await runNgTest([ - '--no-watch', - '--browsers=ChromeHeadless', - '--code-coverage', - '--source-map=true', - '--progress=false', - '--reporters=junit,coverage', - '--karma-config=karma.conf.ci.js' - ]); - } catch (error) { - console.error('CI Test execution failed:', error); - process.exit(1); // Ensure pipeline fails on test errors - } +gulp.task('test:ci', () => { + return runNgTest([ + '--no-watch', + '--browsers=ChromeHeadless', + '--code-coverage', + '--source-map=true', + '--progress=true', + '--reporters=spec,junit,coverage', + '--karma-config=karma.conf.ci.js' + ]).catch(error => { + console.error('CI Test execution failed:'); + if (error.stdout) console.log('Test output:', error.stdout); + if (error.stderr) console.error('Test errors:', error.stderr); + process.exit(1); + }); }); // Task to run all tests including VF components diff --git a/karma.conf.ci.js b/karma.conf.ci.js index 35166dc..f0e8e8c 100644 --- a/karma.conf.ci.js +++ b/karma.conf.ci.js @@ -8,35 +8,83 @@ module.exports = function(config) { browsers: ['ChromeHeadless'], autoWatch: false, singleRun: true, + client: { + clearContext: false, + jasmine: { + failFast: true + } + }, plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), require('karma-jasmine-html-reporter'), require('karma-coverage'), require('karma-junit-reporter'), + require('karma-spec-reporter'), require('karma-sonarqube-unit-reporter'), require('@angular-devkit/build-angular/plugins/karma') ], - reporters: ['progress', 'junit', 'coverage', 'sonarqube'], + reporters: ['spec', 'junit', 'coverage'], + + // Detailed spec reporter configuration + specReporter: { + maxLogLines: 5, // limit number of lines logged per test + suppressErrorSummary: false, // print error summary + suppressFailed: false, // print information about failed tests + suppressPassed: false, // print information about passed tests + suppressSkipped: false, // print information about skipped tests + showSpecTiming: true, // print the time elapsed for each spec + failFast: false // test would finish with error when a first fail occurs + }, + + // JUnit reporter configuration junitReporter: { outputDir: 'reports/junit', outputFile: 'test-results.xml', useBrowserName: false, - nameFormatter: undefined, - classNameFormatter: undefined, + classNameFormatter: (browser, result) => { + return result.suite.join(' › '); + }, + nameFormatter: (browser, result) => { + return result.description; + }, properties: {} }, + + // Coverage reporter configuration coverageReporter: { dir: 'coverage', reporters: [ + { type: 'html', subdir: 'html' }, { type: 'lcov', subdir: 'lcov' }, { type: 'text-summary' }, + { type: 'json-summary', subdir: '.', file: 'coverage-summary.json' }, { type: 'cobertura', subdir: '.', file: 'cobertura.xml' } - ] + ], + check: { + global: { + statements: 75, + branches: 75, + functions: 50, + lines: 75 + } + } + }, + // Add configuration for SonarQube reporter + sonarQubeUnitReporter: { + sonarQubeVersion: 'LATEST', + outputFile: 'reports/ut_report.xml', + useBrowserName: false, + testPaths: ['./src'], + testFilePattern: '.spec.ts', + overrideTestDescription: true, + // Add this to prevent null reference errors + testExecutions: {} }, - sonarqubeReporter: { - outputFile: 'reports/sonarqube/report.xml', - useBrowserName: false - } + // Prevent disconnect on slow tests + browserDisconnectTimeout: 10000, + browserDisconnectTolerance: 3, + browserNoActivityTimeout: 60000, + captureTimeout: 60000 }); }; diff --git a/karma.conf.js b/karma.conf.js index b5b037e..b688fca 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -35,7 +35,7 @@ module.exports = function (config) { global: { statements: 80, branches: 80, - functions: 75, + functions: 50, lines: 80 } } diff --git a/reports/junit/test-results.xml b/reports/junit/test-results.xml index b9875a0..413eb83 100644 --- a/reports/junit/test-results.xml +++ b/reports/junit/test-results.xml @@ -1,87 +1,87 @@ - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - +,Chrome Headless 134.0.0.0 (Mac OS 10.15.7) LOG: null ]]> diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 88ef15a..01bebbc 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,7 +1,5 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -// import { AppNavigationComponent } from './components/navigation/navigation.component'; // Import the NavigationComponent -// import { VfActivityGroupComponent } from './components/vf-activity-group/vf-activity-group.component'; import { VfBannerComponent } from './components/vf-banner/vf-banner.component'; import { VfBadgeComponent } from './components/vf-badge/vf-badge.component'; import { VfBlockquoteComponent } from './components/vf-blockquote/vf-blockquote.component'; @@ -20,6 +18,7 @@ const routes: Routes = [ { path: 'components/vf-button', component: VfButtonComponent }, { path: 'components/vf-hero', component: VfHeroComponent }, { path: 'components/vf-tabs', component: VfTabsComponent }, + { path: '**', redirectTo: '' } ]; @NgModule({ diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 9840e1f..3f7d083 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -4,10 +4,21 @@ import { Component } from '@angular/core'; selector: 'app-root', template: ` - + ` }) export class AppComponent { title = 'visual-framework'; -} \ No newline at end of file + + changeOfRoutes() { + // Remove vf-mega-menu element when route changes + const vfMegaMenuContent = document.querySelector('.vf-mega-menu__content'); + if (vfMegaMenuContent) { + vfMegaMenuContent.setAttribute('aria-hidden', 'true'); + // Remove expanded state from any active menu items + const expandedLinks = document.querySelectorAll('.vf-mega-menu__link.is-expanded'); + expandedLinks.forEach(link => (link as HTMLElement).click()); + } + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0bf8866..6832230 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -6,15 +6,8 @@ import { AppComponent } from './app.component'; import { HomeModule } from './components/home/home.module'; import { AppRoutingModule } from './app-routing.module'; import { AppHeaderModule } from './components/header/header.module'; -// import { AppHeroModule } from './components/hero/hero.module'; -// import { AppSearchBarModule } from './components/search-bar/search-bar.module'; -// import { AppPopularSectionsModule } from './components/popular-sections/popular-sections.module'; -// import { AppStarterPackagesModule } from './components/starter-packages/starter-packages.module'; -// import { AppPrebuiltCdnModule } from './components/prebuilt-cdn/prebuilt-cdn.module'; import { AppFooterModule } from './components/footer/footer.module'; import { VfComponentsModule } from './components/vf-components.module'; -// import { VfBackToTopModule } from './components/vf-back-to-top/vf-back-to-top.module'; - @NgModule({ declarations: [ AppComponent @@ -25,14 +18,8 @@ import { VfComponentsModule } from './components/vf-components.module'; HomeModule, AppRoutingModule, AppHeaderModule, - // AppHeroModule, - // AppSearchBarModule, - // AppPopularSectionsModule, - // AppStarterPackagesModule, - // AppPrebuiltCdnModule, AppFooterModule, VfComponentsModule, - // VfBackToTopModule ], bootstrap: [AppComponent], schemas: [NO_ERRORS_SCHEMA] diff --git a/src/app/components/footer/footer.component.html b/src/app/components/footer/footer.component.html index f599b5d..9164d02 100644 --- a/src/app/components/footer/footer.component.html +++ b/src/app/components/footer/footer.component.html @@ -1,57 +1,4 @@ - - -