Skip to content

Commit

Permalink
E2E Test for Service Account
Browse files Browse the repository at this point in the history
  • Loading branch information
SmitGala committed Sep 6, 2024
1 parent b40da04 commit a013fbc
Show file tree
Hide file tree
Showing 22 changed files with 634 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3]
containers: [1, 2, 3, 4]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -61,6 +61,8 @@ jobs:
CYPRESS_DYNAMIC_SCAN_SYSTEM_IPA_FILE_ID: ${{ vars.CYPRESS_DYNAMIC_SCAN_SYSTEM_IPA_FILE_ID }}
CYPRESS_IGNORE_VULNERABILITY_TEST_PACKAGE_NAME: ${{ vars.CYPRESS_IGNORE_VULNERABILITY_TEST_PACKAGE_NAME }}
CYPRESS_API_HOST: ${{ vars.CYPRESS_API_HOST }}
SERVICE_ACCOUNT_DUPLICATE_ACCOUNT_ID: ${{ vars.SERVICE_ACCOUNT_DUPLICATE_ACCOUNT_ID }}
SERVICE_ACCOUNT_VIEW_ACCOUNT_ID: ${{ vars.SERVICE_ACCOUNT_VIEW_ACCOUNT_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
start: npm run startprod
Expand Down
1 change: 1 addition & 0 deletions app/components/ak-checkbox-tree/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
{{style paddingLeft=(this.calculatePadding node.treeDepth)}}
data-test-ak-checkbox-tree-node
data-test-ak-checkbox-tree-nodeKey='{{node.key}}'
data-test-cy='checkbox-tree-nodeKey-{{node.key}}'
>
<AkStack @alignItems='center'>
{{#if node.showCheckbox}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<AkTable @dense={{true}} as |t|>
<t.head
data-test-serviceAccountAddProjectList-thead
data-test-cy='serviceAccountAddProjectList-thead'
@columns={{this.columns}}
/>
<t.body
Expand All @@ -65,7 +66,11 @@
as |b|
>

<b.row data-test-serviceAccountAddProjectList-row as |r|>
<b.row
data-test-serviceAccountAddProjectList-row
data-test-cy='serviceAccountAddProjectList-row'
as |r|
>
<r.cell data-test-serviceAccountAddProjectList-cell>
{{#if r.columnValue.component}}
{{#let (component r.columnValue.component) as |Component|}}
Expand Down Expand Up @@ -120,6 +125,7 @@

<AkButton
data-test-serviceAccountAddProjectList-addBtn
data-test-cy='serviceAccountAddProjectList-addBtn'
{{on 'click' this.handleAddSelectedProjects}}
@disabled={{this.hasNoSelection}}
@loading={{this.addSelectedProjects.isRunning}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
>
<AkButton
data-test-serviceAccount-confirmDrawer-confirmBtn
data-test-cy='serviceAccount-confirmDrawer-confirmBtn'
@loading={{@disabled}}
{{on 'click' (fn @confirmAction dr.closeHandler)}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

<AkButton
data-test-serviceAccountCreate-saveButton
data-test-cy='serviceAccountCreate-saveButton'
@loading={{this.createServiceAccount.isRunning}}
{{on 'click' (perform this.createServiceAccount)}}
>
Expand Down
2 changes: 2 additions & 0 deletions app/components/organization/service-account/details/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@route={{item.route}}
@linkTitle={{item.linkTitle}}
data-test-serviceAccountDetails-breadcrumbItem='{{item.linkTitle}}'
data-test-cy='serviceAccountDetails-breadcrumbItem-{{item.linkTitle}}'
/>
{{/each}}
</AkBreadcrumbs::Container>
Expand Down Expand Up @@ -39,6 +40,7 @@

<AkIconButton
data-test-serviceAccountDetails-moreOptionsBtn
data-test-cy='serviceAccountDetails-moreOptionsBtn'
@variant='outlined'
{{on 'click' this.handleMoreOptionsClick}}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<AkStack @justifyContent='center' @alignItems='center' @spacing='1'>
<AkLink
data-test-serviceAccountList-viewDetailsLink
data-test-cy='serviceAccountList-viewDetailsLink'
@route='authenticated.dashboard.service-account-details'
@model={{@serviceAccount.id}}
>
Expand All @@ -13,6 +14,7 @@

<AkIconButton
data-test-serviceAccountList-moreOptionBtn
data-test-cy='serviceAccountList-moreOptionBtn'
{{on 'click' (fn @onMoreMenuClick @serviceAccount)}}
>
<AkIcon @iconName='more-vert' />
Expand Down
13 changes: 10 additions & 3 deletions app/components/organization/service-account/list/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
@route='authenticated.dashboard.service-account-create'
@query={{hash duplicate=null}}
>
<AkButton data-test-serviceAccountList-createBtn>
<AkButton
data-test-cy='serviceAccountList-createBtn'
data-test-serviceAccountList-createBtn
>
{{t 'create'}}
</AkButton>
</AkLink>
Expand Down Expand Up @@ -64,14 +67,18 @@
<Organization::ServiceAccount::Empty />
{{else}}
<div class='mb-2'>
<AkTable as |t|>
<AkTable data-test-cy='serviceAccountList-table' as |t|>
<t.head
data-test-serviceAccountList-thead
@columns={{this.columns}}
/>

<t.body @rows={{this.serviceAccountList}} as |b|>
<b.row data-test-serviceAccountList-row as |r|>
<b.row
data-test-serviceAccountList-row
data-test-cy='serviceAccountList-row-{{b.rowValue.id}}'
as |r|
>
<r.cell data-test-serviceAccountList-cell as |value|>
{{#if r.columnValue.component}}
{{#let (component r.columnValue.component) as |Component|}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<div local-class='expiry-text-input-container'>
<AkTextField
data-test-serviceAccountSection-accessToken-expiryInDaysInput
data-test-cy='serviceAccountSection-accessToken-expiryInDaysInput'
@disabled={{this.doesNotExpire}}
@value='{{this.expiryInDays}}'
{{on 'keyup' this.handleExpireInDaysChange}}
Expand Down Expand Up @@ -89,6 +90,7 @@
>
<AkCheckbox
data-test-serviceAccountSection-accessToken-doesNotExpireCheckbox
data-test-cy='serviceAccountSection-accessToken-doesNotExpireCheckbox'
@checked={{this.doesNotExpire}}
@onChange={{this.handleNoExpiryChange}}
/>
Expand Down Expand Up @@ -158,6 +160,7 @@
>
<AkIconButton
data-test-serviceAccountSection-accessToken-secretKeyCopyBtn
data-test-cy='serviceAccountSection-accessToken-secretKeyCopyBtn'
data-clipboard-text={{this.secretAccessKey}}
id={{ac.triggerId}}
@size='small'
Expand Down Expand Up @@ -213,7 +216,10 @@
{{#if this.regenerateKey.isRunning}}
<AkSkeleton @width='225px' />
{{else}}
<AkTypography data-test-serviceAccountSection-accessToken-expiryValue>
<AkTypography
data-test-serviceAccountSection-accessToken-expiryValue
data-test-cy='serviceaccountsection-accesstoken-expiryvalue'
>
{{if this.doesNotExpire (t 'noExpiry') this.expiresOn}}
</AkTypography>
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class={{ha.classes.headerActionBtn}}
{{on 'click' this.handleShowEditView}}
data-test-serviceAccountSection-accountOverview-actionBtn
data-test-cy='serviceAccountSection-accountOverview-actionBtn'
>
<AkIcon @iconName='edit' />
</AkIconButton>
Expand All @@ -25,6 +26,7 @@
{{#if this.isEditOrCreateView}}
<AkTextField
data-test-serviceAccountSection-accountOverview-nameInput
data-test-cy='serviceAccountSection-accountOverview-nameInput'
@label='{{t "serviceAccountModule.nameOfTheServiceAccount"}}'
@labelTypographyColor='textPrimary'
@labelTypographyVariant='subtitle1'
Expand All @@ -46,6 +48,7 @@

<Textarea
data-test-serviceAccountSection-accountOverview-descriptionInput
data-test-cy='serviceAccountSection-accountOverview-descriptionInput'
id='service-account-description'
rows='6'
local-class='
Expand Down Expand Up @@ -80,7 +83,10 @@
/>
</AkStack>

<AkTypography data-test-serviceAccountSection-accountOverview-nameValue>
<AkTypography
data-test-serviceAccountSection-accountOverview-nameValue
data-test-cy='serviceAccountSection-accountOverview-nameValue'
>
{{@serviceAccount.name}}
</AkTypography>
</AkStack>
Expand All @@ -95,6 +101,7 @@

<AkTypography
data-test-serviceAccountSection-accountOverview-descriptionValue
data-test-cy='serviceAccountSection-accountOverview-descriptionValue'
>
{{@serviceAccount.description}}
</AkTypography>
Expand All @@ -105,6 +112,7 @@
<:footerAction>
<AkButton
data-test-serviceAccountSection-accountOverview-updateBtn
data-test-cy='serviceAccountSection-accountOverview-updateBtn'
@loading={{this.updateServiceAccount.isRunning}}
{{on 'click' this.handleUpdateServiceAccount}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
>
<AkIconButton
data-test-serviceAccountSection-selectProject-actionBtn
data-test-cy='serviceAccountSection-selectProject-actionBtn'
@variant='outlined'
class={{ha.classes.headerActionBtn}}
{{on 'click' this.handleShowEditView}}
Expand All @@ -30,6 +31,7 @@
{{#if this.isEditOrCreateView}}
<AkSelect
data-test-serviceAccountSection-selectProject-projectAccessSelect
data-test-cy='serviceAccountSection-selectProject-projectAccessSelect'
class='w-6/12'
@label='Project Access'
@labelTypographyVariant='h6'
Expand Down Expand Up @@ -106,6 +108,7 @@
<:footerAction>
<AkButton
data-test-serviceAccountSection-selectProject-updateBtn
data-test-cy='serviceAccountSection-selectProject-updateBtn'
@loading={{this.updateServiceAccount.isRunning}}
{{on 'click' this.handleUpdateServiceAccount}}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div
data-test-serviceAccountSection-selectProjectList-container
data-test-cy='serviceAccountSection-selectProjectList-container'
class='mt-3'
local-class='projects-list-container'
>
Expand Down Expand Up @@ -35,6 +36,7 @@

<AkButton
data-test-serviceAccountSection-selectProjectList-emptyAddProjectBtn
data-test-cy='serviceAccountSection-selectProjectList-emptyAddProjectBtn'
class='mt-2'
{{on 'click' this.handleOpenAddProjectDrawer}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<li.text
data-test-serviceAccountSection-selectProjectList-projectName
data-test-cy='serviceAccountSection-selectProjectList-projectName'
class='mx-1'
@primaryText={{this.packageName}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
>
<AkIconButton
data-test-serviceAccountSection-selectScope-actionBtn
data-test-cy='serviceAccountSection-selectScope-actionBtn'
@variant='outlined'
class={{ha.classes.headerActionBtn}}
{{on 'click' this.handleShowEditView}}
Expand All @@ -35,12 +36,14 @@
{{#if node.checked}}
<AkIcon
data-test-serviceAccountSection-selectScope-nodeLabelIcon='checked'
data-test-cy='serviceAccountSection-selectScope-nodeLabelIcon-checked'
@iconName='done'
@color='success'
/>
{{else}}
<AkIcon
data-test-serviceAccountSection-selectScope-nodeLabelIcon='unchecked'
data-test-cy='serviceAccountSection-selectScope-nodeLabelIcon-unchecked'
@variant='outlined'
@iconName='do-not-disturb-on'
local-class='scope-unchecked-icon'
Expand Down Expand Up @@ -106,6 +109,7 @@
<:footerAction>
<AkButton
data-test-serviceAccountSection-selectScope-updateBtn
data-test-cy='serviceAccountSection-selectScope-updateBtn'
@loading={{this.updateServiceAccount.isRunning}}
{{on 'click' this.handleUpdateServiceAccount}}
>
Expand Down
81 changes: 81 additions & 0 deletions cypress/support/Actions/common/ServiceAccountActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import cyTranslate from '../../translations';

export default class ServiceAccountActions {
deleteServiceAccount() {
//click more button in service account page
cy.findByTestId('serviceAccountDetails-moreOptionsBtn')
.as('ViewSAMoreButton')
.should('exist');

cy.get('@ViewSAMoreButton').click();

//click delete option in view more
cy.findByText(cyTranslate('delete')).should('exist').click();

//confirm delete in drawer
cy.findByTestId('serviceAccount-confirmDrawer-confirmBtn')
.as('SADeleteButton')
.should('exist');

cy.get('@SADeleteButton').click();
}

editNameInput(text: string, clear: boolean, value?: string) {
cy.findByTestId('serviceAccountSection-accountOverview-nameInput')
.as('SANameInput')
.should('not.have.attr', 'disabled')
.then(() => {
if (clear) {
cy.get('@SANameInput').clear();
}
})
.then(() => {
cy.get('@SANameInput').type(text, { delay: 0 });
})
.then(($input) => {
expect($input.val()).to.equal(value ?? text);
});
}

selectProjectType(type: string) {
cy.findByTestId('serviceAccountSection-selectProject-projectAccessSelect')
.find('[data-test-power-select]')
.click();

cy.findByText(type).should('exist').click();
}

saveServiceAccount() {
cy.findByTestId('serviceAccountCreate-saveButton')
.as('SaveSAButton')
.should('exist');

cy.get('@SaveSAButton').click();
}

assertProjectListContainerState(value: string) {
cy.findByTestId('serviceAccountSection-selectProjectList-container').should(
value
);
}

clickEditOverviewButton() {
cy.findByTestId('serviceAccountSection-accountOverview-actionBtn')
.as('EditOverviewButton')
.should('exist');

cy.get('@EditOverviewButton').click();
}

clickUpdateOverviewButton() {
cy.findByTestId('serviceAccountSection-accountOverview-updateBtn')
.as('UpdateOverviewButton')
.should('exist');

cy.get('@UpdateOverviewButton').click();
}

checkSuccessMessage(msg: string) {
cy.findByText(msg).should('exist');
}
}
Loading

0 comments on commit a013fbc

Please sign in to comment.