Skip to content

Instantly share code, notes, and snippets.

@ivanovzhan
Created February 24, 2025 13:55
Show Gist options
  • Save ivanovzhan/402eef6d8ffc61ac5abb23762fcf6066 to your computer and use it in GitHub Desktop.
Save ivanovzhan/402eef6d8ffc61ac5abb23762fcf6066 to your computer and use it in GitHub Desktop.

Overview

Goal: Transform EmailEditor into a well-tested, easily maintainable library, enabling other teams to integrate it with minimal support overhead.

  • Current Pain Points:

    • Inconsistent testing approaches
    • Frequent support requests from other teams
    • Lack of standardized E2E testing and documentation
  • Proposed Solution:

    1. Migrate to new mono-frontend repository (pnpm-based).
    2. Leverage existing tooling (linting, formatting, Cypress integration, release automation).
    3. Introduce Cypress Page Objects in EmailEditor.
    4. Maintain thorough documentation and automated releases.

Step 1: Project Setup & Tooling

Handled by the new mono-frontend repo.
This covers linting, formatting (Prettier), ESLint rules, and the overall repository structure (monorepo with pnpm).


Step 2: E2E Infrastructure

Handled by the new mono-frontend repo.
This includes setting up Cypress, the test runner configurations, and base CI/CD integration for E2E tests.


Step 3: Cypress Page Objects for EmailEditor

While the new repo covers the baseline Cypress setup, EmailEditor specifically needs Page Objects that simplify testing our Lit components:

  1. Purpose

    • Encapsulate Shadow DOM selectors and repeated interactions into reusable classes.
    • Provide a straightforward interface for other teams to integrate EmailEditor tests.
  2. Example (e.g., EmailHeader.page.ts):

    export class EmailHeaderPage {
      private selector: string;
    
      constructor(selector: string = 'email-header') {
        this.selector = selector;
      }
    
      getTitleElement() {
        return cy.get(this.selector).shadow().find('.title');
      }
    
      setTitle(newTitle: string) {
        cy.get(this.selector).invoke('attr', 'title', newTitle);
      }
    
      assertTitle(expected: string) {
        this.getTitleElement().should('contain.text', expected);
      }
    }
  3. Integration

    • Other teams can import this Page Object (import { EmailHeaderPage } from '@org/email-editor/cypress/page-objects';) and immediately write end-to-end tests without manually dealing with Shadow DOM intricacies.
  4. Maintenance

    • Our team will keep Page Objects updated as components evolve, ensuring consistent test reliability across versions.

Step 4: Documentation & Storybook

Handled by the new mono-frontend repo.
Storybook integration, custom elements documentation (e.g., using @custom-elements-manifest/analyzer), and doc site deployment are part of the existing infrastructure.


Step 5: Release Process & Changelog

Handled by the new mono-frontend repo.
Includes semantic-release (or a similar tool) for automated versioning, changelog generation, and publishing to the internal or public registry.


Step 6: Implementation Timeline

  1. Migration to Mono-Frontend

    • Configure pnpm workspace.
    • Ensure shared ESLint, Prettier, and TS config is applied to all packages.
    • Finalize Cypress test runner setup (already present in monorepo).
  2. Create Cypress Page Objects for EmailEditor

    • Timeline: ~1 week
    • Action Items:
      • Identify key Lit components (header, body, footer, etc.).
      • Implement a Page Object class for each, covering attributes, Shadow DOM queries, and user actions.
      • Provide minimal documentation (e.g., a README.md) explaining how to use these Page Objects.
  3. Add Core E2E Tests (Optional This Sprint)

    • Timeline: ~1 week (overlap possible)
    • Action Items:
      • Use the newly created Page Objects to write “smoke tests” verifying EmailEditor’s main user flows.
      • Confirm the new monorepo pipeline (CI/CD) successfully runs these E2E tests on pull requests.
  4. Documentation & Release Verification

    • Action Items:
      • Ensure EmailEditor stories/docs are present in Storybook.
      • Validate that merges trigger an automated release (semantic-release) for EmailEditor, including a changelog update.

Step 7: Key Takeaways & Conclusion

  • Page Objects drastically reduce the complexity of testing Lit components, benefiting all teams that consume EmailEditor.
  • By migrating to the mono-frontend repo, we inherit:
    1. Established project tooling and consistent code standards (Step 1).
    2. A solid E2E infrastructure with Cypress (Step 2).
    3. Existing documentation processes (Step 4).
    4. Automated releases and changelogs (Step 5).
  • After completing the Page Object creation and verifying E2E flows, EmailEditor will be a reliable, well-tested library that’s easy for other teams to adopt.

Next Steps

  • Management: Approve resource allocation to finalize migration and implement Page Objects for EmailEditor.
  • Development Team: Begin implementation of Page Objects and minimal E2E tests once the repo migration is complete.
  • Stakeholders: Provide feedback on required test scenarios and confirm that new testing workflows meet their needs.

With these steps, EmailEditor will be fully integrated into the new mono-frontend repository, gaining consistent tooling, testing, documentation, and a smooth release pipeline for all future enhancements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment