From ed4da678c2171225bab323bee45ec0327a113971 Mon Sep 17 00:00:00 2001 From: Eric Dobbertin Date: Thu, 9 Jul 2020 12:33:59 -0500 Subject: [PATCH] test: update test expectations to fix failing tests --- .../__snapshots__/buildSteps.test.ts.snap | 135 ++++- .../create-code/ContextEventCollector.test.ts | 2 +- .../CodeFileUpdater.test.ts.snap | 13 +- test/fixtures/login.json | 526 ++++++++++++++++-- 4 files changed, 584 insertions(+), 92 deletions(-) diff --git a/test/build-workflow/__snapshots__/buildSteps.test.ts.snap b/test/build-workflow/__snapshots__/buildSteps.test.ts.snap index 59bccd9a0..c9aff61e7 100644 --- a/test/build-workflow/__snapshots__/buildSteps.test.ts.snap +++ b/test/build-workflow/__snapshots__/buildSteps.test.ts.snap @@ -9,22 +9,52 @@ Array [ "isTrusted": true, "name": "mousedown", "page": 0, - "selector": "text=\\"Log in\\"", + "selector": "p", "target": Object { - "attrs": Object { - "href": "/login", - }, + "attrs": Object {}, "children": Array [ Object { - "content": "Log in", + "content": "To log in, use ", + "type": "text", + }, + Object { + "attrs": Object {}, + "children": Array [ + Object { + "content": "tomsmith", + "type": "text", + }, + ], + "name": "i", + "type": "tag", + "voidElement": false, + }, + Object { + "content": " as the username, and ", + "type": "text", + }, + Object { + "attrs": Object {}, + "children": Array [ + Object { + "content": "SuperSecretPassword!", + "type": "text", + }, + ], + "name": "i", + "type": "tag", + "voidElement": false, + }, + Object { + "content": " as the password.", "type": "text", }, ], - "name": "a", + "name": "p", "type": "tag", "voidElement": false, }, - "time": 1588025517066, + "time": 1594315658170, }, "index": 0, }, @@ -48,16 +78,16 @@ Array [ "type": "tag", "voidElement": true, }, - "time": 1588025518191, + "time": 1594315658987, }, "index": 1, }, Object { - "action": "type", + "action": "fill", "event": Object { - "index": 4, + "index": 25, "isTrusted": true, - "name": "keydown", + "name": "input", "page": 0, "selector": "#username", "target": Object { @@ -65,15 +95,15 @@ Array [ "autocomplete": "off", "id": "username", "type": "text", - "value": "", + "value": "tomsmit", }, "children": Array [], "name": "input", "type": "tag", "voidElement": true, }, - "time": 1588025518976, - "value": "t", + "time": 1594315661241, + "value": "tomsmith", }, "index": 2, "value": "tomsmith", @@ -81,7 +111,7 @@ Array [ Object { "action": "press", "event": Object { - "index": 20, + "index": 28, "isTrusted": true, "name": "keydown", "page": 0, @@ -98,18 +128,18 @@ Array [ "type": "tag", "voidElement": true, }, - "time": 1588025520059, + "time": 1594315661554, "value": "Tab", }, "index": 3, "value": "Tab", }, Object { - "action": "type", + "action": "fill", "event": Object { - "index": 24, + "index": 34, "isTrusted": true, - "name": "paste", + "name": "input", "page": 0, "selector": "#password", "target": Object { @@ -124,7 +154,7 @@ Array [ "type": "tag", "voidElement": true, }, - "time": 1588025520971, + "time": 1594315662066, "value": "SuperSecretPassword!", }, "index": 4, @@ -133,7 +163,7 @@ Array [ Object { "action": "press", "event": Object { - "index": 26, + "index": 37, "isTrusted": true, "name": "keydown", "page": 0, @@ -150,35 +180,80 @@ Array [ "type": "tag", "voidElement": true, }, - "time": 1588025521606, - "value": "Enter", + "time": 1594315663331, + "value": "Tab", }, "index": 5, + "value": "Tab", + }, + Object { + "action": "press", + "event": Object { + "index": 40, + "isTrusted": true, + "name": "keydown", + "page": 0, + "selector": "button", + "target": Object { + "attrs": Object { + "style": "cursor: pointer;", + "type": "submit", + }, + "children": Array [ + Object { + "attrs": Object {}, + "children": Array [ + Object { + "content": "Log in", + "type": "text", + }, + ], + "name": "p", + "type": "tag", + "voidElement": false, + }, + ], + "name": "button", + "type": "tag", + "voidElement": false, + }, + "time": 1594315663737, + "value": "Enter", + }, + "index": 6, "value": "Enter", }, Object { "action": "click", "event": Object { - "index": 29, + "index": 43, "isTrusted": true, "name": "mousedown", "page": 0, - "selector": "text=\\"Log out\\"", + "selector": "text=Log out", "target": Object { "attrs": Object {}, "children": Array [ Object { - "content": "Log out", - "type": "text", + "attrs": Object {}, + "children": Array [ + Object { + "content": "Log out", + "type": "text", + }, + ], + "name": "p", + "type": "tag", + "voidElement": false, }, ], - "name": "p", + "name": "button", "type": "tag", "voidElement": false, }, - "time": 1588025523112, + "time": 1594315665876, }, - "index": 6, + "index": 7, }, ] `; diff --git a/test/create-code/ContextEventCollector.test.ts b/test/create-code/ContextEventCollector.test.ts index 8889a2133..b9a1a291b 100644 --- a/test/create-code/ContextEventCollector.test.ts +++ b/test/create-code/ContextEventCollector.test.ts @@ -131,7 +131,7 @@ describe('ContextEventCollector', () => { await page.close(); const { name, isTrusted, target, value } = events[ - events.length - 1 + events.length - 2 ] as InputEvent; expect(isTrusted).toEqual(false); diff --git a/test/create-code/__snapshots__/CodeFileUpdater.test.ts.snap b/test/create-code/__snapshots__/CodeFileUpdater.test.ts.snap index de77a8f74..b7966e359 100644 --- a/test/create-code/__snapshots__/CodeFileUpdater.test.ts.snap +++ b/test/create-code/__snapshots__/CodeFileUpdater.test.ts.snap @@ -2,7 +2,7 @@ exports[`CodeFileUpdater update saves code with new steps 1`] = ` " someCode(); - await page.click('text=\\"Log in\\"'); + await page.click(\\"p\\"); await page.click(\\"#username\\"); // 🐺 create code here otherCode();" @@ -10,13 +10,14 @@ exports[`CodeFileUpdater update saves code with new steps 1`] = ` exports[`CodeFileUpdater update saves code with new steps 2`] = ` " someCode(); - await page.click('text=\\"Log in\\"'); + await page.click(\\"p\\"); await page.click(\\"#username\\"); - await page.type(\\"#username\\", \\"tomsmith\\"); + await page.fill(\\"#username\\", \\"tomsmith\\"); await page.press(\\"#username\\", \\"Tab\\"); - await page.type(\\"#password\\", \\"SuperSecretPassword!\\"); - await page.press(\\"#password\\", \\"Enter\\"); - await page.click('text=\\"Log out\\"'); + await page.fill(\\"#password\\", \\"SuperSecretPassword!\\"); + await page.press(\\"#password\\", \\"Tab\\"); + await page.press(\\"button\\", \\"Enter\\"); + await page.click(\\"text=Log out\\"); // 🐺 create code here otherCode();" `; diff --git a/test/fixtures/login.json b/test/fixtures/login.json index 93648e46a..41075c213 100644 --- a/test/fixtures/login.json +++ b/test/fixtures/login.json @@ -4,29 +4,65 @@ "isTrusted": true, "name": "mousedown", "page": 0, - "selector": "text=\"Log in\"", + "selector": "p", "target": { "type": "tag", - "name": "a", + "name": "p", "voidElement": false, - "attrs": { "href": "/login" }, - "children": [{ "type": "text", "content": "Log in" }] + "attrs": {}, + "children": [ + { "type": "text", "content": "To log in, use " }, + { + "type": "tag", + "name": "i", + "voidElement": false, + "attrs": {}, + "children": [{ "type": "text", "content": "tomsmith" }] + }, + { "type": "text", "content": " as the username, and " }, + { + "type": "tag", + "name": "i", + "voidElement": false, + "attrs": {}, + "children": [{ "type": "text", "content": "SuperSecretPassword!" }] + }, + { "type": "text", "content": " as the password." } + ] }, - "time": 1588025517066 + "time": 1594315658170 }, { "isTrusted": true, "name": "click", "page": 0, - "selector": "text=\"Log in\"", + "selector": "p", "target": { "type": "tag", - "name": "a", + "name": "p", "voidElement": false, - "attrs": { "href": "/login" }, - "children": [{ "type": "text", "content": "Log in" }] + "attrs": {}, + "children": [ + { "type": "text", "content": "To log in, use " }, + { + "type": "tag", + "name": "i", + "voidElement": false, + "attrs": {}, + "children": [{ "type": "text", "content": "tomsmith" }] + }, + { "type": "text", "content": " as the username, and " }, + { + "type": "tag", + "name": "i", + "voidElement": false, + "attrs": {}, + "children": [{ "type": "text", "content": "SuperSecretPassword!" }] + }, + { "type": "text", "content": " as the password." } + ] }, - "time": 1588025517129 + "time": 1594315658181 }, { "isTrusted": true, @@ -45,7 +81,7 @@ }, "children": [] }, - "time": 1588025518191 + "time": 1594315658987 }, { "isTrusted": true, @@ -64,7 +100,7 @@ }, "children": [] }, - "time": 1588025518254 + "time": 1594315659077 }, { "isTrusted": true, @@ -83,12 +119,12 @@ }, "children": [] }, - "time": 1588025518976, + "time": 1594315659963, "value": "t" }, { "isTrusted": true, - "name": "keyup", + "name": "input", "page": 0, "selector": "#username", "target": { @@ -99,11 +135,11 @@ "autocomplete": "off", "id": "username", "type": "text", - "value": "t" + "value": "" }, "children": [] }, - "time": 1588025519031, + "time": 1594315659973, "value": "t" }, { @@ -123,9 +159,29 @@ }, "children": [] }, - "time": 1588025519093, + "time": 1594315660026, "value": "o" }, + { + "isTrusted": true, + "name": "input", + "page": 0, + "selector": "#username", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "username", + "type": "text", + "value": "t" + }, + "children": [] + }, + "time": 1594315660027, + "value": "to" + }, { "isTrusted": true, "name": "keyup", @@ -143,8 +199,8 @@ }, "children": [] }, - "time": 1588025519168, - "value": "o" + "time": 1594315660047, + "value": "t" }, { "isTrusted": true, @@ -163,9 +219,49 @@ }, "children": [] }, - "time": 1588025519196, + "time": 1594315660069, "value": "m" }, + { + "isTrusted": true, + "name": "input", + "page": 0, + "selector": "#username", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "username", + "type": "text", + "value": "to" + }, + "children": [] + }, + "time": 1594315660071, + "value": "tom" + }, + { + "isTrusted": true, + "name": "keyup", + "page": 0, + "selector": "#username", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "username", + "type": "text", + "value": "tom" + }, + "children": [] + }, + "time": 1594315660159, + "value": "o" + }, { "isTrusted": true, "name": "keyup", @@ -183,7 +279,7 @@ }, "children": [] }, - "time": 1588025519280, + "time": 1594315660182, "value": "m" }, { @@ -203,12 +299,12 @@ }, "children": [] }, - "time": 1588025519287, + "time": 1594315660857, "value": "s" }, { "isTrusted": true, - "name": "keyup", + "name": "input", "page": 0, "selector": "#username", "target": { @@ -219,12 +315,12 @@ "autocomplete": "off", "id": "username", "type": "text", - "value": "toms" + "value": "tom" }, "children": [] }, - "time": 1588025519356, - "value": "s" + "time": 1594315660860, + "value": "toms" }, { "isTrusted": true, @@ -243,9 +339,49 @@ }, "children": [] }, - "time": 1588025519377, + "time": 1594315660947, "value": "m" }, + { + "isTrusted": true, + "name": "input", + "page": 0, + "selector": "#username", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "username", + "type": "text", + "value": "toms" + }, + "children": [] + }, + "time": 1594315660949, + "value": "tomsm" + }, + { + "isTrusted": true, + "name": "keyup", + "page": 0, + "selector": "#username", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "username", + "type": "text", + "value": "tomsm" + }, + "children": [] + }, + "time": 1594315660971, + "value": "s" + }, { "isTrusted": true, "name": "keydown", @@ -263,9 +399,29 @@ }, "children": [] }, - "time": 1588025519497, + "time": 1594315661037, "value": "i" }, + { + "isTrusted": true, + "name": "input", + "page": 0, + "selector": "#username", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "username", + "type": "text", + "value": "tomsm" + }, + "children": [] + }, + "time": 1594315661038, + "value": "tomsmi" + }, { "isTrusted": true, "name": "keyup", @@ -283,7 +439,7 @@ }, "children": [] }, - "time": 1588025519512, + "time": 1594315661081, "value": "m" }, { @@ -303,7 +459,7 @@ }, "children": [] }, - "time": 1588025519584, + "time": 1594315661149, "value": "i" }, { @@ -323,12 +479,12 @@ }, "children": [] }, - "time": 1588025519607, + "time": 1594315661150, "value": "t" }, { "isTrusted": true, - "name": "keyup", + "name": "input", "page": 0, "selector": "#username", "target": { @@ -339,12 +495,12 @@ "autocomplete": "off", "id": "username", "type": "text", - "value": "tomsmit" + "value": "tomsmi" }, "children": [] }, - "time": 1588025519687, - "value": "t" + "time": 1594315661152, + "value": "tomsmit" }, { "isTrusted": true, @@ -363,9 +519,49 @@ }, "children": [] }, - "time": 1588025519732, + "time": 1594315661239, "value": "h" }, + { + "isTrusted": true, + "name": "input", + "page": 0, + "selector": "#username", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "username", + "type": "text", + "value": "tomsmit" + }, + "children": [] + }, + "time": 1594315661241, + "value": "tomsmith" + }, + { + "isTrusted": true, + "name": "keyup", + "page": 0, + "selector": "#username", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "username", + "type": "text", + "value": "tomsmith" + }, + "children": [] + }, + "time": 1594315661244, + "value": "t" + }, { "isTrusted": true, "name": "keyup", @@ -383,7 +579,7 @@ }, "children": [] }, - "time": 1588025519808, + "time": 1594315661351, "value": "h" }, { @@ -403,9 +599,29 @@ }, "children": [] }, - "time": 1588025520059, + "time": 1594315661554, "value": "Tab" }, + { + "isTrusted": true, + "name": "change", + "page": 0, + "selector": "#username", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "username", + "type": "text", + "value": "tomsmith" + }, + "children": [] + }, + "time": 1594315661556, + "value": "tomsmith" + }, { "isTrusted": true, "name": "keyup", @@ -423,7 +639,7 @@ }, "children": [] }, - "time": 1588025520142, + "time": 1594315661643, "value": "Tab" }, { @@ -443,7 +659,7 @@ }, "children": [] }, - "time": 1588025520432, + "time": 1594315661982, "value": "Meta" }, { @@ -463,7 +679,7 @@ }, "children": [] }, - "time": 1588025520825, + "time": 1594315662048, "value": "v" }, { @@ -483,7 +699,27 @@ }, "children": [] }, - "time": 1588025520971, + "time": 1594315662061, + "value": "SuperSecretPassword!" + }, + { + "isTrusted": true, + "name": "input", + "page": 0, + "selector": "#password", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "password", + "type": "password", + "value": "" + }, + "children": [] + }, + "time": 1594315662066, "value": "SuperSecretPassword!" }, { @@ -503,9 +739,29 @@ }, "children": [] }, - "time": 1588025520978, + "time": 1594315662116, "value": "Meta" }, + { + "isTrusted": true, + "name": "keyup", + "page": 0, + "selector": "#password", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "password", + "type": "password", + "value": "SuperSecretPassword!" + }, + "children": [] + }, + "time": 1594315662138, + "value": "v" + }, { "isTrusted": true, "name": "keydown", @@ -523,14 +779,80 @@ }, "children": [] }, - "time": 1588025521606, + "time": 1594315663331, + "value": "Tab" + }, + { + "isTrusted": true, + "name": "change", + "page": 0, + "selector": "#password", + "target": { + "type": "tag", + "name": "input", + "voidElement": true, + "attrs": { + "autocomplete": "off", + "id": "password", + "type": "password", + "value": "SuperSecretPassword!" + }, + "children": [] + }, + "time": 1594315663332, + "value": "SuperSecretPassword!" + }, + { + "isTrusted": true, + "name": "keyup", + "page": 0, + "selector": "button", + "target": { + "type": "tag", + "name": "button", + "voidElement": false, + "attrs": { "type": "submit", "style": "cursor: pointer;" }, + "children": [ + { + "type": "tag", + "name": "p", + "voidElement": false, + "attrs": {}, + "children": [{ "type": "text", "content": "Log in" }] + } + ] + }, + "time": 1594315663423, + "value": "Tab" + }, + { + "isTrusted": true, + "name": "keydown", + "page": 0, + "selector": "button", + "target": { + "type": "tag", + "name": "button", + "voidElement": false, + "attrs": { "type": "submit", "style": "cursor: pointer;" }, + "children": [ + { + "type": "tag", + "name": "p", + "voidElement": false, + "attrs": {}, + "children": [{ "type": "text", "content": "Log in" }] + } + ] + }, + "time": 1594315663737, "value": "Enter" }, { "isTrusted": true, "name": "click", "page": 0, - "selector": "text=\"Log in\"", + "selector": "button", "target": { "type": "tag", "name": "button", @@ -546,7 +868,7 @@ } ] }, - "time": 1588025521608 + "time": 1594315663739 }, { "isTrusted": true, @@ -601,39 +923,133 @@ ] } ] + }, + { + "type": "tag", + "name": "!--", + "voidElement": false, + "attrs": { + "This": "", + "HTML": "", + "file": "", + "is": "", + "a": "", + "template.": "", + "If": "", + "you": "", + "open": "", + "it": "", + "directly": "", + "in": "", + "the": "", + "browser,": "", + "will": "", + "see": "", + "an": "", + "empty": "", + "page.": "", + "You": "", + "can": "", + "add": "", + "webfonts,": "", + "meta": "", + "tags,": "", + "or": "", + "analytics": "", + "to": "", + "this": "", + "file.": "", + "The": "", + "build": "", + "step": "", + "place": "", + "bundled": "", + "scripts": "", + "into": "" + }, + "children": [ + { + "type": "text", + "content": " tag. To begin the development, run `npm start` or `yarn start`. To create a production bundle, use `npm run build` or `yarn build`. --> " + }, + { + "type": "tag", + "name": "script", + "voidElement": false, + "attrs": { "src": "/static/js/bundle.js" }, + "children": [] + }, + { + "type": "tag", + "name": "script", + "voidElement": false, + "attrs": { "src": "/static/js/1.chunk.js" }, + "children": [] + }, + { + "type": "tag", + "name": "script", + "voidElement": false, + "attrs": { "src": "/static/js/main.chunk.js" }, + "children": [] + }, + { + "type": "tag", + "name": "script", + "voidElement": false, + "attrs": { "src": "/main.45b517d682200d870ece.hot-update.js" }, + "children": [] + } + ] } ] }, - "time": 1588025521665, + "time": 1594315663829, "value": "Enter" }, { "isTrusted": true, "name": "mousedown", "page": 0, - "selector": "text=\"Log out\"", + "selector": "text=Log out", "target": { "type": "tag", - "name": "p", + "name": "button", "voidElement": false, "attrs": {}, - "children": [{ "type": "text", "content": "Log out" }] + "children": [ + { + "type": "tag", + "name": "p", + "voidElement": false, + "attrs": {}, + "children": [{ "type": "text", "content": "Log out" }] + } + ] }, - "time": 1588025523112 + "time": 1594315665876 }, { "isTrusted": true, "name": "click", "page": 0, - "selector": "text=\"Log out\"", + "selector": "text=Log out", "target": { "type": "tag", - "name": "p", + "name": "button", "voidElement": false, "attrs": {}, - "children": [{ "type": "text", "content": "Log out" }] + "children": [ + { + "type": "tag", + "name": "p", + "voidElement": false, + "attrs": {}, + "children": [{ "type": "text", "content": "Log out" }] + } + ] }, - "time": 1588025523175 + "time": 1594315665973 } ] }