Skip to content

Commit

Permalink
Fix: schedule tests (#2547)
Browse files Browse the repository at this point in the history
* refactor: update schedule tests

* refactor: remove comments

* fix: update nest tests
  • Loading branch information
valerydluski authored Nov 5, 2024
1 parent eea004c commit 99dddca
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ describe('StatusTabs', () => {

render(<StatusTabs statuses={statuses} onTabChange={onTabChangeMock} />);

const [all, available, review, future, missed, done, archived] = screen.getAllByRole('tab');
const [all, available, review, future, missed, done, registered, unAvailable, archived] =
screen.getAllByRole('tab');
expect(all).toHaveTextContent(new RegExp(ALL_TAB_KEY, 'i'));
expect(available).toHaveTextContent(new RegExp(StatusEnum.Available, 'i'));
expect(review).toHaveTextContent(new RegExp(StatusEnum.Review, 'i'));
expect(future).toHaveTextContent(new RegExp(StatusEnum.Future, 'i'));
expect(missed).toHaveTextContent(new RegExp(StatusEnum.Missed, 'i'));
expect(done).toHaveTextContent(new RegExp(StatusEnum.Done, 'i'));
expect(registered).toHaveTextContent(new RegExp(StatusEnum.Registered, 'i'));
expect(unAvailable).toHaveTextContent(new RegExp(StatusEnum.Unavailable, 'i'));
expect(archived).toHaveTextContent(new RegExp(StatusEnum.Archived, 'i'));
});

Expand Down Expand Up @@ -111,11 +114,13 @@ describe('StatusTabs', () => {
${StatusEnum.Archived}
${StatusEnum.Future}
${StatusEnum.Review}
${StatusEnum.Registered}
${StatusEnum.Unavailable}
`('should call onTabChange with tab name "$tabName"', ({ tabName }: { tabName: string }) => {
const statuses = generateStatuses(undefined, { [tabName]: 2 });
render(<StatusTabs statuses={statuses} onTabChange={onTabChangeMock} />);

const selectedTab = screen.getByText(new RegExp(tabName, 'i'));
const selectedTab = screen.getByText(new RegExp(`^${tabName}$`, 'i'));
fireEvent.click(selectedTab);

expect(onTabChangeMock).toHaveBeenCalledWith(tabName);
Expand Down
2 changes: 2 additions & 0 deletions client/src/modules/Schedule/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const TAG_NAME_MAP: Record<CourseScheduleItemDto['tag'], string> = {
'cross-check-review': 'Cross-Check: Review',
'self-study': 'Self-study',
lecture: 'Lecture',
'team-distribution': 'Team Distribution',
};

export const SCHEDULE_STATUSES = Object.keys(CourseScheduleItemDtoStatusEnum).map(key => ({
Expand Down Expand Up @@ -85,6 +86,7 @@ export const DEFAULT_TAG_COLOR_MAP: Record<CourseScheduleItemDto['tag'], string>
'cross-check-review': '#36A836',
'self-study': '#595959',
lecture: '#eb2f96',
'team-distribution': '#308e00',
};

export const SPECIAL_TASK_TYPES = {
Expand Down
2 changes: 1 addition & 1 deletion nestjs/src/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class ConfigService {
};

this.awsClient = {
region: conf.get('RSSHCOOL_AWS_REGION') ?? '',
region: conf.get('RSSHCOOL_AWS_REGION') ?? 'eu-central-1',
credentials: {
accessKeyId: conf.get('RSSHCOOL_AWS_ACCESS_KEY_ID') ?? '',
secretAccessKey: conf.get('RSSHCOOL_AWS_SECRET_ACCESS_KEY') || '',
Expand Down
10 changes: 10 additions & 0 deletions nestjs/src/courses/course-schedule/course-schedule.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
TaskInterviewResult,
TaskResult,
TaskSolution,
TeamDistribution,
TeamDistributionStudent,
} from '@entities/index';

const MOCK_CURRENT_TIME = new Date('2022-03-22T00:00:00.000Z');
Expand Down Expand Up @@ -111,6 +113,14 @@ describe('CourseScheduleService', () => {
provide: getRepositoryToken(TaskChecker),
useValue: {},
},
{
provide: getRepositoryToken(TeamDistributionStudent),
useValue: {},
},
{
provide: getRepositoryToken(TeamDistribution),
useValue: {},
},
],
}).compile();

Expand Down

0 comments on commit 99dddca

Please sign in to comment.