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[DI-20595] -add region select testcases #1

Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
} from 'support/intercepts/databases';
import { Database } from '@linode/api-v4';
import { mockGetAccount } from 'support/intercepts/account';
import { Flags } from 'src/featureFlags';

/**
* Verifies the presence and values of specific properties within the aclpPreference object
Expand All @@ -44,6 +45,24 @@ import { mockGetAccount } from 'support/intercepts/account';
* @param requestPayload - The payload received from the request, containing the aclpPreference object.
* @param expectedValues - An object containing the expected values for properties to validate against the requestPayload.
*/

const flags: Partial<Flags> = {
aclp: { enabled: true, beta: true },
aclpResourceTypeMap: [
{
dimensionKey: 'LINODE_ID',
maxResourceSelections: 10,
serviceType: 'linode',
supportedRegionIds: 'us-ord',
},
{
dimensionKey: 'cluster_id',
maxResourceSelections: 10,
serviceType: 'dbaas',
supportedRegionIds: 'us-ord',
},
],
};
const {
metrics,
id,
Expand Down Expand Up @@ -78,10 +97,9 @@ const metricDefinitions = {
};

const mockRegion = regionFactory.build({
capabilities: ['Linodes'],
capabilities: ['Managed Databases'],
id: 'us-ord',
label: 'Chicago, IL',
country: 'us',
});

const databaseMock: Database = databaseFactory.build({
Expand All @@ -97,9 +115,7 @@ const mockAccount = accountFactory.build();

describe('Tests for API error handling', () => {
beforeEach(() => {
mockAppendFeatureFlags({
aclp: { beta: true, enabled: true },
});
mockAppendFeatureFlags(flags);
mockGetAccount(mockAccount);
mockGetCloudPulseMetricDefinitions(serviceType, metricDefinitions);
mockGetCloudPulseDashboards(serviceType, [dashboard]).as('fetchDashboard');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { mockGetAccount } from 'support/intercepts/account';
import { mockGetLinodes } from 'support/intercepts/linodes';
import { mockGetUserPreferences } from 'support/intercepts/profile';
import { mockGetRegions } from 'support/intercepts/regions';
import { extendRegion } from 'support/util/regions';
import { CloudPulseMetricsResponse, Database } from '@linode/api-v4';
import { Interception } from 'cypress/types/net-stubbing';
import { generateRandomMetricsData } from 'support/util/cloudpulse';
Expand All @@ -49,14 +48,29 @@ import { formatToolTip } from 'src/features/CloudPulse/Utils/unitConversion';
const expectedGranularityArray = ['Auto', '1 day', '1 hr', '5 min'];
const timeDurationToSelect = 'Last 24 Hours';

const flags: Partial<Flags> = { aclp: { enabled: true, beta: true } };
const flags: Partial<Flags> = {
aclp: { enabled: true, beta: true },
aclpResourceTypeMap: [
{
dimensionKey: 'LINODE_ID',
maxResourceSelections: 10,
serviceType: 'linode',
supportedRegionIds: '',
},
{
dimensionKey: 'cluster_id',
maxResourceSelections: 10,
serviceType: 'dbaas',
supportedRegionIds: 'us-ord',
},
],
};

const {
metrics,
id,
serviceType,
dashboardName,
region,
engine,
clusterName,
nodeType,
Expand Down Expand Up @@ -91,14 +105,18 @@ const mockLinode = linodeFactory.build({
});

const mockAccount = accountFactory.build();
const mockRegion = extendRegion(
regionFactory.build({
capabilities: ['Linodes'],
id: 'us-ord',
label: 'Chicago, IL',
country: 'us',
})
);

const mockRegion = regionFactory.build({
capabilities: ['Managed Databases'],
id: 'us-ord',
label: 'Chicago, IL',
});

const extendedMockRegion = regionFactory.build({
capabilities: ['Managed Databases'],
id: 'us-east',
label: 'Newark,NL',
});
const metricsAPIResponsePayload = cloudPulseMetricsResponseFactory.build({
data: generateRandomMetricsData(timeDurationToSelect, '5 min'),
});
Expand Down Expand Up @@ -151,9 +169,9 @@ const getWidgetLegendRowValuesFromResponse = (
};

const databaseMock: Database = databaseFactory.build({
label: widgetDetails.dbaas.clusterName,
type: widgetDetails.dbaas.engine,
region: widgetDetails.dbaas.region,
label: clusterName,
type: engine,
region: mockRegion.label,
version: '1',
status: 'provisioning',
cluster_size: 1,
Expand All @@ -177,7 +195,7 @@ describe('Integration Tests for DBaaS Dashboard ', () => {
mockCreateCloudPulseMetrics(serviceType, metricsAPIResponsePayload).as(
'getMetrics'
);
mockGetRegions([mockRegion]);
mockGetRegions([mockRegion, extendedMockRegion]);
mockGetUserPreferences({});
mockGetDatabases([databaseMock]).as('getDatabases');

Expand All @@ -191,35 +209,60 @@ describe('Integration Tests for DBaaS Dashboard ', () => {
ui.autocomplete
.findByLabel('Dashboard')
.should('be.visible')
.type(`${dashboardName}{enter}`)
.should('be.visible');
.type(dashboardName);

ui.autocompletePopper
.findByTitle(dashboardName)
.should('be.visible')
.click();

// Select a time duration from the autocomplete input.
ui.autocomplete
.findByLabel('Time Range')
.should('be.visible')
.type(`${timeDurationToSelect}{enter}`)
.should('be.visible');
.type(timeDurationToSelect);

ui.autocompletePopper
.findByTitle(timeDurationToSelect)
.should('be.visible')
.click();

//Select a Engine from the autocomplete input.
//Select a Database Engine from the autocomplete input.
ui.autocomplete
.findByLabel('Database Engine')
.should('be.visible')
.type(`${engine}{enter}`)
.should('be.visible');
.type(engine);

ui.autocompletePopper.findByTitle(engine).should('be.visible').click();

// Select a region from the dropdown.
ui.regionSelect.find().click();

// Select a region from the dropdown.
ui.regionSelect.find().click().type(`${region}{enter}`);
ui.regionSelect.find().type(extendedMockRegion.label);

// Since DBaaS does not support this region, we expect it to not be in the dropdown.

ui.autocompletePopper.find().within(() => {
cy.findByText(
`${extendedMockRegion.label} (${extendedMockRegion.id})`
).should('not.exist');
});

// Select a resource from the autocomplete input.
ui.regionSelect.find().click().clear();
ui.regionSelect
.findItemByRegionId(mockRegion.id, [mockRegion])
.should('be.visible')
.click();

// Select a resource (Database Clusters) from the autocomplete input.
ui.autocomplete
.findByLabel('Database Clusters')
.should('be.visible')
.type(`${clusterName}{enter}`)
.click();
cy.findByText(clusterName).should('be.visible');
.type(clusterName);

ui.autocompletePopper.findByTitle(clusterName).should('be.visible').click();

//Select a Node from the autocomplete input.
// Select a Node from the autocomplete input.
ui.autocomplete
.findByLabel('Node Type')
.should('be.visible')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { mockGetAccount } from 'support/intercepts/account';
import { mockGetLinodes } from 'support/intercepts/linodes';
import { mockGetUserPreferences } from 'support/intercepts/profile';
import { mockGetRegions } from 'support/intercepts/regions';
import { extendRegion } from 'support/util/regions';
import { CloudPulseMetricsResponse } from '@linode/api-v4';
import { generateRandomMetricsData } from 'support/util/cloudpulse';
import { Interception } from 'cypress/types/net-stubbing';
Expand All @@ -46,15 +45,25 @@ import { formatToolTip } from 'src/features/CloudPulse/Utils/unitConversion';
*/
const expectedGranularityArray = ['Auto', '1 day', '1 hr', '5 min'];
const timeDurationToSelect = 'Last 24 Hours';
const flags: Partial<Flags> = { aclp: { enabled: true, beta: true } };
const {
metrics,
id,
serviceType,
dashboardName,
region,
resource,
} = widgetDetails.linode;
const flags: Partial<Flags> = {
aclp: { enabled: true, beta: true },
aclpResourceTypeMap: [
{
dimensionKey: 'LINODE_ID',
maxResourceSelections: 10,
serviceType: 'linode',
supportedRegionIds: 'us-ord',
},
{
dimensionKey: 'cluster_id',
maxResourceSelections: 10,
serviceType: 'dbaas',
supportedRegionIds: '',
},
],
};
const { metrics, id, serviceType, dashboardName, region, resource } =
widgetDetails.linode;

const dashboard = dashboardFactory.build({
label: dashboardName,
Expand Down Expand Up @@ -85,14 +94,18 @@ const mockLinode = linodeFactory.build({
});

const mockAccount = accountFactory.build();
const mockRegion = extendRegion(
regionFactory.build({
capabilities: ['Linodes'],
id: 'us-ord',
label: 'Chicago, IL',
country: 'us',
})
);

const mockRegion = regionFactory.build({
capabilities: ['Linodes'],
id: 'us-ord',
label: 'Chicago, IL',
});

const extendedMockRegion = regionFactory.build({
capabilities: ['Managed Databases'],
id: 'us-east',
label: 'Newark,NL',
});
const metricsAPIResponsePayload = cloudPulseMetricsResponseFactory.build({
data: generateRandomMetricsData(timeDurationToSelect, '5 min'),
});
Expand Down Expand Up @@ -170,18 +183,41 @@ describe('Integration Tests for Linode Dashboard ', () => {
ui.autocomplete
.findByLabel('Dashboard')
.should('be.visible')
.type(`${dashboardName}{enter}`)
.should('be.visible');
.type(dashboardName);

ui.autocompletePopper
.findByTitle(dashboardName)
.should('be.visible')
.click();

// Select a time duration from the autocomplete input.
ui.autocomplete
.findByLabel('Time Range')
.should('be.visible')
.type(`${timeDurationToSelect}{enter}`)
.should('be.visible');
.type(timeDurationToSelect);

ui.autocompletePopper
.findByTitle(timeDurationToSelect)
.should('be.visible')
.click();

ui.regionSelect.find().click();

// Select a region from the dropdown.
ui.regionSelect.find().click();

ui.regionSelect.find().type(extendedMockRegion.label);

// Since Linode does not support this region, we expect it to not be in the dropdown.

ui.autocompletePopper.find().within(() => {
cy.findByText(
`${extendedMockRegion.label} (${extendedMockRegion.id})`
).should('not.exist');
});

// Select a region from the dropdown.
ui.regionSelect.find().click().type(`${region}{enter}`);
ui.regionSelect.find().click().clear().type(`${region}{enter}`);

// Select a resource from the autocomplete input.
ui.autocomplete
Expand All @@ -191,6 +227,7 @@ describe('Integration Tests for Linode Dashboard ', () => {
.click();

cy.findByText(resource).should('be.visible');

// Wait for all metrics query requests to resolve.
cy.wait(['@getMetrics', '@getMetrics', '@getMetrics', '@getMetrics']);
});
Expand Down
Loading