Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DONT MERGE] feat: load limited-time offer signals on the client side #14897

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

starsirius
Copy link
Member

@starsirius starsirius commented Nov 22, 2024

The type of this PR is: Feat

DO NOT MERGE YET. This depends on artsy/metaphysics#6220, and we might want to include tracking changes.

This PR solves EMI-2161

Description

In the previous attempt, we tried a few design options to display the limited-time offer signals on the client-side. We then realized the signal has to be considered together with other badge signals (i.e. "increased interest" and "curators' pick") because we only want to display at most one. So we decided to switch back to the original signals design and let client-side loaded signals, if any, dynamically replace server-side rendered content. We now think it's acceptable to have content shift for this particular data which is relatively lower volume.

  • This is an example that the client-side loaded limited-time offer signal replaces an increased interest badge in-place. We can see the offered price also replaces the listed price shortly after page loads, as well as the timer and save state pops in.

    Recording

    client-side-collector-signals-with-primary-label

  • This is an example when without other badges, the limited-time offer badge is inserted which causes some content shift.

    Recording

    client-side-collector-signals-no-primary-label

cc @artsy/emerald-devs

This depends on MP change that removes partner offers from primary
labels. Primary label should only consist of unauthenticated data.
Now we have to consider partner offer (that's loaded on the client side)
when displaying "increased interest" and "curtors' pick" badges (that
can be loaded on the server and cached), it may visually look better
moving the limited-time offer back to the first line, with the badges.
While there will be some content shift, we can preserve the original
collector signals design (vs. partially porting over the app design).
@starsirius starsirius self-assigned this Nov 22, 2024
@artsy-peril
Copy link
Contributor

artsy-peril bot commented Nov 22, 2024

Fails
🚫

Hi there! 👋

We use conventional commit formatting which has not been detected in your PRs title.

Refer to README#327 and Conventional Commits for PR/commit formatting guidelines.

Generated by 🚫 dangerJS against da81774

Copy link

relativeci bot commented Nov 22, 2024

#1007 Bundle Size — 9.57MiB (+0.25%).

da81774(current) vs ffe4f84 main#484(baseline)

Important

Bundle introduced 1 and removed 4 duplicate packages – View changed duplicate packages

Warning

Bundle introduced 3 new packages: web-vitals, @sentry-internal/browser-utils, stylis – View changed packages

Bundle metrics  Change 8 changes Regression 1 regression Improvement 3 improvements
                 Current
#1007
     Baseline
#484
Improvement  Initial JS 3.7MiB(-6.53%) 3.95MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 87.82% 2.04%
Change  Chunks 142(-0.7%) 143
No change  Assets 146 146
Change  Modules 5701(+1.14%) 5637
Regression  Duplicate Modules 501(+10.11%) 455
Change  Duplicate Code 6.12%(+4.08%) 5.88%
Improvement  Packages 282(-3.09%) 291
Improvement  Duplicate Packages 39(-7.14%) 42
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#1007
     Baseline
#484
Regression  JS 9.36MiB (+0.46%) 9.31MiB
Improvement  Other 218.23KiB (-8.25%) 237.84KiB

Bundle analysis reportBranch review-app-client-side-collector...Project dashboard


Generated by RelativeCIDocumentationReport issue

)
}

const SaleMessageFragmentContainer = createFragmentContainer(SaleMessage, {
Copy link
Member

Choose a reason for hiding this comment

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

#nonblocking and harmless, but would def encourage all new relay code to be written using hooks:

const data = useFragment(...)

Its a bit nicer from an import perspective too; can do import { SaleMessage } from vs having to mention fragment containers.

relayEnvironment: mockEnvironment,
}
})
})
Copy link
Member

Choose a reason for hiding this comment

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

#non-blocking (but recommended): Rather than mocking out all of this stuff, can simply test the fragment via our relay testing tools and skip all of the qury renderer wiring (which historically we typically don't test):

const { renderWithRelay } = setupTestWrapperTL({
  Component: SaleMessageFragmentContainer
  query: ...
})

it('works', () => {
  renderWithRelay(someFixture)
  
  expect(screen.getByText("foo")).toBeOnScreen() 
})

)

act(() => {
mockEnvironment.mock.resolveMostRecentOperation(operation =>
Copy link
Member

Choose a reason for hiding this comment

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

This allows us to skip manually mocking both the test environment and the relay operation; all of those things happen inside of our test tools automatically.

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

Successfully merging this pull request may close these issues.

2 participants