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

feat: provide reset last config method #73

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rochejul
Copy link

Related to issue #71 , this PR contains the ability for each adapter to have a resetLastConfig method.

This pr contains:

  • Add on the base adapter the method
  • Add tests for each adapters
  • Refactor the adapters' inheritance

I needed to revisit the adapters' inheritance because for some inheritance troubles, the last Apex use case fails when we test the getLastConfig:

const cases = [
    // Works
    {
        testName: 'new api (via createApexTestWireAdapter)',
        adapter: ApexMethod,
        adapterName: 'ApexMethod',
    },
    // Works
    {
        testName: 'legacy api (registerApexTestWireAdapter) used with legacy adapter mock',
        adapter: registerApexTestWireAdapter(LegacyApexMethod),
        adapterName: 'LegacyApexMethod',
    },
    // Fails
    {
        testName: 'legacy api (registerApexTestWireAdapter) used with new adapter mock',
        adapter: registerApexTestWireAdapter(ApexMethod),
        adapterName: 'ApexMethod',
    },
];

I have the feeling the case n°2 mutate the adapter and then when we call the restLastConfig on it, the next calls of getLastConfig will fail.

With the refactoring, everything works now

@rochejul rochejul force-pushed the feat/provide-reset-last-config branch from 2b99d90 to 64674db Compare February 21, 2023 08:44
Comment on lines +2 to +9
let lastConfig = null;
const wireInstances = new Set();
Copy link
Author

Choose a reason for hiding this comment

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

With this approach, we generate each time a new class and we don't expose directly the lastConfig and wireInstances variables. Then we ensure to not have some troubles with inheritances

Comment on lines +20 to +28
static resetLastConfig() {
lastConfig = null;
}
Copy link
Author

Choose a reason for hiding this comment

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

The new method

@rochejul rochejul force-pushed the feat/provide-reset-last-config branch from 64674db to 3b87e2d Compare February 24, 2023 13:18
@rochejul
Copy link
Author

@nolanlawson sorry to ping you: do you know which team should I at-mention to review this PR please?

Many thanks for your help

@nolanlawson
Copy link
Contributor

@rochejul The LWC team (my team) owns this.

@rochejul
Copy link
Author

Many thanks

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.

None yet

2 participants