per-merge request GitLab CI pipeline customization
I'd go with what gitlab already offers, the only/except keyword.

Something like:

test:e2e:A:
  script:
    - whatever you do to test A part
  only:
   refs:
      - master
      - /^A-.*/

test:e2e:B:
  script:
    - whatever you do to test B part
  only:
   refs:
      - master
      - /^B-.*/


The only requirement is that work on A or B is done in branches prefixed with A- or B-.

the refs keyword accept regexes to match, more details on gitlab-ci docs here

If your gitlab is pretty recent (>12.3) the rules method would be prefered and the example above for A would become:

test:e2e:A:
  script:
    - whatever you do to test A part
  rules:
    - if: $CI_COMMIT_REF_NAME =~ /^A-.*$/
    when: always
    - if: $CI_COMMIT_REF_NAME =~ /^master$/
    when: always


Or with a single regex:

test:e2e:A:
  script:
    - whatever you do to test A part
  rules:
    - if: $CI_COMMIT_REF_NAME =~ /^(A-.*|master)$/ 
    when: always


I didn't test those entries above, let me know if one fail