Skip to content

Commit c866d75

Browse files
authored
[playground] Fix broken tests (#31573)
Our e2e setup with monaco is kinda brittle since it relies on the dom. It seems like longish text gets truncated so let's just simpify all these test cases. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31573). * __->__ #31573 * #31572
1 parent ee10c74 commit c866d75

15 files changed

+143
-343
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
function TestComponent(t0) {
2-
  const $ = _c(2);
3-
  const { x } = t0;
4-
  let t1;
5-
  if ($[0] !== x) {
6-
    t1 = <Button>{x}</Button>;
7-
    $[0] = x;
8-
    $[1] = t1;
9-
  } else {
10-
    t1 = $[1];
11-
  }
12-
  return t1;
13-
}
1+
function TestComponent(t0) {
2+
const $ = _c(2);
3+
const { x } = t0;
4+
let t1;
5+
if ($[0] !== x) {
6+
t1 = <Button>{x}</Button>;
7+
$[0] = x;
8+
$[1] = t1;
9+
} else {
10+
t1 = $[1];
11+
}
12+
return t1;
13+
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
function MyApp() {
2-
  const $ = _c(1);
3-
  let t0;
4-
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
5-
    t0 = <div>Hello World</div>;
6-
    $[0] = t0;
7-
  } else {
8-
    t0 = $[0];
9-
  }
10-
  return t0;
11-
}
1+
function MyApp() {
2+
const $ = _c(1);
3+
let t0;
4+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
5+
t0 = <div>Hello World</div>;
6+
$[0] = t0;
7+
} else {
8+
t0 = $[0];
9+
}
10+
return t0;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function TestComponent(t0) {
2+
"use memo";
3+
const $ = _c(2);
4+
const { x } = t0;
5+
let t1;
6+
if ($[0] !== x) {
7+
t1 = <Button>{x}</Button>;
8+
$[0] = x;
9+
$[1] = t1;
10+
} else {
11+
t1 = $[1];
12+
}
13+
return t1;
14+
}

compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/function-scope-no-directive-arrow-function-expression-output.txt

-20
This file was deleted.

compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/function-scope-use-memo-arrow-function-expression-output.txt

-32
This file was deleted.

compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/function-scope-use-memo-function-declaration-output.txt

-32
This file was deleted.

compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/function-scope-use-no-memo-function-declaration-output.txt

-32
This file was deleted.

compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/function-scope-use-no-memo-function-expression-output.txt

-18
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
function anonymous_1() {
2-
  const $ = _c(1);
3-
  const handleClick = _temp;
4-
  let t0;
5-
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
6-
    t0 = <h1 onClick={handleClick}>Welcome to the App!</h1>;
7-
    $[0] = t0;
8-
  } else {
9-
    t0 = $[0];
10-
  }
11-
  return t0;
1+
function TestComponent(t0) {
2+
const $ = _c(2);
3+
const { x } = t0;
4+
let t1;
5+
if ($[0] !== x) {
6+
t1 = <Button>{x}</Button>;
7+
$[0] = x;
8+
$[1] = t1;
9+
} else {
10+
t1 = $[1];
11+
}
12+
return t1;
1213
}
13-
function _temp() {
14-
  console.log("Header clicked");
15-
}

compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/module-scope-use-no-memo-function-expression-output.txt

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
function anonymous_1() {
2-
  const handleMouseOver = () => {
3-
    console.log("Footer hovered");
4-
  };
5-
  return <footer onMouseOver={handleMouseOver}>Footer 
6-
      Information</footer>;
7-
}
1+
function TestComponent({ x }) {
2+
return <Button>{x}</Button>;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function TestComponent(t0) {
2+
"use memo";
3+
const $ = _c(2);
4+
const { x } = t0;
5+
let t1;
6+
if ($[0] !== x) {
7+
t1 = <Button>{x}</Button>;
8+
$[0] = x;
9+
$[1] = t1;
10+
} else {
11+
t1 = $[1];
12+
}
13+
return t1;
14+
}
15+
function anonymous_1(t0) {
16+
"use memo";
17+
const $ = _c(2);
18+
const { x } = t0;
19+
let t1;
20+
if ($[0] !== x) {
21+
t1 = <Button>{x}</Button>;
22+
$[0] = x;
23+
$[1] = t1;
24+
} else {
25+
t1 = $[1];
26+
}
27+
return t1;
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function anonymous_1() {
2+
"use no memo";
3+
return <Button>{x}</Button>;
4+
}
5+
function anonymous_3({ x }) {
6+
"use no memo";
7+
return <Button>{x}</Button>;
8+
}

0 commit comments

Comments
 (0)