-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add e2e tests #135
Merged
Merged
feat: add e2e tests #135
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
cc75621
feat: Set baseUrl in cypress config
wama-tw 55877ba
feat: Add e2e tests for home page
wama-tw 271b0b1
feat: Add e2e tests for courses page
wama-tw 08c883a
feat: Change baseUrl port to 4000
wama-tw 004baf5
feat: Add course seeder and department seeder
wama-tw 312ecd1
feat: Remove AuthModule
wama-tw 499de5c
feat: Add course-seeder and department-seeder
juliaouo d5abcea
fix: Change NUXT_PUBLIC_API_BASE_URL
wama-tw f7bdf2a
feat: Add e2e tests for case13-23
juliaouo e305f1e
faet: Clear database before seed
wama-tw 2dd67b1
feat: Clear db before seed
juliaouo 626e5bc
feat: Remove AuthModule
juliaouo 125ca94
fix: Change NUXT_PUBLIC_API_BASE_URL
juliaouo eb2b808
feat: Merge juliaouo master
wama-tw b7da6fa
fix: Fix typo in cypress/e2e/courseShow.cy.ts
wama-tw 6c38292
feat: Merge qawl987 master
wama-tw 9e3b6b3
feat: Add jet lag on daily workflow scheduled time
wama-tw b4aaaed
fix: Change the export type of 'Course'
juliaouo 7c78c89
Merge pull request #36 from juliaouo/master
wama-tw 4a6142a
Update cypress.config.ts
wama-tw b936866
feat: Enable AuthModule
wama-tw 14d9902
feat: Decrease the number of test data
wama-tw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name: "Daily" | ||
on: | ||
schedule: | ||
- cron: "0 6,12,18 * * *" | ||
- cron: "0 10,16,22 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
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
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,11 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Course } from '../../course/course.entity'; | ||
import { CourseSeederService } from './course-seeder.service'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([Course])], | ||
providers: [CourseSeederService], | ||
exports: [CourseSeederService], | ||
}) | ||
export class CourseSeederModule {} |
34 changes: 34 additions & 0 deletions
34
backend/src/seeder/course-seeder/course-seeder.service.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { getRepositoryToken } from '@nestjs/typeorm'; | ||
import { Course } from '../../course/course.entity'; | ||
import { Repository } from 'typeorm'; | ||
import { CourseSeederService } from './course-seeder.service'; | ||
|
||
describe('CourseSeederService', () => { | ||
let service: CourseSeederService; | ||
let courseRepository: Repository<Course>; | ||
|
||
const COURSE_REPOSITORY_TOKEN = getRepositoryToken(Course); | ||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [ | ||
CourseSeederService, | ||
{ | ||
provide: COURSE_REPOSITORY_TOKEN, | ||
useValue: {}, | ||
}, | ||
], | ||
}).compile(); | ||
|
||
service = module.get<CourseSeederService>(CourseSeederService); | ||
courseRepository = module.get<Repository<Course>>(COURSE_REPOSITORY_TOKEN); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(courseRepository).toBeDefined(); | ||
}); | ||
}); |
129 changes: 129 additions & 0 deletions
129
backend/src/seeder/course-seeder/course-seeder.service.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 |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Course } from '../../course/course.entity'; | ||
import { Repository } from 'typeorm'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
|
||
@Injectable() | ||
export class CourseSeederService { | ||
constructor( | ||
@InjectRepository(Course) | ||
private readonly courseRepository: Repository<Course>, | ||
) {} | ||
|
||
async seedCourse() { | ||
await this.courseRepository.clear(); | ||
const course1 = this.courseRepository.create({ | ||
year: 110, | ||
semester: 1, | ||
serialNo: 1001, | ||
classNo: 'PE1022A', | ||
title: '大一體育', | ||
credit: 0, | ||
passwordCard: 'OPTIONAL', | ||
teachers: '["沈淑鳳"]', | ||
classTimes: '["1-3", "1-4"]', | ||
limitCnt: 0, | ||
admitCnt: 0, | ||
waitCnt: 47, | ||
collegeId: 'collegeI0', | ||
departmentId: 'deptI0I1I0', | ||
courseType: 'REQUIRED', | ||
}); | ||
await this.courseRepository.save(course1); | ||
|
||
const course2 = this.courseRepository.create({ | ||
year: 110, | ||
semester: 1, | ||
serialNo: 1002, | ||
classNo: 'CL0126*', | ||
title: '國文(A)經典閱讀:傳統節氣作品選讀', | ||
credit: 3, | ||
passwordCard: 'OPTIONAL', | ||
teachers: '["李宜學"]', | ||
classTimes: '["3-3, 3-4, 1-5"]', | ||
limitCnt: 58, | ||
admitCnt: 0, | ||
waitCnt: 155, | ||
collegeId: 'collegeI1', | ||
departmentId: 'deptI1I1001I0', | ||
courseType: 'REQUIRED', | ||
}); | ||
await this.courseRepository.save(course2); | ||
|
||
const course3 = this.courseRepository.create({ | ||
year: 110, | ||
semester: 1, | ||
serialNo: 1003, | ||
classNo: 'CE2004A', | ||
title: '程式語言', | ||
credit: 3, | ||
passwordCard: 'OPTIONAL', | ||
teachers: '["許富皓"]', | ||
classTimes: '["2-6", "2-7", "2-8"]', | ||
limitCnt: 60, | ||
admitCnt: 0, | ||
waitCnt: 140, | ||
collegeId: 'collegeI5', | ||
departmentId: 'deptI1I5002I0', | ||
courseType: 'REQUIRED', | ||
}); | ||
await this.courseRepository.save(course3); | ||
|
||
const course4 = this.courseRepository.create({ | ||
year: 111, | ||
semester: 0, | ||
serialNo: 1004, | ||
classNo: 'PE1011B', | ||
title: '大一體育', | ||
credit: 0, | ||
passwordCard: 'OPTIONAL', | ||
teachers: '["姚承義"]', | ||
classTimes: '["1-5", "1-6"]', | ||
limitCnt: 0, | ||
admitCnt: 0, | ||
waitCnt: 0, | ||
collegeId: 'collegeI0', | ||
departmentId: 'deptI0I1I0', | ||
courseType: 'REQUIRED', | ||
}); | ||
await this.courseRepository.save(course4); | ||
|
||
const course = new Course(); | ||
course.year = 111; | ||
course.semester = 0; | ||
course.serialNo = 1001; | ||
course.classNo = 'SE6030*'; | ||
course.title = '軟體工程實務'; | ||
course.credit = 1; | ||
course.passwordCard = 'passwordCard'; | ||
course.teachers = '["梁德容", "王尉任", "鄭永斌"]'; | ||
course.classTimes = '["1-2", "1-3", "1-4"]'; | ||
course.limitCnt = 456; | ||
course.admitCnt = 789; | ||
course.waitCnt = 1011; | ||
course.collegeId = 'collegeId'; | ||
course.departmentId = 'csie'; | ||
await this.courseRepository.save(course); | ||
|
||
for (let i = 0; i < 50; i++) { | ||
const course5 = this.courseRepository.create({ | ||
year: 111, | ||
semester: 0, | ||
serialNo: 1005, | ||
classNo: 'EG1007*', | ||
title: '普通化學', | ||
credit: 3, | ||
passwordCard: 'OPTIONAL', | ||
teachers: '["劉奕宏"]', | ||
classTimes: '["2-6", "2-7", "4-2"]', | ||
limitCnt: 0, | ||
admitCnt: 0, | ||
waitCnt: 63, | ||
collegeId: 'collegeI3', | ||
departmentId: 'deptI1I3000I0', | ||
courseType: 'REQUIRED', | ||
}); | ||
await this.courseRepository.save(course5); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
backend/src/seeder/department-seeder/department-seeder.module.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Department } from '../../department/department.entity'; | ||
import { DepartmentSeederService } from './department-seeder.service'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([Department])], | ||
providers: [DepartmentSeederService], | ||
exports: [DepartmentSeederService], | ||
}) | ||
export class DepartmentSeederModule {} |
36 changes: 36 additions & 0 deletions
36
backend/src/seeder/department-seeder/department-seeder.service.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { getRepositoryToken } from '@nestjs/typeorm'; | ||
import { Department } from '../../department/department.entity'; | ||
import { Repository } from 'typeorm'; | ||
import { DepartmentSeederService } from './department-seeder.service'; | ||
|
||
describe('DepartmentSeederService', () => { | ||
let service: DepartmentSeederService; | ||
let departmentRepository: Repository<Department>; | ||
|
||
const DEPARTMENT_REPOSITORY_TOKEN = getRepositoryToken(Department); | ||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [ | ||
DepartmentSeederService, | ||
{ | ||
provide: DEPARTMENT_REPOSITORY_TOKEN, | ||
useValue: {}, | ||
}, | ||
], | ||
}).compile(); | ||
|
||
service = module.get<DepartmentSeederService>(DepartmentSeederService); | ||
departmentRepository = module.get<Repository<Department>>( | ||
DEPARTMENT_REPOSITORY_TOKEN, | ||
); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(departmentRepository).toBeDefined(); | ||
}); | ||
}); |
50 changes: 50 additions & 0 deletions
50
backend/src/seeder/department-seeder/department-seeder.service.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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Department } from '../../department/department.entity'; | ||
import { Repository } from 'typeorm'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
|
||
@Injectable() | ||
export class DepartmentSeederService { | ||
constructor( | ||
@InjectRepository(Department) | ||
private readonly departmentRepository: Repository<Department>, | ||
) {} | ||
|
||
async seedDepartment() { | ||
await this.departmentRepository.clear(); | ||
const department1 = this.departmentRepository.create({ | ||
departmentId: 'deptI0I1I0', | ||
departmentName: '體育室', | ||
collegeId: 'collegeI0', | ||
}); | ||
await this.departmentRepository.save(department1); | ||
|
||
const department2 = this.departmentRepository.create({ | ||
departmentId: 'deptI1I1001I0', | ||
departmentName: '中國文學系', | ||
collegeId: 'collegeI1', | ||
}); | ||
await this.departmentRepository.save(department2); | ||
|
||
const department3 = this.departmentRepository.create({ | ||
departmentId: 'deptI1I3000I0', | ||
departmentName: '工學院', | ||
collegeId: 'collegeI3', | ||
}); | ||
await this.departmentRepository.save(department3); | ||
|
||
const department4 = this.departmentRepository.create({ | ||
departmentId: 'deptI1I5002I0', | ||
departmentName: '資電學院', | ||
collegeId: 'collegeI5', | ||
}); | ||
await this.departmentRepository.save(department4); | ||
|
||
const department = new Department(); | ||
department.departmentId = 'csie'; | ||
department.departmentName = '資訊工程學系'; | ||
department.collegeId = 'ncu'; | ||
|
||
await this.departmentRepository.save(department); | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you extract it into the npm script?