Skip to content

Commit

Permalink
Added more visibility tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Normanwqn committed Apr 20, 2024
1 parent f1dedab commit 41091bb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,19 @@ describe('SingleProject.vue', () => {
let api_errors = <APIErrors> wrapper.findComponent({ref: 'api_errors'}).vm;
expect(api_errors.d_api_errors.length).toBe(1);
});

test('Visibility icons toggle based on project visibility to students', async () => {
// Test when the project is visible to students
wrapper.setProps({ project: make_project(course_1.pk, {visible_to_students: true})});
await wrapper.vm.$nextTick();
expect(wrapper.find('.fa-eye').exists()).toBe(true);
expect(wrapper.find('.fa-eye-slash').exists()).toBe(false);

// Update the project to not visible and check for correct icons
wrapper.setProps({ project: make_project(course_1.pk, {visible_to_students: false} )});
await wrapper.vm.$nextTick();
expect(wrapper.find('.fa-eye').exists()).toBe(false);
expect(wrapper.find('.fa-eye-slash').exists()).toBe(true);

});
});
18 changes: 18 additions & 0 deletions tests/test_components/test_course_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,22 @@ describe('CourseView tests', () => {
expect(wrapper.findAll('.fa-eye').length).toEqual(1);
expect(wrapper.findAll('.fa-eye-slash').length).toEqual(1);
});

test('student cannot see the eye icon', async () => {
user_roles_stub.returns(
Promise.resolve(data_ut.make_user_roles({is_student: true}))
);

wrapper = mount(CourseView, {
stubs: ['router-link', 'router-view'],
mocks: {
$route
}
});
expect(await wait_for_load(wrapper)).toBe(true);

expect(wrapper.findAll('.project').length).toEqual(2);
expect(wrapper.findAll('.fa-eye').length).toEqual(0);
expect(wrapper.findAll('.fa-eye-slash').length).toEqual(0);
});
});

0 comments on commit 41091bb

Please sign in to comment.