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

Proposal: Playwright-based Framework for End-to-end Testing #10337

Closed
planger opened this issue Oct 28, 2021 · 0 comments · Fixed by #10494
Closed

Proposal: Playwright-based Framework for End-to-end Testing #10337

planger opened this issue Oct 28, 2021 · 0 comments · Fixed by #10494
Labels
proposal feature proposals (potential future features) test issues related to unit and api tests

Comments

@planger
Copy link
Contributor

planger commented Oct 28, 2021

Alongside unit and integration tests, it is often very useful to have end-to-end tests, which interact with the full application just like a user would do, e.g. for smoke testing the most relevant user flows. This entails that the end-to-end tests typically interact with the user interface and also only observe the results via the user interface (and not necessarily the internal state), just like a user.

Proposal

To simplify writing end-to-end tests for Theia-based applications, we have developed a Playwright-based page object framework, which introduces an abstraction layer over Theia's user interfaces, encapsulating the details of the user interface interactions, wait conditions, etc., to help keeping end-to-end tests more concise, maintainable, and stable. This framework covers the generic user interface interactions of Theia applications, such as dealing with Theia views or editors (opening, closing, querying dirty state), file explorer, text editor, main menus, context menus, status bar elements, etc. Moreover, the framework is extensible so you can add dedicated page objects for custom Theia components, such as custom views, editors, status bar items, etc.

We'd be happy to contribute the page object framework to Theia!

Example

Below, we show an example of how the framework's page objects TheiaWorkspace, TheiaApp, TheiaTextEditor etc. are used in a test.

Screencast of debugging the example

debug-example

Code of the example test

it("should undo and redo text changes and correctly update the dirty state", async () => {
  // 1. set up workspace contents and open Theia app
  const ws = new TheiaWorkspace(["tests/resources/sample-files1"]);
  const app = await TheiaApp.load(page, "http://localhost:3000", ws);

  // 2. open Theia text editor
  const sampleTextEditor = await app.openEditor("sample.txt", TheiaTextEditor);

  // 3. make a change and verify contents and dirty
  await sampleTextEditor.replaceLineWithLineNumber("change", 1);
  expect(await sampleTextEditor.textContentOfLineByLineNumber(1)).toBe(
    "change"
  );
  expect(await sampleTextEditor.isDirty()).toBe(true);

  // 4. undo and verify contents and dirty state
  await sampleTextEditor.undo(2);
  expect(await sampleTextEditor.textContentOfLineByLineNumber(1)).toBe(
    "this is just a sample file"
  );
  expect(await sampleTextEditor.isDirty()).toBe(false);

  // 5. undo and verify contents and dirty state
  await sampleTextEditor.redo(2);
  expect(await sampleTextEditor.textContentOfLineByLineNumber(1)).toBe(
    "change"
  );
  expect(await sampleTextEditor.isDirty()).toBe(true);

  // 6. save verify dirty state
  await sampleTextEditor.save();
  expect(await sampleTextEditor.isDirty()).toBe(false);
  await sampleTextEditor.close();

  // 7. reopen editor and verify dirty state
  const reopenedEditor = await app.openEditor("sample.txt", TheiaTextEditor);
  expect(await reopenedEditor.textContentOfLineByLineNumber(1)).toBe("change");

  await reopenedEditor.close();
});

Related issues and links

@msujew msujew added proposal feature proposals (potential future features) test issues related to unit and api tests labels Oct 28, 2021
planger added a commit to planger/theia that referenced this issue Nov 30, 2021
Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com>
Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
Co-authored-by: Martin Fleck <mfleck@eclipsesource.com>
Co-authored-by: Simon Graband <sgraband@eclipsesource.com>
Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>

Fixes eclipse-theia#10337
planger added a commit to planger/theia that referenced this issue Nov 30, 2021
Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com>
Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
Co-authored-by: Martin Fleck <mfleck@eclipsesource.com>
Co-authored-by: Simon Graband <sgraband@eclipsesource.com>
Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>

Fixes eclipse-theia#10337
planger added a commit to planger/theia that referenced this issue Jan 7, 2022
Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com>
Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
Co-authored-by: Martin Fleck <mfleck@eclipsesource.com>
Co-authored-by: Simon Graband <sgraband@eclipsesource.com>
Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>

Fixes eclipse-theia#10337
planger added a commit to planger/theia that referenced this issue Jan 7, 2022
Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com>
Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
Co-authored-by: Martin Fleck <mfleck@eclipsesource.com>
Co-authored-by: Simon Graband <sgraband@eclipsesource.com>
Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>

Fixes eclipse-theia#10337
planger added a commit to planger/theia that referenced this issue Jan 7, 2022
Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com>
Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
Co-authored-by: Martin Fleck <mfleck@eclipsesource.com>
Co-authored-by: Simon Graband <sgraband@eclipsesource.com>
Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>

Fixes eclipse-theia#10337
planger added a commit to planger/theia that referenced this issue Jan 11, 2022
Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com>
Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
Co-authored-by: Martin Fleck <mfleck@eclipsesource.com>
Co-authored-by: Simon Graband <sgraband@eclipsesource.com>
Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>

Fixes eclipse-theia#10337
sdirix pushed a commit to planger/theia that referenced this issue Jan 13, 2022
Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com>
Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
Co-authored-by: Martin Fleck <mfleck@eclipsesource.com>
Co-authored-by: Simon Graband <sgraband@eclipsesource.com>
Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>

Fixes eclipse-theia#10337
planger added a commit to planger/theia that referenced this issue Feb 2, 2022
Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com>
Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
Co-authored-by: Martin Fleck <mfleck@eclipsesource.com>
Co-authored-by: Simon Graband <sgraband@eclipsesource.com>
Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>
Co-authored-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>

Fixes eclipse-theia#10337
planger added a commit to planger/theia that referenced this issue Feb 2, 2022
Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com>
Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
Co-authored-by: Martin Fleck <mfleck@eclipsesource.com>
Co-authored-by: Simon Graband <sgraband@eclipsesource.com>
Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>
Co-authored-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>

Fixes eclipse-theia#10337
planger added a commit to planger/theia that referenced this issue Feb 2, 2022
Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com>
Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
Co-authored-by: Martin Fleck <mfleck@eclipsesource.com>
Co-authored-by: Simon Graband <sgraband@eclipsesource.com>
Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>
Co-authored-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>

Fixes eclipse-theia#10337
JonasHelming pushed a commit that referenced this issue Feb 2, 2022
Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com>
Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
Co-authored-by: Martin Fleck <mfleck@eclipsesource.com>
Co-authored-by: Simon Graband <sgraband@eclipsesource.com>
Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>
Co-authored-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>

Fixes #10337
planger added a commit to planger/theia that referenced this issue Feb 3, 2022
planger added a commit to planger/theia that referenced this issue Feb 3, 2022
planger added a commit to planger/theia that referenced this issue Feb 3, 2022
planger added a commit to planger/theia that referenced this issue Feb 3, 2022
planger added a commit to planger/theia that referenced this issue Feb 3, 2022
eclipse-theia#10337

Change-Id: I103f3f54aeab4b163c4d295c2fad0538856bebfc
planger added a commit to planger/theia that referenced this issue Feb 9, 2022
eclipse-theia#10337

Change-Id: I103f3f54aeab4b163c4d295c2fad0538856bebfc
planger added a commit to planger/theia that referenced this issue Feb 9, 2022
eclipse-theia#10337

Change-Id: I103f3f54aeab4b163c4d295c2fad0538856bebfc
planger added a commit to planger/theia that referenced this issue Feb 9, 2022
eclipse-theia#10337

Change-Id: I103f3f54aeab4b163c4d295c2fad0538856bebfc
planger added a commit to planger/theia that referenced this issue Feb 9, 2022
eclipse-theia#10337

Change-Id: I103f3f54aeab4b163c4d295c2fad0538856bebfc
planger added a commit to planger/theia that referenced this issue Feb 9, 2022
eclipse-theia#10337

Change-Id: I05e456933779ec7a9b3408f5f82a8ccf2f50a9e6
planger added a commit to planger/theia that referenced this issue Feb 9, 2022
eclipse-theia#10337

Change-Id: I05e456933779ec7a9b3408f5f82a8ccf2f50a9e6
planger added a commit to planger/theia that referenced this issue Feb 11, 2022
eclipse-theia#10337

Change-Id: I92e8118269c98504d43f9a6bfd4c9693d88e6935
planger added a commit to planger/theia that referenced this issue Feb 11, 2022
eclipse-theia#10337

Change-Id: I4d431777333eb4c516071630379f1e6ed87e1850
planger added a commit to planger/theia that referenced this issue Feb 11, 2022
eclipse-theia#10337

Change-Id: I4d431777333eb4c516071630379f1e6ed87e1850
planger added a commit to planger/theia that referenced this issue Feb 11, 2022
eclipse-theia#10337

Change-Id: I4d431777333eb4c516071630379f1e6ed87e1850
JonasHelming pushed a commit that referenced this issue Feb 12, 2022
fixed #10337

Change-Id: I4d431777333eb4c516071630379f1e6ed87e1850
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal feature proposals (potential future features) test issues related to unit and api tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants