From 8588f5da66c6410d6d2cb3b4e9d59765f8e151fc Mon Sep 17 00:00:00 2001 From: Davit Darsavelidze <76407236+DaveDarsa@users.noreply.github.com> Date: Sun, 30 Jun 2024 22:25:38 +0400 Subject: [PATCH] linter issues (#273) * linter issues * test files * format --- .storybook/mocks/mocks.ts | 2 +- cypress/e2e/organizations/notifications.cy.ts | 5 +++ cypress/e2e/rbac/maintainer.cy.ts | 2 ++ .../actions/deployment/DeploymentAction.ts | 34 +++++++++++++++---- .../actions/settings/SettingsAction.ts | 3 +- src/components/Accordion/index.tsx | 2 +- src/components/HoverTag/index.tsx | 2 +- .../PaginatedTable/PaginatedTable.tsx | 5 +-- tsconfig.json | 2 +- 9 files changed, 42 insertions(+), 15 deletions(-) diff --git a/.storybook/mocks/mocks.ts b/.storybook/mocks/mocks.ts index 1a8a6c2f..e3fcd622 100644 --- a/.storybook/mocks/mocks.ts +++ b/.storybook/mocks/mocks.ts @@ -531,7 +531,7 @@ export const organizationNotifications = () => { }; Object.keys(notifications).forEach((key, idx) => { - notifications[key] = generateNotifications(key, idx - 1); + notifications[key as keyof Notifications] = generateNotifications(key, idx - 1) as any; }); return notifications; diff --git a/cypress/e2e/organizations/notifications.cy.ts b/cypress/e2e/organizations/notifications.cy.ts index 13ad8136..abf5798f 100644 --- a/cypress/e2e/organizations/notifications.cy.ts +++ b/cypress/e2e/organizations/notifications.cy.ts @@ -57,10 +57,15 @@ describe('Org Notifications page', () => { slack: { name: slackName }, } = testData.organizations.notifications; + cy.waitForNetworkIdle('@idle', 500); notifications.doDeleteNotification(webhooknName); + cy.waitForNetworkIdle('@idle', 500); notifications.doDeleteNotification(emailName); + cy.waitForNetworkIdle('@idle', 500); notifications.doDeleteNotification(teamsName); + cy.waitForNetworkIdle('@idle', 500); notifications.doDeleteNotification(rocketChatName); + cy.waitForNetworkIdle('@idle', 500); notifications.doDeleteNotification(slackName); }); }); diff --git a/cypress/e2e/rbac/maintainer.cy.ts b/cypress/e2e/rbac/maintainer.cy.ts index 971df7d2..9809a2b2 100644 --- a/cypress/e2e/rbac/maintainer.cy.ts +++ b/cypress/e2e/rbac/maintainer.cy.ts @@ -28,6 +28,7 @@ const task = new TaskAction(); describe('MAINTAINER permission test suites', () => { beforeEach(() => { cy.login(Cypress.env('user_maintainer'), Cypress.env('user_maintainer')); + registerIdleHandler('idle'); }); context('Settings', () => { @@ -39,6 +40,7 @@ describe('MAINTAINER permission test suites', () => { it('Deletes SSH key', () => { cy.visit(`${Cypress.env('url')}/settings`); + cy.waitForNetworkIdle('@idle', 500); settings.deleteSshKey(testData.ssh.name); }); diff --git a/cypress/support/actions/deployment/DeploymentAction.ts b/cypress/support/actions/deployment/DeploymentAction.ts index 2a87d556..cf2a1024 100644 --- a/cypress/support/actions/deployment/DeploymentAction.ts +++ b/cypress/support/actions/deployment/DeploymentAction.ts @@ -43,13 +43,33 @@ export default class deploymentAction { .should('include.text', 'There was a problem cancelling deployment.'); } doLogViewerCheck() { - deployment.getAccordionHeadings().then($headings => { - for (let i = 0; i < $headings.length - 1; i++) { - cy.wrap($headings.eq(i)).click(); - } - - for (let i = 0; i < $headings.length - 1; i++) { - cy.wrap($headings.eq(i)).next().next().getBySel('section-details').getBySel('log-text').should('exist'); + cy.get('body').then($body => { + if ($body.find('.accordion-heading').length > 0) { + // parsing went ok + cy.get('.accordion-heading') + .each(($heading, index, $headings) => { + if (index < $headings.length - 1) { + cy.wrap($heading).click(); + } + }) + .then($headings => { + for (let i = 0; i < $headings.length - 1; i++) { + cy.wrap($headings.eq(i)) + .next() + .next() + .getBySel('section-details') + .then($sectionDetails => { + if ($sectionDetails.find('.log-text').length > 0) { + cy.wrap($sectionDetails).find('.log-text').should('exist'); + } else { + cy.wrap($sectionDetails).find('.log-viewer').should('not.be.empty'); + } + }); + } + }); + } else { + // parsing failed + cy.get('.log-viewer').should('not.be.empty'); } }); } diff --git a/cypress/support/actions/settings/SettingsAction.ts b/cypress/support/actions/settings/SettingsAction.ts index 30802456..4181df31 100644 --- a/cypress/support/actions/settings/SettingsAction.ts +++ b/cypress/support/actions/settings/SettingsAction.ts @@ -17,8 +17,7 @@ export default class SettingAction { } deleteSshKey(name: string) { - settings.getDeleteBtn().click(); - + settings.getDeleteBtn().should('be.visible').click({ force: true, multiple: true }); cy.contains(name).should('not.exist'); } } diff --git a/src/components/Accordion/index.tsx b/src/components/Accordion/index.tsx index 07b76202..fd5f2337 100644 --- a/src/components/Accordion/index.tsx +++ b/src/components/Accordion/index.tsx @@ -36,7 +36,7 @@ const Accordion: FC = ({ {columns && Object.keys(columns).map((item, i) => (
- {columns[item]} + {(columns as { [key: string]: string })[item]}
))} diff --git a/src/components/HoverTag/index.tsx b/src/components/HoverTag/index.tsx index c7286c1a..deae55f5 100644 --- a/src/components/HoverTag/index.tsx +++ b/src/components/HoverTag/index.tsx @@ -15,7 +15,7 @@ interface Props { } // human friendly strings -const textPairs = { +const textPairs: Record = { deployCompletedWithWarnings: 'Completed with warnings', }; diff --git a/src/components/Organizations/PaginatedTable/PaginatedTable.tsx b/src/components/Organizations/PaginatedTable/PaginatedTable.tsx index 3b5e7676..9389fc14 100644 --- a/src/components/Organizations/PaginatedTable/PaginatedTable.tsx +++ b/src/components/Organizations/PaginatedTable/PaginatedTable.tsx @@ -193,8 +193,8 @@ const PaginatedTable: FC = ({ const key = numericSortOptions.key; if (key) { if (Array.isArray(a[key])) { - first = a[key].length as number; - second = b[key].length as number; + first = a[key].length as unknown as number; + second = b[key].length as unknown as number; } else { first = a[key] as unknown as number; second = b[key] as unknown as number; @@ -207,6 +207,7 @@ const PaginatedTable: FC = ({ if (list && listKey) { const roleToIdx = {}; list.forEach((role, idx) => { + // @ts-ignore roleToIdx[role] = idx; }); //@ts-ignore diff --git a/tsconfig.json b/tsconfig.json index 061dd4fb..0953a8d3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,5 +25,5 @@ "jsx": "preserve" }, "include": ["next-env.d.ts", "styled.d.ts", "**/*.ts", "**/*.tsx"], - "exclude": ["node_modules"] + "exclude": ["node_modules", "**/cypress/**"] }