Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cy 404 test #1318

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions tests/cypress/e2e/404Page.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ describe('Page 404', { testIsolation: false }, () => {
.filter((device) => Cypress.env('devices')[`${device}`])
.forEach((device) => {
context(device, Cypress.env('resolution')[`${device}`], () => {

before(() => {
cy.visit('/93dfcaf3d923ec47edb8580667473987', {failOnStatusCode: false})
cy.visit('/93dfcaf3d923ec47edb8580667473987', { failOnStatusCode: false })
})

it('1. Check if the 404 page is displayed.', () => {
cy.dataCy("404-image").should("be.visible")
cy.dataCy("404-left-side", "> div").contains("404").should("be.visible")
cy.dataCy("404-left-side", "> p").contains("Ľutujeme, pre dané vyhľadávanie sa nenašli žiadne výsledky.").should("be.visible")
cy.dataCy("404-left-side", "> a").should("be.visible").click()
cy.dataCy('404-image').should('be.visible')
cy.dataCy('404-left-side', '> div').contains('404').should('be.visible')
cy.dataCy('404-left-side', '> a').should('be.visible').click()
})

it('2. Check if I was redirected to the homepage.', () => {
cy.location('pathname', {timeout: 4000})
.should('eq', '/');
cy.location('pathname', { timeout: 4000 }).should('eq', '/')
})
})
})
})
})
13 changes: 7 additions & 6 deletions tests/cypress/e2e/accountButton.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,32 @@ describe('Account button', { testIsolation: false }, () => {
.filter((device) => Cypress.env('devices')[`${device}`])
.forEach((device) => {
context(device, Cypress.env('resolution')[`${device}`], () => {

before(() => {
cy.visit('/')
})

it('1. Checking account button.', () => {
if (device === 'desktop') {
cy.dataCy('account-button').should('be.visible')
cy.dataCy('account-button')
.should('be.visible')
.then(($accountButton) => {
expect($accountButton).to.have.attr('target', '_blank')
$accountButton.attr('target', '_self')
})
cy.dataCy('account-button').click()
cy.url().should('include', 'https://konto.bratislava.sk/prihlasenie');
cy.url().should('include', 'https://konto.bratislava.sk/prihlasenie')
} else {
cy.dataCy('mobile-menu-button').click()
cy.dataCy('mobile-account-button').should('be.visible')
cy.dataCy('mobile-account-button')
.should('be.visible')
.then(($a) => {
expect($a).to.have.attr('target', '_blank')
$a.attr('target', '_self')
})
cy.dataCy('mobile-account-button').click()
cy.url().should('include', 'https://konto.bratislava.sk/prihlasenie');
cy.url().should('include', 'https://konto.bratislava.sk/prihlasenie')
}
})
})
})
})
})
28 changes: 14 additions & 14 deletions tests/cypress/e2e/englishTranslation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ describe('English translation', { testIsolation: false }, () => {
.filter((device) => Cypress.env('devices')[`${device}`])
.forEach((device) => {
context(device, Cypress.env('resolution')[`${device}`], () => {

before(() => {
cy.visit('/kontakty')
})

it('1. Translating contact page.', () => {
cy.dataCy('heading-two').eq(0).invoke('text').then((text) => {
expect(text.replace(/\u00a0/g, ' ')).equal('Otváracie hodiny')
})

cy.dataCy('heading-two')
.eq(0)
.invoke('text')
.then((text) => {
expect(text.replace(/\u00a0/g, ' ')).equal('Otváracie hodiny')
})

if (device === 'desktop') {
cy.dataCy('change-language-button').click()
} else {
} else {
cy.dataCy('mobile-change-language-button').click()
}
})

it('2. Checking page heading translation.', () => {
cy.wait(500)
cy.location('pathname', {timeout: 10000})
.should('eq', '/en/visiting-and-office-hours');
cy.dataCy('heading-two').eq(0).should("contain.text", "Opening hours")
cy.location('pathname', { timeout: 10000 }).should('eq', '/en/visiting-and-office-hours')
cy.dataCy('heading-two').eq(0).should('contain.text', 'Opening hours')

if (device === 'desktop') {
cy.dataCy('change-language-button').click()
} else {
} else {
cy.dataCy('mobile-change-language-button').click()
}
})

it('3. Checking original language.', () => {
cy.wait(500)
cy.location('pathname', {timeout: 10000})
.should('eq', '/kontakty');
cy.dataCy('heading-two').eq(0).should("contain.text", 'Otváracie hodiny')
cy.location('pathname', { timeout: 10000 }).should('eq', '/kontakty')
cy.dataCy('heading-two').eq(0).should('contain.text', 'Otváracie hodiny')
})
})
})
})
})
24 changes: 14 additions & 10 deletions tests/cypress/e2e/homepageSearch.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,41 @@ describe('S02 - ', { testIsolation: false }, () => {
.filter((device) => Cypress.env('devices')[`${device}`])
.forEach((device) => {
context(device, Cypress.env('resolution')[`${device}`], () => {

beforeEach(() => {
cy.visit('/')
})

it('1. Checking homepage search with results.', () => {
cy.dataCy('homepage-search-field').should('be.visible')
cy.dataCy('homepage-search-field').type('Bratislava')
cy.dataCy('homepage-search-results').should('be.visible')
cy.dataCy('homepage-search-results').then((results) => {
cy.wrap(Cypress.$('[data-cy=homepage-search-all-results]', results)).should('be.visible')
cy.wrap(Cypress.$('[data-cy=homepage-search-all-results]', results)).should(
'be.visible',
)
cy.wrap(Cypress.$('[data-cy=homepage-search-all-results]', results)).click()
})
cy.location('pathname', {timeout: 4000})
.should('eq', '/vyhladavanie');
cy.location('pathname', { timeout: 4000 }).should('eq', '/vyhladavanie')
cy.dataCy('search-field').should('have.value', 'Bratislava')
cy.dataCy('search-section-Stránky').should('be.visible')
cy.dataCy('search-section-Stránky').then((section) => {
cy.wrap(Cypress.$('[data-cy=search-results]', section)).find('[data-cy=search-result-card]').should('exist')
cy.wrap(Cypress.$('[data-cy=search-results]', section))
.find('[data-cy=search-result-card]')
.should('exist')
})
})

it('2. Checking homepage search with no results.', () => {
cy.dataCy('homepage-search-field').should('be.visible')
cy.dataCy('homepage-search-field').type('jbfhrebhgberhgerbhbcbeybgfyefbhbewhf')
cy.dataCy('homepage-search-no-results').should('be.visible')
cy.dataCy('homepage-search-no-results').should('contain', 'Ľutujeme, pre dané vyhľadávanie sa nenašli žiadne výsledky.')
cy.dataCy('homepage-search-no-results').should(
'contain',
'Ľutujeme, pre dané vyhľadávanie sa nenašli žiadne výsledky.',
)
cy.dataCy('homepage-search-button').click()
cy.location('pathname', {timeout: 4000})
.should('eq', '/vyhladavanie');

cy.location('pathname', { timeout: 4000 }).should('eq', '/vyhladavanie')

cy.dataCy('search-field').should('have.value', 'jbfhrebhgberhgerbhbcbeybgfyefbhbewhf')
cy.dataCy('search-section-Stránky').should('be.visible')
cy.dataCy('search-section-Stránky').should('contain', 'Žiadne výsledky')
Expand Down
9 changes: 5 additions & 4 deletions tests/cypress/e2e/officialBoard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ describe('OB - 1', { testIsolation: false }, () => {
.filter((device) => Cypress.env('devices')[`${device}`])
.forEach((device) => {
context(device, Cypress.env('resolution')[`${device}`], () => {

before(() => {
cy.visit('/')
})
Expand All @@ -17,8 +16,10 @@ describe('OB - 1', { testIsolation: false }, () => {
cy.dataCy('homepage-tab-OfficialBoard').should('have.class', 'selected:font-semibold')
cy.dataCy('official-board-results').find('[data-cy=search-result-card]')
cy.dataCy('official-board-button').click()
cy.location('pathname', { timeout: 4000 })
.should('eq', '/mesto-bratislava/transparentne-mesto/uradna-tabula');
cy.location('pathname', { timeout: 4000 }).should(
'eq',
'/mesto-bratislava/transparentne-mesto/uradna-tabula',
)
cy.dataCy('search-results').should('exist')
cy.dataCy('search-results').find('[data-cy=search-result-card]').should('exist')
cy.dataCy('pagination').should('exist')
Expand All @@ -31,5 +32,5 @@ describe('OB - 1', { testIsolation: false }, () => {
cy.dataCy('no-search-results').should('contain', 'Žiadne výsledky')
})
})
})
})
})
64 changes: 47 additions & 17 deletions tests/cypress/e2e/organizationalStructure.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,60 @@ describe('OS01 -', { testIsolation: false }, () => {
.filter((device) => Cypress.env('devices')[`${device}`])
.forEach((device) => {
context(device, Cypress.env('resolution')[`${device}`], () => {

before(() => {
cy.visit('/mesto-bratislava/sprava-mesta/magistrat/organizacna-struktura')
})

it('1. Check organizational structure data.', () => {
cy.dataCy('page-heading').invoke('text').then((text) => {
expect(text.replace(/\u00a0/g, ' ')).equal('Organizačná štruktúra')
})
cy.dataCy('page-heading')
.invoke('text')
.then((text) => {
expect(text.replace(/\u00a0/g, ' ')).equal('Organizačná štruktúra')
})

cy.dataCy('organizational-structure-container').then((container) => {
cy.wrap(Cypress.$(`[data-cy=organizational-structure-accordion]`, container)).should('have.length', 3)
cy.wrap(Cypress.$(`[data-cy=organizational-structure-accordion]`, container).eq(0)).should('contain', 'Magistrát hlavného mesta SR Bratislavy')
cy.wrap(Cypress.$(`[data-cy=organizational-structure-accordion]`, container).eq(1)).should('contain', 'Primátor hlavného mesta SR Bratislavy')
cy.wrap(Cypress.$(`[data-cy=organizational-structure-accordion]`, container).eq(2)).should('contain', 'Útvar mestskej kontrolórky')
cy.wrap(Cypress.$(`[data-cy=organizational-structure-accordion]`, container)).should(
'have.length',
3,
)
cy.wrap(
Cypress.$(`[data-cy=organizational-structure-accordion]`, container).eq(0),
).should('contain', 'Magistrát hlavného mesta SR Bratislavy')
cy.wrap(
Cypress.$(`[data-cy=organizational-structure-accordion]`, container).eq(1),
).should('contain', 'Primátor hlavného mesta SR Bratislavy')
cy.wrap(
Cypress.$(`[data-cy=organizational-structure-accordion]`, container).eq(2),
).should('contain', 'Útvar mestskej kontrolórky')

cy.wrap(Cypress.$(`[data-cy=organizational-structure-accordion]`, container).eq(1)).click()
cy.wrap(
Cypress.$(`[data-cy=organizational-structure-accordion]`, container).eq(1),
).click()
})

cy.dataCy('organizational-structure-accordion-content').then((content) => {
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-name]`, content)).should('contain', 'Vallo Matúš, Ing. arch.')
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-job]`, content)).should('contain', 'Primátor')
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-name]`, content)).should('contain', 'Vallo Matúš, Ing. arch.')
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-phone]`, content)).should('contain', '+421-904099004')
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-name]`, content)).should(
'contain',
'Vallo Matúš, Ing. arch.',
)
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-job]`, content)).should(
'contain',
'Primátor',
)
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-name]`, content)).should(
'contain',
'Vallo Matúš, Ing. arch.',
)
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-phone]`, content)).should(
'contain',
'+421-904099004',
)

if (device === 'mobile') {
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-email-mobile]`, content)).should('contain', '[email protected]')
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-email-mobile]`, content)).should(
'contain',
'[email protected]',
)
cy.dataCy('file-wrapper-mobile').within((wrapper) => {
cy.wrap(Cypress.$(`[data-cy=file-card]`, wrapper)).should('exist')

Expand All @@ -44,7 +71,10 @@ describe('OS01 -', { testIsolation: false }, () => {
.and('include', '.pdf')
})
} else {
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-email]`, content)).should('contain', '[email protected]')
cy.wrap(Cypress.$(`[data-cy=structure-accordion-card-email]`, content)).should(
'contain',
'[email protected]',
)
cy.dataCy('file-wrapper-desktop').within((wrapper) => {
cy.wrap(Cypress.$(`[data-cy=file-card]`, wrapper)).should('exist')

Expand All @@ -53,10 +83,10 @@ describe('OS01 -', { testIsolation: false }, () => {
.should('have.attr', 'href')
.should('not.be.empty')
.and('include', '.pdf')
})
})
}
})
})
})
})
})
})
Loading
Loading