Skip to content

Commit

Permalink
chore: [M3-8598] - Remove Linode Create v1 (#10958)
Browse files Browse the repository at this point in the history
* round 1 of deleting stuff

* round 2 of deleting stuff

* round 3 of deleting stuff

* round 4 of deleting stuff

* fix up one click app tests

* fix unit test

* Added changeset: Remove Linode Create v1

* remove `.only()`

* get test working

* clean up unused utils and lodash packages

---------

Co-authored-by: Banks Nussman <[email protected]>
  • Loading branch information
bnussman-akamai and bnussman authored Sep 25, 2024
1 parent fdca0e4 commit 0a70c60
Show file tree
Hide file tree
Showing 84 changed files with 125 additions and 7,838 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

Remove Linode Create v1 ([#10958](https://github.com/linode/manager/pull/10958))
133 changes: 63 additions & 70 deletions packages/manager/cypress/e2e/core/oneClickApps/one-click-apps.spec.ts
Original file line number Diff line number Diff line change
@@ -1,119 +1,109 @@
import { containsVisible } from 'support/helpers';
import { ui } from 'support/ui';
import {
interceptGetStackScripts,
mockGetStackScript,
mockGetStackScripts,
} from 'support/intercepts/stackscripts';
import { mockCreateLinode } from 'support/intercepts/linodes';
import {
filterOneClickApps,
handleAppLabel,
} from 'src/features/Linodes/LinodesCreate/utilities';
import { randomLabel, randomString } from 'support/util/random';
import { chooseRegion } from 'support/util/regions';
import { mapStackScriptLabelToOCA } from 'src/features/OneClickApps/utils';
import { stackScriptFactory } from 'src/factories/stackscripts';
import { oneClickApps } from 'src/features/OneClickApps/oneClickAppsv2';
import { getMarketplaceAppLabel } from 'src/features/Linodes/LinodeCreatev2/Tabs/Marketplace/utilities';

import type { StackScript } from '@linode/api-v4';
import type { OCA } from '@src/features/OneClickApps/types';
import { imageFactory, linodeFactory } from 'src/factories';
import { mockGetAllImages } from 'support/intercepts/images';

describe('OneClick Apps (OCA)', () => {
it('Lists all the OneClick Apps', () => {
cy.tag('method:e2e');
interceptGetStackScripts().as('getStackScripts');

interceptGetStackScripts().as('getStackScripts');
cy.visitWithLogin(`/linodes/create?type=One-Click`);

cy.wait('@getStackScripts').then((xhr) => {
const stackScripts: StackScript[] = xhr.response?.body.data ?? [];

const trimmedApps: StackScript[] = filterOneClickApps({
baseAppIds: Object.keys(oneClickApps).map(Number),
newApps: {},
queryResults: stackScripts,
});

// Check the content of the OCA listing
// Check the content of the app list
cy.findByTestId('one-click-apps-container').within(() => {
// Check that all sections are present (note: New apps can be empty so not asserting its presence)
cy.findByText('Popular apps').should('be.visible');
cy.findByText('All apps').should('be.visible');

trimmedApps.forEach((stackScript) => {
const { decodedLabel, label } = handleAppLabel(stackScript);

// Check that every OCA is listed with the correct label
cy.get(`[data-qa-select-card-heading="${label.trim()}"]`).should(
'exist'
);

// Check that every OCA has a drawer match
// This validates the regex in `mapStackScriptLabelToOCA`
// and ensures every app listed has a corresponding populated drawer
// This is only true for the apps defined in `oneClickApps.ts`
expect(
mapStackScriptLabelToOCA({
oneClickApps: Object.values(oneClickApps),
stackScriptLabel: decodedLabel,
})
).to.not.be.undefined;
});
// For every Marketplace app defined in Cloud Manager, make sure the API returns
// the nessesary StackScript and that the app renders on the page.
for (const stackscriptId in oneClickApps) {
const stackscript = stackScripts.find((s) => s.id === +stackscriptId);
const app = oneClickApps[stackscriptId];

if (!stackscript) {
throw new Error(
`Cloud Manager's fetch to GET /v4/linode/stackscripts did not recieve a StackScript with ID ${stackscriptId}. We expected that StackScript to be in the response for the Marketplace app named "${app.name}".`
);
}

// Using `findAllByText` because some apps may be duplicatd under different sections
cy.findAllByText(getMarketplaceAppLabel(app.name)).should('exist');
}
});
});
});

// Check drawer content for one OCA candidate.
const candidateApp = trimmedApps[0];
const candidateLabel = handleAppLabel(trimmedApps[0]).label;
it('Can view app details of a marketplace app', () => {
cy.tag('method:e2e');

const stackScriptCandidate = cy
.get(`[data-qa-selection-card-info="${candidateLabel.trim()}"]`)
.first();
stackScriptCandidate.should('exist').click();
interceptGetStackScripts().as('getStackScripts');
cy.visitWithLogin(`/linodes/create?type=One-Click`);

const app: OCA | undefined = mapStackScriptLabelToOCA({
oneClickApps: Object.values(oneClickApps),
stackScriptLabel: candidateApp.label,
});
cy.wait('@getStackScripts').then((xhr) => {
const stackScripts: StackScript[] = xhr.response?.body.data ?? [];

// For the sake of this test, use the first marketplace app defined in Cloud Manager
const candidateStackScriptId = +Object.keys(oneClickApps)[0];

if (!app) {
const candidateApp = oneClickApps[candidateStackScriptId];

if (!candidateApp) {
throw new Error(
'The candidate app for this test no longer exists. The tests needs updating.'
);
}

const candidateStackScript = stackScripts.find(
(s) => s.id === candidateStackScriptId
);

if (!candidateStackScript) {
throw new Error(
`Failed to map StackScript label '${candidateLabel}' to a One-Click App`
'No StackScript returned by the API for the candidate app.'
);
}

cy.findByTestId('one-click-apps-container').within(() => {
cy.findAllByLabelText(`Info for "${candidateApp.name}"`)
.first()
.scrollIntoView()
.should('be.visible')
.should('be.enabled')
.click();
});

ui.drawer
.findByTitle(trimmedApps[0].label.trim())
.findByTitle(candidateApp.name)
.should('be.visible')
.within(() => {
containsVisible(app.description);
containsVisible(app.summary);
containsVisible(app.website!);
cy.findByText(candidateApp.description).should('be.visible');
cy.findByText(candidateApp.summary).should('be.visible');
cy.findByText(candidateApp.website!).should('be.visible');
});

ui.drawerCloseButton.find().click();
ui.drawer.find().should('not.exist');

// Check the filtering of the apps
cy.scrollTo(0, 0);
const initialNumberOfApps = trimmedApps.length;
cy.findByPlaceholderText('Search for app name')
.should('exist')
.type(candidateLabel);
cy.findByTestId('one-click-apps-container').within(() => {
cy.get('[data-qa-selection-card="true"]').should(
'have.length.below',
initialNumberOfApps
);
cy.get(
`[data-qa-selection-card-info="${candidateLabel.trim()}"]`
).should('be.visible');
});
});
});

it('Deploys a Linode from a One Click App', () => {
it('Deploys a Linode from a One Click App with user defined fields', () => {
const images = [
imageFactory.build({
id: 'linode/ubuntu22.04',
Expand All @@ -125,8 +115,11 @@ describe('OneClick Apps (OCA)', () => {
}),
];

// For the sake of this test, use the first marketplace app defined in Cloud Manager
const candidateStackScriptId = +Object.keys(oneClickApps)[0];

const stackscript = stackScriptFactory.build({
id: 0,
id: candidateStackScriptId,
username: 'linode',
user_gravatar_id: '9d4d301385af69ceb7ad658aad09c142',
label: 'E2E Test App',
Expand Down Expand Up @@ -187,7 +180,7 @@ describe('OneClick Apps (OCA)', () => {
cy.findByText('New apps').should('be.visible');

// Check that the app is listed and select it
cy.get('[data-qa-selection-card="true"]').should('have.length', 3);
cy.get('[data-qa-selection-card="true"]').should('have.length', 2);
cy.findAllByText(stackscript.label).first().should('be.visible').click();
});

Expand Down
4 changes: 0 additions & 4 deletions packages/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
"jspdf-autotable": "^3.5.14",
"launchdarkly-react-client-sdk": "3.0.10",
"libphonenumber-js": "^1.10.6",
"lodash.clonedeep": "^4.5.0",
"lodash.curry": "^4.1.1",
"logic-query-parser": "^0.0.5",
"luxon": "3.4.4",
"markdown-it": "^12.3.2",
Expand Down Expand Up @@ -144,8 +142,6 @@
"@types/highlight.js": "~10.1.0",
"@types/jsdom": "^21.1.4",
"@types/jspdf": "^1.3.3",
"@types/lodash.clonedeep": "^4.5.9",
"@types/lodash.curry": "^4.1.9",
"@types/luxon": "3.4.2",
"@types/markdown-it": "^10.0.2",
"@types/md5": "^2.1.32",
Expand Down
28 changes: 0 additions & 28 deletions packages/manager/src/__data__/UserDefinedFields.ts

This file was deleted.

49 changes: 0 additions & 49 deletions packages/manager/src/__data__/stackScripts.ts

This file was deleted.

24 changes: 0 additions & 24 deletions packages/manager/src/components/PrimaryNav/PrimaryNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { useIsPlacementGroupsEnabled } from 'src/features/PlacementGroups/utils'
import { useFlags } from 'src/hooks/useFlags';
import { usePrefetch } from 'src/hooks/usePreFetch';
import { useAccountSettings } from 'src/queries/account/settings';
import { useMarketplaceAppsQuery } from 'src/queries/stackscripts';

import useStyles from './PrimaryNav.styles';
import { linkIsActive } from './utils';
Expand Down Expand Up @@ -88,34 +87,14 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
const flags = useFlags();
const location = useLocation();

const [
enableMarketplacePrefetch,
setEnableMarketplacePrefetch,
] = React.useState(false);

const { data: accountSettings } = useAccountSettings();
const isManaged = accountSettings?.managed ?? false;

const {
data: oneClickApps,
error: oneClickAppsError,
isLoading: oneClickAppsLoading,
} = useMarketplaceAppsQuery(enableMarketplacePrefetch);

const allowMarketplacePrefetch =
!oneClickApps && !oneClickAppsLoading && !oneClickAppsError;

const { isACLPEnabled } = useIsACLPEnabled();

const { isPlacementGroupsEnabled } = useIsPlacementGroupsEnabled();
const { isDatabasesEnabled, isDatabasesV2Beta } = useIsDatabasesEnabled();

const prefetchMarketplace = () => {
if (!enableMarketplacePrefetch) {
setEnableMarketplacePrefetch(true);
}
};

const primaryLinkGroups: PrimaryLink[][] = React.useMemo(
() => [
[
Expand Down Expand Up @@ -220,8 +199,6 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
display: 'Marketplace',
href: '/linodes/create?type=One-Click',
icon: <OCA />,
prefetchRequestCondition: allowMarketplacePrefetch,
prefetchRequestFn: prefetchMarketplace,
},
],
[
Expand All @@ -248,7 +225,6 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
isDatabasesEnabled,
isDatabasesV2Beta,
isManaged,
allowMarketplacePrefetch,
isPlacementGroupsEnabled,
isACLPEnabled,
]
Expand Down
23 changes: 0 additions & 23 deletions packages/manager/src/containers/account.container.ts

This file was deleted.

Loading

0 comments on commit 0a70c60

Please sign in to comment.