Skip to content

Commit

Permalink
update to use mocks only
Browse files Browse the repository at this point in the history
  • Loading branch information
coliu-akamai committed Oct 22, 2024
1 parent 10f143a commit e45fd5e
Showing 1 changed file with 41 additions and 17 deletions.
58 changes: 41 additions & 17 deletions packages/manager/cypress/e2e/core/kubernetes/lke-create.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
kubernetesClusterFactory,
kubernetesControlPlaneACLFactory,
kubernetesControlPlaneACLOptionsFactory,
linodeTypeFactory,
regionFactory,
} from 'src/factories';
import {
mockCreateCluster,
Expand All @@ -14,6 +16,10 @@ import {
mockGetControlPlaneACL,
} from 'support/intercepts/lke';
import { mockGetAccount } from 'support/intercepts/account';
import {
mockGetRegions,
mockGetRegionAvailability,
} from 'support/intercepts/regions';
import { KubernetesCluster } from '@linode/api-v4';
import { LkePlanDescription } from 'support/api/lke';
import { lkeClusterPlans } from 'support/constants/lke';
Expand Down Expand Up @@ -412,6 +418,30 @@ describe('LKE Cluster Creation with ACL', () => {
cy.contains('Add IPv6 Address').should('not.exist');
});

const clusterLabel = randomLabel();
const mockRegion = regionFactory.build({
capabilities: ['Linodes', 'Kubernetes'],
id: 'us-east',
label: 'Newark, US',
});
const mockLinodeTypes = [
linodeTypeFactory.build({
id: 'dedicated-1',
label: 'dedicated-1',
class: 'dedicated',
}),
linodeTypeFactory.build({
id: 'dedicated-2',
label: 'dedicated-2',
class: 'dedicated',
}),
];
const clusterVersion = '1.31';
const clusterPlan = { size: 2, tab: 'Dedicated CPU', type: 'Dedicated' };
const nodeCount = 1;
const planName = 'dedicated-1';
const checkoutName = 'dedicated-1 Plan';

describe('with LKE IPACL account capability', () => {
beforeEach(() => {
mockGetAccount(
Expand All @@ -422,18 +452,11 @@ describe('LKE Cluster Creation with ACL', () => {
],
})
).as('getAccount');
mockGetRegions([mockRegion]).as('getRegions');
mockGetLinodeTypes(mockLinodeTypes).as('getLinodeTypes');
mockGetRegionAvailability(mockRegion.id, []).as('getRegionAvailability');
});

const clusterLabel = randomLabel();
const clusterRegion = chooseRegion({
capabilities: ['Kubernetes'],
});
const clusterVersion = '1.31';
const clusterPlan = { size: 4, tab: 'Dedicated CPU', type: 'Dedicated' };
const nodeCount = 1;
const planName = getLkePlanName(clusterPlan);
const checkoutName = getLkePlanCheckoutName(clusterPlan);

/**
* - Confirms create flow when ACL is toggled off
* - Confirms LKE summary page shows that ACL is not enabled
Expand All @@ -445,10 +468,9 @@ describe('LKE Cluster Creation with ACL', () => {
'revision-id': '',
},
});

const mockCluster = kubernetesClusterFactory.build({
label: clusterLabel,
region: clusterRegion.id,
region: mockRegion.id,
k8s_version: clusterVersion,
control_plane: mockACL,
});
Expand All @@ -465,15 +487,16 @@ describe('LKE Cluster Creation with ACL', () => {
.click();

cy.url().should('endWith', '/kubernetes/create');
cy.wait(['@getAccount']);
cy.wait(['@getAccount', '@getRegions', '@getLinodeTypes']);

// Fill out LKE creation form label, region, and Kubernetes version fields.
cy.findByLabelText('Cluster Label')
.should('be.visible')
.click()
.type(`${clusterLabel}{enter}`);

ui.regionSelect.find().click().type(`${clusterRegion.label}{enter}`);
ui.regionSelect.find().click().type(`${mockRegion.label}{enter}`);
cy.wait(['@getRegionAvailability']);

cy.findByText('Kubernetes Version')
.should('be.visible')
Expand Down Expand Up @@ -574,7 +597,7 @@ describe('LKE Cluster Creation with ACL', () => {

const mockCluster = kubernetesClusterFactory.build({
label: clusterLabel,
region: clusterRegion.id,
region: mockRegion.id,
k8s_version: clusterVersion,
control_plane: mockACL,
});
Expand All @@ -599,7 +622,7 @@ describe('LKE Cluster Creation with ACL', () => {
.click()
.type(`${clusterLabel}{enter}`);

ui.regionSelect.find().click().type(`${clusterRegion.label}{enter}`);
ui.regionSelect.find().click().type(`${mockRegion.label}{enter}`);

cy.findByText('Kubernetes Version')
.should('be.visible')
Expand Down Expand Up @@ -728,7 +751,7 @@ describe('LKE Cluster Creation with ACL', () => {
.click()
.type(`${clusterLabel}{enter}`);

ui.regionSelect.find().click().type(`${clusterRegion.label}{enter}`);
ui.regionSelect.find().click().type(`${mockRegion.label}{enter}`);

cy.findByText('Kubernetes Version')
.should('be.visible')
Expand Down Expand Up @@ -798,6 +821,7 @@ describe('LKE Cluster Creation with ACL', () => {
.click();
});

// Confirm API error displays
cy.wait('@createClusterError');
cy.contains(mockErrorMessage).should('be.visible');
});
Expand Down

0 comments on commit e45fd5e

Please sign in to comment.