Background
So I am sure this will probably get a lot of opinions but I am sure there are some things people with they thought of when starting to implement an automation framework from scratch, which is exactly what I am about to do.
I was given the go-ahead to start as the lead on implementing "automation" (as in we have no automated tests period) on a fairly mature project (Which is good, less maintenance nightmares) but I wanted to start off on the right foot.
I've essentially chosen which tools to use (Enzyme for Component/Unit tests, Cypress for e2e tests and "something" for API/Integration...haven't quite figured that one out). That being said I did work on a "proof of concept" when learning Cypress on this project so I at least have some idea of where to start out there.
On my proof of concept it was also my first dive into the Page Object Model. I quickly became almost stalled when trying to figure out things such as how to structure pages....and how "abstract" do I want to make components. Even things such as how to structure all the page objects and components quickly got me overwhelmed.
Is there a good guide? (Although I guess it's probably opinionated) or things people with they thought of when starting out with PoM. I've also heard of the screenplay pattern but am not super familiar with that either.
Thoughts
Generally (at least in my head) I tried to think about each "Page" as a actual page of the web-application. And tried to abstract individual items (Text boxes/buttons/input fields/etc...) into components. I treated the Page Object as a public api essentially to be called by the test cases (Sort of a black box) but I quickly realized I was doing a lot of duplication in test cases.
For example something such as a Login page, you have a few options here.
Break down the elements (buttons/inputs) into components. Those components have methods (get the element, fill in the element, other special cases as needed)--->Import these components into the "LoginPage" object. call the components individually in the test case.
Just keep all the components in the page object as private selectors (or private methods) and do the same thing as #1.
Do either 1 or 2 but also have public methods as shortcuts in the page object (Such as a "Login()" method that handles everything for you.
I had difficulty when deciding how far down to abstract things and when to make "helper" public methods in the page objects. Since 1 and 2 keeps things abstracted...but you end up making duplicate calls when doing multiple test cases (As opposed to just calling the Login() method).
Sorry for a bit of a ramble, just trying to start out on the right foot.
Problem
How should I handle building this automation from scratch? I definitely want to use the Page Object Model, but I don't want to have too much duplicated code.