Skip to content

Conversation

@penyaskito
Copy link
Contributor

@penyaskito penyaskito commented Feb 26, 2025

Adds iframe mocks support

TODO:

  • Add docs and examples

Usage

import { defineVisualDiffConfig } from '@packages/playwright-drupal';
import { Youtube } from '../packages/playwright-drupal/util/mock/youtube';
import { Mock } from '../packages/playwright-drupal/util/mock/mock';

export const config = defineVisualDiffConfig({
  name: "MySite Visual Diffs",
  description: "A series of visual diffs against MySite default site.",
  groups: [
    {
      name: "Landing Pages",
      description: "Pages built with Layout Builder.",
      testCases: [
        {
          name: "About Us",
          description: "Note only the YouTube video directly in the viewport will show.",
          path: "/about-us",
          mockClass: Mock // or Youtube
        }
      ]
    }
  ],
});

@penyaskito
Copy link
Contributor Author

@deviantintegral this is WIP, but would love your opinion on the direction.

Comment on lines +20 to +21
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? We don't have a yarn lockfile or the like.

import {Mockable} from "../../testcase";
import {Youtube} from "./youtube";

export class Mock implements Mockable{
Copy link
Member

Choose a reason for hiding this comment

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

It's not clear to me that loading a Mock here actually does something with YouTube. I'm not clear why we need this extra Mock class. Would it be clearer to have YouTubeMock Implements Mockable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is definitely bad naming. This extra Mock class was using in some projects to call all the mocks mock method. As we only have youtube here for now, makes not a lot of sense. Maybe renaming to EveryIframeServiceMock would make sense.

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.

3 participants