From a6be9ab4177854b12a09f4b67448e27c2ceb0445 Mon Sep 17 00:00:00 2001 From: Jaalah Ramos <125309814+jaalah-akamai@users.noreply.github.com> Date: Wed, 31 Jul 2024 17:23:22 -0400 Subject: [PATCH 1/3] deps: Upgrade to latest DLS 2.6.1 (#10734) Co-authored-by: Jaalah Ramos --- .../.changeset/pr-10734-tech-stories-1722442550964.md | 5 +++++ packages/manager/package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 packages/manager/.changeset/pr-10734-tech-stories-1722442550964.md diff --git a/packages/manager/.changeset/pr-10734-tech-stories-1722442550964.md b/packages/manager/.changeset/pr-10734-tech-stories-1722442550964.md new file mode 100644 index 00000000000..9b19a96b677 --- /dev/null +++ b/packages/manager/.changeset/pr-10734-tech-stories-1722442550964.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Tech Stories +--- + +Upgraded to latest Design Language System (DLS) 2.6.1 ([#10734](https://github.com/linode/manager/pull/10734)) diff --git a/packages/manager/package.json b/packages/manager/package.json index 807f75deb1d..74c32249693 100644 --- a/packages/manager/package.json +++ b/packages/manager/package.json @@ -18,7 +18,7 @@ "@emotion/styled": "^11.11.0", "@hookform/resolvers": "2.9.11", "@linode/api-v4": "*", - "@linode/design-language-system": "^2.6.0", + "@linode/design-language-system": "^2.6.1", "@linode/validation": "*", "@linode/search": "*", "@lukemorales/query-key-factory": "^1.3.4", diff --git a/yarn.lock b/yarn.lock index 2046c89aabb..ae496788710 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2304,10 +2304,10 @@ resolved "https://registry.yarnpkg.com/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz#8ace5259254426ccef57f3175bc64ed7095ed919" integrity sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw== -"@linode/design-language-system@^2.6.0": - version "2.6.0" - resolved "https://registry.yarnpkg.com/@linode/design-language-system/-/design-language-system-2.6.0.tgz#be3083c07bfa6ede803357a31dcf7b812d9b4ef0" - integrity sha512-SOhTXpUlgqYIvsUD9CqL+R4duM/04vpksYPPxK5wVRL6RLa4GEXiN3l0QwHRRTHHZry7zQu8eMWYGFQwm3vbLw== +"@linode/design-language-system@^2.6.1": + version "2.6.1" + resolved "https://registry.yarnpkg.com/@linode/design-language-system/-/design-language-system-2.6.1.tgz#dac21f50d5087eaa273f76a3b3542f6160ee6076" + integrity sha512-cnj8X8s5ykxCCrHOwkEkroz/b1od5NTvidDDuyy5147Hqo7V5BWtdS+gLDqdvTKtYO0ybrORXRCD4y9qHf88HA== dependencies: "@tokens-studio/sd-transforms" "1.2.0" react "^17.0.2" From 4a405c58a2f4c314ec7caf4c08f51b789444e580 Mon Sep 17 00:00:00 2001 From: Azure-akamai Date: Thu, 1 Aug 2024 09:10:12 -0400 Subject: [PATCH 2/3] test: [M3-8319] - Add CM Logout test (#10733) * Add CM Logout test * Added changeset: E2E coverage for Logout flow * Update from views --- .../pr-10733-tests-1722436583624.md | 5 +++ .../e2e/core/account/account-logout.spec.ts | 34 +++++++++++++++++++ .../cypress/support/intercepts/account.ts | 9 +++++ 3 files changed, 48 insertions(+) create mode 100644 packages/manager/.changeset/pr-10733-tests-1722436583624.md create mode 100644 packages/manager/cypress/e2e/core/account/account-logout.spec.ts diff --git a/packages/manager/.changeset/pr-10733-tests-1722436583624.md b/packages/manager/.changeset/pr-10733-tests-1722436583624.md new file mode 100644 index 00000000000..3686d12b404 --- /dev/null +++ b/packages/manager/.changeset/pr-10733-tests-1722436583624.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Tests +--- + +E2E coverage for Logout flow ([#10733](https://github.com/linode/manager/pull/10733)) diff --git a/packages/manager/cypress/e2e/core/account/account-logout.spec.ts b/packages/manager/cypress/e2e/core/account/account-logout.spec.ts new file mode 100644 index 00000000000..bb72c9795b4 --- /dev/null +++ b/packages/manager/cypress/e2e/core/account/account-logout.spec.ts @@ -0,0 +1,34 @@ +import { LOGIN_ROOT } from 'src/constants'; +import { interceptGetAccount } from 'support/intercepts/account'; +import { ui } from 'support/ui'; + +describe('Logout Test', () => { + beforeEach(() => { + cy.tag('purpose:syntheticTesting'); + }); + + /* + * - Confirms that Cloud Manager log out functionality works as expected. + * - Confirms that the login application is up after account logout. + */ + it('can logout the account and redirect to login endpoint', () => { + interceptGetAccount().as('getAccount'); + + cy.visitWithLogin('/account'); + cy.wait('@getAccount'); + + // User can click Logout via user menu. + ui.userMenuButton.find().click(); + ui.userMenu + .find() + .should('be.visible') + .within(() => { + cy.findByText('Log Out').should('be.visible').click(); + }); + // Upon clicking "Log Out", the user is redirected to the login endpoint at /login + cy.url().should('equal', `${LOGIN_ROOT}/login`); + // Using cy.visit to navigate back to Cloud results in another redirect to the login page + cy.visit('/'); + cy.url().should('startWith', `${LOGIN_ROOT}/login`); + }); +}); diff --git a/packages/manager/cypress/support/intercepts/account.ts b/packages/manager/cypress/support/intercepts/account.ts index d4bcb1afae4..54472bb1fe1 100644 --- a/packages/manager/cypress/support/intercepts/account.ts +++ b/packages/manager/cypress/support/intercepts/account.ts @@ -36,6 +36,15 @@ export const mockGetAccount = (account: Account): Cypress.Chainable => { return cy.intercept('GET', apiMatcher('account'), makeResponse(account)); }; +/** + * Intercepts GET request to fetch account. + * + * @returns Cypress chainable. + */ +export const interceptGetAccount = (): Cypress.Chainable => { + return cy.intercept('GET', apiMatcher('account')); +}; + /** * Intercepts PUT request to update account and mocks response. * From 4f699e954a79fbb55201547ec2b00997527093d6 Mon Sep 17 00:00:00 2001 From: Azure-akamai Date: Thu, 1 Aug 2024 09:10:32 -0400 Subject: [PATCH 3/3] test: [M3-8197,M3-8150] - Cypress test for refactored events and placement group (#10719) * Add new test for M3-8197&m3-8150 * Added changeset: Cypress test for refactored events and placement group * Update from views --- .../pr-10719-tests-1722001957079.md | 5 ++ .../notificationsAndEvents/events.spec.ts | 2 + ...reate-linode-with-placement-groups.spec.ts | 80 ++++++++++++++++++- 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 packages/manager/.changeset/pr-10719-tests-1722001957079.md diff --git a/packages/manager/.changeset/pr-10719-tests-1722001957079.md b/packages/manager/.changeset/pr-10719-tests-1722001957079.md new file mode 100644 index 00000000000..f86097f331d --- /dev/null +++ b/packages/manager/.changeset/pr-10719-tests-1722001957079.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Tests +--- + +E2E coverage for refactored Events and Placement Groups flows ([#10719](https://github.com/linode/manager/pull/10719)) diff --git a/packages/manager/cypress/e2e/core/notificationsAndEvents/events.spec.ts b/packages/manager/cypress/e2e/core/notificationsAndEvents/events.spec.ts index 0adc8a7f8c1..ee659c4cd4d 100644 --- a/packages/manager/cypress/e2e/core/notificationsAndEvents/events.spec.ts +++ b/packages/manager/cypress/e2e/core/notificationsAndEvents/events.spec.ts @@ -135,6 +135,8 @@ describe('verify notification types and icons', () => { }); } containsClick('View all events'); + // Clicking "View all events" navigates to Events page at /events + cy.url().should('endWith', '/events'); events.forEach((event) => { const text = [`${event.message}`, `${event.entity?.label}`]; const regex = new RegExp(`${text.join('|')}`, 'g'); diff --git a/packages/manager/cypress/e2e/core/placementGroups/create-linode-with-placement-groups.spec.ts b/packages/manager/cypress/e2e/core/placementGroups/create-linode-with-placement-groups.spec.ts index 554bf09e06d..78f38efda26 100644 --- a/packages/manager/cypress/e2e/core/placementGroups/create-linode-with-placement-groups.spec.ts +++ b/packages/manager/cypress/e2e/core/placementGroups/create-linode-with-placement-groups.spec.ts @@ -11,17 +11,21 @@ import { } from 'src/factories'; import { regionFactory } from 'src/factories'; import { ui } from 'support/ui/'; -import { mockCreateLinode } from 'support/intercepts/linodes'; +import { + mockCreateLinode, + mockGetLinodeDetails, +} from 'support/intercepts/linodes'; import { mockGetRegions } from 'support/intercepts/regions'; import { mockCreatePlacementGroup, mockGetPlacementGroups, } from 'support/intercepts/placement-groups'; -import { randomString } from 'support/util/random'; +import { randomNumber, randomString } from 'support/util/random'; import { CANNOT_CHANGE_PLACEMENT_GROUP_POLICY_MESSAGE } from 'src/features/PlacementGroups/constants'; import type { Region } from '@linode/api-v4'; import type { Flags } from 'src/featureFlags'; +import { linodeCreatePage } from 'support/ui/pages'; const mockAccount = accountFactory.build(); const mockRegions: Region[] = [ @@ -208,4 +212,76 @@ describe('Linode create flow with Placement Group', () => { ); }); }); + + /* + * - Confirms UI flow to create a Linode with an existing Placement Group using mock API data. + * - Confirms that Placement Group is reflected in create summary section. + * - Confirms that outgoing Linode Create API request specifies the selected Placement Group to be attached. + */ + it('can assign existing Placement Group during Linode Create flow', () => { + const mockPlacementGroup = placementGroupFactory.build({ + label: 'pg-1-us-east', + region: mockRegions[0].id, + placement_group_type: 'anti_affinity:local', + placement_group_policy: 'strict', + is_compliant: true, + }); + + const linodeLabel = 'linode-with-placement-group'; + const mockLinode = linodeFactory.build({ + id: randomNumber(), + label: linodeLabel, + region: mockRegions[0].id, + placement_group: { + id: mockPlacementGroup.id, + }, + }); + + mockGetPlacementGroups([mockPlacementGroup]).as('getPlacementGroups'); + mockCreateLinode(mockLinode).as('createLinode'); + mockGetLinodeDetails(mockLinode.id, mockLinode); + + cy.visitWithLogin('/linodes/create'); + + linodeCreatePage.selectRegionById(mockRegions[0].id); + cy.wait('@getPlacementGroups'); + linodeCreatePage.selectPlan('Shared CPU', 'Nanode 1 GB'); + linodeCreatePage.setRootPassword(randomString(32)); + linodeCreatePage.setLabel(mockLinode.label); + + // Confirm that mocked Placement Group is shown in the Autocomplete, and then select it. + cy.findByText('Placement Groups in Newark, NJ (us-east)') + .click() + .type(`${mockPlacementGroup.label}`); + ui.autocompletePopper + .findByTitle(mockPlacementGroup.label) + .should('be.visible') + .click(); + + // Confirm the Placement group assignment is accounted for in the summary. + cy.get('[data-qa-summary="true"]').within(() => { + cy.findByText('Assigned to Placement Group').should('be.visible'); + }); + + // Create Linode and confirm contents of outgoing API request payload. + ui.button + .findByTitle('Create Linode') + .should('be.visible') + .should('be.enabled') + .click(); + + cy.wait('@createLinode').then((xhr) => { + const requestPayload = xhr.request.body; + expect(requestPayload['region']).to.equal(mockRegions[0].id); + expect(requestPayload['label']).to.equal(linodeLabel); + expect(requestPayload['placement_group'].id).to.equal( + mockPlacementGroup.id + ); + }); + + // Confirm redirect to new Linode. + cy.url().should('endWith', `/linodes/${mockLinode.id}`); + // Confirm toast notification should appear on Linode create. + ui.toast.assertMessage(`Your Linode ${mockLinode.label} is being created.`); + }); });