In Selenium Page Object model pattern web pages are represented as classes, various elements on the page are defined as variables in the class, and user interactions are implemented as methods in the class.
That is for each page separate class is created.
There's an ecommerce application with pages- login, home, search, product, cart, checkout, and order confirmation.
There are variuos modals also, like cart preview, add customer, etc. Some modals will be visible on multiple pages and some modals will be visible on particular page only.
E.g. Cart preview modal will show information like current products in cart, quantity, price, total, etc and it can be accessed from home, search, product, and cart pages.
Whereas add customer modal will have fields to add new customer- Name, Conact information, Address, etc. and this modal will be visible only on checkout page.
If I am using page object model pattern, where should I define these modals I mean shall I create a separate class for modals or shall I define them in the respective enclosing page?
Shall I create a separate class for modal that is visible on multiple pages and define the page specific modal in the respective enclosing class?