test(ckeditor5): add check for translation override

This commit is contained in:
Elian Doran 2025-06-18 14:44:44 +03:00
parent 93f544a221
commit 578310a1c0
No known key found for this signature in database
2 changed files with 39 additions and 21 deletions

View File

@ -11,31 +11,12 @@ export default defineConfig( {
svg() svg()
], ],
test: { test: {
browser: { environment: "happy-dom",
enabled: true,
name: 'chrome',
provider: 'webdriverio',
providerOptions: {},
headless: true,
ui: false
},
include: [ include: [
'tests/**/*.[jt]s' 'tests/**/*.[jt]s'
], ],
globals: true, globals: true,
watch: false, watch: false,
passWithNoTests: true, passWithNoTests: true
coverage: {
thresholds: {
lines: 100,
functions: 100,
branches: 100,
statements: 100
},
provider: 'istanbul',
include: [
'src'
]
}
} }
} ); } );

View File

@ -0,0 +1,37 @@
import { it } from "vitest";
import { describe } from "vitest";
import { ClassicEditor } from "../src/index.js";
import { type BalloonEditor, type ButtonView, type Editor } from "ckeditor5";
import { beforeEach } from "vitest";
import { expect } from "vitest";
describe("Text snippets", () => {
let editorElement: HTMLDivElement;
let editor: Editor;
beforeEach(async () => {
editorElement = document.createElement( 'div' );
document.body.appendChild( editorElement );
console.log("Trigger each");
editor = await ClassicEditor.create(editorElement, {
licenseKey: "GPL",
toolbar: {
items: [
"insertTemplate"
]
}
});
});
it("uses correct translations", () => {
const itemsWithButtonView = Array.from(editor.ui.view.toolbar?.items)
.filter(item => "buttonView" in item)
.map(item => (item.buttonView as ButtonView).label);
expect(itemsWithButtonView).not.toContain("Insert template");
expect(itemsWithButtonView).toContain("Insert text snippet");
});
});