-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: [M3-8626] - Create linode in a distributed region with Gecko (#…
…11572) * test: [M3-8626] - Cypress test for Linode Create "Distributed" Region with Gecko * removed afterEach() block * added mockRegions() query * added mock for LinodeType * Added changeset: Create linode in a distributed region * removed cy.get() wherever possible * create nanode type instead of dedicated * changeset update
- Loading branch information
1 parent
872cde9
commit ab2a7e5
Showing
3 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@linode/manager': Tests | ||
--- | ||
|
||
Add E2E test coverage for creating linode in a distributed region ([#11572](https://github.com/linode/manager/pull/11572)) |
88 changes: 88 additions & 0 deletions
88
packages/manager/cypress/e2e/core/linodes/create-linode-in-distributed-region.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { Region } from '@linode/api-v4'; | ||
import { linodeFactory, linodeTypeFactory, regionFactory } from 'src/factories'; | ||
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags'; | ||
import { | ||
mockCreateLinode, | ||
mockGetLinodeTypes, | ||
} from 'support/intercepts/linodes'; | ||
import { | ||
mockGetRegionAvailability, | ||
mockGetRegions, | ||
} from 'support/intercepts/regions'; | ||
import { ui } from 'support/ui'; | ||
import { linodeCreatePage } from 'support/ui/pages'; | ||
import { randomLabel, randomString } from 'support/util/random'; | ||
import { extendRegion } from 'support/util/regions'; | ||
|
||
describe('Create Linode in Distributed Region', () => { | ||
/* | ||
* - Confirms Linode create flow can be completed with a distributed region | ||
* - Creates a basic Nanode and confirms interactions succeed and outgoing request contains expected data. | ||
*/ | ||
it('should be able to select a distributed region', () => { | ||
// create mocks | ||
const mockRegionOptions: Partial<Region> = { | ||
capabilities: ['Linodes', 'Distributed Plans'], | ||
site_type: 'distributed', | ||
}; | ||
const mockRegion = extendRegion(regionFactory.build(mockRegionOptions)); | ||
const mockLinodeTypes = [ | ||
linodeTypeFactory.build({ | ||
id: 'nanode-edge-1', | ||
label: 'Nanode 1GB', | ||
class: 'nanode', | ||
}), | ||
]; | ||
const mockLinode = linodeFactory.build({ | ||
label: randomLabel(), | ||
region: mockRegion.id, | ||
}); | ||
const rootPass = randomString(32); | ||
|
||
mockAppendFeatureFlags({ | ||
gecko2: { | ||
enabled: true, | ||
la: true, | ||
}, | ||
}).as('getFeatureFlags'); | ||
mockGetRegions([mockRegion]).as('getRegions'); | ||
mockGetLinodeTypes(mockLinodeTypes).as('getLinodeTypes'); | ||
mockGetRegionAvailability(mockRegion.id, []).as('getRegionAvailability'); | ||
mockCreateLinode(mockLinode).as('createLinode'); | ||
|
||
cy.visitWithLogin('/linodes/create'); | ||
cy.wait(['@getFeatureFlags', '@getRegions', '@getLinodeTypes']); | ||
|
||
// Pick a region from the distributed region list | ||
cy.findByTestId('region').within(() => { | ||
ui.tabList.findTabByTitle('Distributed').should('be.visible').click(); | ||
linodeCreatePage.selectRegionById(mockRegion.id); | ||
}); | ||
|
||
cy.wait(['@getRegionAvailability']); | ||
linodeCreatePage.setLabel(mockLinode.label); | ||
linodeCreatePage.selectImage('Debian 11'); | ||
linodeCreatePage.setRootPassword(rootPass); | ||
|
||
cy.get('[data-qa-tp="Linode Plan"]').within(() => { | ||
cy.findByRole('row', { name: /Nanode 1 GB/i }) | ||
.should('be.visible') | ||
.click(); | ||
}); | ||
|
||
ui.button | ||
.findByTitle('Create Linode') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
|
||
// Submit form to create Linode and confirm that outgoing API request | ||
// contains expected user data. | ||
cy.wait('@createLinode').then((xhr) => { | ||
const requestPayload = xhr.request.body; | ||
const regionId = requestPayload['region']; | ||
expect(regionId).to.equal(mockLinode.region); | ||
}); | ||
ui.toast.assertMessage(`Your Linode ${mockLinode.label} is being created.`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters