Skip to content

Commit

Permalink
Cypress (#141)
Browse files Browse the repository at this point in the history
* Update cypress-tests
---------
  • Loading branch information
stutlerxgod authored Oct 3, 2023
1 parent 957b5ea commit 7f92446
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 73 deletions.
11 changes: 6 additions & 5 deletions cypress/commands/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ Cypress.Commands.add('protectionCookie', () => {

Cypress.Commands.add('login', (user: string, password?: string, timeout?: number) => {
if (user != 'anonym') {
if ('forceLoginLink' in CY.credential[user]) {
cy.visit(CY.credential[user].forceLoginLink, { timeout: timeout })
if (CY.credentials[user].isForceLogin === true) {
cy.visit(CY.credentials[user].forceLoginLink, { timeout: timeout })
} else {
cy.visit('/')
cy.getCy('login-form').should('be.visible')
cy.getCy('username').type(CY.credential[user].name || user)
cy.getCy('password').type(CY.credential[user].password || password)
cy.getCy('login-form').should('be.visible') // central.sme.localhost
cy.getCy('username').type(CY.credentials[user].name || user)
cy.getCy('password').type(CY.credentials[user].password || password)
cy.getCyVisibleClick('button-login')
}
}

})

export {}
2 changes: 1 addition & 1 deletion cypress/commands/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Cypress.Commands.add('urlNotContains', (string: string) => {
Cypress.Commands.add('alertMessage', (message: string) => {
cy.log(`Expect alert message: ${message}`)
cy.get('.v-alert').should('be.visible').and('contain.text', `${message}`)
cy.get('.v-alert__close').click()
cy.get('.mdi-close').eq(0).click()
})

Cypress.Commands.add('visitBaseUrl', (value?: boolean, timeout?: number) => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/commands/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Cypress.Commands.add('verifyFileType', (fileID: string, fileGroup: 'image' | 'au
if (fileType.includes('mp3')) return 'mpeg'
else if (fileType.includes('mov')) return 'quicktime'
else if (fileType.includes('avi')) return 'x-msvideo'
else if (fileType.includes('m4a')) return 'mp4'
//else if (fileType.includes('m4a')) return 'mp4' // until bug is fixed
else return fileType
}

Expand Down
4 changes: 2 additions & 2 deletions cypress/config/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default defineConfig({
viewportHeight: 1080,
viewportWidth: 1920,
env: {
cfg: 'local',
cfg: 'qa', // local...
loginUser: 'admin',
failOnUncaughtException: false,
visitBaseUrl: true,
Expand All @@ -27,7 +27,7 @@ export default defineConfig({
grepIntegrationFolder: '../../',
},
e2e: {
baseUrl: 'http://admin-dam.anzusystems.localhost:8150/',
baseUrl: 'http://LoremIpsum',
specPattern: 'cypress/e2e/**/*.cy.ts',
setupNodeEvents(on, config) {
require('cypress-mochawesome-reporter/plugin')(on)
Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/navigation/logOut.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ describe(`Test Log-out function, Env: ${CY.cfg}`, () => {
cy.getCyVisibleClick('navbar-user', 10000)
cy.getCyVisibleClick('navbar-user-logout')
cy.getCyVisibleClick('button-confirm')
cy.urlContains('login', 10000)
cy.get('.v-btn')
.should('be.visible')
.invoke('text')
.should('eq', ' Log in ')
})
})
3 changes: 1 addition & 2 deletions cypress/e2e/settings/assetLicences.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ describe(
cy.getCy('button-cancel').should('be.visible')
cy.getCy('button-confirm').click()
cy.alertMessage(ALERT_CREATE)
cy.getCy('filter-submit').click() // until bug is fixed
cy.contains(`${EXTERNAL_SYS[0]}${RAND_NUM}`).click() // until bug is fixed
cy.contains(`${EXTERNAL_SYS[0]}${RAND_NUM}`).click()
cy.cardLoad()
cy.getCy('copy-text')
.invoke('text')
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/settings/author.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ describe(`Test authors function, Env: ${CY.cfg}`, { tags: '@author', env: { visi
cy.getCy('button-cancel').should('be.visible')
cy.getCyVisibleClick('button-confirm')
cy.alertMessage(ALERT_CREATE)
cy.getCy('filter-reset').click() // until bug is fixed
cy.getCy('filter-string').eq(1).type(`${USER_FIRST_NAME}{ENTER}`)
cy.contains(`${USER_FIRST_NAME}`).click() // until bug is fixed
cy.contains(`${USER_FIRST_NAME}`).click()
cy.cardLoad()
cy.getCy('copy-text')
.invoke('text')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { ALERT_CREATE, ALERT_UPDATE, CY, USER_FIRST_NAME } from '../../utils/common'

let CATEGOTY_ID = ''
//let CATEGORY_ID = ''
describe(
`Test distribution category function, Env: ${CY.cfg}`,
{ tags: '@distributionCategory', env: { visitBaseUrl: false } },
Expand All @@ -19,12 +19,12 @@ describe(
cy.get('.v-overlay__content > .v-list > .v-list-item').first().click()
cy.getCy('distribution-category-select').eq(2).click()
cy.get('.v-overlay__content > .v-list > .v-list-item').first().click()
cy.get('body').type('{ESC}')
cy.getCy('button-close').should('be.visible')
cy.getCy('button-cancel').should('be.visible')
cy.getCyVisibleClick('button-confirm')
cy.alertMessage(ALERT_CREATE)
cy.getCy('filter-submit').click() // until bug is fixed
cy.contains(`${USER_FIRST_NAME}`).click() // until bug is fixed
cy.contains(`${USER_FIRST_NAME}`).click()
cy.cardLoad()
cy.getCy('copy-text')
.invoke('text')
Expand All @@ -33,12 +33,13 @@ describe(
cy.getCyVisibleClick('button-close')
cy.urlNotContains(text)
cy.urlContains('/distribution-category')
CATEGOTY_ID = text
//CATEGORY_ID = text
})
})
it('Edit distribution category', () => {
cy.visit('distribution-category')
cy.getCy('filter-string').first().type(`${CATEGOTY_ID}{ENTER}`)
//cy.getCy('filter-string').first().type(`${CATEGORY_ID}{ENTER}`) //todo ctrl-v(paste) in ID-filed is not working
cy.getCy('filter-string').eq(1).type(`${USER_FIRST_NAME}{ENTER}`) //todo until bug is fixed
cy.cardLoad()
cy.getCyVisibleClick('table-edit')
cy.urlContains('/edit')
Expand All @@ -50,8 +51,10 @@ describe(
cy.contains('.v-list-item-title', /^Science$/).click()
cy.getCy('distribution-category-select').eq(2).click()
cy.contains('.v-list-item-title', /^Drama$/).click()
cy.getCyVisibleClick('button-save-close')
cy.getCy('button-close').should('be.visible')
cy.getCyVisibleClick('button-save')
cy.alertMessage(ALERT_UPDATE)
cy.getCyVisibleClick('button-close')
cy.urlNotContains('/edit')
cy.getCyVisibleClick('filter-reset')
cy.getCy('filter-string').last().type(`${USER_FIRST_NAME}-edit{ENTER}`)
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/settings/groupPermission.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ describe(
cy.getCy('button-cancel').should('be.visible')
cy.getCyVisibleClick('button-confirm')
cy.alertMessage(ALERT_CREATE)
cy.getCy('filter-submit').click() // until bug is fixed
cy.contains(`${PERMISSION_GROUP}`).click() // until bug is fixed
cy.contains(`${PERMISSION_GROUP}`).click()
cy.cardLoad()
cy.getCy('copy-text')
.invoke('text')
Expand Down
16 changes: 3 additions & 13 deletions cypress/e2e/settings/job.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,17 @@ describe(`Test job function, Env: ${CY.cfg}`, { tags: '@job', env: { visitBaseUr
cy.getCyVisibleClick('job-select')
cy.contains('.v-list-item', JOB_SYNC)
cy.contains('.v-list-item', JOB_DELETE).click()
cy.getCy('targetUser').type(CY.credential.admin.id)
cy.getCy('anonymizeUser')
cy.getCy('targetUser').type(CY.credentials.admin.id)
cy.get('#switch-92').click()
cy.get('.v-card-actions > .bg-primary').click()
cy.alertMessage(ALERT_CREATE)
cy.getCyVisibleClick('filter-reset')
cy.cardLoad()
cy.contains('td', JOB_DELETE).click()
cy.cardLoad()
cy.get(':nth-child(2) > :nth-child(1) > .v-col').should('contain', CY.credential.admin.id)
cy.get(':nth-child(2) > :nth-child(1) > .v-col').should('contain', CY.credentials.admin.id)
cy.getCyVisibleClick('button-close')
cy.cardLoad()
cy.get('.v-table').should('be.visible')

// cy.contains('.v-list-item', 'adminDam').click()
// cy.getCyVisibleClick('filter-submit')
// cy.cardLoad()
// cy.get('.v-tabs').should('be.visible')
// cy.get('.v-table').should('be.visible')
// cy.getCyVisibleClick('filter-reset')
// cy.cardLoad()
// cy.get('.v-tabs').should('not.exist')
// cy.get('.v-table').should('not.exist')
})
})
3 changes: 1 addition & 2 deletions cypress/e2e/settings/keyword.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ describe(`Test keyword function, Env: ${CY.cfg}`, { tags: '@keyword', env: { vis
cy.getCy('button-cancel').should('be.visible')
cy.getCyVisibleClick('button-confirm')
cy.alertMessage(ALERT_CREATE)
cy.getCy('filter-submit').click() // until bug is fixed
cy.contains(`${USER_FIRST_NAME}`).click() // until bug is fixed
cy.contains(`${USER_FIRST_NAME}`).click()
cy.cardLoad()
cy.getCy('copy-text')
.invoke('text')
Expand Down
32 changes: 13 additions & 19 deletions cypress/e2e/settings/podcast.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ describe(`Test Podcast function, Env: ${CY.cfg}`, { tags: '@podcast', env: { vis
cy.getCy('button-cancel').should('be.visible')
cy.getCy('button-confirm').click()
cy.alertMessage(ALERT_CREATE)
cy.getCy('filter-submit').click() // until bug is fixed
cy.contains(`${PODCAST_TITLE}`).click() // until bug is fixed
cy.contains(`${PODCAST_TITLE}`).click()
cy.cardLoad()
cy.getCyVisibleClick('podcast-list')
cy.getCy('podcast-id')
Expand All @@ -49,16 +48,12 @@ describe(`Test Podcast function, Env: ${CY.cfg}`, { tags: '@podcast', env: { vis
cy.getCy('podcast-description').clear().type(`${PODCAST_TITLE}-edit-description`)
//eslint-disable-next-line cypress/unsafe-to-chain-command
cy.getCy('podcast-rss-url').find('input').clear().type(`https://${PODCAST_TITLE}-edit.com`)
// cy.getCy('select-image-preview').within(() => {
// cy.get('button').click()
// cy.get('.asset-list-tiles').first().click()
// cy.contains('button', 'Zvoliť').click()
// })
// cy.getCy('select-image-alt').within(() => {
// cy.get('button').click()
// cy.get('.asset-list-tiles__item').eq(1).click()
// cy.contains('button', 'Zvoliť').click()
// })
cy.get('[data-cy=select-image-preview]').find('button').click()
cy.get('.asset-list-tiles > :nth-child(1)').click()
cy.contains('button', 'Zvoliť').click()
cy.get('[data-cy=select-image-alt]').find('button').click()
cy.get('.asset-list-tiles > :nth-child(1)').click()
cy.contains('button', 'Zvoliť').click()
cy.getCyVisibleClick('button-save')
cy.alertMessage(ALERT_UPDATE)
cy.getCyVisibleClick('button-close')
Expand All @@ -77,8 +72,7 @@ describe(`Test Podcast function, Env: ${CY.cfg}`, { tags: '@podcast', env: { vis
cy.getCy('button-cancel').should('be.visible')
cy.getCy('button-confirm').click()
cy.alertMessage(ALERT_CREATE)
cy.getCy('filter-submit').click() // until bug is fixed
cy.contains(`${EPISODE_TITLE}`).click() // until bug is fixed
cy.contains(`${EPISODE_TITLE}`).click()
cy.cardLoad()
cy.getCy('copy-text')
.invoke('text')
Expand Down Expand Up @@ -112,11 +106,11 @@ describe(`Test Podcast function, Env: ${CY.cfg}`, { tags: '@podcast', env: { vis
cy.getCy('episode-ext-id').type(`${Cypress._.random(1, 1000)}`)
cy.get('.mdi-calendar').click()
cy.get('[data-index="0"]').click()
// cy.getCy('select-image-preview').within(() => {
// cy.get('button').click()
// cy.get('.asset-list-tiles').first().click()
// cy.contains('button', 'Zvoliť').click()
// })
cy.get('body').type('{ESC}')
cy.get(':nth-child(1) > :nth-child(2) > .v-btn').click()
cy.get('.asset-list-tiles > :nth-child(2)').click()
cy.contains('button', 'Zvoliť').click()

cy.getCyVisibleClick('button-save')
cy.alertMessage(ALERT_UPDATE)
cy.getCyVisibleClick('button-close')
Expand Down
22 changes: 13 additions & 9 deletions cypress/e2e/settings/user.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ describe(`Test user function, Env: ${CY.cfg}`, { tags: '@user', env: { visitBase
it('Edit User', () => {
cy.visit('/settings')
cy.visitSubpage('user-settings', 'user', 'Používatelia')
cy.getCy('filter-string').last().type(`${CY.credential.admin.email}{ENTER}`)
cy.getCy('filter-string').last().type(`${CY.credentials.admin.email}{ENTER}`)
cy.getCyVisibleClick('filter-submit')
cy.cardLoad()
cy.contains(`${CY.credential.admin.email}`).click()
cy.contains(`${CY.credentials.admin.email}`).click()
cy.cardLoad()
cy.getCy('copy-text')
.invoke('text')
Expand All @@ -29,20 +29,22 @@ describe(`Test user function, Env: ${CY.cfg}`, { tags: '@user', env: { visitBase
cy.getCy('user-asset-licences').type(`${licence}`)
cy.contains('.v-list-item-title', `${licence}`).click()
})
cy.get('#anzu-actionbar').click()
cy.get('i[aria-label="Zatvoriť"]').click()
cy.getCy('user-admin-to-ext-systems').click()
EXTERNAL_SYS.forEach((admin) => {
cy.contains('.v-list-item-title', `${admin}`).click()
})
cy.get('#anzu-actionbar').click()
cy.get('i[aria-label="Zatvoriť"]').click()
cy.getCy('user-allowed-asset-external-providers').click()
cy.contains('.v-list-item-title', `${EXTERNAL_PROVIDER}`).click()
cy.get('#anzu-actionbar').click()
cy.get('[aria-expanded="false"]').invoke('attr', 'aria-expanded', 'true') // until aria-label,
// aria-title is added
cy.getCy('user-allowed-distribution-services').click()
DISTRIBUTION_SERVICE.forEach((service) => {
cy.contains('.v-list-item-title', `${service}`).click()
})
cy.get('#anzu-actionbar').click()
cy.get('[aria-expanded="false"]').invoke('attr', 'aria-expanded', 'true') // until aria-label,
// aria-title is added
cy.getCyVisibleClick('button-save')
cy.alertMessage(ALERT_UPDATE)
cy.getCyVisibleClick('button-close')
Expand All @@ -55,15 +57,17 @@ describe(`Test user function, Env: ${CY.cfg}`, { tags: '@user', env: { visitBase
EXTERNAL_SYS.forEach((admin) => {
cy.contains('.v-list-item-title', `${admin}`).click()
})
cy.get('#anzu-actionbar').click()
cy.get('i[aria-label="Zatvoriť"]').click()
cy.getCy('user-allowed-asset-external-providers').click()
cy.contains('.v-list-item-title', `${EXTERNAL_PROVIDER}`).click()
cy.get('#anzu-actionbar').click()
cy.get('[aria-expanded="false"]').invoke('attr', 'aria-expanded', 'true') // until aria-label,
// aria-title is added
cy.getCy('user-allowed-distribution-services').click()
DISTRIBUTION_SERVICE.forEach((service) => {
cy.contains('.v-list-item-title', `${service}`).click()
})
cy.get('#anzu-actionbar').click()
cy.get('[aria-expanded="false"]').invoke('attr', 'aria-expanded', 'true') // until aria-label,
// aria-title is added
cy.getCy('user-asset-licences').click()
USER_LICENCE.forEach((licence) => {
cy.getCy('user-asset-licences').type(`${licence}`)
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/settings/userPermission.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe(
cy.getCy('button-cancel').should('be.visible')
cy.getCyVisibleClick('button-confirm')
cy.alertMessage(ALERT_CREATE)
cy.getCy('filter-submit').click() // until bug is fixed
cy.contains(`${USER_EMAIL}`).click() // until bug is fixed
cy.get('[value="50"]').click()
cy.contains(`${USER_EMAIL}`).click()
cy.cardLoad()
cy.getCy('copy-text')
.invoke('text')
Expand All @@ -45,7 +45,7 @@ describe(
cy.cardLoad()
cy.getCy('user-first-name').type('test')
cy.getCy('user-last-name').type('test')
cy.getCy('enable-switch').click()
cy.get('.v-selection-control > .v-label').click()
cy.getCyVisibleClick('button-save')
cy.alertMessage(ALERT_UPDATE)
cy.getCyVisibleClick('button-close')
Expand All @@ -60,7 +60,7 @@ describe(
cy.getCyVisibleClick('table-edit')
cy.urlContains('/edit')
cy.cardLoad()
cy.getCy('enable-switch').click()
cy.get('.v-selection-control > .v-label').click()
cy.getCyVisibleClick('button-save')
cy.alertMessage(ALERT_UPDATE)
cy.getCyVisibleClick('button-close')
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ beforeEach(function () {
CY.loginUser,
() => {
//Setup protection cookie based on env
cy.protectionCookie()
//cy.protectionCookie()
//Login with provided user
cy.login(CY.loginUser)
},
Expand Down
3 changes: 2 additions & 1 deletion cypress/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const USER_PASSWORD = `pwd${RAND_NUM}`
export const USER_LICENCE = ['CMS licence']
export const EXTERNAL_SYS = ['cms', 'blog', 'tools']
export const EXTERNAL_PROVIDER = 'Unsplash'
export const DISTRIBUTION_SERVICE = ['Youtube', 'Youtube Fičí', 'JwVideo']
export const DISTRIBUTION_SERVICE = ['Youtube CMS', 'Youtube Fičí', 'JwVideo', 'Artemis Video CMS',
'Artemis Podcast CMS']
export const PERMISSION_GROUP_TITLE = `TestGroup${RAND_NUM}`
export const PODCAST_TITLE = `TestPodcast${RAND_NUM}`
export const EPISODE_TITLE = `TestEpisode${RAND_NUM}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { onMounted } from 'vue'
const props = withDefaults(
defineProps<{
modelValue: string | null | string[] | any
modelValue: string | number | null | string[] | number[]
assetType: AssetType
label?: string | undefined
required?: boolean | undefined
Expand All @@ -26,7 +26,7 @@ const props = withDefaults(
}
)
const emit = defineEmits<{
(e: 'update:modelValue', data: string | null | string[]): void
(e: 'update:modelValue', data: string | number | null | string[] | number[]): void
}>()
const { fetchItems, fetchItemsByIds } = useDistributionCategorySelectActions()
Expand Down

0 comments on commit 7f92446

Please sign in to comment.