Skip to content
Open
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
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"plugins": ["cypress"],
"extends": ["plugin:cypress/recommended"]
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# react-burger

Graduation project for Yandex.Praktikum React-developer course

«[Stellar Burgers on GH-Pages](https://mrhalless.github.io/react-burger/)»
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в задеплоенном приложении просто черный экран https://disk.yandex.ru/i/78GIs7OZt8OoVQ


# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
Expand Down
17 changes: 17 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
baseUrl: "http://localhost:3000/",
setupNodeEvents(on, config) {
// implement node event listeners here
},
},

component: {
devServer: {
framework: "create-react-app",
bundler: "webpack",
},
},
});
62 changes: 62 additions & 0 deletions cypress/e2e/burger-constructor/burger-constructor.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {
testBun,
modalButton,
constructorSection,
} from "../../../src/utils/constant";

console.log(testBun);

describe("service is available", function () {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beforeEach(() => {
cy.viewport(1280, 720);
cy.visit("http://localhost:3000");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://localhost:3000 будет повторяться несколько раз в коде тестов. Нужно вынести в константу testUrl, чтобы можно было одним движением изменить урл для тестов
А можно в документации посмотреть, как настроить быстро baseUrl для cypress https://docs.cypress.io/api/commands/visit#Visit-is-automatically-prefixed-with-baseUrl

// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(3000);
});
it("should open burger constructor page by default and test modal", function () {
cy.contains(testBun).click();
cy.get(`${modalButton}`).click();
cy.contains("Сыр с астероидной плесенью").click();
cy.get(`${modalButton}`).click();
cy.contains("Соус традиционный галактический").click();
cy.get(`${modalButton}`).click();
cy.contains(testBun).click();
cy.get(`${modalButton}`).click();
});

it("should drag and drop ingredients, login and place an order", function () {
cy.get(`img[alt*="${testBun}"]`).trigger("dragstart").trigger("dragleave");
cy.get(constructorSection)
.trigger("dragenter")
.trigger("dragover")
.trigger("drop")
.trigger("dragend");

cy.get('img[alt*="Сыр с астероидной плесенью"]')
.trigger("dragstart")
.trigger("dragleave");
cy.get(constructorSection)
.trigger("dragenter")
.trigger("dragover")
.trigger("drop")
.trigger("dragend");

cy.get('img[alt*="Мини-салат Экзо-Плантаго"]')
.trigger("dragstart")
.trigger("dragleave");
cy.get(constructorSection)
.trigger("dragenter")
.trigger("dragover")
.trigger("drop")
.trigger("dragend");

cy.get("button").contains("Оформить заказ").click();

cy.get('input[type*="email"]').click().type("jkjkkj@yandex.ru");
cy.get('input[type*="password"]').click().type("123456");
cy.get("button").contains("Войти").click();
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get("button").contains("Оформить заказ").click();
});
});
5 changes: 5 additions & 0 deletions 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"
}
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts 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) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
12 changes: 12 additions & 0 deletions cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
39 changes: 39 additions & 0 deletions cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// ***********************************************************
// This example support/component.ts 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')

import { mount } from 'cypress/react'

// Augment the Cypress namespace to include type definitions for
// your custom command.
// Alternatively, can be defined in cypress/support/component.d.ts
// with a <reference path="./component" /> at the top of your spec.
declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount
}
}
}

Cypress.Commands.add('mount', mount)

// Example use:
// cy.mount(<MyComponent />)
20 changes: 20 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts 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