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

tests/Cypress-06. Сhecking object properties #794

Merged
merged 1 commit into from
Mar 28, 2023
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
29 changes: 29 additions & 0 deletions .github/workflows/cypress_unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Unit tests"

on:
pull_request:
push:
workflow_call:
workflow_dispatch:

jobs:
smoke_job:
name: Cypress unit tests
runs-on: ubuntu-latest

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

- name: run server with the front of the game
run: python3 -m http.server 8080 &

- name: check whether game is UP
run: |
curl -X GET "http://localhost:8080/"

- name: cypress run
uses: cypress-io/github-action@v5
with:
working-directory: tests/tests_cypress/unit
start: npm run start
10 changes: 10 additions & 0 deletions tests/tests_cypress/unit/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

export default ({
e2e: {
baseUrl: 'http://localhost:8080',
setupNodeEvents(on, config) {
video: false;
// implement node event listeners here
},
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

describe('Сhecking object properties in file: ', () => {

beforeEach(() => {
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")');
});

})

it('Сhecking object properties', () => {

// *********************************************************************
// Checking the file objects_artifacts.js
// *********************************************************************

let artefacts;
let checkArt;
let tempCheckArt;

cy.window().then((win) => {
artefacts = win.eval('Object.keys(artefacts)');

console.log(artefacts);
artefacts.forEach(function (item) {
console.log("item ==>> " + item);
checkArt = win.eval('artefacts.' + item);

artefacts.forEach(function (tempItem) {
tempCheckArt = win.eval('artefacts.' + tempItem);

if (checkArt === tempCheckArt) {
expect(tempCheckArt.id).to.eql(checkArt.id);
expect(tempCheckArt.name['default']).to.eql(checkArt.name['default']);
expect(tempCheckArt.name['en-US']).to.eql(checkArt.name['en-US']);
expect(tempCheckArt.name['ru-RU']).to.eql(checkArt.name['ru-RU']);
} else {
if (tempCheckArt.id === checkArt.id) {
expect(tempCheckArt.id).to.not.eql(checkArt.id)
}
if (tempCheckArt.name['default'] === checkArt.name['default']) {
expect(tempCheckArt.name['default']).to.not.eql(checkArt.name['default']);
}
if (tempCheckArt.name['en-US'] === checkArt.name['en-US']) {
expect(tempCheckArt.name['en-US']).to.not.eql(checkArt.name['en-US']);
}
if (tempCheckArt.name['ru-RU'] === checkArt.name['ru-RU']) {
expect(tempCheckArt.name['ru-RU']).to.not.eql(checkArt.name['ru-RU']);
}
}
})

})

});
});
});
5 changes: 5 additions & 0 deletions tests/tests_cypress/unit/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/unit/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/unit/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