-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:fga-eps-mds/2023.2-UnB-TV-Fronte…
…nd into 59-admin-crud
- Loading branch information
Showing
38 changed files
with
1,259 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: CI Pipeline Frontend | ||
|
||
on: push | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout ✅ | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup 🏗 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: lts/* | ||
cache: 'npm' | ||
|
||
- name: Install ⚙️ | ||
run: npm install | ||
|
||
- name: Build 🛠 | ||
run: npm run build | ||
|
||
- name: Test 📋 | ||
run: npm run test:prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: netlify-deploy | ||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout ✅ | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup 🏗 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: lts/* | ||
cache: 'npm' | ||
|
||
- name: Install ⚙️ | ||
run: npm install | ||
|
||
- name: Build 🛠 | ||
run: npm run build | ||
|
||
- name: Test 📋 | ||
run: npm run test:prod | ||
|
||
- name: Deploy to Netlify | ||
uses: nwtgck/[email protected] | ||
with: | ||
publish-dir: './dist/unb-tv-frontend' | ||
production-branch: devel | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
env: | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | ||
timeout-minutes: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,4 @@ testem.log | |
Thumbs.db | ||
|
||
./github | ||
/src/app/secret/ | ||
/src/app/environment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Karma configuration file, see link for more information | ||
// https://karma-runner.github.io/1.0/config/configuration-file.html | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
customLaunchers: { | ||
ChromeHeadless: { | ||
base: 'Chrome', | ||
flags: [ | ||
'--no-sandbox', | ||
'--disable-gpu', | ||
'--headless', | ||
'--remote-debugging-port=9222' | ||
] | ||
} | ||
}, | ||
basePath: '', | ||
frameworks: ['jasmine', '@angular-devkit/build-angular'], | ||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-jasmine-html-reporter'), | ||
require('karma-coverage'), | ||
require('@angular-devkit/build-angular/plugins/karma') | ||
], | ||
client: { | ||
jasmine: { | ||
// you can add configuration options for Jasmine here | ||
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html | ||
// for example, you can disable the random execution with `random: false` | ||
// or set a specific seed with `seed: 4321` | ||
}, | ||
clearContext: false // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
jasmineHtmlReporter: { | ||
suppressAll: true // removes the duplicated traces | ||
}, | ||
coverageReporter: { | ||
dir: require('path').join(__dirname, './coverage/unb-tv-frontend'), | ||
subdir: '.', | ||
reporters: [ | ||
{ type: 'html' }, | ||
{ type: 'lcov' }, | ||
{ type: 'cobertura' }, | ||
{ type: 'text-summary' } | ||
] | ||
}, | ||
reporters: ['progress', 'kjhtml'], | ||
browsers: ['Chrome'], | ||
restartOnFileChange: true | ||
}); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* /index.html 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,24 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { AppComponent } from './app.component'; | ||
import { BackgroundComponent } from './components/background/background.component'; | ||
|
||
describe('AppComponent', () => { | ||
let component: AppComponent; | ||
let fixture: ComponentFixture<AppComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ | ||
RouterTestingModule | ||
], | ||
declarations: [ | ||
AppComponent | ||
], | ||
imports: [RouterTestingModule], | ||
declarations: [AppComponent, BackgroundComponent], | ||
}).compileComponents(); | ||
}); | ||
|
||
it('should create the app', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app).toBeTruthy(); | ||
fixture = TestBed.createComponent(AppComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it(`should have as title 'UnB-TV-Frontend'`, () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app.title).toEqual('UnB-TV-Frontend'); | ||
it('should create the app', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
// it('should render title', () => { | ||
// const fixture = TestBed.createComponent(AppComponent); | ||
// fixture.detectChanges(); | ||
// const compiled = fixture.nativeElement as HTMLElement; | ||
// expect(compiled.querySelector('.content span')?.textContent).toContain('UnB-TV-Frontend app is running!'); | ||
// }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const EDUPLAY_CLIENT_KEY = "a1cdba06226408fcda63b49c50223c68d56005d234cc98bcdc1ae787d2b4de1d"; | ||
export const environment = { | ||
apiURL: 'http://localhost:8000/api' | ||
apiURL: 'https://unb-tv-backend-2be1ed3a0485.herokuapp.com/api', | ||
}; |
71 changes: 68 additions & 3 deletions
71
src/app/pages/active-account/active-account.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,88 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ActiveAccountComponent } from './active-account.component'; | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { AuthService } from 'src/app/services/auth.service'; | ||
import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; | ||
import { of, throwError } from 'rxjs'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { LoginComponent } from '../login/login.component'; | ||
|
||
const mockData: any = { | ||
"email": "[email protected]", | ||
"code": 123456, | ||
} | ||
|
||
class AuthServiceMock { | ||
constructor() { } | ||
activeAccount() { | ||
return of({ success: true }); | ||
} | ||
resendCode() { | ||
return of({ success: true }); | ||
} | ||
} | ||
|
||
describe('ActiveAccountComponent', () => { | ||
let component: ActiveAccountComponent; | ||
let fixture: ComponentFixture<ActiveAccountComponent>; | ||
let authService: AuthService; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ActiveAccountComponent ] | ||
imports: [HttpClientTestingModule, RouterTestingModule.withRoutes( | ||
[ | ||
{ path: 'login', component: LoginComponent }, | ||
] | ||
), ReactiveFormsModule], | ||
providers: [{ provide: AuthService, useValue: new AuthServiceMock() }, FormBuilder], | ||
declarations: [ActiveAccountComponent] | ||
}) | ||
.compileComponents(); | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ActiveAccountComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
authService = TestBed.inject(AuthService); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should call activeAccount method when the form is submitted', () => { | ||
fixture.detectChanges(); | ||
spyOn(component, 'activeAccount').and.callThrough(); | ||
const form = component.userForm; | ||
form.setValue(mockData); | ||
|
||
const submitButton = fixture.nativeElement.querySelector( | ||
'button[type="submit"]' | ||
); | ||
submitButton.click(); | ||
|
||
expect(component.activeAccount).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should call alert when form is not valid', () => { | ||
spyOn(component, 'activeAccount').and.callThrough(); | ||
const alertSpy = spyOn(window, 'alert'); | ||
fixture.detectChanges(); | ||
|
||
const submitButton = fixture.nativeElement.querySelector( | ||
'button[type="submit"]' | ||
); | ||
submitButton.click(); | ||
|
||
expect(alertSpy).toHaveBeenCalledWith('Preencha todos os campos corretamente!'); | ||
}); | ||
|
||
it('should call activeAccount and return an error', () => { | ||
fixture.detectChanges(); | ||
const form = component.userForm; | ||
form.setValue(mockData); | ||
const mySpy = spyOn(authService, 'activeAccount').and.returnValue(throwError(() => new Error('Erro'))); | ||
component.activeAccount(); | ||
expect(mySpy).toHaveBeenCalled(); | ||
}); | ||
|
||
}); |
Oops, something went wrong.