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

refactor: [M3-9211] - Refactor Linode Rebuild Dialog #11629

Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions packages/api-v4/src/linodes/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Region, RegionSite } from '../regions';
import type { IPAddress, IPRange } from '../networking/types';
import type { SSHKey } from '../profile/types';
import type { LinodePlacementGroupPayload } from '../placement-groups/types';
import { InferType } from 'yup';
import {
CreateLinodeInterfaceSchema,
ModifyLinodeInterfaceSchema,
RebuildLinodeSchema,
UpdateLinodeInterfaceSettingsSchema,
UpgradeToLinodeInterfaceSchema,
} from '@linode/validation';
Expand Down Expand Up @@ -646,17 +646,7 @@ export interface LinodeCloneData {
disks?: number[];
}

export interface RebuildRequest {
image: string;
root_pass: string;
metadata?: UserData;
authorized_keys?: SSHKey[];
authorized_users?: string[];
stackscript_id?: number;
stackscript_data?: any;
booted?: boolean;
disk_encryption?: EncryptionStatus;
}
export type RebuildRequest = InferType<typeof RebuildLinodeSchema>;

export interface LinodeDiskCreationData {
label: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { checkComponentA11y } from 'support/util/accessibility';
import { componentTests, visualTests } from 'support/util/components';

import PasswordInput from 'src/components/PasswordInput/PasswordInput';
import { PasswordInput } from 'src/components/PasswordInput/PasswordInput';

const fakePassword = 'this is a password';
const props = {
Expand Down
45 changes: 23 additions & 22 deletions packages/manager/cypress/e2e/core/linodes/rebuild-linode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,13 @@ const submitRebuild = () => {
ui.button
.findByTitle('Rebuild Linode')
.scrollIntoView()
.should('have.attr', 'data-qa-form-data-loading', 'false')
.should('be.visible')
.should('be.enabled')
.click();
};

// Error message that is displayed when desired password is not strong enough.
const passwordComplexityError =
'Password does not meet complexity requirements.';
const passwordComplexityError = 'Password does not meet strength requirement.';

authenticate();
describe('rebuild linode', () => {
Expand Down Expand Up @@ -135,11 +133,11 @@ describe('rebuild linode', () => {
findRebuildDialog(linode.label).within(() => {
// "From Image" should be selected by default; no need to change the value.
ui.autocomplete
.findByLabel('From Image')
.findByLabel('Rebuild From')
.should('be.visible')
.should('have.value', 'From Image');
.should('have.value', 'Image');

ui.autocomplete.findByLabel('Images').should('be.visible').click();
ui.autocomplete.findByLabel('Image').should('be.visible').click();
ui.autocompletePopper.findByTitle(image).should('be.visible').click();

// Type to confirm.
Expand Down Expand Up @@ -191,24 +189,26 @@ describe('rebuild linode', () => {

openRebuildDialog(linode.label);
findRebuildDialog(linode.label).within(() => {
ui.autocomplete.findByLabel('From Image').should('be.visible').click();
ui.autocomplete
.findByLabel('Rebuild From')
.should('be.visible')
.click();
ui.autocompletePopper
.findByTitle('From Community StackScript')
.findByTitle('Community StackScript')
.should('be.visible')
.click();

cy.wait('@getStackScripts');
cy.findByLabelText('Search by Label, Username, or Description')
cy.findByPlaceholderText('Search StackScripts')
.scrollIntoView()
.should('be.visible')
.type(`${stackScriptName}`);

cy.wait('@getStackScripts');
cy.findByLabelText('List of StackScripts').within(() => {
cy.get(`[id="${stackScriptId}"][type="radio"]`).click();
});

ui.autocomplete.findByLabel('Images').should('be.visible').click();
cy.get(`[id="stackscript-${stackScriptId}"]`).click();

ui.autocomplete.findByLabel('Image').should('be.visible').click();
ui.autocompletePopper.findByTitle(image).should('be.visible').click();

cy.findByLabelText('Linode Label')
Expand Down Expand Up @@ -267,22 +267,23 @@ describe('rebuild linode', () => {

openRebuildDialog(linode.label);
findRebuildDialog(linode.label).within(() => {
ui.autocomplete.findByLabel('From Image').should('be.visible').click();
ui.autocomplete
.findByLabel('Rebuild From')
.should('be.visible')
.click();
ui.autocompletePopper
.findByTitle('From Account StackScript')
.findByTitle('Account StackScript')
.should('be.visible')
.click();

cy.findByLabelText('Search by Label, Username, or Description')
cy.findByPlaceholderText('Search StackScripts')
.scrollIntoView()
.should('be.visible')
.type(`${stackScript.label}`);

cy.findByLabelText('List of StackScripts').within(() => {
cy.get(`[id="${stackScript.id}"][type="radio"]`).click();
});
cy.get(`[id="stackscript-${stackScript.id}"]`).click();

ui.autocomplete.findByLabel('Images').should('be.visible').click();
ui.autocomplete.findByLabel('Image').should('be.visible').click();
ui.autocompletePopper.findByTitle(image).should('be.visible').click();

cy.findByLabelText('Linode Label')
Expand Down Expand Up @@ -316,9 +317,9 @@ describe('rebuild linode', () => {

cy.visitWithLogin(`/linodes/${mockLinode.id}?rebuild=true`);
findRebuildDialog(mockLinode.label).within(() => {
ui.autocomplete.findByLabel('From Image').should('be.visible');
ui.autocomplete.findByLabel('Rebuild From').should('be.visible');
ui.autocomplete
.findByLabel('Images')
.findByLabel('Image')
.should('be.visible')
.click()
.type(image);
Expand Down
Loading
Loading