Skip to content

Commit

Permalink
Merge branch 'linode:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
cpathipa authored Aug 1, 2024
2 parents d9bd490 + 4f699e9 commit 960415e
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 7 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10719-tests-1722001957079.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

E2E coverage for refactored Events and Placement Groups flows ([#10719](https://github.com/linode/manager/pull/10719))
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10733-tests-1722436583624.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

E2E coverage for Logout flow ([#10733](https://github.com/linode/manager/pull/10733))
Original file line number Diff line number Diff line change
@@ -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))
34 changes: 34 additions & 0 deletions packages/manager/cypress/e2e/core/account/account-logout.spec.ts
Original file line number Diff line number Diff line change
@@ -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 <REACT_APP_LOGIN_ROOT>/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`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down Expand Up @@ -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.`);
});
});
9 changes: 9 additions & 0 deletions packages/manager/cypress/support/intercepts/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ export const mockGetAccount = (account: Account): Cypress.Chainable<null> => {
return cy.intercept('GET', apiMatcher('account'), makeResponse(account));
};

/**
* Intercepts GET request to fetch account.
*
* @returns Cypress chainable.
*/
export const interceptGetAccount = (): Cypress.Chainable<null> => {
return cy.intercept('GET', apiMatcher('account'));
};

/**
* Intercepts PUT request to update account and mocks response.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 960415e

Please sign in to comment.