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-3475 - As a user, I want to add/edit alternative text to images #2790

Merged
merged 109 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
257c7fe
Call preview api for display of preview
bischofmax Aug 24, 2023
40c851c
Merge branch 'main' into BC-3465-display-previews
bischofmax Aug 24, 2023
063b3d0
Use fileProperties for footer
bischofmax Aug 24, 2023
6cfa827
Generate file storage client
bischofmax Aug 24, 2023
b9b84ef
Add notification for preview status
bischofmax Aug 24, 2023
fe57d7a
Refactor Alert
bischofmax Aug 24, 2023
c9f78bb
Show FileElement only to user with read permission if not blocked
bischofmax Aug 24, 2023
08c15bf
Fix conditional rendering of alert
bischofmax Aug 24, 2023
952cd5f
Revert "Show FileElement only to user with read permission if not blo…
bischofmax Aug 25, 2023
e7d695f
Merge branch 'main' into BC-3465-display-previews
bischofmax Aug 25, 2023
4f468c8
Remove fileRecordComposable and fix disaable of download button
bischofmax Aug 25, 2023
e8ac427
Add more translations
bischofmax Aug 28, 2023
7fd6d7a
Add reload status link
bischofmax Aug 28, 2023
dd5ed6a
Remove empty line
bischofmax Aug 28, 2023
6a7ef82
Add width param to convertDownloadToPreviewUrl
bischofmax Aug 28, 2023
0875ea6
Add href to alert
bischofmax Aug 28, 2023
1a047df
Fix tests
bischofmax Aug 28, 2023
457ac5c
Merge branch 'main' into BC-3465-display-previews
bischofmax Aug 28, 2023
a68be75
Merge branch 'main' into BC-3465-display-previews
bischofmax Aug 29, 2023
76060d1
Refactor file content element with new structure
bischofmax Aug 30, 2023
10d6ae5
Merge branch 'main' into BC-4590-refactor-filecontentelement
bischofmax Aug 30, 2023
9f22d19
Fix german translation
bischofmax Aug 31, 2023
d842356
Add margin right to progress bar to prevent conflict with 3dotmenu
bischofmax Aug 31, 2023
d4f0ca2
Add margin right to filepicker
bischofmax Aug 31, 2023
b8b93d0
Hide Details on v-file-input
bischofmax Aug 31, 2023
8400bbc
Adjust Image Display tests
bischofmax Aug 31, 2023
bd53f1d
align icons under each other
KalliSfak Aug 31, 2023
314097e
Merge branches 'BC-4590-refactor-filecontentelement' and 'BC-4590-ref…
KalliSfak Aug 31, 2023
c214cf9
fix test fileDisplay
KalliSfak Sep 1, 2023
efda07d
test for fileDisplay component
KalliSfak Sep 1, 2023
c7bf757
Add Default Display test
bischofmax Sep 4, 2023
15543f8
Remove unecessary questions marks
bischofmax Sep 4, 2023
ba8ba62
Add file content test
bischofmax Sep 4, 2023
622c74b
Merge branch 'main' into BC-4590-refactor-filecontentelement
bergatco Sep 4, 2023
13ecca0
Adjust tests for file content element
bischofmax Sep 4, 2023
d98c24a
Fix file and image display tests
bischofmax Sep 4, 2023
5f56ad4
Merge branch 'BC-4590-refactor-filecontentelement' of github.com:hpi-…
bischofmax Sep 4, 2023
1e0d578
Merge branch 'main' into BC-4590-refactor-filecontentelement
bergatco Sep 5, 2023
bb44f3d
BC-4590 - remove not needed `wrapper.overview`s
bergatco Sep 6, 2023
180002e
BC-4590 - fix unit test for `move-keyboard:edit` event
bergatco Sep 6, 2023
7ef2e17
Fix key down and up test
bischofmax Sep 6, 2023
6bed970
Remove unecessary computed value needsFileUpload
bischofmax Sep 6, 2023
e31f32d
Merge branch 'BC-4590-refactor-filecontentelement' of github.com:hpi-…
bischofmax Sep 6, 2023
b1ee349
BC-4590 - add / fix `move-keyboard:edit` event unit tests for `Submis…
bergatco Sep 6, 2023
68ee907
Merge branch 'main' into BC-4590-refactor-filecontentelement
bergatco Sep 6, 2023
da90ed0
Only show default display when preview url is undefined
bischofmax Sep 6, 2023
b555b5f
Merge branch 'BC-4590-refactor-filecontentelement' of github.com:hpi-…
bischofmax Sep 6, 2023
c1296b4
Fix Image Display Tests
bischofmax Sep 6, 2023
387841e
Use v-card components in stead of list components in default display
bischofmax Sep 6, 2023
1ce11fa
Revert "Use v-card components in stead of list components in default …
bischofmax Sep 6, 2023
99e9769
Change folder structure of file content element
bischofmax Sep 7, 2023
c08cdad
Rename FileContentElementAlert
bischofmax Sep 7, 2023
1b4b0ec
Rename FileContentElementChips
bischofmax Sep 7, 2023
9426b74
Fix imports
bischofmax Sep 7, 2023
eb14503
rename filecontentelementdownload
bischofmax Sep 7, 2023
7e92da8
Rename FileContentElementFooter
bischofmax Sep 7, 2023
c6e3a01
Fix test descriptions
bischofmax Sep 7, 2023
fdb7d99
Fix naming in test
bischofmax Sep 7, 2023
063c1bc
created alternativetext component
KalliSfak Sep 7, 2023
c0c99fc
added translations for alternative text
KalliSfak Sep 7, 2023
54dfded
add alternative text component to imagedisplay
KalliSfak Sep 7, 2023
b392836
added fileelementresponse
KalliSfak Sep 8, 2023
9201ec0
rename translation names
KalliSfak Sep 8, 2023
7d3d84f
add text for empty alt
KalliSfak Sep 8, 2023
ba5267e
check for empty alt
KalliSfak Sep 8, 2023
65fe479
move alt text component in filecontent
KalliSfak Sep 8, 2023
48f8ad3
add test for alternativetext component
KalliSfak Sep 8, 2023
2a19966
fix test
KalliSfak Sep 8, 2023
ac7415d
test for imagedisplay
KalliSfak Sep 8, 2023
25efee9
Add tests for alternative text
bischofmax Sep 11, 2023
4a4ea70
Add alternativeText to ImageDisplay test setup
bischofmax Sep 11, 2023
9d23d39
Merge branch 'main' into BC-3475-add-edit-alternative-text
bischofmax Sep 11, 2023
781a4b4
Remove div in image-display
bischofmax Sep 11, 2023
014e4ba
Remove css from filedownload
bischofmax Sep 11, 2023
de3085f
fix imagedisplay test
KalliSfak Sep 11, 2023
4c86459
added test for alt in filecontent
KalliSfak Sep 11, 2023
6d97089
added tests for filecontent component
KalliSfak Sep 11, 2023
6a4d83a
move to alternative-text folder
KalliSfak Sep 11, 2023
1155df6
fix path
KalliSfak Sep 11, 2023
cdc2f27
change to v-text-field
KalliSfak Sep 11, 2023
ef3cc5f
fix test for v-text-field
KalliSfak Sep 11, 2023
d3411e2
change to v-card-text
KalliSfak Sep 11, 2023
1cf0c61
BC-3475 - add panding
SevenWaysDP Sep 11, 2023
03157fc
Merge remote-tracking branch 'origin/main' into BC-3475-add-edit-alte…
SevenWaysDP Sep 11, 2023
c244bbf
BC-3475 - fix unit tests
bergatco Sep 12, 2023
a46d4e0
fix tests
KalliSfak Sep 12, 2023
2c7deab
Merge branch 'BC-3475-add-edit-alternative-text' of github.com:hpi-sc…
KalliSfak Sep 12, 2023
490c4f2
fix typo
KalliSfak Sep 12, 2023
0919ebe
fix tag
KalliSfak Sep 12, 2023
cd8f1de
BC-3475 - fix lint errors
SevenWaysDP Sep 12, 2023
5d11523
use v-textarea
KalliSfak Sep 13, 2023
0528206
change translation texts for hint
KalliSfak Sep 13, 2023
9b67a36
fix unit test
KalliSfak Sep 13, 2023
e4a0ca0
fix translations
KalliSfak Sep 13, 2023
ac20547
added persistent hint
KalliSfak Sep 13, 2023
7dfe5c0
fix unit test
KalliSfak Sep 14, 2023
c47014a
removed grey background
KalliSfak Sep 14, 2023
25d6dcc
Merge branch 'main' into BC-3475-add-edit-alternative-text
SevenWaysDP Sep 14, 2023
e1131fb
emit alternative text
KalliSfak Sep 15, 2023
0cedcbf
fix persistent hint error
KalliSfak Sep 15, 2023
a61d8a2
fix unit tests
KalliSfak Sep 15, 2023
0053a4e
added onUpdateAlternativeText function
KalliSfak Sep 19, 2023
0b14bf1
added data-testid
KalliSfak Sep 19, 2023
5a3981c
Merge branch 'main' of github.com:hpi-schul-cloud/nuxt-client into BC…
KalliSfak Sep 20, 2023
bb50ed3
fix conflict
KalliSfak Sep 20, 2023
2ed020e
fix test
KalliSfak Sep 20, 2023
87dc37a
Merge branch 'main' into BC-3475-add-edit-alternative-text
bischofmax Sep 21, 2023
a67526e
Merge branch 'main' into BC-3475-add-edit-alternative-text
bischofmax Sep 21, 2023
54519d5
Merge branch 'main' into BC-3475-add-edit-alternative-text
bischofmax Sep 21, 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
1 change: 1 addition & 0 deletions src/components/data-board/BoardApi.composable.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ describe("BoardApi.composable", () => {
type: ContentElementType.File,
content: {
caption: "caption",
alternativeText: "alternative text",
},
timestamps: timestampsResponseFactory.build(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ describe("FileContentElement", () => {
previewUrl: convertDownloadToPreviewUrl(fileRecordResponse.url),
size: fileRecordResponse.size,
previewStatus: fileRecordResponse.previewStatus,
element,
};

const { wrapper, deleteElementMock } = getWrapper({
Expand Down Expand Up @@ -600,6 +601,7 @@ describe("FileContentElement", () => {
previewUrl: convertDownloadToPreviewUrl(fileRecordResponse.url),
size: fileRecordResponse.size,
previewStatus: fileRecordResponse.previewStatus,
element,
};

const { wrapper, deleteElementMock } = getWrapper({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default defineComponent({
isDownloadAllowed: isDownloadAllowed(
fileRecord.value.securityCheckStatus
),
element: props.element,
};
});

Expand Down
231 changes: 180 additions & 51 deletions src/components/feature-board-file-element/content/FileContent.unit.ts
Original file line number Diff line number Diff line change
@@ -1,76 +1,205 @@
import { PreviewStatus } from "@/fileStorageApi/v3";
import { fileElementResponseFactory } from "@@/tests/test-utils";
import createComponentMocks from "@@/tests/test-utils/componentMocks";
import { shallowMount } from "@vue/test-utils";
import FileAlert from "./alert/FileAlert.vue";
import AlternativeText from "./alternative-text/AlternativeText.vue";
import FileContent from "./FileContent.vue";
import ContentElementFooter from "./footer/ContentElementFooter.vue";

describe("FileContent", () => {
const setup = () => {
document.body.setAttribute("data-app", "true");

const fileProperties = {
name: "test",
size: 100,
url: "test",
previewUrl: "test",
previewStatus: PreviewStatus.PREVIEW_POSSIBLE,
isDownloadAllowed: true,
};
const wrapper = shallowMount(FileContent, {
propsData: {
fileProperties,
isEditMode: true,
},
...createComponentMocks({}),
});
describe("When EditMode is true", () => {
describe("When PreviewUrl is defined", () => {
const setup = () => {
document.body.setAttribute("data-app", "true");

return {
wrapper,
fileProperties,
};
};
const element = fileElementResponseFactory.build();

it("should pass props to FileContent", () => {
const { wrapper, fileProperties } = setup();
const fileProperties = {
name: "test",
size: 100,
url: "test",
previewUrl: "test",
previewStatus: PreviewStatus.PREVIEW_POSSIBLE,
isDownloadAllowed: true,
element,
};
const wrapper = shallowMount(FileContent, {
propsData: {
fileProperties,
isEditMode: true,
},
...createComponentMocks({}),
});

const fileContent = wrapper.findComponent(FileContent);
return {
wrapper,
fileProperties,
};
};

expect(fileContent.props()).toEqual({
fileProperties,
isEditMode: true,
});
});
it("should pass props to FileContent", () => {
const { wrapper, fileProperties } = setup();

it("should pass props to ContentElementFooter", () => {
const { wrapper, fileProperties } = setup();
const fileContent = wrapper.findComponent(FileContent);

const contentElementFooter = wrapper.findComponent(ContentElementFooter);
expect(fileContent.props()).toEqual({
fileProperties,
isEditMode: true,
});
});

expect(contentElementFooter.props()).toEqual({
fileProperties,
});
});
it("should pass props to ContentElementFooter", () => {
const { wrapper, fileProperties } = setup();

it("Should pass props to FileAlert", () => {
const { wrapper, fileProperties } = setup();
const contentElementFooter =
wrapper.findComponent(ContentElementFooter);

const fileAlert = wrapper.findComponent(FileAlert);
expect(contentElementFooter.props()).toEqual({
fileProperties,
});
});

expect(fileAlert.props()).toEqual({
previewStatus: fileProperties.previewStatus,
});
});
it("Should pass props to FileAlert", () => {
const { wrapper, fileProperties } = setup();

const fileAlert = wrapper.findComponent(FileAlert);

expect(fileAlert.props()).toEqual({
previewStatus: fileProperties.previewStatus,
});
});

it("Should AlternativeText component be in dom", () => {
const { wrapper } = setup();

const alternativeText = wrapper.findComponent(AlternativeText);

describe("when alert emits on-status-reload", () => {
it("should emit delete event", async () => {
const { wrapper } = setup();
expect(alternativeText.exists()).toBe(true);
});

const fileAlert = wrapper.findComponent(FileAlert);
it("Should pass element to alternative text", () => {
const { wrapper, fileProperties } = setup();

await fileAlert.vm.$emit("on-status-reload");
const alternativeText = wrapper.findComponent(AlternativeText);

expect(alternativeText.props()).toEqual({
element: fileProperties.element,
});
});

describe("when alert emits on-status-reload", () => {
it("should emit delete event", async () => {
const { wrapper } = setup();

const fileAlert = wrapper.findComponent(FileAlert);

await fileAlert.vm.$emit("on-status-reload");

expect(wrapper.emitted("fetch:file")).toBeTruthy();
});
});
});

describe("When PreviewUrl is undefined", () => {
const setup = () => {
document.body.setAttribute("data-app", "true");

const element = fileElementResponseFactory.build();

const fileProperties = {
previewUrl: undefined,
element,
};
const wrapper = shallowMount(FileContent, {
propsData: {
fileProperties,
isEditMode: true,
},
...createComponentMocks({}),
});

return {
wrapper,
fileProperties,
};
};

it("Should AlternativeText component not be in dom", () => {
const { wrapper } = setup();

const alternativeText = wrapper.findComponent(AlternativeText);

expect(alternativeText.exists()).toBe(false);
});
});
});

describe("When EditMode is false", () => {
describe("When PreviewUrl is defined", () => {
const setup = () => {
document.body.setAttribute("data-app", "true");

const element = fileElementResponseFactory.build();

const fileProperties = {
previewUrl: "test",
element,
};
const wrapper = shallowMount(FileContent, {
propsData: {
fileProperties,
isEditMode: false,
},
...createComponentMocks({}),
});

return {
wrapper,
fileProperties,
};
};

it("Should AlternativeText component not be in dom", () => {
const { wrapper } = setup();

const alternativeText = wrapper.findComponent(AlternativeText);

expect(alternativeText.exists()).toBe(false);
});
});

expect(wrapper.emitted("fetch:file")).toBeTruthy();
describe("When PreviewUrl is undefined", () => {
const setup = () => {
document.body.setAttribute("data-app", "true");

const element = fileElementResponseFactory.build();

const fileProperties = {
previewUrl: undefined,
element,
};
const wrapper = shallowMount(FileContent, {
propsData: {
fileProperties,
isEditMode: false,
},
...createComponentMocks({}),
});

return {
wrapper,
fileProperties,
};
};

it("Should AlternativeText component not be in dom", () => {
const { wrapper } = setup();

const alternativeText = wrapper.findComponent(AlternativeText);

expect(alternativeText.exists()).toBe(false);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<template>
<div>
<FileDisplay :file-properties="fileProperties" :is-edit-mode="isEditMode" />
<AlternativeText
v-if="isEditMode && fileProperties.previewUrl"
:element="fileProperties.element"
/>
<ContentElementFooter :fileProperties="fileProperties" />
<FileAlert :previewStatus="previewStatus" @on-status-reload="onFetchFile" />
</div>
Expand All @@ -11,6 +15,7 @@ import { computed, defineComponent, PropType } from "vue";
import FileAlert from "../content/alert/FileAlert.vue";
import FileDisplay from "../content/display/FileDisplay.vue";
import { FileProperties } from "../shared/types/file-properties";
import AlternativeText from "./alternative-text/AlternativeText.vue";
import ContentElementFooter from "./footer/ContentElementFooter.vue";

export default defineComponent({
Expand All @@ -19,6 +24,7 @@ export default defineComponent({
FileDisplay,
ContentElementFooter,
FileAlert,
AlternativeText,
},
props: {
fileProperties: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { fileElementResponseFactory } from "@@/tests/test-utils";
import createComponentMocks from "@@/tests/test-utils/componentMocks";
import { shallowMount } from "@vue/test-utils";
import AlternativeText from "./AlternativeText.vue";

const alternativeText = "alt text";
jest.mock("@data-board", () => {
return {
useContentElementState: jest.fn(() => ({
modelValue: { alternativeText },
})),
};
});

describe("AlternativeText", () => {
const setup = () => {
document.body.setAttribute("data-app", "true");

const propsData = { element: fileElementResponseFactory.build() };

const wrapper = shallowMount(AlternativeText, {
propsData,
...createComponentMocks({}),
});

return {
wrapper,
};
};

it("should be found in dom", () => {
const { wrapper } = setup();

const fileContentElement = wrapper.findComponent(AlternativeText);

expect(fileContentElement.exists()).toBe(true);
});

it("should have the modelValue as value", async () => {
const { wrapper } = setup();

const textarea = wrapper.find("v-textarea-stub");

const valueAttribute = textarea.attributes("value");

expect(valueAttribute).toBe(alternativeText);
});

it("should have a hint translation", async () => {
const { wrapper } = setup();

const textarea = wrapper.find("v-textarea-stub");

const hint = textarea.attributes("hint");

expect(hint).toBe(
wrapper.vm.$i18n
.t("components.cardElement.fileElement.altDescription")
.toString()
);
});

it("should have a label translation", async () => {
const { wrapper } = setup();

const textarea = wrapper.find("v-textarea-stub");

const label = textarea.attributes("label");

expect(label).toBe(
wrapper.vm.$i18n
.t("components.cardElement.fileElement.alternativeText")
.toString()
);
});
});
Loading
Loading