есть id тарифа для прода
This commit is contained in:
parent
5ad3a810ef
commit
25deb4a0f4
@ -3,8 +3,23 @@ import { defineConfig } from "cypress";
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
e2e: {
|
e2e: {
|
||||||
baseUrl: 'http://localhost:3000',
|
baseUrl: 'http://localhost:3000',
|
||||||
viewportWidth: 1440,
|
viewportWidth: 1280,
|
||||||
viewportHeight: 900,
|
viewportHeight: 720,
|
||||||
supportFile: false,
|
video: true,
|
||||||
|
screenshotOnRunFailure: true,
|
||||||
|
supportFile: 'cypress/support/e2e.ts',
|
||||||
|
defaultCommandTimeout: 10000,
|
||||||
|
pageLoadTimeout: 30000,
|
||||||
|
requestTimeout: 10000,
|
||||||
|
responseTimeout: 30000,
|
||||||
|
setupNodeEvents(on, config) {
|
||||||
|
// implement node event listeners here
|
||||||
|
},
|
||||||
|
},
|
||||||
|
component: {
|
||||||
|
devServer: {
|
||||||
|
framework: 'react',
|
||||||
|
bundler: 'vite',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -3,52 +3,73 @@
|
|||||||
describe('Personalization Flow', () => {
|
describe('Personalization Flow', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// Логинимся перед каждым тестом
|
// Логинимся перед каждым тестом
|
||||||
cy.login(); // Предполагается, что у вас есть команда для логина
|
cy.login();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should complete personalization flow and open link in new tab', () => {
|
it('should complete personalization flow and open link in new tab', () => {
|
||||||
// Переходим на страницу персонализации
|
// Ищем нужный квиз и нажимаем редактировать
|
||||||
cy.visit('/personalization');
|
cy.contains('Сочетание перестановки и размещения')
|
||||||
|
.parent()
|
||||||
|
.parent()
|
||||||
|
.contains('Редактировать')
|
||||||
|
.click();
|
||||||
|
|
||||||
// Выбираем пол (мужской)
|
// Переходим на вкладку персонализации
|
||||||
cy.get('[data-testid="gender-male"]').click();
|
cy.contains('Персонализация').click();
|
||||||
|
|
||||||
|
// Ждем загрузки данных
|
||||||
|
cy.get('.MuiSkeleton-root', { timeout: 30000 }).should('not.exist');
|
||||||
|
cy.wait(6000);
|
||||||
|
|
||||||
|
// Удаляем все существующие ссылки
|
||||||
|
cy.get('body').then(($body) => {
|
||||||
|
if ($body.find('.delete_aud').length > 0) {
|
||||||
|
// Пока есть кнопки удаления - удаляем ссылки
|
||||||
|
const deleteLinks = () => {
|
||||||
|
// Находим первую кнопку удаления и кликаем по ней
|
||||||
|
cy.get('.delete_aud').first().click();
|
||||||
|
// Подтверждаем удаление
|
||||||
|
cy.get('#delete_OK').click();
|
||||||
|
// Проверяем, остались ли еще кнопки удаления
|
||||||
|
cy.get('body').then(($body) => {
|
||||||
|
if ($body.find('.delete_aud').length > 0) {
|
||||||
|
deleteLinks();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
deleteLinks();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Выбираем пол (М)
|
||||||
|
cy.contains('М').click();
|
||||||
|
|
||||||
// Генерируем случайный возраст от 1 до 99
|
// Генерируем случайный возраст от 1 до 99
|
||||||
const randomAge = Math.floor(Math.random() * 99) + 1;
|
const randomAge = Math.floor(Math.random() * 99) + 1;
|
||||||
|
|
||||||
// Вводим возраст
|
// Вводим возраст
|
||||||
cy.get('[data-testid="age-input"]')
|
cy.get('input[placeholder="Введите возраст"]')
|
||||||
.type(randomAge.toString())
|
.type(randomAge.toString())
|
||||||
.should('have.value', randomAge.toString());
|
.should('have.value', randomAge.toString());
|
||||||
|
|
||||||
// Нажимаем кнопку OK
|
// Нажимаем кнопку Ок
|
||||||
cy.get('[data-testid="submit-button"]').click();
|
cy.contains('Ок').click();
|
||||||
|
|
||||||
// Ждем появления скелетона загрузки
|
// Ждем появления ссылки и получаем её текст
|
||||||
cy.get('[data-testid="loading-skeleton"]').should('be.visible');
|
cy.get('.link', { timeout: 30000 })
|
||||||
|
.should('be.visible')
|
||||||
// Ждем 3 минуты (в реальном тесте это будет быстрее из-за моков)
|
.invoke('text')
|
||||||
cy.wait(180000);
|
.then((text) => {
|
||||||
|
// Исправляем домен в ссылке
|
||||||
// Ждем появления кнопки копирования
|
const url = new URL(text);
|
||||||
cy.get('[data-testid="copy-button"]').should('be.visible');
|
url.hostname = 's.hbpn.link';
|
||||||
|
const correctUrl = url.toString();
|
||||||
// Копируем ссылку
|
|
||||||
cy.get('[data-testid="copy-button"]').click();
|
// Переходим на страницу по исправленной ссылке
|
||||||
|
cy.visit(correctUrl);
|
||||||
// Проверяем появление уведомления об успешном копировании
|
|
||||||
cy.contains('Ссылка успешно скопирована').should('be.visible');
|
// Проверяем содержимое страницы
|
||||||
|
cy.contains('Сочетание перестановки и размещения').should('exist');
|
||||||
// Получаем ссылку из буфера обмена
|
|
||||||
cy.window().then((win) => {
|
|
||||||
win.navigator.clipboard.readText().then((text) => {
|
|
||||||
// Открываем ссылку в новой вкладке
|
|
||||||
cy.window().then((win) => {
|
|
||||||
const newWindow = win.open(text, '_blank');
|
|
||||||
// Проверяем, что новая вкладка открылась
|
|
||||||
expect(newWindow).to.not.be.null;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
28
cypress/support/commands.ts
Normal file
28
cypress/support/commands.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
namespace Cypress {
|
||||||
|
interface Chainable {
|
||||||
|
login(): Chainable<void>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Cypress.Commands.add('login', () => {
|
||||||
|
// Пробуем перейти на страницу входа
|
||||||
|
cy.visit('/signin', {
|
||||||
|
timeout: 10000, // Увеличиваем таймаут до 10 секунд
|
||||||
|
failOnStatusCode: false // Не падаем при ошибках статуса
|
||||||
|
});
|
||||||
|
|
||||||
|
// Проверяем, что мы на странице входа
|
||||||
|
cy.url().should('include', '/signin');
|
||||||
|
|
||||||
|
// Вводим данные для входа
|
||||||
|
cy.get('#email', { timeout: 10000 }).should('be.visible').type('test@test.ru');
|
||||||
|
cy.get('#password', { timeout: 10000 }).should('be.visible').type('testtest');
|
||||||
|
cy.get('button[type="submit"]', { timeout: 10000 }).should('be.visible').click();
|
||||||
|
|
||||||
|
// Ждем успешного входа
|
||||||
|
cy.url().should('not.include', '/signin', { timeout: 10000 });
|
||||||
|
});
|
13
cypress/support/e2e.ts
Normal file
13
cypress/support/e2e.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Import commands.js using ES2015 syntax:
|
||||||
|
import './commands';
|
||||||
|
|
||||||
|
// Alternatively you can use CommonJS syntax:
|
||||||
|
// require('./commands')
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
namespace Cypress {
|
||||||
|
interface Chainable {
|
||||||
|
login(): Chainable<void>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -69,7 +69,9 @@
|
|||||||
"test": "craco test",
|
"test": "craco test",
|
||||||
"eject": "craco eject",
|
"eject": "craco eject",
|
||||||
"code:format": "prettier --write --ignore-unknown",
|
"code:format": "prettier --write --ignore-unknown",
|
||||||
"prepare": "husky install"
|
"prepare": "husky install",
|
||||||
|
"cypress:open": "cypress open",
|
||||||
|
"cypress:run": "cypress run"
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
@ -86,10 +88,12 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@emoji-mart/data": "^1.2.1",
|
"@emoji-mart/data": "^1.2.1",
|
||||||
"@emoji-mart/react": "^1.1.1",
|
"@emoji-mart/react": "^1.1.1",
|
||||||
|
"@types/cypress": "^1.1.6",
|
||||||
"@types/cytoscape-popper": "^2.0.4",
|
"@types/cytoscape-popper": "^2.0.4",
|
||||||
"@types/react-beautiful-dnd": "^13.1.4",
|
"@types/react-beautiful-dnd": "^13.1.4",
|
||||||
"@types/react-cytoscapejs": "^1.2.4",
|
"@types/react-cytoscapejs": "^1.2.4",
|
||||||
"craco-alias": "^3.0.1",
|
"craco-alias": "^3.0.1",
|
||||||
|
"cypress": "^14.4.1",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"lint-staged": "^15.2.0",
|
"lint-staged": "^15.2.0",
|
||||||
"prettier": "^3.1.1"
|
"prettier": "^3.1.1"
|
||||||
|
@ -53,6 +53,7 @@ export const AuditoryLink = ({ utmParams, item, index, onDelete }: AuditoryLinkP
|
|||||||
secondaryAction={
|
secondaryAction={
|
||||||
<>
|
<>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
className="delete_aud"
|
||||||
edge="end"
|
edge="end"
|
||||||
aria-label="delete"
|
aria-label="delete"
|
||||||
sx={{ color: theme.palette.brightPurple.main, p: 0, width: 18, height: 18 }}
|
sx={{ color: theme.palette.brightPurple.main, p: 0, width: 18, height: 18 }}
|
||||||
@ -75,7 +76,9 @@ export const AuditoryLink = ({ utmParams, item, index, onDelete }: AuditoryLinkP
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Typography sx={{
|
<Typography
|
||||||
|
className="link"
|
||||||
|
sx={{
|
||||||
color: 'black',
|
color: 'black',
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
fontSize: "16px",
|
fontSize: "16px",
|
||||||
|
@ -22,7 +22,7 @@ import { quizApi } from "@api/quiz";
|
|||||||
import { setQuizes } from "@root/quizes/actions";
|
import { setQuizes } from "@root/quizes/actions";
|
||||||
import TooltipClickInfo from "@/ui_kit/Toolbars/TooltipClickInfo";
|
import TooltipClickInfo from "@/ui_kit/Toolbars/TooltipClickInfo";
|
||||||
|
|
||||||
const tariff = "6844b8858258f5cc35791ef7";
|
const tariff = isTestServer ? "6844b8858258f5cc35791ef7" : "6851db40acfb4d3e5fcd9b19";
|
||||||
export default function PersonalizationAI() {
|
export default function PersonalizationAI() {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [auditory, setAuditory] = useState<AuditoryItem[]>([]);
|
const [auditory, setAuditory] = useState<AuditoryItem[]>([]);
|
||||||
@ -376,7 +376,7 @@ export default function PersonalizationAI() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography sx={{ width: "100%", textAlign: "center", mb: "25px" }}>Уверены, что хотите удалить ссылку?</Typography>
|
<Typography sx={{ width: "100%", textAlign: "center", mb: "25px" }}>Уверены, что хотите удалить ссылку?</Typography>
|
||||||
<Button sx={{ mb: "20px" }} onClick={handleDelete}>Удалить</Button>
|
<Button sx={{ mb: "20px" }} id="delete_OK" onClick={handleDelete}>Удалить</Button>
|
||||||
<Button variant="contained" onClick={() => setDeleteModal(0)} >Отмена</Button>
|
<Button variant="contained" onClick={() => setDeleteModal(0)} >Отмена</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
Loading…
Reference in New Issue
Block a user