Skip to content
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

Qa #3128

Merged
merged 4 commits into from
Jul 11, 2024
Merged

Qa #3128

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions myuw_vue/components/academics/adviser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,18 @@ export default {
profile: (state) => state.profile.value,
}),
...mapGetters('advisers', {
isReadyAdvisers: 'isReady',
isFetchingAdvisers: 'isFetching',
isErroredAdvisers: 'isErrored',
statusCodeAdvisers: 'statusCode',
}),
...mapGetters('profile', {
isReadyProfile: 'isReady',
isFetchingProfile: 'isFetching',
isErroredProfile: 'isErrored',
statusCodeProfile: 'statusCode',
}),
shouldLoad() {
return !this.isPCE && (this.isUndergrad || this.studEmployee) && !this.isGrad;
},
termMajors() {
return this.profile.term_majors;
},
Expand All @@ -156,27 +159,35 @@ export default {
},
showError() {
return (
this.isErroredAdvisers &&
this.statusCodeAdvisers != 404 ||
this.isErroredProfile &&
this.statusCodeProfile != 404
this.isErroredAdvisers && this.statusCodeAdvisers != 404 ||
this.isErroredProfile && this.statusCodeProfile != 404
);
},
showCard() {
return !this.isPCE && (this.isUndergrad || this.studEmployee && !this.isGrad);
},
hasAdviser() {
return this.isReadyAdvisers && this.advisers && this.advisers.length > 0;
return this.advisers && this.advisers.length > 0;
},
hasCompus() {
return this.profile && this.profile.campus !== undefined;
hasProfile() {
return (
this.profile &&
this.profile.campus !== undefined &&
(this.profile.class_level === 'FRESHMAN' ||
this.profile.class_level === "SOPHOMORE" ||
this.profile.class_level === "JUNIOR" ||
this.profile.class_level === "SENIOR")
); //MUWM-5349
},
showContent() {
return this.hasAdviser || this.hasCompus;
return this.hasAdviser || this.hasProfile;
},
showCard() {
return (
this.shouldLoad &&
(this.isFetchingAdvisers || this.isFetchingProfile || this.showContent ||
this.showError));
}
},
created() {
if (this.showCard) {
if (this.shouldLoad) {
this.fetchAdvisers();
this.fetchProfile();
}
Expand Down
64 changes: 63 additions & 1 deletion myuw_vue/components/teaching/classlist/photo-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@
<h3 class="visually-hidden">
Grid of Student Photos
</h3>
<div class="sort-buttons myuw-text-md">
<span class="py-1" style=""><strong>Sort by:</strong></span><button
v-for="field in fields"
:key="field.key"
type="button"
:class="buttonClass(field.key)"
@click="setSortKey(field.key)"
>
{{ field.label }}
</button>
</div>
<ol class="list-unstyled d-flex flex-wrap">
<li v-for="(reg, i) in registrations"
<li v-for="(reg, i) in sortedRegistrations"
:id="`student-photo-${reg.regid}`"
:key="i"
class="p-1 mb-1"
Expand Down Expand Up @@ -41,5 +52,56 @@ export default {
default: false,
},
},
data() {
return {
sortKey: 'surname',
fields: [
{ key: 'first_name', label: 'first name', sortable: true },
{ key: 'surname', label: 'last name', sortable: true }
]
};
},
computed: {
sortedRegistrations() {
const key = this.sortKey;
return [...this.registrations].sort((a, b) => {
if (a[key] < b[key]) return -1;
if (a[key] > b[key]) return 1;
return 0;
});
},
},
methods: {
setSortKey(key) {
this.sortKey = key;
},
buttonClass(key) {
return {
'btn': true,
'btn-link': true,
'active': this.sortKey === key,
'inactive': this.sortKey !== key,
'disabled': this.sortKey === key,
'myuw-text-md': true,
'px-1': true,
'py-1': true
};
}
}
};
</script>
<style scoped>
.sort-buttons{
padding-bottom:.5em;
}
.active {
font-weight: bold;
}
.inactive {
font-weight: normal;
}
.btn-link.disabled {
color: #000;
opacity:1;
}
</style>
54 changes: 36 additions & 18 deletions myuw_vue/tests/adviser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import profile from '../vuex/store/profile';
import javgAdvisers from './mock_data/advisers/javerage.json';
import inactiveAdvisers from './mock_data/advisers/jbot.json';
import javgProfile from './mock_data/profile/javerage.json';
import jintProfile from './mock_data/profile/jinter.json';

import AssignedAdviserCard from '../components/academics/adviser.vue';
import UwCard from '../components/_templates/card.vue';
Expand Down Expand Up @@ -38,7 +39,7 @@ describe('Assigned Adviser Card', () => {
});
});

it('Show Assigned Adviser card for undergrad (javerage)', async () => {
it('Show Adviser card for undergrad (javerage)', async () => {
axios.get.mockImplementation((url) => {
const urlData = {
'/api/v1/advisers/': javgAdvisers,
Expand All @@ -48,16 +49,16 @@ describe('Assigned Adviser Card', () => {
});
const wrapper = mount(AssignedAdviserCard, {store, localVue});
await new Promise(setImmediate);

expect(wrapper.vm.hasAdviser).toBe(true);
expect(wrapper.vm.hasProfile).toBe(true);
expect(wrapper.vm.showCard).toBe(true);
expect(wrapper.findComponent(UwCard).exists()).toBe(true);
expect(wrapper.findAllComponents(UwCardProperty)).toHaveLength(2);
expect(wrapper.vm.showCard).toBe(true);
expect(wrapper.vm.isUndergrad).toBe(true);
expect(wrapper.vm.hasMajors).toBe(true);
expect(wrapper.vm.hasMinors).toBe(true);
});

it('Show card but no Assigned Adviser (jbot)', async () => {
it('Show card has profile but no Assigned Adviser (jbot)', async () => {
axios.get.mockImplementation((url) => {
const urlData = {
'/api/v1/advisers/': inactiveAdvisers,
Expand All @@ -67,28 +68,44 @@ describe('Assigned Adviser Card', () => {
});
const wrapper = mount(AssignedAdviserCard, { store, localVue });
await new Promise(setImmediate);

expect(wrapper.findComponent(UwCard).exists()).toBe(true);
expect(wrapper.findAllComponents(UwCardProperty)).toHaveLength(2);
expect(wrapper.vm.showCard).toBe(true);
expect(wrapper.vm.advisers.length).toBe(0);
expect(wrapper.vm.hasAdviser).toBe(false);
expect(wrapper.vm.hasProfile).toBe(true);
expect(wrapper.vm.hasMajors).toBe(true);
expect(wrapper.vm.hasMinors).toBe(true);
expect(wrapper.findComponent(UwCard).exists()).toBe(true);
expect(wrapper.findAllComponents(UwCardProperty)).toHaveLength(2);
});

it('Hide Assigned Adviser card if not undergrad', async () => {
it('Hide Adviser card if not undergrad', async () => {
store.state.user.affiliations.undergrad = false;
const wrapper = mount(AssignedAdviserCard, {store, localVue});
await new Promise(setImmediate);
expect(wrapper.vm.showCard).toBe(false);
});

it('Hide Assigned Adviser card if is a student employee and grad', async () => {
it('Hide Adviser card if is a student employee and grad', async () => {
store.state.user.affiliations.stud_employee = true;
store.state.user.affiliations.grad = true;
store.state.user.affiliations.undergrad = false;
const wrapper = mount(AssignedAdviserCard, { store, localVue });
await new Promise(setImmediate);
expect(wrapper.vm.shouldLoad).toBe(false);
expect(wrapper.vm.showCard).toBe(false);
});

it('Hide Adviser card if class level is not desired', async () => {
axios.get.mockImplementation((url) => {
const urlData = {
'/api/v1/advisers/': inactiveAdvisers,
'/api/v1/profile/': jintProfile,
};
return Promise.resolve({ data: urlData[url] });
});
const wrapper = mount(AssignedAdviserCard, { store, localVue });
await new Promise(setImmediate);
expect(wrapper.vm.hasProfile).toBe(false);
expect(wrapper.vm.showContent).toBe(false);
expect(wrapper.vm.showCard).toBe(false);
});

Expand All @@ -105,8 +122,8 @@ describe('Assigned Adviser Card', () => {
const wrapper = mount(AssignedAdviserCard, {store, localVue});
await new Promise(setImmediate);
expect(wrapper.vm.showCard).toBe(true);
expect(wrapper.vm.isReadyAdvisers).toBe(false);
expect(wrapper.vm.isReadyProfile).toBe(true);
expect(wrapper.vm.hasAdviser).toBe(false);
expect(wrapper.vm.hasProfile).toBe(true);
expect(wrapper.findComponent(UwCard).exists()).toBe(true);
expect(wrapper.vm.showError).toBe(false);
});
Expand All @@ -117,8 +134,9 @@ describe('Assigned Adviser Card', () => {
});
const wrapper = mount(AssignedAdviserCard, {store, localVue});
await new Promise(setImmediate);
expect(wrapper.findComponent(UwCard).exists()).toBe(true);
expect(wrapper.vm.showError).toBe(true);
expect(wrapper.vm.showCard).toBe(true);
expect(wrapper.findComponent(UwCard).exists()).toBe(true);
});

it('Hide error', async () => {
Expand All @@ -127,9 +145,9 @@ describe('Assigned Adviser Card', () => {
});
const wrapper = mount(AssignedAdviserCard, {store, localVue,});
await new Promise(setImmediate);
expect(wrapper.vm.showCard).toBe(true);
expect(wrapper.vm.showCard).toBe(false);
expect(wrapper.vm.showError).toBe(false);
expect(wrapper.vm.isReadyAdvisers).toBe(false);
expect(wrapper.vm.isReadyProfile).toBe(false);
expect(wrapper.vm.hasAdviser).toBe(false);
expect(wrapper.vm.hasProfile).toBe(false);
});
});
});
Loading