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

N21 1264 new class page extension #2865

Merged
merged 22 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
67631af
add icons to new class view WIP
IgorCapCoder Oct 11, 2023
7ed64f7
add icons to new class view
IgorCapCoder Oct 12, 2023
b8eb162
cleanup
IgorCapCoder Oct 12, 2023
88e6897
functionality for action icons and new locales
IgorCapCoder Oct 12, 2023
123597c
Merge branch 'main' into N21-1264-new-class-page-extension
IgorCapCoder Oct 12, 2023
e7f16e7
unit test WIP
IgorCapCoder Oct 13, 2023
913be2e
Merge branch 'main' into N21-1264-new-class-page-extension
IgorCapCoder Oct 16, 2023
8ecf0df
Merge branch 'main' into N21-1264-new-class-page-extension
IgorCapCoder Oct 16, 2023
85650b7
unit tests, todos, merge main
IgorCapCoder Oct 16, 2023
177a6c4
Merge branch 'main' into N21-1264-new-class-page-extension
IgorCapCoder Oct 19, 2023
327d72a
request changes, merge main
IgorCapCoder Oct 19, 2023
3046fd7
request changes
IgorCapCoder Oct 19, 2023
8313be6
request changes
IgorCapCoder Oct 20, 2023
d3aa21d
Changes by mohlerki
IgorCapCoder Oct 20, 2023
b998d8d
finish tests
MarvinOehlerkingCap Oct 20, 2023
6378714
Merge branch 'main' into N21-1264-new-class-page-extension
MarvinOehlerkingCap Oct 20, 2023
4f9bd2b
Merge branch 'main' into N21-1264-new-class-page-extension
arnegns Oct 20, 2023
7b5b527
Merge remote-tracking branch 'origin/N21-1264-new-class-page-extensio…
arnegns Oct 20, 2023
bfd00cb
N21-1264 reloads page on deletion
arnegns Oct 20, 2023
f77d353
Merge branch 'main' into N21-1264-new-class-page-extension
arnegns Oct 20, 2023
0eba1b1
generate api
IgorCapCoder Oct 20, 2023
d2626c2
N21-1264 regenerate api
arnegns Oct 20, 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
2 changes: 2 additions & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@
"pages.administration.school.index.authSystems.delete": "{system} löschen",
"pages.administration.classes.index.title": "Klassen verwalten",
"pages.administration.classes.index.add": "Klasse hinzufügen",
"pages.administration.classes.deleteDialog.title": "Klasse löschen?",
"pages.administration.classes.deleteDialog.content": "\"Möchten Sie wirklich die Klasse '<i>{itemName}</i>' löschen?\"",
IgorCapCoder marked this conversation as resolved.
Show resolved Hide resolved
"pages.content._id.addToTopic": "Hinzufügen zu",
"pages.content._id.collection.selectElements": "Wählen Sie die Elemente, die Sie zum Thema hinzufügen möchten",
"pages.content._id.metadata.author": "Autor",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,8 @@
"pages.administration.school.index.authSystems.delete": "Delete {system}",
"pages.administration.classes.index.title": "Manage classes",
"pages.administration.classes.index.add": "Add class",
"pages.administration.classes.deleteDialog.title": "Delete class?",
"pages.administration.classes.deleteDialog.content": "\"Are you sure you want to delete class '<i>{itemName}<i>'?\"",
"pages.content._id.addToTopic": "To be added to",
"pages.content._id.collection.selectElements": "Select the items you want to add to the topic",
"pages.content._id.metadata.author": "Author",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@
"pages.administration.school.index.authSystems.delete": "Eliminar {system}",
"pages.administration.classes.index.title": "Administrar clases",
"pages.administration.classes.index.add": "Agregar clase",
"pages.administration.classes.deleteDialog.title": "¿Eliminar clase?",
"pages.administration.classes.deleteDialog.content": "\"¿Está seguro de que desea eliminar la clase '<i>{itemName}<i>'?\"",
"pages.content._id.addToTopic": "Para ser añadido a",
"pages.content._id.collection.selectElements": "Selecciona los elementos que deses añadir al tema",
"pages.content._id.metadata.author": "Autor",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@
"pages.administration.teachers.table.edit.ariaLabel": "Редагування вчителя",
"pages.administration.classes.index.title": "Керувати заняттями",
"pages.administration.classes.index.add": "Додати клас",
"pages.administration.classes.deleteDialog.title": "Видалити клас?",
"pages.administration.classes.deleteDialog.content": "\"Ви впевнені, що хочете видалити клас \"<i>{itemName}<i>\"?\"",
"pages.content._id.addToTopic": "Для додавання в",
"pages.content._id.collection.selectElements": "Виберіть елементи, які треба додати до теми",
"pages.content._id.metadata.author": "Автор",
Expand Down
276 changes: 275 additions & 1 deletion src/pages/administration/ClassOverview.page.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,26 @@ import createComponentMocks from "@@/tests/test-utils/componentMocks";
import Vue from "vue";
import { SortOrder } from "@/store/types/sort-order.enum";
import { Pagination } from "@/store/types/commons";
import setupStores from "../../../tests/test-utils/setupStores";
import AuthModule from "../../store/auth";
import { authModule } from "../../store";
IgorCapCoder marked this conversation as resolved.
Show resolved Hide resolved

const $router = {
push: jest.fn(),
};

describe("ClassOverview", () => {
const getWrapper = (getters: Partial<GroupModule> = {}) => {
document.body.setAttribute("data-app", "true");

const groupModule = createModuleMocks(GroupModule, {
getClasses: [classInfoFactory.build()],
getClasses: [
classInfoFactory.build(),
classInfoFactory.build({
externalSourceName: "",
isUpgradable: true,
}),
],
getPagination: {
limit: 10,
skip: 0,
Expand All @@ -31,6 +44,7 @@ describe("ClassOverview", () => {
[I18N_KEY.valueOf()]: i18nMock,
[GROUP_MODULE_KEY.valueOf()]: groupModule,
},
mocks: { $router },
});

return {
Expand All @@ -39,6 +53,13 @@ describe("ClassOverview", () => {
};
};

beforeEach(() => {
$router.push.mockReset();
setupStores({
authModule: AuthModule,
});
});

afterEach(() => {
jest.clearAllMocks();
});
Expand Down Expand Up @@ -202,4 +223,257 @@ describe("ClassOverview", () => {
});
});
});

MarvinOehlerkingCap marked this conversation as resolved.
Show resolved Hide resolved
describe("action icons", () => {
describe("when classes are available", () => {
IgorCapCoder marked this conversation as resolved.
Show resolved Hide resolved
const setup = () => {
authModule.addUserPermmission("CLASS_EDIT");

const { wrapper } = getWrapper();

return {
wrapper,
};
};

it("should render 4 icons", () => {
const { wrapper } = setup();

const manageIcon = wrapper.find(
'[data-testid="class-table-manage-icon"]'
);

const editIcon = wrapper.find('[data-testid="class-table-edit-icon"]');

const deleteIcon = wrapper.find(
'[data-testid="class-table-delete-icon"]'
);

const successorIcon = wrapper.find(
'[data-testid="class-table-successor-icon"]'
);

expect(manageIcon.exists()).toBeTruthy();
expect(editIcon.exists()).toBeTruthy();
expect(deleteIcon.exists()).toBeTruthy();
expect(successorIcon.exists()).toBeTruthy();
});
});

describe("when no classes are available", () => {
const setup = () => {
authModule.addUserPermmission("CLASS_EDIT");

const { wrapper } = getWrapper({
getClasses: [classInfoFactory.build()],
});

return {
wrapper,
};
};

it("should not render any icons", () => {
const { wrapper } = setup();

const manageIcon = wrapper.find(
'[data-testid="class-table-manage-icon"]'
);

const editIcon = wrapper.find('[data-testid="class-table-edit-icon"]');

const deleteIcon = wrapper.find(
'[data-testid="class-table-delete-icon"]'
);

const successorIcon = wrapper.find(
'[data-testid="class-table-successor-icon"]'
);

expect(manageIcon.exists()).toBeFalsy();
expect(editIcon.exists()).toBeFalsy();
expect(deleteIcon.exists()).toBeFalsy();
expect(successorIcon.exists()).toBeFalsy();
});
});

describe("when clicking on the manage class icon", () => {
const setup = () => {
authModule.addUserPermmission("CLASS_EDIT");

const { wrapper, groupModule } = getWrapper();

const classId: string = groupModule.getClasses[1].id;

return {
wrapper,
classId,
};
};

it("should redirect to legacy class manage page", async () => {
const { wrapper, classId } = setup();

await wrapper
.find('[data-testid="class-table-manage-icon"]')
.trigger("click");

expect($router.push).toHaveBeenCalledWith({
path: `/administration/classes/${classId}/manage`,
});
});
});

describe("when clicking on the edit class icon", () => {
const setup = () => {
authModule.addUserPermmission("CLASS_EDIT");

const { wrapper, groupModule } = getWrapper();

const classId: string = groupModule.getClasses[1].id;

return {
wrapper,
classId,
};
};

it("should redirect to legacy class edit page", async () => {
const { wrapper, classId } = setup();

await wrapper
.find('[data-testid="class-table-edit-icon"]')
.trigger("click");

expect($router.push).toHaveBeenCalledWith({
path: `/administration/classes/${classId}/edit`,
});
});
});

describe("when class is upgradable", () => {
describe("when clicking on the upgrade class icon", () => {
const setup = () => {
authModule.addUserPermmission("CLASS_EDIT");

const { wrapper, groupModule } = getWrapper();

const classId: string = groupModule.getClasses[1].id;

return {
wrapper,
classId,
};
};

it("should redirect to legacy class upgrade page", async () => {
const { wrapper, classId } = setup();

await wrapper
.find('[data-testid="class-table-successor-icon"]')
.trigger("click");

expect($router.push).toHaveBeenCalledWith({
path: `/administration/classes/${classId}/createSuccessor`,
});
});
});
});

describe("when class is not upgradable", () => {
const setup = () => {
authModule.addUserPermmission("CLASS_EDIT");

const { wrapper } = getWrapper({
getClasses: [
classInfoFactory.build({
externalSourceName: undefined,
isUpgradable: false,
}),
],
});

return {
wrapper,
};
};

it("should display the upgrade icon as disabled", () => {
const { wrapper } = setup();

const icon = wrapper.find('[data-testid="class-table-successor-icon"]');

expect(icon.attributes().disabled).toBe("disabled");
});
});

describe("when clicking on the delete class icon", () => {
const setup = () => {
authModule.addUserPermmission("CLASS_EDIT");

const { wrapper } = getWrapper();

return {
wrapper,
};
};

it("should open the delete dialog", async () => {
const { wrapper } = setup();

await wrapper
.find('[data-testid="class-table-delete-icon"]')
.trigger("click");

const dialog = wrapper.find('[data-testid="delete-dialog"]');

expect(dialog.exists()).toBeTruthy();
IgorCapCoder marked this conversation as resolved.
Show resolved Hide resolved
});
});

describe("when delete dialog is open", () => {
const setup = () => {
authModule.addUserPermmission("CLASS_EDIT");

const { wrapper, groupModule } = getWrapper();

return {
wrapper,
groupModule,
};
};

describe("when clicking on cancel button", () => {
it("should not delete class", async () => {
const { wrapper, groupModule } = setup();

await wrapper
.find('[data-testid="class-table-delete-icon"]')
.trigger("click");

const dialog = wrapper.find('[data-testid="delete-dialog"]');

await dialog.find('[data-testid="dialog-cancel"').trigger("click");

expect(groupModule.deleteClass).not.toHaveBeenCalled();
});
});

describe("when clicking on confirm button", () => {
it("should delete class", async () => {
const { wrapper, groupModule } = setup();

await wrapper
.find('[data-testid="class-table-delete-icon"]')
.trigger("click");

const dialog = wrapper.find('[data-testid="delete-dialog"]');

await dialog.find('[data-testid="dialog-confirm"').trigger("click");

expect(groupModule.deleteClass).toHaveBeenCalled();
});
});
});
});
});
Loading
Loading