Skip to content

Commit

Permalink
Merge pull request #775 from aablatov/tests/Cypress-03
Browse files Browse the repository at this point in the history
tests/cypress-03. Verification of authorization and loading of the save
  • Loading branch information
Areso authored Mar 10, 2023
2 parents 261dd80 + 3c0af1f commit cce55bf
Show file tree
Hide file tree
Showing 11 changed files with 4,216 additions and 25 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/cypress_SP.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "PROD Check save Game"

on:
pull_request:
push:
workflow_call:
workflow_dispatch:

jobs:
smoke_job:
name: Cypress PROD Check save Game
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: cypress run
uses: cypress-io/github-action@v5
with:
working-directory: tests/tests_cypress/smoke_prod
start: npm run start
38 changes: 26 additions & 12 deletions .htmlvalidate.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
{
"extends": ["html-validate:recommended"],
"extends": [
"html-validate:recommended"
],
"rules": {
"require-sri": "warn",
"script-type": "warn",
"wcag/h30": "warn",
"wcag/h37": "warn",
"heading-level": "warn",
"element-permitted-content": "warn",
"input-missing-label": "warn",
"no-deprecated-attr": "warn",
"attribute-allowed-values": "warn",
"element-name": "warn"
"element-required-attributes": [
"warn",
{
"exclude": [
"html lang"
]
}
],
"require-sri": "warn",
"script-type": "warn",
"wcag/h30": "warn",
"wcag/h37": "warn",
"heading-level": "warn",
"element-permitted-content": "warn",
"input-missing-label": "warn",
"no-deprecated-attr": "warn",
"attribute-allowed-values": "warn",
"element-name": "warn",
"attribute-boolean-style": "warn",
"no-inline-style": "warn",
"valid-id": "warn",
"void-style": "warn"
},
"elements": [
"html5"
"html5"
]
}
4 changes: 2 additions & 2 deletions tests/tests_cypress/E2E/cypress/e2e/buttonSettings.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ describe('Settings', () => {
cy.get('#login').should('have.attr', 'type', 'text');
cy.get('#password').should('have.attr', 'type', 'password');
cy.get('#email').should('have.attr', 'type', 'text');
cy.get('#btnRegLogin').should('have.attr', 'onclick', 'remoteRegLogin()'); //cy.get('.connectors-list > li').should(($lis) => {
cy.get('#btnRegLogin').should('have.attr', 'onclick', 'remoteRegLogin()');

cy.get('#selectLng').should('have.attr', 'onchange', 'reloadLang()');
cy.get('#selectLng').should('have.attr', 'onchange', 'reloadLang()');//cy.get('.connectors-list > li').should(($lis) => {
cy.get('#labelAutosave');
cy.get('#autosaveImg').should('have.attr', 'onclick', 'changeAutosave()');
cy.get('#buttonExportGame').should('have.attr', 'onclick', 'exportGame()');
Expand Down
9 changes: 9 additions & 0 deletions tests/tests_cypress/smoke_prod/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

export default ({
e2e: {
baseUrl: 'https://1255.areso.pro/',
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
67 changes: 67 additions & 0 deletions tests/tests_cypress/smoke_prod/cypress/e2e/checkSaveGame.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
describe('Verification of authorization and loading of the save', () => {

it('Verification of authorization and loading of the save', () => {
cy.visit('/');

Cypress.on('uncaught:exception', (err, runnable) => {
return false;
});

//close windows canvas
cy.window().then((win) => {
win.eval('document.getElementById("myDCanvas").classList.remove("active-modal")');
});

cy.get('#tabSettings').click();
cy.get('#selectLng').select('English');
cy.get('#btnLogin').click();
cy.get('#login').type('tester16');
cy.get('#password').type('tester16');
cy.get('#btnRegLogin').click();
cy.get('#log').contains('login successfull');
cy.get('#buttonLoadFromCloud', { timeout: 9000 }).click();

// Check
cy.get('#autosaveImg').should('have.attr', 'src', 'resources/button_green.png');
cy.get('#panelGoldValue').should("have.text", 24180);
cy.get('#panelPopValue').should("have.text", 648);
cy.get('#gems').should("have.text", 10);
cy.get('#spnServerStatusValue').should("have.text", "Up");

cy.window().its('game.year').should('equal', 1308);
cy.window().its('game.season').should('equal', 3);
cy.window().its('game.food').should('equal', 20);
cy.window().its('game.treasuryGuard').should('equal', 20);
cy.window().its('game.happiness').should('equal', 80);
cy.window().its('game.fire').should('equal', 0);
cy.window().its('game.fireSteps').should('equal', 0);
cy.window().its('game.fireGuard').should('equal', 0);
cy.window().its('game.hero').should('equal', 0);

// checking available buildings
cy.get('#btnOpenTabBuilding').click();

cy.get('#homes').should('have.text', 'Build Homelvl 17131072 gold');
// bugs
// cy.get('#defence').should('have.class', 'Build Walllvl 3125000 gold');
cy.get('#treasury').should('have.text', 'Build Treasurylvl 1381920000000000000 gold');
cy.get('#buttonBldGallows').should('have.text', 'Build Gallowslvl 150 gold');
cy.get('#buttonBldFountain').should('have.text', 'Build Fountainlvl 3125000 gold');
cy.get('#buttonBldStash').should('have.text', 'Build Stashlvl 3125000 gold');
cy.get('#buttonBldStable').should('have.text', 'Build Stablelvl 3125000 gold');
cy.get('#buttonBldArchery').should('have.text', 'Build Archery rangelvl 3125000 gold');
cy.get('#buttonBldInn').should('have.text', 'Build Innlvl 4160000 gold');
cy.get('#buttonBuildUniversity').should('have.text', 'Build university200 gold');

cy.get('#chat_btn').click();
cy.get('#log_btn').click();

cy.get('#log').within(() => {
cy.contains('Hello player in this incremental game!');
cy.contains('Your task is simple - manage the city as mayor of the city!');
cy.contains('Citizen will pay taxes each season (30 secs) and population will grow each season');
cy.contains('login successfull');
cy.contains('game loaded successfully');
});
});
})
5 changes: 5 additions & 0 deletions tests/tests_cypress/smoke_prod/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
25 changes: 25 additions & 0 deletions tests/tests_cypress/smoke_prod/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions tests/tests_cypress/smoke_prod/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Loading

0 comments on commit cce55bf

Please sign in to comment.