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

test: [M3-7667] - (Proof of Concept) Add tagging capability for Cypress tests #10475

Merged
merged 10 commits into from
Jun 12, 2024
7 changes: 4 additions & 3 deletions docs/development-guide/08-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ These environment variables are specific to Cloud Manager UI tests. They can be
###### General
Environment variables related to the general operation of the Cloud Manager Cypress tests.

| Environment Variable | Description | Example | Default |
|----------------------|-------------------------------------------------------------------------------------------------------|----------|---------------------------------|
| `CY_TEST_SUITE` | Name of the Cloud Manager UI test suite to run. Possible values are `core`, `region`, or `synthetic`. | `region` | Unset; defaults to `core` suite |
| Environment Variable | Description | Example | Default |
|----------------------|-------------------------------------------------------------------------------------------------------|--------------|---------------------------------|
| `CY_TEST_SUITE` | Name of the Cloud Manager UI test suite to run. Possible values are `core`, `region`, or `synthetic`. | `region` | Unset; defaults to `core` suite |
| `CY_TEST_TAGS` | Query identifying tests that should run by specifying allowed and disallowed tags. | `method:e2e` | Unset; all tests run by default |

###### Regions
These environment variables are used by Cloud Manager's UI tests to override region selection behavior. This can be useful for testing Cloud Manager functionality against a specific region.
Expand Down
2 changes: 2 additions & 0 deletions packages/manager/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { fetchAccount } from './cypress/support/plugins/fetch-account';
import { fetchLinodeRegions } from './cypress/support/plugins/fetch-linode-regions';
import { splitCypressRun } from './cypress/support/plugins/split-run';
import { enableJunitReport } from './cypress/support/plugins/junit-report';
import { logTestTagInfo } from './cypress/support/plugins/test-tagging-info';

/**
* Exports a Cypress configuration object.
Expand Down Expand Up @@ -66,6 +67,7 @@ export default defineConfig({
fetchAccount,
fetchLinodeRegions,
regionOverrideCheck,
logTestTagInfo,
splitCypressRun,
enableJunitReport,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('Account service transfers', () => {
cy.wait(['@getTransfers', '@getTransfers', '@getTransfers']);

// Confirm that pending transfers are displayed in "Pending Service Transfers" panel.
cy.defer(getProfile(), 'getting profile').then((profile: Profile) => {
cy.defer(() => getProfile(), 'getting profile').then((profile: Profile) => {
const dateFormatOptions = { timezone: profile.timezone };
cy.get('[data-qa-panel="Pending Service Transfers"]')
.should('be.visible')
Expand Down Expand Up @@ -262,7 +262,7 @@ describe('Account service transfers', () => {
return linode;
};

cy.defer(setupLinode(), 'creating and booting Linode').then(
cy.defer(() => setupLinode(), 'creating and booting Linode').then(
(linode: Linode) => {
interceptInitiateEntityTransfer().as('initiateTransfer');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Third party access tokens', () => {
.closest('tr')
.within(() => {
cy.findByText(token.label).should('be.visible');
cy.defer(getProfile()).then((profile: Profile) => {
cy.defer(() => getProfile()).then((profile: Profile) => {
const dateFormatOptions = { timezone: profile.timezone };
cy.findByText(formatDate(token.created, dateFormatOptions)).should(
'be.visible'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('Billing Activity Feed', () => {
mockGetPayments(paymentMocks6Months).as('getPayments');
mockGetPaymentMethods([]);

cy.defer(getProfile()).then((profile: Profile) => {
cy.defer(() => getProfile()).then((profile: Profile) => {
const timezone = profile.timezone;
cy.visitWithLogin('/account/billing');
cy.wait(['@getInvoices', '@getPayments']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Clone a Domain', () => {

const domainRecords = createDomainRecords();

cy.defer(createDomain(domainRequest), 'creating domain').then(
cy.defer(() => createDomain(domainRequest), 'creating domain').then(
(domain: Domain) => {
// Add records to the domain.
cy.visitWithLogin(`/domains/${domain.id}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Delete a Domain', () => {
group: 'test-group',
});

cy.defer(createDomain(domainRequest), 'creating domain').then(
cy.defer(() => createDomain(domainRequest), 'creating domain').then(
(domain: Domain) => {
cy.visitWithLogin('/domains');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('create firewall', () => {
};

cy.defer(
createTestLinode(linodeRequest, { securityMethod: 'powered_off' }),
() => createTestLinode(linodeRequest, { securityMethod: 'powered_off' }),
'creating Linode'
).then((linode) => {
interceptCreateFirewall().as('createFirewall');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('delete firewall', () => {
label: randomLabel(),
});

cy.defer(createFirewall(firewallRequest), 'creating firewalls').then(
cy.defer(() => createFirewall(firewallRequest), 'creating firewalls').then(
(firewall: Firewall) => {
cy.visitWithLogin('/firewalls');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('Migrate Linode With Firewall', () => {
interceptGetFirewalls().as('getFirewalls');

// Create a Linode, then navigate to the Firewalls landing page.
cy.defer(
cy.defer(() =>
createTestLinode(linodePayload, { securityMethod: 'powered_off' })
).then((linode: Linode) => {
interceptMigrateLinode(linode.id).as('migrateLinode');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe('update firewall', () => {
});

cy.defer(
createLinodeAndFirewall(linodeRequest, firewallRequest),
() => createLinodeAndFirewall(linodeRequest, firewallRequest),
'creating Linode and firewall'
).then(([linode, firewall]) => {
cy.visitWithLogin('/firewalls');
Expand Down Expand Up @@ -324,7 +324,7 @@ describe('update firewall', () => {
});

cy.defer(
createLinodeAndFirewall(linodeRequest, firewallRequest),
() => createLinodeAndFirewall(linodeRequest, firewallRequest),
'creating Linode and firewall'
).then(([_linode, firewall]) => {
cy.visitWithLogin('/firewalls');
Expand Down Expand Up @@ -420,7 +420,7 @@ describe('update firewall', () => {
const newFirewallLabel = randomLabel();

cy.defer(
createLinodeAndFirewall(linodeRequest, firewallRequest),
() => createLinodeAndFirewall(linodeRequest, firewallRequest),
'creating Linode and firewall'
).then(([_linode, firewall]) => {
cy.visitWithLogin('/firewalls');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('create image (e2e)', () => {
const disk = 'Alpine 3.19 Disk';

cy.defer(
createTestLinode({ image }, { waitForDisks: true }),
() => createTestLinode({ image }, { waitForDisks: true }),
'create linode'
).then((linode: Linode) => {
cy.visitWithLogin('/images/create');
Expand Down
210 changes: 105 additions & 105 deletions packages/manager/cypress/e2e/core/linodes/backup-linode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,52 +53,53 @@ describe('linode backups', () => {
booted: false,
});

cy.defer(createTestLinode(createLinodeRequest), 'creating Linode').then(
(linode: Linode) => {
interceptGetLinode(linode.id).as('getLinode');
interceptEnableLinodeBackups(linode.id).as('enableBackups');

// Navigate to Linode details page "Backups" tab.
cy.visitWithLogin(`linodes/${linode.id}/backup`);
cy.wait('@getLinode');

// Wait for Linode to finish provisioning.
cy.findByText('OFFLINE').should('be.visible');

// Confirm that enable backups prompt is shown.
cy.contains(
'Three backup slots are executed and rotated automatically'
).should('be.visible');

ui.button
.findByTitle('Enable Backups')
.should('be.visible')
.should('be.enabled')
.click();

ui.dialog
.findByTitle('Enable backups?')
.should('be.visible')
.within(() => {
// Confirm that user is warned of additional backup charges.
cy.contains(/.* This will add .* to your monthly bill\./).should(
'be.visible'
);
ui.button
.findByTitle('Enable Backups')
.should('be.visible')
.should('be.enabled')
.click();
});
cy.defer(
() => createTestLinode(createLinodeRequest),
'creating Linode'
).then((linode: Linode) => {
interceptGetLinode(linode.id).as('getLinode');
interceptEnableLinodeBackups(linode.id).as('enableBackups');

// Navigate to Linode details page "Backups" tab.
cy.visitWithLogin(`linodes/${linode.id}/backup`);
cy.wait('@getLinode');

// Wait for Linode to finish provisioning.
cy.findByText('OFFLINE').should('be.visible');

// Confirm that enable backups prompt is shown.
cy.contains(
'Three backup slots are executed and rotated automatically'
).should('be.visible');

ui.button
.findByTitle('Enable Backups')
.should('be.visible')
.should('be.enabled')
.click();

ui.dialog
.findByTitle('Enable backups?')
.should('be.visible')
.within(() => {
// Confirm that user is warned of additional backup charges.
cy.contains(/.* This will add .* to your monthly bill\./).should(
'be.visible'
);
ui.button
.findByTitle('Enable Backups')
.should('be.visible')
.should('be.enabled')
.click();
});

// Confirm that toast notification appears and UI updates to reflect enabled backups.
cy.wait('@enableBackups');
ui.toast.assertMessage('Backups are being enabled for this Linode.');
cy.findByText(
'Automatic and manual backups will be listed here'
).should('be.visible');
}
);
// Confirm that toast notification appears and UI updates to reflect enabled backups.
cy.wait('@enableBackups');
ui.toast.assertMessage('Backups are being enabled for this Linode.');
cy.findByText('Automatic and manual backups will be listed here').should(
'be.visible'
);
});
});

/*
Expand All @@ -116,71 +117,70 @@ describe('linode backups', () => {

const snapshotName = randomLabel();

cy.defer(createTestLinode(createLinodeRequest), 'creating Linode').then(
(linode: Linode) => {
interceptGetLinode(linode.id).as('getLinode');
interceptCreateLinodeSnapshot(linode.id).as('createSnapshot');

// Navigate to Linode details page "Backups" tab.
cy.visitWithLogin(`/linodes/${linode.id}/backup`);
cy.wait('@getLinode');
cy.defer(
() => createTestLinode(createLinodeRequest),
'creating Linode'
).then((linode: Linode) => {
interceptGetLinode(linode.id).as('getLinode');
interceptCreateLinodeSnapshot(linode.id).as('createSnapshot');

// Navigate to Linode details page "Backups" tab.
cy.visitWithLogin(`/linodes/${linode.id}/backup`);
cy.wait('@getLinode');

// Wait for the Linode to finish provisioning.
cy.findByText('OFFLINE').should('be.visible');

cy.findByText('Manual Snapshot')
.should('be.visible')
.parent()
.within(() => {
// Confirm that "Take Snapshot" button is disabled until a name is entered.
ui.button
.findByTitle('Take Snapshot')
.should('be.visible')
.should('be.disabled');

// Wait for the Linode to finish provisioning.
cy.findByText('OFFLINE').should('be.visible');
// Enter a snapshot name, click "Take Snapshot".
cy.findByLabelText('Name Snapshot')
.should('be.visible')
.clear()
.type(snapshotName);

cy.findByText('Manual Snapshot')
.should('be.visible')
.parent()
.within(() => {
// Confirm that "Take Snapshot" button is disabled until a name is entered.
ui.button
.findByTitle('Take Snapshot')
.should('be.visible')
.should('be.disabled');

// Enter a snapshot name, click "Take Snapshot".
cy.findByLabelText('Name Snapshot')
.should('be.visible')
.clear()
.type(snapshotName);

ui.button
.findByTitle('Take Snapshot')
.should('be.visible')
.should('be.enabled')
.click();
});
ui.button
.findByTitle('Take Snapshot')
.should('be.visible')
.should('be.enabled')
.click();
});

// Submit confirmation, confirm that toast message appears.
ui.dialog
.findByTitle('Take a snapshot?')
.should('be.visible')
.within(() => {
// Confirm user is warned that previous snapshot will be replaced.
cy.contains('overriding your previous snapshot').should(
'be.visible'
);
cy.contains('Are you sure?').should('be.visible');

ui.button
.findByTitle('Take Snapshot')
.should('be.visible')
.should('be.enabled')
.click();
});
// Submit confirmation, confirm that toast message appears.
ui.dialog
.findByTitle('Take a snapshot?')
.should('be.visible')
.within(() => {
// Confirm user is warned that previous snapshot will be replaced.
cy.contains('overriding your previous snapshot').should('be.visible');
cy.contains('Are you sure?').should('be.visible');

ui.button
.findByTitle('Take Snapshot')
.should('be.visible')
.should('be.enabled')
.click();
});

cy.wait('@createSnapshot');
ui.toast.assertMessage('Starting to capture snapshot');
cy.wait('@createSnapshot');
ui.toast.assertMessage('Starting to capture snapshot');

// Confirm that new snapshot is listed in backups table.
cy.findByText(snapshotName)
.should('be.visible')
.closest('tr')
.within(() => {
cy.findByText('Pending').should('be.visible');
});
}
);
// Confirm that new snapshot is listed in backups table.
cy.findByText(snapshotName)
.should('be.visible')
.closest('tr')
.within(() => {
cy.findByText('Pending').should('be.visible');
});
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('clone linode', () => {

const newLinodeLabel = `${linodePayload.label}-clone`;

cy.defer(createTestLinode(linodePayload)).then((linode: Linode) => {
cy.defer(() => createTestLinode(linodePayload)).then((linode: Linode) => {
const linodeRegion = getRegionById(linodePayload.region!);

interceptCloneLinode(linode.id).as('cloneLinode');
Expand Down
Loading
Loading