@digabi/exam-engine-core 23.13.6 → 23.13.8-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/playwright/exam/AudioAnswer.test.d.ts +2 -0
- package/dist/__tests__/playwright/exam/AudioAnswer.test.d.ts.map +1 -0
- package/dist/__tests__/playwright/exam/AudioAnswer.test.js +111 -0
- package/dist/__tests__/playwright/exam/AudioAnswer.test.js.map +1 -0
- package/dist/__tests__/playwright/exam/AudioPlayer.test.d.ts +2 -0
- package/dist/__tests__/playwright/exam/AudioPlayer.test.d.ts.map +1 -0
- package/dist/__tests__/playwright/exam/AudioPlayer.test.js +70 -0
- package/dist/__tests__/playwright/exam/AudioPlayer.test.js.map +1 -0
- package/dist/__tests__/playwright/pages/AudioPlayer.page.d.ts +12 -0
- package/dist/__tests__/playwright/pages/AudioPlayer.page.d.ts.map +1 -0
- package/dist/__tests__/playwright/pages/AudioPlayer.page.js +15 -0
- package/dist/__tests__/playwright/pages/AudioPlayer.page.js.map +1 -0
- package/dist/__tests__/playwright/stories/exam/AudioAnswer.story.d.ts +5 -0
- package/dist/__tests__/playwright/stories/exam/AudioAnswer.story.d.ts.map +1 -0
- package/dist/__tests__/playwright/stories/exam/AudioAnswer.story.js +15 -0
- package/dist/__tests__/playwright/stories/exam/AudioAnswer.story.js.map +1 -0
- package/dist/__tests__/results/ResultsContext.test.js +1 -1
- package/dist/__tests__/tsconfig.tsbuildinfo +1 -1
- package/dist/components/context/AudioRecorderContext.d.ts +8 -0
- package/dist/components/context/AudioRecorderContext.d.ts.map +1 -0
- package/dist/components/context/AudioRecorderContext.js +7 -0
- package/dist/components/context/AudioRecorderContext.js.map +1 -0
- package/dist/components/exam/AudioAnswer.d.ts +4 -1
- package/dist/components/exam/AudioAnswer.d.ts.map +1 -1
- package/dist/components/exam/AudioAnswer.js +13 -19
- package/dist/components/exam/AudioAnswer.js.map +1 -1
- package/dist/components/exam/Exam.d.ts.map +1 -1
- package/dist/components/exam/Exam.js +2 -1
- package/dist/components/exam/Exam.js.map +1 -1
- package/dist/components/exam/internal/AudioRecorder.d.ts +2 -2
- package/dist/components/exam/internal/AudioRecorder.d.ts.map +1 -1
- package/dist/components/exam/internal/AudioRecorder.js +65 -31
- package/dist/components/exam/internal/AudioRecorder.js.map +1 -1
- package/dist/components/grading/GradingAnswer.d.ts.map +1 -1
- package/dist/components/grading/GradingAnswer.js +2 -1
- package/dist/components/grading/GradingAnswer.js.map +1 -1
- package/dist/components/results/AudioAnswer.d.ts.map +1 -1
- package/dist/components/results/AudioAnswer.js +2 -1
- package/dist/components/results/AudioAnswer.js.map +1 -1
- package/dist/components/shared/Audio.d.ts.map +1 -1
- package/dist/components/shared/Audio.js +2 -2
- package/dist/components/shared/Audio.js.map +1 -1
- package/dist/components/shared/internal/AudioPlayer.d.ts +9 -0
- package/dist/components/shared/internal/AudioPlayer.d.ts.map +1 -0
- package/dist/components/shared/internal/AudioPlayer.js +77 -0
- package/dist/components/shared/internal/AudioPlayer.js.map +1 -0
- package/dist/components/shared/internal/RestrictedAudioPlayer.d.ts.map +1 -1
- package/dist/components/shared/internal/RestrictedAudioPlayer.js +1 -1
- package/dist/components/shared/internal/RestrictedAudioPlayer.js.map +1 -1
- package/dist/i18n/fi-FI.d.ts +13 -3
- package/dist/i18n/fi-FI.d.ts.map +1 -1
- package/dist/i18n/fi-FI.js +13 -3
- package/dist/i18n/fi-FI.js.map +1 -1
- package/dist/i18n/sv-FI.d.ts.map +1 -1
- package/dist/i18n/sv-FI.js +13 -3
- package/dist/i18n/sv-FI.js.map +1 -1
- package/dist/main-bundle.js +2 -2
- package/dist/main.css +1 -1
- package/dist/types/ExamServerAPI.d.ts +2 -0
- package/dist/types/ExamServerAPI.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/__tests__/annotations.test.d.ts +0 -2
- package/dist/__tests__/annotations.test.d.ts.map +0 -1
- package/dist/__tests__/annotations.test.js +0 -217
- package/dist/__tests__/annotations.test.js.map +0 -1
- package/dist/assets/NotoMono.ttf +0 -0
- package/dist/assets/NotoSans-Bold.ttf +0 -0
- package/dist/assets/NotoSans-BoldItalic.ttf +0 -0
- package/dist/assets/NotoSans-Italic.ttf +0 -0
- package/dist/assets/NotoSans-Light.ttf +0 -0
- package/dist/assets/NotoSans-LightItalic.ttf +0 -0
- package/dist/assets/NotoSans-Regular.ttf +0 -0
- package/dist/assets/NotoSans-SemiBold.ttf +0 -0
- package/dist/assets/NotoSans-SemiBoldItalic.ttf +0 -0
- package/dist/assets/closeButton.svg +0 -1
- package/dist/assets/collapse.svg +0 -12
- package/dist/assets/expand.svg +0 -12
- package/dist/assets/helpButton.svg +0 -9
- package/dist/assets/redoButton.svg +0 -5
- package/dist/assets/undoButton.svg +0 -5
- package/dist/components/context/AudioContext.d.ts +0 -9
- package/dist/components/context/AudioContext.d.ts.map +0 -1
- package/dist/components/context/AudioContext.js +0 -9
- package/dist/components/context/AudioContext.js.map +0 -1
- package/dist/components/exam/ExamineExam.d.ts +0 -5
- package/dist/components/exam/ExamineExam.d.ts.map +0 -1
- package/dist/components/exam/ExamineExam.js +0 -20
- package/dist/components/exam/ExamineExam.js.map +0 -1
- package/dist/components/grading/examAnnotationUtils.d.ts +0 -4
- package/dist/components/grading/examAnnotationUtils.d.ts.map +0 -1
- package/dist/components/grading/examAnnotationUtils.js +0 -51
- package/dist/components/grading/examAnnotationUtils.js.map +0 -1
- package/dist/components/shared/AnnotatableText.d.ts +0 -7
- package/dist/components/shared/AnnotatableText.d.ts.map +0 -1
- package/dist/components/shared/AnnotatableText.js +0 -73
- package/dist/components/shared/AnnotatableText.js.map +0 -1
- package/dist/components/shared/AnnotationPopup.d.ts +0 -3
- package/dist/components/shared/AnnotationPopup.d.ts.map +0 -1
- package/dist/components/shared/AnnotationPopup.js +0 -74
- package/dist/components/shared/AnnotationPopup.js.map +0 -1
- package/dist/components/shared/internal/AudioPlaybackError.d.ts +0 -8
- package/dist/components/shared/internal/AudioPlaybackError.d.ts.map +0 -1
- package/dist/components/shared/internal/AudioPlaybackError.js +0 -17
- package/dist/components/shared/internal/AudioPlaybackError.js.map +0 -1
- package/dist/components/surround.d.ts +0 -8
- package/dist/components/surround.d.ts.map +0 -1
- package/dist/components/surround.js +0 -19
- package/dist/components/surround.js.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AudioAnswer.test.d.ts","sourceRoot":"","sources":["../../../../__tests__/playwright/exam/AudioAnswer.test.tsx"],"names":[],"mappings":""}
|
@@ -0,0 +1,111 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const react_1 = __importDefault(require("react"));
|
7
|
+
const experimental_ct_react_1 = require("@playwright/experimental-ct-react");
|
8
|
+
const AudioAnswer_story_1 = require("../stories/exam/AudioAnswer.story");
|
9
|
+
const exam_engine_mastering_1 = require("@digabi/exam-engine-mastering");
|
10
|
+
const AudioPlayer_page_1 = require("../pages/AudioPlayer.page");
|
11
|
+
const RECORD = 'Äänitä vastaus';
|
12
|
+
const STOP = 'Lopeta äänitys';
|
13
|
+
const DELETE = 'Poista äänitteesi';
|
14
|
+
experimental_ct_react_1.test.describe('AudioAnswer', () => {
|
15
|
+
let component;
|
16
|
+
experimental_ct_react_1.test.beforeEach(async ({ mount }) => {
|
17
|
+
const results = await (0, exam_engine_mastering_1.masterExam)(audioXml, () => '', getMediaMetadata);
|
18
|
+
const examXml = results[0].xml;
|
19
|
+
component = await mount(react_1.default.createElement(AudioAnswer_story_1.AudioAnswerStory, { examXml: examXml }));
|
20
|
+
});
|
21
|
+
(0, experimental_ct_react_1.test)('contains only button to start recording', async () => {
|
22
|
+
await expectStartRecordingButtonToBeVisible();
|
23
|
+
});
|
24
|
+
(0, experimental_ct_react_1.test)('clicking start button starts recording', async () => {
|
25
|
+
await startRecording();
|
26
|
+
await expectStopRecordingButtonToBeVisible();
|
27
|
+
});
|
28
|
+
(0, experimental_ct_react_1.test)('clicking stop button after start stops recording and shows player for the recording', async () => {
|
29
|
+
await startRecording();
|
30
|
+
await expectTimeElapsed('0:02');
|
31
|
+
await stopRecording();
|
32
|
+
await expectAudioPlayerToBeVisible();
|
33
|
+
});
|
34
|
+
(0, experimental_ct_react_1.test)('recording shows time elapsed', async () => {
|
35
|
+
await startRecording();
|
36
|
+
await expectTimeElapsed('0:01');
|
37
|
+
await expectTimeElapsed('0:02');
|
38
|
+
await expectTimeElapsed('0:03');
|
39
|
+
await stopRecording();
|
40
|
+
});
|
41
|
+
(0, experimental_ct_react_1.test)('recorded audio can be deleted', async () => {
|
42
|
+
await startRecording();
|
43
|
+
await expectTimeElapsed('0:03');
|
44
|
+
await stopRecording();
|
45
|
+
await expectDeleteRecordingButtonToBeVisible();
|
46
|
+
await deleteRecording();
|
47
|
+
await expectStartRecordingButtonToBeVisible();
|
48
|
+
});
|
49
|
+
(0, experimental_ct_react_1.test)('recording is available for one audio recorder at the time', async () => {
|
50
|
+
await startRecording();
|
51
|
+
await expectTimeElapsed('0:01');
|
52
|
+
await expectAlreadyRecordingError(1);
|
53
|
+
});
|
54
|
+
async function expectButtonToBeVisible(name, nth) {
|
55
|
+
await (0, experimental_ct_react_1.expect)(component.getByTestId('audio-answer').nth(nth).getByRole('button', { name })).toBeVisible();
|
56
|
+
}
|
57
|
+
async function expectStartRecordingButtonToBeVisible(nth = 0) {
|
58
|
+
await expectButtonToBeVisible(RECORD, nth);
|
59
|
+
}
|
60
|
+
async function expectStopRecordingButtonToBeVisible(nth = 0) {
|
61
|
+
await expectButtonToBeVisible(STOP, nth);
|
62
|
+
}
|
63
|
+
async function expectDeleteRecordingButtonToBeVisible(nth = 0) {
|
64
|
+
await expectButtonToBeVisible(DELETE, nth);
|
65
|
+
}
|
66
|
+
async function expectAudioPlayerToBeVisible(nth = 0) {
|
67
|
+
const audioPlayer = new AudioPlayer_page_1.AudioPlayerPage(component, nth);
|
68
|
+
await (0, experimental_ct_react_1.expect)(audioPlayer.baseLocator).toBeVisible();
|
69
|
+
}
|
70
|
+
async function expectAlreadyRecordingError(nth = 0) {
|
71
|
+
await (0, experimental_ct_react_1.expect)(component.getByTestId('audio-answer').nth(nth)).toContainText('Äänitys on käynnissä toisessa tehtävässä');
|
72
|
+
}
|
73
|
+
async function expectTimeElapsed(text, nth = 0) {
|
74
|
+
await (0, experimental_ct_react_1.expect)(component.getByTestId('audio-answer-time-elapsed').nth(nth)).toHaveText(text);
|
75
|
+
}
|
76
|
+
async function pushButton(name, nth) {
|
77
|
+
await component.getByTestId('audio-answer').nth(nth).getByRole('button', { name }).click();
|
78
|
+
}
|
79
|
+
async function startRecording(nth = 0) {
|
80
|
+
await expectButtonToBeVisible(RECORD, nth);
|
81
|
+
await pushButton(RECORD, nth);
|
82
|
+
}
|
83
|
+
async function stopRecording(nth = 0) {
|
84
|
+
await expectButtonToBeVisible(STOP, nth);
|
85
|
+
await pushButton(STOP, nth);
|
86
|
+
}
|
87
|
+
async function deleteRecording(nth = 0) {
|
88
|
+
await expectButtonToBeVisible(DELETE, nth);
|
89
|
+
await pushButton(DELETE, nth);
|
90
|
+
}
|
91
|
+
});
|
92
|
+
const getMediaMetadata = (_src, _type) => Promise.resolve({ duration: 999 });
|
93
|
+
const audioXml = `<e:exam xmlns:e="http://ylioppilastutkinto.fi/exam.xsd" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ylioppilastutkinto.fi/exam.xsd https://abitti.net/schema/exam.xsd" exam-schema-version="0.5">
|
94
|
+
<e:exam-versions>
|
95
|
+
<e:exam-version lang="fi-FI"/>
|
96
|
+
</e:exam-versions>
|
97
|
+
<e:exam-title>Exam</e:exam-title>
|
98
|
+
<e:exam-instruction/>
|
99
|
+
<e:table-of-contents/>
|
100
|
+
<e:section>
|
101
|
+
<e:section-title>Section</e:section-title>
|
102
|
+
<e:section-instruction/>
|
103
|
+
<e:question>
|
104
|
+
<e:question-title>Audiotehtävä</e:question-title>
|
105
|
+
<e:question-instruction />
|
106
|
+
<e:audio-answer max-score="5" />
|
107
|
+
<e:audio-answer max-score="5" />
|
108
|
+
</e:question>
|
109
|
+
</e:section>
|
110
|
+
</e:exam>`;
|
111
|
+
//# sourceMappingURL=AudioAnswer.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AudioAnswer.test.js","sourceRoot":"","sources":["../../../../__tests__/playwright/exam/AudioAnswer.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,6EAA6E;AAC7E,yEAAoE;AACpE,yEAA4E;AAC5E,gEAA2D;AAE3D,MAAM,MAAM,GAAG,gBAAgB,CAAA;AAC/B,MAAM,IAAI,GAAG,gBAAgB,CAAA;AAC7B,MAAM,MAAM,GAAG,mBAAmB,CAAA;AAElC,4BAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAChC,IAAI,SAAsB,CAAA;IAE1B,4BAAI,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAClC,MAAM,OAAO,GAAG,MAAM,IAAA,kCAAU,EAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAA;QACtE,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;QAC9B,SAAS,GAAG,MAAM,KAAK,CAAC,8BAAC,oCAAgB,IAAC,OAAO,EAAE,OAAO,GAAI,CAAC,CAAA;IACjE,CAAC,CAAC,CAAA;IAEF,IAAA,4BAAI,EAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,qCAAqC,EAAE,CAAA;IAC/C,CAAC,CAAC,CAAA;IAEF,IAAA,4BAAI,EAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,c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AE,CAAA;IAC5F,CAAC;IAED,KAAK,UAAU,cAAc,CAAC,MAAc,CAAC;QAC3C,MAAM,uBAAuB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QAC1C,MAAM,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,CAAC;IAED,KAAK,UAAU,aAAa,CAAC,MAAc,CAAC;QAC1C,MAAM,uBAAuB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACxC,MAAM,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAC7B,CAAC;IAED,KAAK,UAAU,eAAe,CAAC,MAAc,CAAC;QAC5C,MAAM,uBAAuB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QAC1C,MAAM,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,CAAC;AACH,CAAC,CAAC,CAAA;AAEF,MAAM,gBAAgB,GAAqB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAA;AAE9F,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;UAiBP,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AudioPlayer.test.d.ts","sourceRoot":"","sources":["../../../../__tests__/playwright/exam/AudioPlayer.test.tsx"],"names":[],"mappings":""}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const react_1 = __importDefault(require("react"));
|
7
|
+
const experimental_ct_react_1 = require("@playwright/experimental-ct-react");
|
8
|
+
const exam_engine_mastering_1 = require("@digabi/exam-engine-mastering");
|
9
|
+
const Exam_story_1 = require("../stories/exam/Exam.story");
|
10
|
+
const AudioPlayer_page_1 = require("../pages/AudioPlayer.page"); // Import the Page Object
|
11
|
+
const path_1 = __importDefault(require("path"));
|
12
|
+
const AUDIO_FILE_NAME = 'audio-5s.mp3';
|
13
|
+
// Renamed for clarity
|
14
|
+
const AUDIO_PLAYER_EXAM_XML = `<e:exam xmlns:e="http://ylioppilastutkinto.fi/exam.xsd" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ylioppilastutkinto.fi/exam.xsd https://abitti.dev/schema/exam.xsd" exam-schema-version="0.5">
|
15
|
+
<e:exam-versions>
|
16
|
+
<e:exam-version lang="fi-FI"/>
|
17
|
+
</e:exam-versions>
|
18
|
+
<e:exam-title>Uusi koe</e:exam-title>
|
19
|
+
<e:exam-instruction/>
|
20
|
+
<e:table-of-contents/>
|
21
|
+
<e:section>
|
22
|
+
<e:section-title/>
|
23
|
+
<e:section-instruction/>
|
24
|
+
<e:question>
|
25
|
+
<e:question-title/>
|
26
|
+
<e:question-instruction/>
|
27
|
+
<e:audio src="${AUDIO_FILE_NAME}"/>
|
28
|
+
</e:question>
|
29
|
+
</e:section>
|
30
|
+
</e:exam>`;
|
31
|
+
const test = experimental_ct_react_1.test.extend({
|
32
|
+
audioPlayerPage: async ({ page, mount }, use) => {
|
33
|
+
const resolveAttachment = (filename) => path_1.default.resolve(__dirname, '../data', filename);
|
34
|
+
const results = await (0, exam_engine_mastering_1.masterExam)(AUDIO_PLAYER_EXAM_XML, () => '', (0, exam_engine_mastering_1.getMediaMetadataFromLocalFile)(resolveAttachment));
|
35
|
+
const masteredExamXml = results[0];
|
36
|
+
await page.route(`**/attachments/${AUDIO_FILE_NAME}`, async (route) => {
|
37
|
+
await route.fulfill({
|
38
|
+
status: 200,
|
39
|
+
contentType: 'audio/mpeg',
|
40
|
+
path: path_1.default.resolve(__dirname, `../data/${AUDIO_FILE_NAME}`)
|
41
|
+
});
|
42
|
+
});
|
43
|
+
const mountResult = await mount(react_1.default.createElement(Exam_story_1.ExamStory, { masteredExam: masteredExamXml }));
|
44
|
+
const audioPlayerPageInstance = new AudioPlayer_page_1.AudioPlayerPage(mountResult);
|
45
|
+
await use(audioPlayerPageInstance);
|
46
|
+
}
|
47
|
+
});
|
48
|
+
test('all UI elements are visible and in correct state', async ({ audioPlayerPage }) => {
|
49
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.playPauseButton).toBeVisible();
|
50
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.playPauseButton).toHaveAttribute('aria-label', 'Toista äänite');
|
51
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.progressBar).toBeVisible();
|
52
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.progressBar).toHaveAttribute('aria-label', 'Aikajana');
|
53
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.progressBar).toHaveAttribute('aria-valuetext', '00:00/00:05');
|
54
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.progressBar).toHaveAttribute('style', /--range-progress: 0%/);
|
55
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.currentTimeDisplay).toHaveText('00:00');
|
56
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.durationDisplay).toHaveText('00:05');
|
57
|
+
});
|
58
|
+
test('player is in correct state after playing whole audio', async ({ page, audioPlayerPage }) => {
|
59
|
+
await audioPlayerPage.playPauseButton.click();
|
60
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.playPauseButton).toHaveAttribute('aria-label', 'Keskeytä äänite');
|
61
|
+
await page.waitForTimeout(6000);
|
62
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.currentTimeDisplay).toHaveText('00:05');
|
63
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.durationDisplay).toHaveText('00:05');
|
64
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.playPauseButton).toHaveAttribute('aria-label', 'Toista äänite');
|
65
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.progressBar).toHaveValue(/5\.\d*/);
|
66
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.progressBar).toHaveAttribute('aria-label', 'Aikajana');
|
67
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.progressBar).toHaveAttribute('aria-valuetext', '00:05/00:05');
|
68
|
+
await (0, experimental_ct_react_1.expect)(audioPlayerPage.progressBar).toHaveAttribute('style', /--range-progress: 100%/);
|
69
|
+
});
|
70
|
+
//# sourceMappingURL=AudioPlayer.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AudioPlayer.test.js","sourceRoot":"","sources":["../../../../__tests__/playwright/exam/AudioPlayer.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,6EAA4E;AAC5E,yEAAyF;AACzF,2DAAsD;AACtD,gEAA2D,CAAC,yBAAyB;AACrF,gDAAuB;AAEvB,MAAM,eAAe,GAAG,cAAc,CAAA;AACtC,sBAAsB;AACtB,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;4BAaF,eAAe;;;UAGjC,CAAA;AAMV,MAAM,IAAI,GAAG,4BAAQ,CAAC,MAAM,CAAiB;IAC3C,eAAe,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;QAC9C,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;QAE5F,MAAM,OAAO,GAAG,MAAM,IAAA,kCAAU,EAAC,qBAAqB,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,IAAA,qDAA6B,EAAC,iBAAiB,CAAC,CAAC,CAAA;QACnH,MAAM,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;QAElC,MAAM,IAAI,CAAC,KAAK,CAAC,kBAAkB,eAAe,EAAE,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YA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
4
|
+
readonly mountResult: MountResult;
|
5
|
+
readonly baseLocator: Locator;
|
6
|
+
readonly playPauseButton: Locator;
|
7
|
+
readonly progressBar: Locator;
|
8
|
+
readonly currentTimeDisplay: Locator;
|
9
|
+
readonly durationDisplay: Locator;
|
10
|
+
constructor(mountResult: MountResult, nth?: number);
|
11
|
+
}
|
12
|
+
//# sourceMappingURL=AudioPlayer.page.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AudioPlayer.page.d.ts","sourceRoot":"","sources":["../../../../__tests__/playwright/pages/AudioPlayer.page.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAEpE,qBAAa,eAAe;IAC1B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;IACjC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;IAC7B,SAAgB,eAAe,EAAE,OAAO,CAAA;IACxC,SAAgB,WAAW,EAAE,OAAO,CAAA;IACpC,SAAgB,kBAAkB,EAAE,OAAO,CAAA;IAC3C,SAAgB,eAAe,EAAE,OAAO,CAAA;gBAE5B,WAAW,EAAE,WAAW,EAAE,GAAG,GAAE,MAAU;CAQtD"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.AudioPlayerPage = void 0;
|
4
|
+
class AudioPlayerPage {
|
5
|
+
constructor(mountResult, nth = 0) {
|
6
|
+
this.mountResult = mountResult;
|
7
|
+
this.baseLocator = this.mountResult.getByTestId('audio-player-container').nth(nth);
|
8
|
+
this.playPauseButton = this.baseLocator.getByTestId('audio-player-play-pause-button');
|
9
|
+
this.progressBar = this.baseLocator.getByTestId('audio-player-progress-bar');
|
10
|
+
this.currentTimeDisplay = this.baseLocator.getByTestId('audio-player-current-time');
|
11
|
+
this.durationDisplay = this.baseLocator.getByTestId('audio-player-duration');
|
12
|
+
}
|
13
|
+
}
|
14
|
+
exports.AudioPlayerPage = AudioPlayerPage;
|
15
|
+
//# sourceMappingURL=AudioPlayer.page.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AudioPlayer.page.js","sourceRoot":"","sources":["../../../../__tests__/playwright/pages/AudioPlayer.page.tsx"],"names":[],"mappings":";;;AAGA,MAAa,eAAe;IAQ1B,YAAY,WAAwB,EAAE,MAAc,CAAC;QACnD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,wBAAwB,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAClF,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,gCAAgC,CAAC,CAAA;QACrF,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAAA;QAC5E,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAAA;QACnF,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAA;IAC9E,CAAC;CACF;AAhBD,0CAgBC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AudioAnswer.story.d.ts","sourceRoot":"","sources":["../../../../../__tests__/playwright/stories/exam/AudioAnswer.story.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,eAAO,MAAM,gBAAgB,GAAI,aAAa;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,sBAGhE,CAAA"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.AudioAnswerStory = void 0;
|
7
|
+
const react_1 = __importDefault(require("react"));
|
8
|
+
const src_1 = require("../../../../src");
|
9
|
+
const examServerApi_1 = require("../../../examServerApi");
|
10
|
+
const AudioAnswerStory = ({ examXml }) => {
|
11
|
+
const doc = new DOMParser().parseFromString(examXml, 'application/xml');
|
12
|
+
return react_1.default.createElement(src_1.Exam, { doc: doc, examServerApi: examServerApi_1.examServerApi });
|
13
|
+
};
|
14
|
+
exports.AudioAnswerStory = AudioAnswerStory;
|
15
|
+
//# sourceMappingURL=AudioAnswer.story.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AudioAnswer.story.js","sourceRoot":"","sources":["../../../../../__tests__/playwright/stories/exam/AudioAnswer.story.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,yCAAsC;AACtC,0DAAsD;AAE/C,MAAM,gBAAgB,GAAG,CAAC,EAAE,OAAO,EAAuB,EAAE,EAAE;IACnE,MAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAA;IACvE,OAAO,8BAAC,UAAI,IAAC,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,6BAAa,GAAI,CAAA;AACzD,CAAC,CAAA;AAHY,QAAA,gBAAgB,oBAG5B"}
|
@@ -145,7 +145,7 @@ describe(`Total score calculation for ${testExam}`, () => {
|
|
145
145
|
const choiceAnswer = {
|
146
146
|
type: 'choice',
|
147
147
|
questionId: 1,
|
148
|
-
value: '
|
148
|
+
value: '105',
|
149
149
|
displayNumber: '1.1'
|
150
150
|
};
|
151
151
|
expect((0, ResultsContext_1.calculateQuestionSumScore)(topLevelQuestions[0], result.gradingStructure, [], (0, lodash_es_1.keyBy)([choiceAnswer], 'questionId'))).toBe(3);
|