Skip to content

Commit 710ef9c

Browse files
test: [M3 8070]: apply linting to more test files (linode#11695)
* M3-8070 apply linting to more test directories * M3-8070 another directory linted * M3-8070 lint another dir * M3-8070 fix problems from bad merge * M3-8070 fix test broken by linter * M3-8070 fix broken test
1 parent 23028c3 commit 710ef9c

21 files changed

+318
-304
lines changed

packages/manager/.eslintrc.cjs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ module.exports = {
2323
'build',
2424
'storybook-static',
2525
'.storybook',
26-
'e2e/core/domains',
27-
'e2e/core/firewalls',
28-
'e2e/core/general',
29-
'e2e/core/helpAndSupport',
3026
'e2e/core/images',
3127
'e2e/core/kubernetes',
3228
'e2e/core/linodes',
@@ -43,7 +39,6 @@ module.exports = {
4339
'e2e/core/stackscripts',
4440
'e2e/core/volumes',
4541
'e2e/core/vpc',
46-
'e2e/core/cloudpulse/timerange-verification.spec.ts',
4742
'public',
4843
'!.eslintrc.js',
4944
],

packages/manager/cypress/e2e/core/cloudpulse/timerange-verification.spec.ts

Lines changed: 68 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
/**
22
* @file Integration Tests for CloudPulse Custom and Preset Verification
33
*/
4-
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
4+
import { DateTime } from 'luxon';
5+
import { widgetDetails } from 'support/constants/widgets';
6+
import { mockGetAccount } from 'support/intercepts/account';
57
import {
68
mockCreateCloudPulseJWEToken,
7-
mockGetCloudPulseDashboard,
89
mockCreateCloudPulseMetrics,
10+
mockGetCloudPulseDashboard,
911
mockGetCloudPulseDashboards,
1012
mockGetCloudPulseMetricDefinitions,
1113
mockGetCloudPulseServices,
1214
} from 'support/intercepts/cloudpulse';
15+
import { mockGetDatabases } from 'support/intercepts/databases';
16+
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
17+
import {
18+
mockGetProfile,
19+
mockGetUserPreferences,
20+
} from 'support/intercepts/profile';
21+
import { mockGetRegions } from 'support/intercepts/regions';
1322
import { ui } from 'support/ui';
14-
import { widgetDetails } from 'support/constants/widgets';
23+
import { generateRandomMetricsData } from 'support/util/cloudpulse';
24+
1525
import {
1626
accountFactory,
1727
cloudPulseMetricsResponseFactory,
@@ -22,20 +32,12 @@ import {
2232
regionFactory,
2333
widgetFactory,
2434
} from 'src/factories';
25-
import { mockGetAccount } from 'support/intercepts/account';
26-
import {
27-
mockGetProfile,
28-
mockGetUserPreferences,
29-
} from 'support/intercepts/profile';
30-
import { mockGetRegions } from 'support/intercepts/regions';
31-
import { Database, DateTimeWithPreset } from '@linode/api-v4';
32-
import { generateRandomMetricsData } from 'support/util/cloudpulse';
33-
import { mockGetDatabases } from 'support/intercepts/databases';
34-
import type { Flags } from 'src/featureFlags';
35-
import type { Interception } from 'support/cypress-exports';
3635
import { convertToGmt } from 'src/features/CloudPulse/Utils/CloudPulseDateTimePickerUtils';
3736
import { formatDate } from 'src/utilities/formatDate';
38-
import { DateTime } from 'luxon';
37+
38+
import type { Database, DateTimeWithPreset } from '@linode/api-v4';
39+
import type { Flags } from 'src/featureFlags';
40+
import type { Interception } from 'support/cypress-exports';
3941

4042
const formatter = "yyyy-MM-dd'T'HH:mm:ss'Z'";
4143
const currentDate = new Date();
@@ -59,7 +61,7 @@ const mockRegion = regionFactory.build({
5961
});
6062

6163
const flags: Partial<Flags> = {
62-
aclp: { enabled: true, beta: true },
64+
aclp: { beta: true, enabled: true },
6365
aclpResourceTypeMap: [
6466
{
6567
dimensionKey: 'cluster_id',
@@ -70,23 +72,23 @@ const flags: Partial<Flags> = {
7072
],
7173
};
7274

73-
const { metrics, id, serviceType, dashboardName, engine } = widgetDetails.dbaas;
75+
const { dashboardName, engine, id, metrics, serviceType } = widgetDetails.dbaas;
7476

7577
const dashboard = dashboardFactory.build({
7678
label: dashboardName,
7779
service_type: serviceType,
78-
widgets: metrics.map(({ title, yLabel, name, unit }) => {
80+
widgets: metrics.map(({ name, title, unit, yLabel }) => {
7981
return widgetFactory.build({
8082
label: title,
81-
y_label: yLabel,
8283
metric: name,
8384
unit,
85+
y_label: yLabel,
8486
});
8587
}),
8688
});
8789

8890
const metricDefinitions = {
89-
data: metrics.map(({ title, name, unit }) =>
91+
data: metrics.map(({ name, title, unit }) =>
9092
dashboardMetricFactory.build({
9193
label: title,
9294
metric: name,
@@ -102,8 +104,8 @@ const metricsAPIResponsePayload = cloudPulseMetricsResponseFactory.build({
102104
});
103105

104106
const databaseMock: Database = databaseFactory.build({
105-
type: engine,
106107
region: mockRegion.label,
108+
type: engine,
107109
});
108110
const mockProfile = profileFactory.build({
109111
timezone: 'Etc/GMT',
@@ -235,8 +237,8 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
235237
aclpPreference: {
236238
dashboardId: id,
237239
engine: engine.toLowerCase(),
238-
resources: ['1'],
239240
region: mockRegion.id,
241+
resources: ['1'],
240242
},
241243
}).as('fetchPreferences');
242244
mockGetDatabases([databaseMock]);
@@ -284,24 +286,26 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
284286
.click();
285287

286288
// Selects the start hour, minute, and meridiem (AM/PM) in the time picker.
287-
288289
cy.findByLabelText('Select hours')
289-
.scrollIntoView({ easing: 'linear' })
290-
.within(() => {
291-
cy.get(`[aria-label="${startHour} hours"]`).click();
292-
});
290+
.as('selectHours')
291+
.scrollIntoView({ easing: 'linear' });
292+
cy.get('@selectHours').within(() => {
293+
cy.get(`[aria-label="${startHour} hours"]`).click();
294+
});
293295

294296
cy.findByLabelText('Select minutes')
295-
.scrollIntoView({ easing: 'linear', duration: 500 })
296-
.within(() => {
297-
cy.get(`[aria-label="${startMinute} minutes"]`).click();
298-
});
297+
.as('selectMinutes')
298+
.scrollIntoView({ duration: 500, easing: 'linear' });
299+
cy.get('@selectMinutes').within(() => {
300+
cy.get(`[aria-label="${startMinute} minutes"]`).click();
301+
});
299302

300303
cy.findByLabelText('Select meridiem')
301-
.scrollIntoView({ easing: 'linear', duration: 500 })
302-
.within(() => {
303-
cy.get(`[aria-label="PM"]`).click();
304-
});
304+
.as('selectMeridiem')
305+
.scrollIntoView({ duration: 500, easing: 'linear' });
306+
cy.get('@selectMeridiem').within(() => {
307+
cy.get(`[aria-label="PM"]`).click();
308+
});
305309

306310
// Click the "Apply" button to confirm the start date and time
307311
ui.button
@@ -312,7 +316,9 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
312316

313317
// Assert that the start date and time is correctly displayed
314318
cy.findByPlaceholderText('Select Start Date')
315-
.scrollIntoView({ easing: 'linear' })
319+
.as('selectStartDate')
320+
.scrollIntoView({ easing: 'linear' });
321+
cy.get('@selectStartDate')
316322
.should('be.visible')
317323
.should('have.value', `${cleanText(startActualDate)} PM`);
318324

@@ -329,23 +335,29 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
329335
.click();
330336

331337
// Selects the start hour, minute, and meridiem (AM/PM) in the time picker.
332-
cy.findByLabelText('Select hours')
333-
.scrollIntoView({ easing: 'linear', duration: 500 })
334-
.within(() => {
335-
cy.get(`[aria-label="${endHour} hours"]`).click();
336-
});
338+
cy.findByLabelText('Select hours').scrollIntoView({
339+
duration: 500,
340+
easing: 'linear',
341+
});
342+
cy.get('@selectHours').within(() => {
343+
cy.get(`[aria-label="${endHour} hours"]`).click();
344+
});
337345

338-
cy.findByLabelText('Select minutes')
339-
.scrollIntoView({ easing: 'linear', duration: 500 })
340-
.within(() => {
341-
cy.get(`[aria-label="${endMinute} minutes"]`).click();
342-
});
346+
cy.findByLabelText('Select minutes').scrollIntoView({
347+
duration: 500,
348+
easing: 'linear',
349+
});
350+
cy.get('@selectMinutes').within(() => {
351+
cy.get(`[aria-label="${endMinute} minutes"]`).click();
352+
});
343353

344-
cy.findByLabelText('Select meridiem')
345-
.scrollIntoView({ easing: 'linear', duration: 500 })
346-
.within(() => {
347-
cy.get(`[aria-label="PM"]`).click();
348-
});
354+
cy.findByLabelText('Select meridiem').scrollIntoView({
355+
duration: 500,
356+
easing: 'linear',
357+
});
358+
cy.get('@selectMeridiem').within(() => {
359+
cy.get(`[aria-label="PM"]`).click();
360+
});
349361

350362
// Click the "Apply" button to confirm the end date and time
351363
ui.button
@@ -355,8 +367,10 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
355367
.click();
356368

357369
// Assert that the end date and time is correctly displayed
370+
cy.findByPlaceholderText('Select End Date').scrollIntoView({
371+
easing: 'linear',
372+
});
358373
cy.findByPlaceholderText('Select End Date')
359-
.scrollIntoView({ easing: 'linear' })
360374
.should('be.visible')
361375
.should('have.value', `${cleanText(endActualDate)} PM`);
362376

@@ -455,7 +469,7 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
455469
});
456470

457471
it('Select the "Last Month" preset from the "Time Range" dropdown and verify its functionality.', () => {
458-
const { start, end } = getLastMonthRange();
472+
const { end, start } = getLastMonthRange();
459473

460474
ui.autocomplete
461475
.findByLabel('Time Range')
@@ -486,7 +500,7 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
486500
});
487501

488502
it('Select the "This Month" preset from the "Time Range" dropdown and verify its functionality.', () => {
489-
const { start, end } = getThisMonthRange();
503+
const { end, start } = getThisMonthRange();
490504

491505
ui.autocomplete
492506
.findByLabel('Time Range')

packages/manager/cypress/e2e/core/domains/domains-empty-landing-page.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ui } from 'support/ui';
21
import { mockGetDomains } from 'support/intercepts/domains';
2+
import { ui } from 'support/ui';
33

44
describe('Domains empty landing page', () => {
55
/**

packages/manager/cypress/e2e/core/domains/smoke-clone-domain.spec.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { Domain } from '@linode/api-v4';
1+
import { createDomain } from '@linode/api-v4/lib/domains';
22
import { domainFactory } from '@src/factories';
33
import { authenticate } from 'support/api/authentication';
4-
import { randomDomainName } from 'support/util/random';
5-
import { createDomain } from '@linode/api-v4/lib/domains';
64
import { createDomainRecords } from 'support/constants/domains';
75
import { interceptCreateDomainRecord } from 'support/intercepts/domains';
86
import { ui } from 'support/ui';
97
import { cleanUp } from 'support/util/cleanup';
8+
import { randomDomainName } from 'support/util/random';
9+
10+
import type { Domain } from '@linode/api-v4';
1011

1112
authenticate();
1213
describe('Clone a Domain', () => {
@@ -45,7 +46,8 @@ describe('Clone a Domain', () => {
4546
interceptCreateDomainRecord().as('apiCreateRecord');
4647
cy.findByText(rec.name).click();
4748
rec.fields.forEach((f) => {
48-
cy.get(f.name).click().type(f.value);
49+
cy.get(f.name).click();
50+
cy.focused().type(f.value);
4951
});
5052
cy.findByText('Save').click();
5153
cy.wait('@apiCreateRecord');
@@ -101,18 +103,18 @@ describe('Clone a Domain', () => {
101103
.should('be.disabled');
102104

103105
// Confirm that an error is displayed when entering an invalid domain name
104-
cy.findByLabelText('New Domain').click().type(invalidDomainName);
106+
cy.findByLabelText('New Domain').click();
107+
cy.focused().type(invalidDomainName);
105108
ui.buttonGroup
106109
.findButtonByTitle('Create Domain')
107110
.should('be.visible')
108111
.should('be.enabled')
109112
.click();
110113
cy.findByText('Domain is not valid.').should('be.visible');
111114

112-
cy.findByLabelText('New Domain')
113-
.click()
114-
.clear()
115-
.type(clonedDomainName);
115+
cy.findByLabelText('New Domain').click();
116+
cy.focused().clear();
117+
cy.focused().type(clonedDomainName);
116118
ui.buttonGroup
117119
.findButtonByTitle('Create Domain')
118120
.should('be.visible')

packages/manager/cypress/e2e/core/domains/smoke-create-domain-records.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { authenticate } from 'support/api/authentication';
22
import { createDomain } from 'support/api/domains';
3-
import { interceptCreateDomainRecord } from 'support/intercepts/domains';
43
import { createDomainRecords } from 'support/constants/domains';
4+
import { interceptCreateDomainRecord } from 'support/intercepts/domains';
55
import { ui } from 'support/ui';
66
import { cleanUp } from 'support/util/cleanup';
77

@@ -42,7 +42,8 @@ const editCaaRecord = (name: string, newValue: string) => {
4242
ui.actionMenuItem.findByTitle('Edit').should('be.visible').click();
4343

4444
// Edit the value field
45-
cy.findByLabelText('Value').clear().type(newValue);
45+
cy.findByLabelText('Value').clear();
46+
cy.focused().type(newValue);
4647
ui.button.findByTitle('Save').click();
4748
};
4849

packages/manager/cypress/e2e/core/domains/smoke-create-domain.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Domain } from '@linode/api-v4';
21
import { domainFactory } from '@src/factories';
32
import { authenticate } from 'support/api/authentication';
43
import {
@@ -8,6 +7,8 @@ import {
87
import { cleanUp } from 'support/util/cleanup';
98
import { randomDomainName } from 'support/util/random';
109

10+
import type { Domain } from '@linode/api-v4';
11+
1112
authenticate();
1213
describe('Create a Domain', () => {
1314
before(() => {

packages/manager/cypress/e2e/core/domains/smoke-delete-domain.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { Domain } from '@linode/api-v4';
1+
import { createDomain } from '@linode/api-v4/lib/domains';
22
import { domainFactory } from '@src/factories';
33
import { authenticate } from 'support/api/authentication';
4-
import { randomDomainName } from 'support/util/random';
5-
import { createDomain } from '@linode/api-v4/lib/domains';
64
import { ui } from 'support/ui';
5+
import { randomDomainName } from 'support/util/random';
6+
7+
import type { Domain } from '@linode/api-v4';
78

89
authenticate();
910
beforeEach(() => {
@@ -72,7 +73,8 @@ describe('Delete a Domain', () => {
7273
.findButtonByTitle('Delete Domain')
7374
.should('be.visible')
7475
.should('be.disabled');
75-
cy.contains('Domain Name').click().type(domain.domain);
76+
cy.contains('Domain Name').click();
77+
cy.focused().type(domain.domain);
7678

7779
ui.buttonGroup
7880
.findButtonByTitle('Delete Domain')

0 commit comments

Comments
 (0)