feat(assessment): keep real attempts in fullscreen and protect the task text
This commit is contained in:
1 parent
56dcf32f8c
commit
efa41d5967
46 files changed
+1940
-72
No files matched your search
@@ -0,0 +1,69 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { AssessmentItem } from "../../../shared/api/schemas";
|
||||
import { AnswerForm } from "./answer-form";
|
||||
|
||||
const item = {
|
||||
id: "01928f7a-4a10-7b2c-9d3e-5f6a7b8c9d02",
|
||||
sequence: 1,
|
||||
prompt: "Выберите вариант",
|
||||
content: {
|
||||
format: "choice",
|
||||
multiple: false,
|
||||
options: [
|
||||
{ id: "a", text: "Первый вариант" },
|
||||
{ id: "b", text: "Второй вариант" },
|
||||
],
|
||||
},
|
||||
} satisfies AssessmentItem;
|
||||
|
||||
const numberItem = {
|
||||
id: "01928f7a-4a10-7b2c-9d3e-5f6a7b8c9d03",
|
||||
sequence: 2,
|
||||
prompt: "Сколько",
|
||||
content: { format: "number", unit: null },
|
||||
} satisfies AssessmentItem;
|
||||
|
||||
const practiceItem = {
|
||||
id: "01928f7a-4a10-7b2c-9d3e-5f6a7b8c9d04",
|
||||
sequence: 3,
|
||||
prompt: "Решите",
|
||||
content: {
|
||||
format: "practice",
|
||||
languages: ["python"],
|
||||
public_examples: [],
|
||||
max_source_length: 4096,
|
||||
},
|
||||
} satisfies AssessmentItem;
|
||||
|
||||
function render(concealed: boolean, answered: AssessmentItem = item): string {
|
||||
return renderToStaticMarkup(
|
||||
<AnswerForm
|
||||
attemptId="attempt"
|
||||
item={answered}
|
||||
isSaving={false}
|
||||
retryable={false}
|
||||
errorMessage={null}
|
||||
concealed={concealed}
|
||||
onSubmit={() => undefined}
|
||||
onRetry={() => undefined}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
describe("answer form", () => {
|
||||
it("shows the options and the submit button", () => {
|
||||
const markup = render(false);
|
||||
expect(markup).toContain("Первый вариант");
|
||||
expect(markup).toContain("Отправить ответ");
|
||||
});
|
||||
|
||||
it("renders nothing while concealed, so no option text stays in the page", () => {
|
||||
expect(render(true)).toBe("");
|
||||
});
|
||||
|
||||
it("marks only the code editor as a field where pasting is allowed", () => {
|
||||
expect(render(false, practiceItem)).toContain('data-paste="allowed"');
|
||||
expect(render(false, numberItem)).not.toContain("data-paste");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user