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

fix: [M3-7083 & M3-7175] MarketPlace regex fix + end to end coverage #9704

Merged
merged 16 commits into from
Sep 28, 2023

Conversation

abailly-akamai
Copy link
Contributor

@abailly-akamai abailly-akamai commented Sep 20, 2023

Description 📝

This PR achieves a few things:

  • fix the overly permissive regex to map stackcripts labels to OCA labels.
  • implements an e2e suite for the marketplace, which doubles as validating the fix above (there was no e2e coverage before and this will be quite helpful when migrating those class components into functional ones and avoid state issues such as M3-7045.
  • Improve code structure & quality, and utility coverage of the feature
  • Remove reliance on hard coded OCAs for the "New apps" section

Preview 📷

This PR aims to introduce no visual change or regression

How to test 🧪

  1. Pull code locally and make sure no functional or visual regression was introduced by comparing local and production for the OCA create flow (/linodes/create?type=One-Click)
  2. Test info drawers for some apps and confirm they are populated
  3. run yarn cy:debug and run one-click-apps.spec.ts

@abailly-akamai abailly-akamai changed the title fix: [M3-7083] draft fix: [M3-7083 & M3-7175] MarketPlace regex fix + end to end coverage Sep 26, 2023
@abailly-akamai abailly-akamai self-assigned this Sep 26, 2023
@@ -9,6 +9,7 @@
"moduleResolution": "node",
"lib": ["es6", "dom"],
"baseUrl": "..",
"jsx": "react",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was necessary to remove an import warning when importing a utility from a .tsx extension

const label = isCluster
? decodedLabel.split(' Cluster')[0]
: decodedLabel;
const { decodedLabel, isCluster, label } = handleAppLabel(eachApp);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this to a util so it's reusable and testable in isolation.

const trimmedApps = filteredApps.map((stackscript) =>
trimOneClickFromLabel(stackscript)
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here. Moved to a util. This helps testing in isolation and re-use as an assertion in the e2e test.

'hashicorp nomad clients cluster',
'hashicorp nomad cluster',
].includes(app.label.toLowerCase().trim());
return newAppsIds.includes(app.id.toString());
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand why we were hardcoding those since they are already returning from the oneClickApps feature flag. This fix also makes the New Apps selection more robust since it references the Id rather than a label. This is the reason for passing the flags from the Class Component to the selection panel. (also a class component so no useFlag hook there...)

Confirmed with @HanaXu this was the right thing to do.


const cleanedAppName = app.name.replace('®', '');

return cleanedStackScriptLabel === cleanedAppName;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@abailly-akamai abailly-akamai marked this pull request as ready for review September 26, 2023 18:13
@abailly-akamai abailly-akamai requested a review from a team as a code owner September 26, 2023 18:13
@abailly-akamai abailly-akamai requested review from jdamore-linode and carrillo-erik and removed request for a team September 26, 2023 18:13
Comment on lines +117 to +118
data-qa-drawer
data-testid="drawer"
Copy link
Contributor

@jdamore-linode jdamore-linode Sep 28, 2023

Choose a reason for hiding this comment

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

Suggested change
data-qa-drawer
data-testid="drawer"
data-qa-drawer
data-testid="drawer"

Nice catch. Curious what's special about this drawer that we need to use the MUI component and re-implement these attributes and the close button instead of using the component in src/components/Drawer.tsx

Edit: Oh never mind, I forgot that this drawer has the really nice styling

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah i thought about moving it to our drawer but it would have expanded the scope too much cause I would have had to add props to our Drawer etc. for another time 😄

Copy link
Contributor

@jdamore-linode jdamore-linode left a comment

Choose a reason for hiding this comment

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

Looks great @abailly-akamai! Tests look good and are passing for me, and manually testing OCA I wasn't able to notice any regressions or differences between this and Prod.

Comment on lines +99 to +103
cy.scrollTo(0, 0);
const initialNumberOfApps = trimmedApps.length;
cy.findByPlaceholderText('Search for app name')
.should('exist')
.type(candidate);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cy.scrollTo(0, 0);
const initialNumberOfApps = trimmedApps.length;
cy.findByPlaceholderText('Search for app name')
.should('exist')
.type(candidate);
const initialNumberOfApps = trimmedApps.length;
cy.findByPlaceholderText('Search for app name')
.scrollIntoView()
.should('be.visible')
.type(candidate);

This might be slightly clearer about what the test is trying to do but very minor difference

@carrillo-erik
Copy link
Contributor

Looks good to me. After running the e2e tests in debug mode I was able to verify that they passed.

Screenshot 2023-09-28 at 8 45 26 AM

@abailly-akamai abailly-akamai merged commit 77db948 into linode:develop Sep 28, 2023
11 checks passed
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.

3 participants