Skip to content

remove enzyme test #3997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
57 changes: 1 addition & 56 deletions frontend/javascripts/test/enzyme/e2e-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import fs from "fs";
import shell from "shelljs";

const requests = [];
const minimumWait = 100; // ms
const tokenUserA =
"1b88db86331a38c21a0b235794b9e459856490d70408bcffb767f64ade0f83d2bdb4c4e181b9a9a30cdece7cb7c65208cc43b6c1bb5987f5ece00d348b1a905502a266f8fc64f0371cd6559393d72e031d0c2d0cabad58cccf957bb258bc86f05b5dc3d4fff3d5e3d9c0389a6027d861a21e78e3222fb6c5b7944520ef21761e";
const tokenUserB =
Expand All @@ -22,31 +21,6 @@ const tokenUserE =
"5f88db86331a38c21a0b235794b9e459856490d70408bcffb767f64ade0f83d2bdb4c4e181b9a9a30cdece7cb7c65208cc43b6c1bb5987f5ece00d348b1a905502a266f8fc64f0371cd6559393d72e031d0c2d0cabad58cccf957bb258bc86f05b5dc3d4fff3d5e3d9c0389a6027d861a21e78e3222fb6c5b7944520ef21765e";
let currToken = tokenUserA;

async function waitForAllRequests(el: Object) {
let length = requests.length;
async function tolerantWait() {
// Add a small timeout so that other promise handlers get some execution time
await wait(minimumWait);
if (length < requests.length) {
// Retry if new requests were added
length = requests.length;
await waitForAllRequests(el).then(tolerantWait);
}
}
// Even if all promises are already resolved, we should wait
// for a few milliseconds. This can avoid race conditions (such as
// is-clicked classes disappearing when clicking a button)
// await wait(minimumWait);
await Promise.all(requests);
await tolerantWait();
// enzyme caches the DOM tree, we need to call update after the async requests finished
el.update();
}

function wait(milliseconds: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, milliseconds));
}

function setCurrToken(token: string) {
currToken = token;
}
Expand Down Expand Up @@ -122,24 +96,6 @@ global.navigator = {
};
copyProps(window, global);

function trim(string) {
return string.replace(/^\s+/gm, "");
}

function createSnapshotable(wrapper: any) {
// debug() returns a multi-line html string
// We remove leading whitespace to avoid large diffs caused by changes in indentation
return trim(wrapper.debug());
}

function debugWrapper(wrapper: any, name: string) {
fs.writeFile(
`frontend/javascripts/test/snapshots/debug-htmls/test-wk-snapshots-${name}.html`,
wrapper.debug(),
() => {},
);
}

export async function writeFlowCheckingFile(
object: Array<any> | Object,
name: string,
Expand All @@ -165,15 +121,4 @@ export function resetDatabase() {
shell.exec("tools/postgres/prepareTestDB.sh > /dev/null 2> /dev/null");
}

export {
waitForAllRequests,
createSnapshotable,
wait,
debugWrapper,
tokenUserA,
tokenUserB,
tokenUserC,
tokenUserD,
tokenUserE,
setCurrToken,
};
export { tokenUserA, tokenUserB, tokenUserC, tokenUserD, tokenUserE, setCurrToken };
123 changes: 0 additions & 123 deletions frontend/javascripts/test/enzyme/snapshot.e2e.js

This file was deleted.

Loading