Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions karma.fast.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const argv = require('minimist')(process.argv.slice(2));
const components = argv.components !== true && argv.components;
const testPathPattern = argv.testPathPattern !== true && argv.testPathPattern;
const testNamePattern = argv.testNamePattern !== true && argv.testNamePattern;
const runCoverage = typeof argv.coverage !== 'undefined';
const runFirefox = typeof argv.firefox !== 'undefined';
const runChrome = typeof argv.chrome !== 'undefined';
Expand Down Expand Up @@ -69,8 +71,13 @@ module.exports = function (config) {
plugins,
client: {
components: components,
testPathPattern: testPathPattern,
testNamePattern: testNamePattern,
clearContext: false,
captureConsole: true,
jasmine: {
grep: testNamePattern || null,
},
},
browsers: launcher,
files: ['tools/karma.test.all.js'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import type {

const LIST_ELEMENT_TAGS = ['UL', 'OL', 'LI'];
const LIST_ELEMENT_SELECTOR = LIST_ELEMENT_TAGS.join(',');
const END_OF_PARAGRAPH = 'EOP';
const SELECTED_CLASS = 'Selected';

interface WacContext extends DomToModelListFormat {
/**
Expand Down Expand Up @@ -77,7 +79,11 @@ const wacElementProcessor: ElementProcessor<HTMLElement> = (
return;
}

if (TEMP_ELEMENTS_CLASSES.some(className => element.classList.contains(className))) {
if (
TEMP_ELEMENTS_CLASSES.some(className => element.classList.contains(className)) ||
// This is needed to remove some temporary End of paragraph elements that WAC sometimes preserves
(element.classList.contains(SELECTED_CLASS) && element.classList.contains(END_OF_PARAGRAPH))
) {
return;
} else if (shouldClearListContext(elementTag, element, context)) {
const { listFormat } = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6112,4 +6112,69 @@ describe('wordOnlineHandler', () => {
true
);
});

it('Should skip elements with both Selected and EOP classes', () => {
runTest(
'<div>Hello<span class="Selected EOP"></span>World</div>',
'<div>HelloWorld</div>',
{
blockGroupType: 'Document',
blocks: [
{
blockType: 'Paragraph',
segments: [
{ segmentType: 'Text', text: 'Hello', format: {} },
{ segmentType: 'Text', text: 'World', format: {} },
],
format: {},
},
],
},
true
);
});

it('Should not skip elements with only Selected class', () => {
runTest(
'<div>Hello<span class="Selected">!</span>World</div>',
'<div>Hello!World</div>',
{
blockGroupType: 'Document',
blocks: [
{
blockType: 'Paragraph',
segments: [
{ segmentType: 'Text', text: 'Hello', format: {} },
{ segmentType: 'Text', text: '!', format: {} },
{ segmentType: 'Text', text: 'World', format: {} },
],
format: {},
},
],
},
true
);
});

it('Should not skip elements with only EOP class', () => {
runTest(
'<div>Hello<span class="EOP">!</span>World</div>',
'<div>Hello!World</div>',
{
blockGroupType: 'Document',
blocks: [
{
blockType: 'Paragraph',
segments: [
{ segmentType: 'Text', text: 'Hello', format: {} },
{ segmentType: 'Text', text: '!', format: {} },
{ segmentType: 'Text', text: 'World', format: {} },
],
format: {},
},
],
},
true
);
});
});
18 changes: 14 additions & 4 deletions tools/karma.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
module.exports = function (contexts) {
if (!!__karma__.config.components) {
const filenameWithoutTest = __karma__.config.components.replace('Test', '');
const filterRegExpByFilename = new RegExp(filenameWithoutTest);
const components = __karma__.config.components;
const testPathPattern = __karma__.config.testPathPattern;

if (!!components || !!testPathPattern) {
const pattern = testPathPattern || components.replace('Test', '');
const filterRegExpByFilename = new RegExp(pattern);
const specificFiles = [];

contexts.forEach(context => {
specificFiles.push(...context.keys().filter(path => filterRegExpByFilename.test(path)));
});

return specificFiles.map(context);
console.log(
'\n\nRunning test cases from ' +
specificFiles.length +
' files matching pattern: ' +
pattern
);

return specificFiles.map(file => contexts[0](file));
} else {
const specificFiles = [];

Expand Down
Loading