Skip to content

Commit 1637d18

Browse files
committed
Finished fixing browser tests
1 parent 904278f commit 1637d18

File tree

7 files changed

+39
-44
lines changed

7 files changed

+39
-44
lines changed

packages/less/Gruntfile.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ module.exports = function(grunt) {
8585
"relative-urls",
8686
"rewrite-urls",
8787
"browser",
88-
"no-js-errors",
89-
"legacy"
88+
"no-js-errors"
9089
];
9190

9291
function makeJob(testName) {

packages/less/test/browser/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ testErrorSheet = function (sheet) {
169169
errorTxt = errorTxt
170170
.replace(/\{path\}/g, '')
171171
.replace(/\{pathrel\}/g, '')
172-
.replace(/\{pathhref\}/g, 'http://localhost:8081/test/less/errors/')
172+
.replace(/\{pathhref\}/g, 'http://localhost:8081/packages/less/node_modules/@less/test-data/tests-error/eval/')
173173
.replace(/\{404status\}/g, ' (404)')
174174
.replace(/\{node\}[\s\S]*\{\/node\}/g, '')
175175
.replace(/\n$/, '')

packages/less/test/browser/generator/runner.config.js

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,32 @@ var { forceCovertToBrowserPath } = require('./utils');
44

55
/** Root of repo */
66
var testFolder = forceCovertToBrowserPath(path.dirname(resolve.sync('@less/test-data')));
7-
var lessFolder = forceCovertToBrowserPath(path.join(testFolder, 'less'));
7+
var testsUnitFolder = forceCovertToBrowserPath(path.join(testFolder, 'tests-unit'));
8+
var testsConfigFolder = forceCovertToBrowserPath(path.join(testFolder, 'tests-config'));
89
var localTests = forceCovertToBrowserPath(path.resolve(__dirname, '..'));
910

1011
module.exports = {
1112
main: {
1213
// src is used to build list of less files to compile
1314
src: [
14-
`${lessFolder}/_main/*.less`,
15-
`!${lessFolder}/_main/plugin-preeval.less`, // uses ES6 syntax
15+
`${testsUnitFolder}/*/*.less`,
16+
`!${testsUnitFolder}/plugin-preeval/plugin-preeval.less`, // uses ES6 syntax
1617
// Don't test NPM import, obviously
17-
`!${lessFolder}/_main/plugin-module.less`,
18-
`!${lessFolder}/_main/import-module.less`,
19-
`!${lessFolder}/_main/javascript.less`,
20-
`!${lessFolder}/_main/urls.less`,
21-
`!${lessFolder}/_main/empty.less`
18+
`!${testsUnitFolder}/plugin-module/plugin-module.less`,
19+
`!${testsUnitFolder}/import/import-module.less`,
20+
`!${testsUnitFolder}/javascript/javascript.less`,
21+
`!${testsUnitFolder}/urls/urls.less`,
22+
`!${testsUnitFolder}/empty/empty.less`,
23+
`!${testsUnitFolder}/color-functions/operations.less` // conflicts with operations/operations.less
2224
],
2325
options: {
2426
helpers: 'test/browser/runner-main-options.js',
2527
specs: 'test/browser/runner-main-spec.js',
2628
outfile: 'tmp/browser/test-runner-main.html'
2729
}
2830
},
29-
legacy: {
30-
src: [`${lessFolder}/legacy/*.less`],
31-
options: {
32-
helpers: 'test/browser/runner-legacy-options.js',
33-
specs: 'test/browser/runner-legacy-spec.js',
34-
outfile: 'tmp/browser/test-runner-legacy.html'
35-
}
36-
},
3731
strictUnits: {
38-
src: [`${lessFolder}/units/strict/*.less`],
32+
src: [`${testsConfigFolder}/units/strict/*.less`],
3933
options: {
4034
helpers: 'test/browser/runner-strict-units-options.js',
4135
specs: 'test/browser/runner-strict-units-spec.js',
@@ -44,8 +38,8 @@ module.exports = {
4438
},
4539
errors: {
4640
src: [
47-
`${lessFolder}/errors/*.less`,
48-
`${testFolder}/errors/javascript-error.less`,
41+
`${testFolder}/tests-error/eval/*.less`,
42+
`${testFolder}/tests-error/parse/*.less`,
4943
`${localTests}/less/errors/*.less`
5044
],
5145
options: {
@@ -56,7 +50,7 @@ module.exports = {
5650
}
5751
},
5852
noJsErrors: {
59-
src: [`${lessFolder}/no-js-errors/*.less`],
53+
src: [`${testsConfigFolder}/no-js-errors/*.less`],
6054
options: {
6155
helpers: 'test/browser/runner-no-js-errors-options.js',
6256
specs: 'test/browser/runner-no-js-errors-spec.js',
@@ -141,7 +135,7 @@ module.exports = {
141135
}
142136
},
143137
postProcessorPlugin: {
144-
src: [`${lessFolder}/postProcessorPlugin/*.less`],
138+
src: [`${testsConfigFolder}/postProcessorPlugin/*.less`],
145139
options: {
146140
helpers: [
147141
'test/plugins/postprocess/index.js',
@@ -153,7 +147,7 @@ module.exports = {
153147
}
154148
},
155149
preProcessorPlugin: {
156-
src: [`${lessFolder}/preProcessorPlugin/*.less`],
150+
src: [`${testsConfigFolder}/preProcessorPlugin/*.less`],
157151
options: {
158152
helpers: [
159153
'test/plugins/preprocess/index.js',
@@ -164,7 +158,7 @@ module.exports = {
164158
}
165159
},
166160
visitorPlugin: {
167-
src: [`${lessFolder}/visitorPlugin/*.less`],
161+
src: [`${testsConfigFolder}/visitorPlugin/*.less`],
168162
options: {
169163
helpers: [
170164
'test/plugins/visitor/index.js',
@@ -175,7 +169,7 @@ module.exports = {
175169
}
176170
},
177171
filemanagerPlugin: {
178-
src: [`${lessFolder}/filemanagerPlugin/*.less`],
172+
src: [`${testsConfigFolder}/filemanagerPlugin/*.less`],
179173
options: {
180174
helpers: [
181175
'test/plugins/filemanager/index.js',

packages/less/test/browser/generator/template.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,20 @@ module.exports = (stylesheets, helpers, spec, less) => {
2525
<!-- for each test, generate CSS/LESS link tags -->
2626
$${stylesheets.map(function(fullLessName) {
2727
var pathParts = fullLessName.split('/');
28-
var fullCssName = fullLessName
29-
.replace(/\/(browser|test-data)\/less\//g, '/$1/css/')
30-
.replace(/less$/, 'css')
28+
var fullCssName = fullLessName.replace(/less$/, 'css');
29+
30+
// Check if the CSS file exists in the same directory as the LESS file
31+
var fs = require('fs');
32+
var cssExists = fs.existsSync(fullCssName);
33+
34+
// If not, try the css/ directory for local browser tests
35+
if (!cssExists && fullLessName.includes('/test/browser/less/')) {
36+
var cssInCssDir = fullLessName.replace('/test/browser/less/', '/test/browser/css/').replace(/less$/, 'css');
37+
if (fs.existsSync(cssInCssDir)) {
38+
fullCssName = cssInCssDir;
39+
}
40+
}
41+
3142
var lessName = pathParts[pathParts.length - 1];
3243
var name = lessName.split('.')[0];
3344
return `

packages/less/test/browser/runner-browser-options.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ var less = {
66
};
77

88
// test inline less in style tags by grabbing an assortment of less files and doing `@import`s
9-
var testFiles = ['charsets', 'colors', 'comments', 'css-3', 'strings', 'media', 'mixins'],
9+
var testFiles = ['charsets/charsets', 'color-functions/basic', 'comments/comments', 'css-3/css-3', 'strings/strings', 'media/media', 'mixins/mixins'],
1010
testSheets = [];
1111

1212
// setup style tags with less and link tags pointing to expected css output
1313

1414
/**
1515
* @todo - generate the node_modules path for this file and in templates
1616
*/
17-
var lessFolder = '../../node_modules/@less/test-data/less'
18-
var cssFolder = '../../node_modules/@less/test-data/css'
17+
var lessFolder = '../../node_modules/@less/test-data/tests-unit'
18+
var cssFolder = '../../node_modules/@less/test-data/tests-unit'
1919

2020
for (var i = 0; i < testFiles.length; i++) {
2121
var file = testFiles[i],
22-
lessPath = lessFolder + '/_main/' + file + '.less',
23-
cssPath = cssFolder + '/_main/' + file + '.css',
22+
lessPath = lessFolder + '/' + file + '.less',
23+
cssPath = cssFolder + '/' + file + '.css',
2424
lessStyle = document.createElement('style'),
2525
cssLink = document.createElement('link'),
2626
lessText = '@import "' + lessPath + '";';

packages/less/test/browser/runner-legacy-options.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/less/test/browser/runner-legacy-spec.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)