Skip to content

Commit

Permalink
fix(codegen): do not forget to reset currentAction in didPerformAction (
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman committed Jan 28, 2021
1 parent e50f11c commit 2793d14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/server/supplements/recorder/codeGenerator.ts
Expand Up @@ -93,8 +93,10 @@ export class CodeGenerator {
eraseLastAction = true;
}
if (lastAction && action.name === 'navigate' && lastAction.name === 'navigate') {
if (action.url === lastAction.url)
if (action.url === lastAction.url) {
this._currentAction = undefined;
return;
}
}
for (const name of ['check', 'uncheck']) {
if (lastAction && action.name === name && lastAction.name === 'click') {
Expand Down
18 changes: 18 additions & 0 deletions test/cli/cli-codegen.spec.ts
Expand Up @@ -638,4 +638,22 @@ describe('cli codegen', (test, { browserName, headful }) => {
url: '${otherFrame.url()}'
}).click('text="Hi, I\\'m frame"');`);
});

it('should record navigations after identical pushState', async ({ page, recorder, httpServer }) => {
httpServer.setHandler((req: http.IncomingMessage, res: http.ServerResponse) => {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end('Hello world');
});
await recorder.setContentAndWait(`
<script>
function pushState() {
history.pushState({}, 'title', '${httpServer.PREFIX}');
}
</script>`, httpServer.PREFIX);
for (let i = 1; i < 3; ++i)
await page.evaluate('pushState()');

await page.goto(httpServer.PREFIX + '/page2.html');
await recorder.waitForOutput(`await page.goto('${httpServer.PREFIX}/page2.html');`);
});
});

0 comments on commit 2793d14

Please sign in to comment.