From d89f9a48cb1440ff34ebb06c06ae58e20db64632 Mon Sep 17 00:00:00 2001 From: Anton Napolskyi Date: Tue, 4 Jun 2024 15:36:02 +0200 Subject: [PATCH] Add fixes --- README-TEST.md | 6 +----- cypress/commands/auth.ts | 13 ------------- cypress/commands/common.ts | 10 +++++----- cypress/commands/upload.ts | 4 ++-- cypress/e2e/distribution/audioDistribution.cy.ts | 1 + cypress/e2e/navigation/headerNavigation.cy.ts | 4 ++-- cypress/e2e/settings/author.cy.ts | 2 +- cypress/e2e/settings/userPermission.cy.ts | 2 +- cypress/support/e2e.ts | 4 ++-- 9 files changed, 15 insertions(+), 31 deletions(-) diff --git a/README-TEST.md b/README-TEST.md index 3c540d54..e7e55f05 100644 --- a/README-TEST.md +++ b/README-TEST.md @@ -18,7 +18,7 @@ Follow the [installation guide](README.md) to install the project and run dev se in `cypress.config.ts` -- Some are stored in [LastPass](https://lastpass.com/) under name `Cypress Config - DAM` or use following example: +- Some are stored in [BitWarden](https://vault.bitwarden.com/#/vault?collectionId=5ec1888a-edc3-4141-8d69-b14800d2726c&itemId=2d496bd8-9b56-41f7-811a-b148007cd710) under name `Cypress Config - DAM` or use following example: ```typescript function extendCypressConfigStg(config) { config.baseUrl = '' @@ -29,10 +29,6 @@ function extendCypressConfigStg(config) { forceLoginLink: '', // admin forceLoginLink }, } - config.env.cookie = { - name: '', - value: '', - } config.env.url = { domain: '', proto: '', diff --git a/cypress/commands/auth.ts b/cypress/commands/auth.ts index 542c8a8a..ba05384d 100644 --- a/cypress/commands/auth.ts +++ b/cypress/commands/auth.ts @@ -16,10 +16,6 @@ declare global { * Clear all cookies, local storage, session storage and set protection cookie */ clearAll(): Chainable - /** - * Setup protection cookie based on env - */ - protectionCookie(): Chainable /** * Login to sme web * Provide user credentials form config/cypress.config.ts env to login @@ -31,15 +27,6 @@ declare global { } } -Cypress.Commands.add('protectionCookie', () => { - if (CY.cookie != undefined) { - cy.setCookie(CY.cookie.name, CY.cookie.value, { - domain: CY.url.domain, - log: false, - }) - } -}) - Cypress.Commands.add('login', (user: string, timeout?: number) => { cy.visit(CY.credentials[user].forceLoginLink, { timeout: timeout }) }) diff --git a/cypress/commands/common.ts b/cypress/commands/common.ts index 0d58a365..c434f2a2 100644 --- a/cypress/commands/common.ts +++ b/cypress/commands/common.ts @@ -70,7 +70,7 @@ declare global { } } -Cypress.Commands.add('waitResponse', (request: string, timeout?: number) => { +Cypress.Commands.add('waitResponse', (request: string, timeout: number = 10000) => { cy.log(`Wait for response: ${request}`) cy.intercept(request, {}).as('waitResponse') cy.wait('@waitResponse', { timeout: timeout }) @@ -81,15 +81,15 @@ Cypress.Commands.add('waitSec', (sec: number) => { cy.wait(sec * 1000) }) -Cypress.Commands.add('getCy', (selector: string, timeout?: number) => { +Cypress.Commands.add('getCy', (selector: string, timeout: number = 10000) => { cy.get(`[data-cy='${selector}']`, { timeout: timeout }) }) -Cypress.Commands.add('getCyVisibleClick', (selector: string, timeout?: number) => { +Cypress.Commands.add('getCyVisibleClick', (selector: string, timeout: number = 10000) => { cy.get(`[data-cy='${selector}']`, { timeout: timeout }).should('be.visible').click() }) -Cypress.Commands.add('urlContains', (string: string, timeout?: number) => { +Cypress.Commands.add('urlContains', (string: string, timeout: number = 10000) => { cy.url({ timeout: timeout }).should('contain', string) }) @@ -103,7 +103,7 @@ Cypress.Commands.add('alertMessage', (message: string) => { cy.get('.mdi-close').eq(0).click() }) -Cypress.Commands.add('visitBaseUrl', (value?: boolean, timeout?: number) => { +Cypress.Commands.add('visitBaseUrl', (value?: boolean, timeout: number = 10000) => { if (value) { cy.visit('/', { timeout: timeout }) } diff --git a/cypress/commands/upload.ts b/cypress/commands/upload.ts index d42aa0f7..8ef3e190 100644 --- a/cypress/commands/upload.ts +++ b/cypress/commands/upload.ts @@ -41,10 +41,10 @@ Cypress.Commands.add('verifyFileType', fileGroup = fileType.includes('txt') ? 'text' : fileGroup expect(type).to.contain(fileGroup).and.to.contain(getFileType(fileType))}) }) -Cypress.Commands.add('waitForUpload', (alertUpload: string, timeout?: number) => { +Cypress.Commands.add('waitForUpload', (alertUpload: string, timeout?: number = 10000) => { cy.contains('[data-cy="upload-overlay-title"]', alertUpload, { timeout: timeout | 90000 }) }) -Cypress.Commands.add('uploadFile', (fileName: string, action: 'select' | 'drag-drop', timeout?: number) => { +Cypress.Commands.add('uploadFile', (fileName: string, action: 'select' | 'drag-drop', timeout?: number = 10000) => { cy.get('input[type="file"]', { timeout: timeout | 10000 }) .first() .selectFile( diff --git a/cypress/e2e/distribution/audioDistribution.cy.ts b/cypress/e2e/distribution/audioDistribution.cy.ts index fd3833dd..4d7d4c7f 100644 --- a/cypress/e2e/distribution/audioDistribution.cy.ts +++ b/cypress/e2e/distribution/audioDistribution.cy.ts @@ -34,6 +34,7 @@ describe(`Test distribution Audio function, Env: ${CY.cfg}`, cy.getCy('button-add-new-podcast-episode').should('be.visible').click() cy.getCy('field-choose-podcast').click() cy.waitSec(2) + cy.getCy('field-choose-podcast').type(DISTRIBUTION_DATA.PODCAST) cy.get('.v-list-item').contains(DISTRIBUTION_DATA.PODCAST).click() cy.circleLoad() cy.get('textarea').eq(0).type(ASSET_DESCRIPTION) diff --git a/cypress/e2e/navigation/headerNavigation.cy.ts b/cypress/e2e/navigation/headerNavigation.cy.ts index dfb8a43f..888cab88 100644 --- a/cypress/e2e/navigation/headerNavigation.cy.ts +++ b/cypress/e2e/navigation/headerNavigation.cy.ts @@ -10,7 +10,7 @@ describe(`Test header navigation menu function, Env: ${CY.cfg}`, cy.get('.v-list-item .mdi-plus').should('be.visible').click() cy.get('.v-toolbar-title').invoke('text') .should('contain', 'Vytvoriť prázdny asset') - cy.getCy('button-close').should('be.visible').click() + cy.getCy('button-close').click() cy.get('[href="/podcast"]').should('be.visible').click() cy.urlContains('podcast') cy.getCy('back-to-assets-settings').should('be.visible').click() @@ -22,7 +22,7 @@ describe(`Test header navigation menu function, Env: ${CY.cfg}`, cy.getCy('button-switch-licence').click() cy.get('.v-toolbar-title').invoke('text') .should('contain', 'Prepnutie externého systému') - cy.getCy('button-cancel').should('be.visible').click() + cy.getCy('button-cancel').click() cy.getCy('button-settings').click() cy.urlContains('settings') }) diff --git a/cypress/e2e/settings/author.cy.ts b/cypress/e2e/settings/author.cy.ts index ba640a26..5d06460d 100644 --- a/cypress/e2e/settings/author.cy.ts +++ b/cypress/e2e/settings/author.cy.ts @@ -35,7 +35,7 @@ describe(`Test authors function, Env: ${CY.cfg}`, }) it('Edit author', () => { cy.visit('/author') - cy.getCy('filter-string', { timeout: 20000 }).first().type(`${USER_ID}{ENTER}`) + cy.getCy('filter-string', 20000).first().type(`${USER_ID}{ENTER}`) cy.cardLoad() cy.getCyVisibleClick('table-edit') cy.urlContains('/edit') diff --git a/cypress/e2e/settings/userPermission.cy.ts b/cypress/e2e/settings/userPermission.cy.ts index 1e443d63..9b95bf2e 100644 --- a/cypress/e2e/settings/userPermission.cy.ts +++ b/cypress/e2e/settings/userPermission.cy.ts @@ -5,11 +5,11 @@ import { ALERT_UPDATE, CY, JOB_DELETE, JOB_SYNC, - RAND_NUM, USER_EMAIL, USER_ROLE } from '../../utils/common' let USER_ID = '' +const RAND_NUM = `${Cypress._.random(50, 100)}` describe( `Test permission user function, Env: ${CY.cfg}`, { tags: ['@userPermission', '@settings'], env: { visitBaseUrl: false } }, diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index c81db945..80e537c1 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -21,11 +21,11 @@ beforeEach(function () { cy.session( CY.loginUser, () => { - //Setup protection cookie based on env - cy.protectionCookie() //Login with provided user cy.login(CY.loginUser) cy.changeToSlovakDarkTheme() + // go to main licence + cy.changeLicence(100000) }, { cacheAcrossSpecs: true,