Skip to content

Commit

Permalink
Add ci/cd on frontend
Browse files Browse the repository at this point in the history
Signed-off-by: DaviMarinho <[email protected]>
  • Loading branch information
DaviMarinho committed Nov 6, 2023
1 parent 2b73995 commit 8c1095b
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 12 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI/CD Pipeline Frontend

on: push

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Test
run: ng test

deploy:
needs: build
runs-on: ubuntu-latest

steps:
- name: Deploy to Heroku
uses: akhileshns/[email protected]
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: your-heroku-app-name
heroku_email: [email protected]
heroku_deploy_branch: main
2 changes: 1 addition & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/un-b-tv-frontend",
"outputPath": "dist/unb-tv-frontend",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "un-b-tv-frontend",
"name": "unb-tv-frontend",
"version": "0.0.0",
"scripts": {
"ng": "ng",
Expand Down
47 changes: 42 additions & 5 deletions src/app/pages/login/login.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { LoginComponent } from './login.component';
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';

describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoginComponent ]
})
.compileComponents();
TestBed.configureTestingModule({
declarations: [LoginComponent],
imports: [ReactiveFormsModule],
providers: [FormBuilder],
}).compileComponents();

fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
Expand All @@ -20,4 +21,40 @@ describe('LoginComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});

it('should have a valid form on initialization', () => {
expect(component.userForm.valid).toBeFalse();
});

it('should call login method when the form is submitted', () => {
spyOn(component, 'login');
const form = component.userForm;
form.setValue({ email: '[email protected]', password: 'password' });
fixture.detectChanges();

const submitButton = fixture.nativeElement.querySelector(
'button[type="submit"]'
);
submitButton.click();

expect(component.login).toHaveBeenCalled();
});

it('should call navigator method when "Esqueceu a senha?" is clicked', () => {
spyOn(component, 'navigator');
const forgotPasswordLink =
fixture.nativeElement.querySelector('.text-gray-400');
forgotPasswordLink.click();

expect(component.navigator).toHaveBeenCalledWith('/sendCodeResetPassword');

it('should call navigator method when "Cadastre-se" is clicked', () => {
spyOn(component, 'navigator');
const registerLink =
fixture.nativeElement.querySelector('.text-blue-brand');
registerLink.click();

expect(component.navigator).toHaveBeenCalledWith('/register');
});
});
});
2 changes: 1 addition & 1 deletion src/app/pages/video-viewer/video-viewer.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from "@angular/router/testing";
import { VideoViewerComponent } from './video-viewer.component';
import { VideoService } from './video.service';
import { VideoService } from '../../services/video.service';
import { SafePipe } from 'src/app/pipes/safe.pipe';

describe('VideoViewerComponent', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/video/video.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { VideoComponent } from './video.component';
import { VideoService } from './video.service';
import { VideoService } from '../../services/video.service';

describe('VideoComponent', () => {
let component: VideoComponent;
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/video.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { VideoService } from './video.service';
import { EDUPLAY_API_URL, UNB_ID } from 'src/app/app.constant';
import { EDUPLAY_CLIENT_KEY } from 'src/app/secret/eduplay.credentials';
import { EDUPLAY_CLIENT_KEY } from '../environment/environment';

describe('VideoService', () => {
let service: VideoService;
Expand Down

0 comments on commit 8c1095b

Please sign in to comment.