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

BC-4783 Migrate GET endpoints of school API #2847

Merged
merged 38 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1445aa6
Adjust StudentTeamCreation feature
dyedwiper Oct 4, 2023
c150097
Remove inMaintenanceSince prop from mock
dyedwiper Oct 4, 2023
ecca66b
Update school props
dyedwiper Nov 1, 2023
19a99af
Merge branch 'main' into bc-4783-migrate-school-get
dyedwiper Nov 2, 2023
314b606
Fix name of id prop
dyedwiper Nov 3, 2023
abf1d03
Add check in fetchFederalState
dyedwiper Nov 5, 2023
e205031
Remove console.log
dyedwiper Nov 6, 2023
18de461
Merge branch 'main' into bc-4783-migrate-school-get
dyedwiper Nov 6, 2023
01b09ae
Merge branch 'main' into bc-4783-migrate-school-get
dyedwiper Nov 17, 2023
c7b5d15
Merge branch 'main' into bc-4783-migrate-school-get
dyedwiper Nov 20, 2023
722ab99
Remove leftover version keys
dyedwiper Nov 20, 2023
28155e9
Merge branch 'main' into bc-4783-migrate-school-get
dyedwiper Nov 23, 2023
cbf5c93
Integrate new api (WIP)
dyedwiper Nov 23, 2023
b5bbaca
Fix import
dyedwiper Nov 23, 2023
9abef15
Merge branch 'main' into bc-4783-migrate-school-get
dyedwiper Nov 27, 2023
2f9fe8b
Fix setting of county
dyedwiper Nov 27, 2023
f0f3883
Update update of systems
dyedwiper Nov 27, 2023
e4edb6c
Adjust systems getter
dyedwiper Nov 27, 2023
beb975f
Fix unit test of general settings
dyedwiper Nov 27, 2023
aee966a
Update api client
dyedwiper Nov 28, 2023
31954ec
Remove defaultYear from YearsResponse
dyedwiper Nov 28, 2023
fcf24c8
Update schoolYearResponseFactory
dyedwiper Nov 28, 2023
d758c74
Add id back to county
dyedwiper Nov 28, 2023
9d370ed
Fix mapping of enableStudentTeamCreation
dyedwiper Nov 28, 2023
b0dde2f
Update api client
dyedwiper Dec 4, 2023
30592a7
Remove populated systems from school response
dyedwiper Dec 6, 2023
d7a55f1
Merge branch 'main' into bc-4783-migrate-school-get
uidp Dec 13, 2023
bba4ed9
Update api client
dyedwiper Dec 13, 2023
8ce30bc
Fix calls of api methods
dyedwiper Dec 13, 2023
2acd514
Fix school mock
dyedwiper Dec 13, 2023
9c60ffb
Replace string by enum value
dyedwiper Dec 13, 2023
a7180a5
Merge branch 'main' into bc-4783-migrate-school-get
dyedwiper Dec 14, 2023
38a24c1
Merge branch 'main' into bc-4783-migrate-school-get
dyedwiper Dec 15, 2023
b0294b1
Update api client
dyedwiper Dec 15, 2023
661a31d
Update api client
dyedwiper Dec 15, 2023
f7d2332
Merge branch 'main' into bc-4783-migrate-school-get
dyedwiper Dec 15, 2023
448e975
Fix api client
dyedwiper Dec 15, 2023
af6b7b0
Merge branch 'main' into bc-4783-migrate-school-get
bergatco Dec 19, 2023
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
66 changes: 26 additions & 40 deletions src/components/organisms/administration/GeneralSettings.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,45 @@ import EnvConfigModule from "@/store/env-config";
import AuthModule from "@/store/auth";

const school = {
_id: { $oid: "5f2987e020834114b8efd6f8" },
id: "5f2987e020834114b8efd6f8",
name: "Paul-Gerhardt-Gymnasium",
federalState: { $oid: "0000b186816abba584714c53" },
federalState: {
id: "0000b186816abba584714c53",
counties: [
{
id: "5fa55eb53f472a2d986c8812",
antaresKey: "BRB",
countyId: 12051,
name: "Brandenburg an der Havel",
},
{
id: "5fa55eb53f472a2d986c8813",
antaresKey: "CB",
countyId: 12052,
name: "Cottbus",
},
],
name: "Brandenburg",
abbreviation: "BB",
},
county: {
id: "5fa55eb53f472a2d986c8812",
antaresKey: "BRB",
_id: { $oid: "5fa55eb53f472a2d986c8812" },
countyId: 12051,
name: "Brandenburg an der Havel",
},
systems: [{ $oid: "0000d186816abba584714c90" }],
updatedAt: { $date: "2020-07-27T08:21:14.719Z" },
createdAt: { $date: "2017-01-01T00:06:37.148Z" },
currentYear: {
_id: { $oid: "5ebd6dc14a431f75ec9a3e77" },
id: "5ebd6dc14a431f75ec9a3e77",
name: "2021/22",
startDate: "2021-08-01T00:00:00.000Z",
endDate: "2022-07-31T00:00:00.000Z",
},
purpose: "demo",
enableStudentTeamCreation: false,
officialSchoolNumber: "123",
};

const federalState = {
_id: "0000b186816abba584714c53",
counties: [
{
antaresKey: "BRB",
_id: "5fa55eb53f472a2d986c8812",
countyId: 12051,
name: "Brandenburg an der Havel",
},
{
antaresKey: "CB",
_id: "5fa55eb53f472a2d986c8813",
countyId: 12052,
name: "Cottbus",
},
],
name: "Brandenburg",
abbreviation: "BB",
};

const syncedSystem = [
{
_id: "0000d186816abba584714c90",
Expand Down Expand Up @@ -112,8 +108,8 @@ const mockData = {
},
},
county: {
id: "5fa55eb53f472a2d986c8813",
antaresKey: "CB",
_id: "5fa55eb53f472a2d986c8813",
countyId: 12052,
name: "Cottbus",
},
Expand All @@ -131,8 +127,6 @@ describe("GeneralSettings", () => {
});

schoolsModule.setSchool(school);
schoolsModule.setFederalState(federalState);
schoolsModule.setSystems(syncedSystem);

envConfigModule.setEnvs({
I18N__AVAILABLE_LANGUAGES: "de,en,es",
Expand Down Expand Up @@ -178,50 +172,42 @@ describe("GeneralSettings", () => {
});

it("should not be possible to edit the school name if the school is synced", async () => {
schoolsModule.setSystems(syncedSystem);
const wrapper = mount(GeneralSettings, {
...createComponentMocks({
i18n: true,
store: generateMockStore,
vuetify: true,
}),
});
await wrapper.setData(mockData);

const ele = wrapper.find(searchStrings.schoolName);
expect(ele.vm.disabled).toBeTruthy();
});

it("should be possible to edit the school name if the school is not synced", async () => {
schoolsModule.setSystems(unsyncedSystem);
const wrapper = mount(GeneralSettings, {
...createComponentMocks({
i18n: true,
store: generateMockStore,
vuetify: true,
}),
});
const localMockData = {
localSchool: {
...mockData.localSchool,
systems: [{ $oid: unsyncedSystem[0]._id }],
},
};
schoolsModule.setSystems(unsyncedSystem);
await wrapper.setData(localMockData);

const ele = wrapper.find(searchStrings.schoolName);
expect(ele.vm.disabled).toBeFalsy();
});

it("should be possible to edit the school name if the school is not attached to a system", async () => {
schoolsModule.setSystems([]);
const wrapper = mount(GeneralSettings, {
...createComponentMocks({
i18n: true,
store: generateMockStore,
vuetify: true,
}),
});
schoolsModule.setSystems([]);
await wrapper.setData(mockData);

const ele = wrapper.find(searchStrings.schoolName);
expect(ele.vm.disabled).toBeFalsy();
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/administration/GeneralSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"
:items="federalState.counties"
item-text="name"
item-value="_id"
item-value="id"
return-object
dense
:disabled="!!localSchool.county"
Expand Down Expand Up @@ -283,9 +283,9 @@ export default {
if (
!this.school.county &&
this.localSchool.county &&
this.localSchool.county._id
this.localSchool.county.id
) {
updatedSchool.county = this.localSchool.county._id;
updatedSchool.county = this.localSchool.county.id;
}

updatedSchool.logo_dataUrl = this.logoFile
Expand Down
1 change: 0 additions & 1 deletion src/pages/administration/ClassOverview.page.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ describe("ClassOverview", () => {
name: "2023/24",
} as Year,
lastYear: {} as Year,
defaultYear: {} as Year,
},
} as unknown as School,
...getters,
Expand Down
16 changes: 6 additions & 10 deletions src/pages/administration/SchoolSettings.page.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,18 @@ describe("SchoolSettingsPage", () => {
let schoolsModule: jest.Mocked<SchoolsModule>;

const mockFederalState: FederalState = {
_id: "00001234597947823",
id: "00001234597947823",
counties: [
{
antaresKey: "BRB",
_id: "00001234597998793",
id: "00001234597998793",
countyId: "12051",
antaresKey: "BRB",
countyId: 12051,
name: "Brandenburg an der Havel",
},
{
antaresKey: "CB",
_id: "00001234597913216",
id: "00001234597913216",
countyId: "12052",
antaresKey: "CB",
countyId: 12052,
name: "Cottbus",
},
],
Expand All @@ -62,7 +60,7 @@ describe("SchoolSettingsPage", () => {
getFederalState: mockFederalState,
getSystems: mockSystems,
getCurrentYear: {
_id: "123",
id: "123",
name: "School Year 3000",
startDate: "",
endDate: "",
Expand Down Expand Up @@ -181,12 +179,10 @@ describe("SchoolSettingsPage", () => {

it("should load needed data from server", async () => {
const fetchSystemsSpy = jest.spyOn(schoolsModule, "fetchSystems");
const fetchFederalStateSpy = jest.spyOn(schoolsModule, "fetchFederalState");

const wrapper = setup();
await wrapper.vm.$nextTick();

expect(fetchSystemsSpy).toHaveBeenCalled();
expect(fetchFederalStateSpy).toHaveBeenCalled();
});
});
6 changes: 2 additions & 4 deletions src/pages/administration/SchoolSettings.page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,18 @@ export default defineComponent({
]);

const school: ComputedRef<School> = computed(() => schoolsModule.getSchool);

watch(
school,
(newSchool, oldSchool) => {
// fetch school year and systems when the school is loaded
// fetch systems when the school is loaded
// if the school object gets a new reference (e.g. after updating it) do not reload the year or systems
if (
!schoolsModule.getFederalState ||
!schoolsModule.getFederalState._id ||
!schoolsModule.systems ||
!schoolsModule.systems.length ||
(newSchool && newSchool.id && (!oldSchool || !oldSchool.id))
) {
schoolsModule.fetchSystems();
schoolsModule.fetchFederalState();
}
},
{ immediate: true }
Expand Down
47 changes: 17 additions & 30 deletions src/pages/administration/migration.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ const getWrapperShallow: any = (props: object, options?: object) => {
};

const schoolMock = {
_id: "5f2987e020834114b8efd6f8",
id: "5f2987e020834114b8efd6f8",
dyedwiper marked this conversation as resolved.
Show resolved Hide resolved
name: "Schule_100000",
fileStorageType: "awsS3",
federalState: "0000b186816abba584714c53",
federalState: {
id: "0000b186816abba584714c53",
counties: [],
name: "",
abbreviation: "",
logoUrl: "",
},
logo_name: "Schule_logo",
county: {
id: "5fa55eb53f472a2d986c8812",
antaresKey: "BRB",
_id: "5fa55eb53f472a2d986c8812",
countyId: "12051",
countyId: 12051,
name: "Brandenburg an der Havel",
id: "5fa55eb53f472a2d986c8812",
},
systems: [
"0000d186816abba584714c91",
"0000d186816abba584714c90",
"6204fb6dcd5e9eb7240bc93f",
],
updatedAt: "2022-02-10T11:56:22.817Z",
createdAt: "2017-01-01T00:06:37.148Z",
currentYear: {
_id: "5ebd6dc14a431f75ec9a3e77",
id: "5ebd6dc14a431f75ec9a3e77",
name: "2021/22",
startDate: "2021-08-01T00:00:00.000Z",
endDate: "2022-07-31T00:00:00.000Z",
Expand All @@ -75,62 +75,49 @@ const schoolMock = {
ldapUniventionMigrationSchool: false,
showOutdatedUsers: false,
enableLdapSyncDuringMigration: false,
isTeamCreationByStudentsEnabled: false,
nextcloud: false,
oauthProvisioningEnabled: false,
},
enableStudentTeamCreation: false,
permissions: { teacher: { STUDENT_LIST: true } },
officialSchoolNumber: "100000",
documentBaseDirType: "",
inMaintenanceSince: "2022-02-10T11:55:50.344Z",
inUserMigration: true,
ldapSchoolIdentifier: "100000",
inMaintenance: true,
documentBaseDir: "https://s3.hidrive.strato.com/cloud-instances/default/",
isExternal: true,
id: "5f2987e020834114b8efd6f8",
years: {
schoolYears: [
{
_id: "5ebd6dc14a431f75ec9a3e77",
id: "5ebd6dc14a431f75ec9a3e77",
name: "2021/22",
startDate: "2021-08-01T00:00:00.000Z",
endDate: "2022-07-31T00:00:00.000Z",
},
{
_id: "5ebd6dc14a431f75ec9a3e78",
id: "5ebd6dc14a431f75ec9a3e78",
name: "2022/23",
startDate: "2022-08-01T00:00:00.000Z",
endDate: "2023-07-31T00:00:00.000Z",
},
],
activeYear: {
_id: "5ebd6dc14a431f75ec9a3e77",
name: "2021/22",
startDate: "2021-08-01T00:00:00.000Z",
endDate: "2022-07-31T00:00:00.000Z",
},
defaultYear: {
_id: "5ebd6dc14a431f75ec9a3e77",
id: "5ebd6dc14a431f75ec9a3e77",
name: "2021/22",
startDate: "2021-08-01T00:00:00.000Z",
endDate: "2022-07-31T00:00:00.000Z",
},
nextYear: {
_id: "5ebd6dc14a431f75ec9a3e78",
id: "5ebd6dc14a431f75ec9a3e78",
name: "2022/23",
startDate: "2022-08-01T00:00:00.000Z",
endDate: "2023-07-31T00:00:00.000Z",
},
lastYear: {
_id: "5d44297075e1502c27e405e2",
id: "5d44297075e1502c27e405e2",
name: "2020/21",
startDate: "2020-08-01T00:00:00.000Z",
endDate: "2021-07-31T00:00:00.000Z",
},
},
isTeamCreationByStudentsEnabled: false,
enableMigrationStart: false,
};

window.scrollTo = jest.fn();
Expand Down
Loading
Loading