Skip to content
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

tests(): Start moving visual tests to playwright #9481

Merged
merged 12 commits into from
Jul 2, 2024

Conversation

asturur
Copy link
Member

@asturur asturur commented Nov 4, 2023

Motivation

This is an idea / proposal to have something simpler to setup when doing visual tests.
As the old QUNIT-VISUAL we can just prepare a list of functions with some metadata and have them run in sequence.
Those will run opening a single browser window and a single ci action, deprecating the old qunit-visual that runs on 3 node versions and 2 browsers.

The code is a bit messy and is not integrated ( on purpose ) with our generic pattern for single interactive e2e tests.
Eventually also my before function would be moved away from where i added it and just be specific of this kind of test.

I didn't convert more tests because i wanted to talk about it first.
Also is not urgent.

@asturur asturur marked this pull request as draft November 4, 2023 12:51
Copy link
Contributor

github-actions bot commented Nov 4, 2023

Build Stats

file / KB (diff) bundled minified
fabric 912.885 (0) 304.811 (0)

@ShaMan123
Copy link
Contributor

please merge #9110 #9333 before you migrate the tests

@ShaMan123
Copy link
Contributor

ShaMan123 commented Nov 6, 2023

#9110 does what you suggest, using a single browser to run all the snapshots. It is very fast.
I remeber you had some things you wanted to change there.

Copy link
Contributor

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that Polyline code has creeped in from another branch
I would do this differently as explained in the comments

if (testCase.disabled !== 'node') {
await test.step(`node - ${testCase.title}`, async () => {
// we want the browser snapshot of a test to be committed and not the node snapshot
config.config.updateSnapshots = 'none';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong because it will override the -u flag passed in argv

Comment on lines +59 to +78
export async function beforeRenderTest(
cb: (
canvas: Canvas
) => AsyncReturnValue<{ title: string; boundFunction: () => void }[]>,
options
) {
const el = document.querySelector<HTMLCanvasElement>('#canvas');
const canvas = new Canvas(el, options);
// cb has to bind the rendering test to the specific canvas and add a clear before the test
const renderingTests = await cb(canvas);
renderingTests.forEach((renderTest) => {
if (renderingTestMap.has(renderTest.title)) {
throw new Error(
`test identifiers must be unique: ${renderTest.title} is already defined`
);
}
renderingTestMap.set(renderTest.title, renderTest.boundFunction);
});
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I under this.
Do you want to create a new canvas for every test?
Why? What is the gain?
What about simply resizing the canvas before the test and adding a canvas.clear() after the snapshot call?
Seems more straight forward, simpler and faster and can be exposed on the CanvasUtil.

Copy link
Contributor

github-actions bot commented Jul 2, 2024

Coverage after merging create-tests-rendering-same-window into master will be

84.76%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
index.node.ts14.29%100%0%25%23, 26, 29, 41, 44, 47
src
   ClassRegistry.ts90.32%61.54%100%97.73%31, 52
   Collection.ts78.47%42.62%87.10%85.82%130, 138, 153, 155–157, 159, 169–170, 181, 197, 215, 217, 228, 243, 254, 265, 270, 279, 281, 286–287, 302, 304, 309–310, 329, 333–334, 338–344, 346–348, 350
   CommonMethods.ts91.43%71.43%100%96%50, 52
   Intersection.ts85.25%48.91%100%97.30%184–188, 190, 228, 237, 239, 289, 297, 297
   Observable.ts79.89%54.55%93.75%87.10%136, 145, 148, 160, 162, 167, 68–70, 72, 76, 80, 84–85, 87–91
   Point.ts90.27%61.22%100%93.60%104, 117, 148, 157, 179, 197, 206, 216, 225, 236–239, 259, 285, 297, 317, 328, 341, 349, 359, 95
   Shadow.ts88.98%73.91%100%90.19%145, 148, 150–155, 164, 201, 204, 211, 228–235, 239–240
   cache.ts84.88%45.45%100%90.14%57, 59, 71–72, 74–77
   config.ts87.73%55%66.67%94.03%132, 134–137, 139, 142–143, 147, 152
   constants.ts100%100%100%100%
src/LayoutManager
   ActiveSelectionLayoutManager.ts93.33%76.92%85.71%100%
   LayoutManager.ts90.54%65.06%76.92%99.29%269, 333, 344
   constants.ts100%100%100%100%
   index.ts48.57%37.50%80%66.67%1, 1, 1–2, 2, 2–3, 3, 3–4, 4, 4–5, 5, 5, 5–6
   types.ts100%100%100%100%
src/LayoutManager/LayoutStrategies
   ClipPathLayout.ts73.08%50%100%78.95%39, 41–44, 46–48, 57–58, 66–69
   FitContentLayout.ts100%100%100%100%
   FixedLayout.ts85.71%20%100%100%23, 23
   LayoutStrategy.ts87.60%55.56%100%96.55%46, 54, 72, 72, 74
   utils.ts72.58%50%100%78.72%29–32, 34–35, 40–44
src/Pattern
   Pattern.ts70.18%90.91%80%65.95%105–107, 114, 118–119, 119–122, 130–138, 140–141, 143, 153–164, 174, 176–181, 183–188, 190–199, 204–205, 207–209, 211, 33, 37
src/brushes
   BaseBrush.ts89.33%91.67%100%88.55%110, 115, 124–125, 130, 135, 143, 146, 155–160, 99
   CircleBrush.ts52.10%12.50%12.50%58.25%100–108, 108–118, 122, 130–139, 55, 67, 69, 76, 76, 78–79, 79, 83, 85–86, 92–98
   PatternBrush.ts97.06%87.50%100%100%21
   PencilBrush.ts91.06%82.35%100%93.81%122–123, 152, 152–154, 176, 176, 276, 280, 285–286, 68–69, 84–85
   SprayBrush.ts0%0%0%0%107, 107, 107, 107, 107–108, 110–111, 118–119, 121, 123–127, 136, 140–141, 141, 148, 148, 148–151, 153–156, 160–161, 163, 165–168, 17, 171, 178–179, 18, 181, 183–184, 186, 193–194, 196–197, 20, 200, 200, 207, 207, 21, 211, 22, 22, 22–24, 28, 32, 39, 46, 53, 60, 67, 84–86, 94–96, 98–99
src/canvas
   Canvas.ts75.45%39.53%92.86%85%1004, 1007–1008, 1012–1013, 1018, 1063–1068, 1105, 1126, 1128, 1130, 1137, 1140, 1203–1207, 1286–1290, 1317, 1334, 1380–1397, 1403–1408, 1411–1412, 1414, 1418, 1420–1421, 1423–1425, 1429, 1431, 1433–1435, 1438–1443, 1446–1448, 1451, 1453, 1467, 1474, 1476–1487, 1489–1492, 1492, 1494, 1498–1499, 1502–1503, 1506–1508, 1511, 328, 353, 369, 388, 443, 559–563, 566–567, 569, 579, 582–583, 585, 588–590, 602, 609–613, 615–620, 622–626, 659, 661, 668–672, 674–679, 681, 683–684, 686–689, 691–692, 747, 783–786, 789, 791, 794, 796, 798, 824, 886–887, 932–933, 935–936, 938, 947–953, 956, 963–964, 966–970, 972, 974, 995–996, 999
   CanvasOptions.ts100%100%100%100%
   SelectableCanvas.ts85.57%53.68%100%94.62%1012, 1021, 1089–1093, 1139–1140, 1142–1143, 1145, 1172, 1174–1175, 1175, 1177, 1216, 1218, 1220, 1236, 1238, 1242, 1245, 1266, 1269, 1312–1319, 1322, 1325, 1334–1335, 1339–1348, 1352, 1354–1355, 1361–1366, 1370, 362, 384, 462, 513, 515, 591, 596, 673, 701, 992, 994–995
   StaticCanvas.ts75.74%69.50%98.91%75.30%1005, 1008, 1010, 1012, 1020, 1022–1028, 1038, 1041, 1044–1050, 1052–1053, 1055–1076, 1083–1085, 1087, 1095, 1101–1103, 1103–1104, 1104–1105, 1107, 1107–1112, 1125, 1130–1132, 1136, 1140, 1142, 1144, 1149–1153, 1155, 1157–1160, 1163, 1165, 1174, 1176–1177, 1184–1187, 1189, 1195–1198, 1202–1203, 1213, 1219–1221, 1223–1228, 1228, 1228–1232, 1232, 1232–1237, 1239–1246, 1275–1276, 1278–1283, 1285–1291, 1295, 1297–1310, 1318–1319, 1329, 1340, 1381–1385, 1387, 1389, 1391–1395, 1414, 1430, 1447, 1467, 1500, 1504, 1515–1517, 424, 435, 443–448, 456, 495,

@asturur asturur marked this pull request as ready for review July 2, 2024 23:32
@asturur asturur changed the title DRAFT: Visual tests in playrigth with a function list tests(): Start moving visual tests to playwright Jul 2, 2024
@asturur asturur merged commit 4a67106 into master Jul 2, 2024
21 checks passed
@asturur asturur deleted the create-tests-rendering-same-window branch July 2, 2024 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants