mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Add regression self-test
This commit is contained in:
1
tools/tests/apps/ecmascript-regression/.gitignore
vendored
Normal file
1
tools/tests/apps/ecmascript-regression/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules/
|
||||
@@ -0,0 +1,19 @@
|
||||
# This file contains information which helps Meteor properly upgrade your
|
||||
# app when you run 'meteor update'. You should check it into version control
|
||||
# with your project.
|
||||
|
||||
notices-for-0.9.0
|
||||
notices-for-0.9.1
|
||||
0.9.4-platform-file
|
||||
notices-for-facebook-graph-api-2
|
||||
1.2.0-standard-minifiers-package
|
||||
1.2.0-meteor-platform-split
|
||||
1.2.0-cordova-changes
|
||||
1.2.0-breaking-changes
|
||||
1.3.0-split-minifiers-package
|
||||
1.4.0-remove-old-dev-bundle-link
|
||||
1.4.1-add-shell-server-package
|
||||
1.4.3-split-account-service-packages
|
||||
1.5-add-dynamic-import-package
|
||||
1.7-split-underscore-from-meteor-base
|
||||
1.8.3-split-jquery-from-blaze
|
||||
1
tools/tests/apps/ecmascript-regression/.meteor/.gitignore
vendored
Normal file
1
tools/tests/apps/ecmascript-regression/.meteor/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
local
|
||||
7
tools/tests/apps/ecmascript-regression/.meteor/.id
Normal file
7
tools/tests/apps/ecmascript-regression/.meteor/.id
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file contains a token that is unique to your project.
|
||||
# Check it into your repository along with the rest of this directory.
|
||||
# It can be used for purposes such as:
|
||||
# - ensuring you don't accidentally deploy one app on top of another
|
||||
# - providing package authors with aggregated statistics
|
||||
|
||||
y1s06jw2jowx.c256atzmooh5
|
||||
23
tools/tests/apps/ecmascript-regression/.meteor/packages
Normal file
23
tools/tests/apps/ecmascript-regression/.meteor/packages
Normal file
@@ -0,0 +1,23 @@
|
||||
# Meteor packages used by this project, one per line.
|
||||
# Check this file (and the other files in this directory) into your repository.
|
||||
#
|
||||
# 'meteor add' and 'meteor remove' will edit this file for you,
|
||||
# but you can also edit it by hand.
|
||||
|
||||
meteor-base@1.5.1 # Packages every Meteor app needs to have
|
||||
mobile-experience@1.1.0 # Packages for a great mobile UX
|
||||
mongo@1.13.0 # The database Meteor supports right now
|
||||
reactive-var@1.0.11 # Reactive variable for tracker
|
||||
|
||||
standard-minifier-css@1.7.4 # CSS minifier run for production mode
|
||||
standard-minifier-js@2.7.0 # JS minifier run for production mode
|
||||
es5-shim@4.8.0 # ECMAScript 5 compatibility for older browsers
|
||||
ecmascript@0.15.3 # Enable ECMAScript2015+ syntax in app code
|
||||
typescript@4.3.5 # Enable TypeScript syntax in .ts and .tsx modules
|
||||
shell-server@0.5.0 # Server-side component of the `meteor shell` command
|
||||
hot-module-replacement@0.3.0 # Update client in development without reloading the page
|
||||
|
||||
autopublish@1.0.7 # Publish all data to the clients (for prototyping)
|
||||
insecure@1.0.7 # Allow all DB writes from clients (for prototyping)
|
||||
static-html@1.3.2 # Define static page content in .html files
|
||||
react-meteor-data # React higher-order component for reactively tracking Meteor data
|
||||
2
tools/tests/apps/ecmascript-regression/.meteor/platforms
Normal file
2
tools/tests/apps/ecmascript-regression/.meteor/platforms
Normal file
@@ -0,0 +1,2 @@
|
||||
server
|
||||
browser
|
||||
1
tools/tests/apps/ecmascript-regression/.meteor/release
Normal file
1
tools/tests/apps/ecmascript-regression/.meteor/release
Normal file
@@ -0,0 +1 @@
|
||||
METEOR@2.4
|
||||
78
tools/tests/apps/ecmascript-regression/.meteor/versions
Normal file
78
tools/tests/apps/ecmascript-regression/.meteor/versions
Normal file
@@ -0,0 +1,78 @@
|
||||
allow-deny@1.1.0
|
||||
autopublish@1.0.7
|
||||
autoupdate@1.7.0
|
||||
babel-compiler@7.7.0
|
||||
babel-runtime@1.5.0
|
||||
base64@1.0.12
|
||||
binary-heap@1.0.11
|
||||
blaze-tools@1.1.2
|
||||
boilerplate-generator@1.7.1
|
||||
caching-compiler@1.2.2
|
||||
caching-html-compiler@1.2.1
|
||||
callback-hook@1.4.0
|
||||
check@1.3.1
|
||||
ddp@1.4.0
|
||||
ddp-client@2.5.0
|
||||
ddp-common@1.4.0
|
||||
ddp-server@2.5.0
|
||||
diff-sequence@1.1.1
|
||||
dynamic-import@0.7.1
|
||||
ecmascript@0.15.3
|
||||
ecmascript-runtime@0.8.0
|
||||
ecmascript-runtime-client@0.12.1
|
||||
ecmascript-runtime-server@0.11.0
|
||||
ejson@1.1.1
|
||||
es5-shim@4.8.0
|
||||
fetch@0.1.1
|
||||
geojson-utils@1.0.10
|
||||
hot-code-push@1.0.4
|
||||
hot-module-replacement@0.3.0
|
||||
html-tools@1.1.2
|
||||
htmljs@1.1.1
|
||||
http@1.0.10
|
||||
id-map@1.1.1
|
||||
insecure@1.0.7
|
||||
inter-process-messaging@0.1.1
|
||||
launch-screen@1.3.0
|
||||
logging@1.3.1
|
||||
meteor@1.10.0
|
||||
meteor-base@1.5.1
|
||||
meteortesting:browser-tests@1.3.4
|
||||
meteortesting:mocha@2.0.3
|
||||
meteortesting:mocha-core@8.0.1
|
||||
minifier-css@1.6.0
|
||||
minifier-js@2.7.1
|
||||
minimongo@1.7.0
|
||||
mobile-experience@1.1.0
|
||||
mobile-status-bar@1.1.0
|
||||
modern-browsers@0.1.7
|
||||
modules@0.17.0
|
||||
modules-runtime@0.12.0
|
||||
modules-runtime-hot@0.13.0
|
||||
mongo@1.13.0
|
||||
mongo-decimal@0.1.2
|
||||
mongo-dev-server@1.1.0
|
||||
mongo-id@1.0.8
|
||||
npm-mongo@3.9.1
|
||||
ordered-dict@1.1.0
|
||||
promise@0.12.0
|
||||
random@1.2.0
|
||||
react-fast-refresh@0.1.1
|
||||
react-meteor-data@2.3.3
|
||||
reactive-var@1.0.11
|
||||
reload@1.3.1
|
||||
retry@1.1.0
|
||||
routepolicy@1.1.1
|
||||
shell-server@0.5.0
|
||||
socket-stream-client@0.4.0
|
||||
spacebars-compiler@1.3.0
|
||||
standard-minifier-css@1.7.4
|
||||
standard-minifier-js@2.7.1
|
||||
static-html@1.3.2
|
||||
templating-tools@1.2.1
|
||||
tracker@1.2.0
|
||||
typescript@4.3.5
|
||||
underscore@1.0.10
|
||||
url@1.3.2
|
||||
webapp@1.12.0
|
||||
webapp-hashing@1.1.0
|
||||
4
tools/tests/apps/ecmascript-regression/client/main.css
Normal file
4
tools/tests/apps/ecmascript-regression/client/main.css
Normal file
@@ -0,0 +1,4 @@
|
||||
body {
|
||||
padding: 10px;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
7
tools/tests/apps/ecmascript-regression/client/main.html
Normal file
7
tools/tests/apps/ecmascript-regression/client/main.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<head>
|
||||
<title>escmascript-regression</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="react-target"></div>
|
||||
</body>
|
||||
8
tools/tests/apps/ecmascript-regression/client/main.jsx
Normal file
8
tools/tests/apps/ecmascript-regression/client/main.jsx
Normal file
@@ -0,0 +1,8 @@
|
||||
import React from 'react';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { render } from 'react-dom';
|
||||
import { App } from '/imports/ui/App';
|
||||
|
||||
Meteor.startup(() => {
|
||||
render(<App/>, document.getElementById('react-target'));
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import { Hello } from './Hello.jsx';
|
||||
|
||||
export const App = () => (
|
||||
<div>
|
||||
<h1>Welcome to Meteor!</h1>
|
||||
<Hello />
|
||||
</div>
|
||||
);
|
||||
16
tools/tests/apps/ecmascript-regression/imports/ui/Hello.jsx
Normal file
16
tools/tests/apps/ecmascript-regression/imports/ui/Hello.jsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import React, { useState } from 'react';
|
||||
|
||||
export const Hello = () => {
|
||||
const [counter, setCounter] = useState(0);
|
||||
|
||||
const increment = () => {
|
||||
setCounter(counter + 1);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<button onClick={increment}>Click Me</button>
|
||||
<p>You've pressed the button {counter} times.</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
1248
tools/tests/apps/ecmascript-regression/package-lock.json
generated
Normal file
1248
tools/tests/apps/ecmascript-regression/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
tools/tests/apps/ecmascript-regression/package.json
Normal file
23
tools/tests/apps/ecmascript-regression/package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "escmascript-regression",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "meteor run",
|
||||
"test": "meteor test --driver-package meteortesting:mocha",
|
||||
"test-app": "TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha --exclude-archs web.browser"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"meteor-node-stubs": "^1.1.0",
|
||||
"puppeteer": "^10.4.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
},
|
||||
"meteor": {
|
||||
"mainModule": {
|
||||
"client": "client/main.jsx",
|
||||
"server": "server/main.js"
|
||||
},
|
||||
"testModule": "tests/main.js"
|
||||
}
|
||||
}
|
||||
1
tools/tests/apps/ecmascript-regression/server/main.js
Normal file
1
tools/tests/apps/ecmascript-regression/server/main.js
Normal file
@@ -0,0 +1 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
27
tools/tests/apps/ecmascript-regression/tests/main.js
Normal file
27
tools/tests/apps/ecmascript-regression/tests/main.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import assert from 'assert';
|
||||
|
||||
describe('escmascript-regression', function() {
|
||||
if (Meteor.isClient) {
|
||||
it('NodeList spread', function() {
|
||||
const div = document.createElement('div');
|
||||
document.body.appendChild(div);
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const child = document.createElement('div');
|
||||
child.innerText = `child ${i}`;
|
||||
div.appendChild(child);
|
||||
}
|
||||
|
||||
try {
|
||||
assert.strictEqual(div.childNodes?.length, 5);
|
||||
const arr = [...div.childNodes];
|
||||
|
||||
arr.forEach((el, i) => {
|
||||
assert.equal(el.innerText, `child ${i}`);
|
||||
});
|
||||
} finally {
|
||||
document.body.removeChild(div);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,51 +1,54 @@
|
||||
var selftest = require('../tool-testing/selftest.js');
|
||||
var Sandbox = selftest.Sandbox;
|
||||
var utils = require('../utils/utils.js');
|
||||
import { getUrl } from '../utils/http-helpers.js';
|
||||
|
||||
var MONGO_LISTENING =
|
||||
{ stdout: " [initandlisten] waiting for connections on port" };
|
||||
var MONGO_LISTENING = {
|
||||
stdout: ' [initandlisten] waiting for connections on port',
|
||||
};
|
||||
|
||||
function startRun(sandbox) {
|
||||
var run = sandbox.run();
|
||||
run.match("myapp");
|
||||
run.match("proxy");
|
||||
run.match('myapp');
|
||||
run.match('proxy');
|
||||
run.tellMongo(MONGO_LISTENING);
|
||||
run.waitSecs(20);
|
||||
run.match("MongoDB");
|
||||
run.match('MongoDB');
|
||||
return run;
|
||||
};
|
||||
}
|
||||
|
||||
selftest.define("modules - test app", function () {
|
||||
selftest.define('modules - test app', function() {
|
||||
const s = new Sandbox();
|
||||
|
||||
// Make sure we use the right "env" section of .babelrc.
|
||||
s.set("NODE_ENV", "development");
|
||||
s.set('NODE_ENV', 'development');
|
||||
|
||||
// For meteortesting:mocha to work we must set test broswer driver
|
||||
// For meteortesting:mocha to work we must set test browser driver
|
||||
// See https://github.com/meteortesting/meteor-mocha
|
||||
s.set("TEST_BROWSER_DRIVER", "puppeteer");
|
||||
s.set('TEST_BROWSER_DRIVER', 'puppeteer');
|
||||
|
||||
s.createApp("modules-test-app", "modules");
|
||||
s.cd("modules-test-app", function () {
|
||||
s.createApp('modules-test-app', 'modules');
|
||||
s.cd('modules-test-app', function() {
|
||||
const run = s.run(
|
||||
"test", "--once", "--full-app",
|
||||
"--driver-package", "meteortesting:mocha"
|
||||
'test',
|
||||
'--once',
|
||||
'--full-app',
|
||||
'--driver-package',
|
||||
'meteortesting:mocha'
|
||||
);
|
||||
|
||||
run.waitSecs(60);
|
||||
run.match("App running at");
|
||||
run.match("SERVER FAILURES: 0");
|
||||
run.match("CLIENT FAILURES: 0");
|
||||
run.match('App running at');
|
||||
run.match('SERVER FAILURES: 0');
|
||||
run.match('CLIENT FAILURES: 0');
|
||||
run.expectExit(0);
|
||||
});
|
||||
});
|
||||
|
||||
selftest.define("modules - unimported lazy files", function() {
|
||||
selftest.define('modules - unimported lazy files', function() {
|
||||
const s = new Sandbox();
|
||||
s.createApp("myapp", "app-with-unimported-lazy-file");
|
||||
s.cd("myapp", function() {
|
||||
const run = s.run("--once");
|
||||
s.createApp('myapp', 'app-with-unimported-lazy-file');
|
||||
s.cd('myapp', function() {
|
||||
const run = s.run('--once');
|
||||
run.waitSecs(30);
|
||||
run.expectExit(1);
|
||||
run.forbid("This file shouldn't be loaded");
|
||||
@@ -55,43 +58,47 @@ selftest.define("modules - unimported lazy files", function() {
|
||||
// Checks that `import X from 'meteor/package'` will import (and re-export) the
|
||||
// mainModule if one exists, otherwise will simply export Package['package'].
|
||||
// Overlaps with compiler-plugin.js's "install-packages.js" code.
|
||||
selftest.define("modules - import chain for packages", () => {
|
||||
selftest.define('modules - import chain for packages', () => {
|
||||
const s = new Sandbox({ fakeMongo: true });
|
||||
|
||||
s.createApp("myapp", "package-tests");
|
||||
s.cd("myapp");
|
||||
s.createApp('myapp', 'package-tests');
|
||||
s.cd('myapp');
|
||||
|
||||
s.write(".meteor/packages", [
|
||||
"meteor-base",
|
||||
"modules",
|
||||
"with-add-files",
|
||||
"with-main-module",
|
||||
""
|
||||
].join("\n"));
|
||||
s.write(
|
||||
'.meteor/packages',
|
||||
['meteor-base', 'modules', 'with-add-files', 'with-main-module', ''].join(
|
||||
'\n'
|
||||
)
|
||||
);
|
||||
|
||||
s.write("main.js", [
|
||||
"var packageNameA = require('meteor/with-add-files').name;",
|
||||
"var packageNameB = require('meteor/with-main-module').name;",
|
||||
"",
|
||||
"console.log('with-add-files: ' + packageNameA);",
|
||||
"console.log('with-main-module: ' + packageNameB);",
|
||||
""
|
||||
].join("\n"));
|
||||
s.write(
|
||||
'main.js',
|
||||
[
|
||||
"var packageNameA = require('meteor/with-add-files').name;",
|
||||
"var packageNameB = require('meteor/with-main-module').name;",
|
||||
'',
|
||||
"console.log('with-add-files: ' + packageNameA);",
|
||||
"console.log('with-main-module: ' + packageNameB);",
|
||||
'',
|
||||
].join('\n')
|
||||
);
|
||||
|
||||
const run = startRun(s);
|
||||
|
||||
run.waitSecs(30);
|
||||
|
||||
// On the server, we just check that importing *works*, not *how* it works
|
||||
run.match("with-add-files: with-add-files");
|
||||
run.match("with-main-module: with-main-module");
|
||||
run.match('with-add-files: with-add-files');
|
||||
run.match('with-main-module: with-main-module');
|
||||
|
||||
// On the client, we just check that install() is called correctly
|
||||
checkModernAndLegacyUrls("/packages/modules.js", body => {
|
||||
checkModernAndLegacyUrls('/packages/modules.js', body => {
|
||||
selftest.expectTrue(body.includes('\ninstall("with-add-files");'));
|
||||
selftest.expectTrue(
|
||||
body.includes('\ninstall("with-main-module", ' +
|
||||
'"meteor/with-main-module/with-main-module.js");')
|
||||
body.includes(
|
||||
'\ninstall("with-main-module", ' +
|
||||
'"meteor/with-main-module/with-main-module.js");'
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -99,9 +106,9 @@ selftest.define("modules - import chain for packages", () => {
|
||||
});
|
||||
|
||||
function checkModernAndLegacyUrls(path, test) {
|
||||
if (! path.startsWith("/")) {
|
||||
path = "/" + path;
|
||||
if (!path.startsWith('/')) {
|
||||
path = '/' + path;
|
||||
}
|
||||
test(getUrl("http://localhost:3000" + path));
|
||||
test(getUrl("http://localhost:3000/__browser.legacy" + path));
|
||||
test(getUrl('http://localhost:3000' + path));
|
||||
test(getUrl('http://localhost:3000/__browser.legacy' + path));
|
||||
}
|
||||
|
||||
38
tools/tests/regressions.js
Normal file
38
tools/tests/regressions.js
Normal file
@@ -0,0 +1,38 @@
|
||||
var selftest = require('../tool-testing/selftest.js');
|
||||
var Sandbox = selftest.Sandbox;
|
||||
// import { getUrl } from '../utils/http-helpers.js';
|
||||
|
||||
selftest.define('regressions - web.browser.legacy', function() {
|
||||
const s = new Sandbox();
|
||||
|
||||
// Make sure we use the right "env" section of .babelrc.
|
||||
s.set('NODE_ENV', 'development');
|
||||
|
||||
// For meteortesting:mocha to work we must set test browser driver
|
||||
// See https://github.com/meteortesting/meteor-mocha
|
||||
s.set('TEST_BROWSER_DRIVER', 'puppeteer');
|
||||
|
||||
s.createApp('modules-test-app', 'ecmascript-regression');
|
||||
s.cd('modules-test-app', function() {
|
||||
const run = s.run(
|
||||
'test',
|
||||
'--once',
|
||||
'--full-app',
|
||||
'--driver-package',
|
||||
'meteortesting:mocha',
|
||||
'--exclude-archs',
|
||||
'web.browser'
|
||||
);
|
||||
|
||||
run.waitSecs(60);
|
||||
run.match('App running at');
|
||||
run.match('SERVER FAILURES: 0');
|
||||
run.match('CLIENT FAILURES: 0');
|
||||
run.expectExit(0);
|
||||
});
|
||||
});
|
||||
|
||||
// function checkModernAndLegacyUrls(test) {
|
||||
// test(getUrl("http://localhost:3000"));
|
||||
// test(getUrl("http://localhost:3000/__browser.legacy"));
|
||||
// }
|
||||
Reference in New Issue
Block a user