Skip to content

Metas feature#26

Open
BrunoMog wants to merge 15 commits intopauloborba:mainfrom
BrunoMog:metas_feature
Open

Metas feature#26
BrunoMog wants to merge 15 commits intopauloborba:mainfrom
BrunoMog:metas_feature

Conversation

@BrunoMog
Copy link

@BrunoMog BrunoMog commented Dec 9, 2025

Pull Request - Teaching Assistant

📝 Descrição

O que foi feito:
Implementação completa da funcionalidade de Criação e Manutenção de Metas de Avaliação por turma.

  • Frontend: Criação de modal e interface para adicionar metas na tela de Turmas. Melhorias de acessibilidade nos botões de fechar modais.
  • Backend: Refatoração profunda do modelo Class e Classes para encapsular a lógica de metas, validação e persistência, removendo lógica de negócio do controlador (server.ts).
  • Testes: Adição de cenários de teste E2E (Cucumber) cobrindo tanto a interface gráfica (GUI) quanto a API (Server).

Por que foi feito:
Para permitir que cada turma tenha seus próprios critérios de avaliação (metas) de forma independente, flexibilizando o sistema que antes não suportava essa personalização. Além disso, a refatoração foi necessária para garantir a integridade dos dados (evitando o uso de any e garantindo o estado de "bloqueio" das metas após a criação).

📌 Observações

Impacto:

  • 🟢 Baixo - Mudança isolada, sem efeitos colaterais
  • 🟡 Médio - Afeta algumas funcionalidades (Modelo de Turmas e Persistência)
  • 🔴 Alto - Mudanças críticas ou estruturais

Riscos identificados:

  • Compatibilidade com turmas antigas salvas no JSON (tratado no método fromJSON com lógica de fallback).

📦 Área afetada

Frontend (Client - React):

  • 🖥️ Componentes React (Classes.tsx)
  • 🔌 Services/API
  • 📝 Types/Interfaces TypeScript
  • 🎨 Estilos e UI

Backend (Server - Express/Node.js):

  • 🔌 API Routes/Endpoints
  • 📊 Models e lógica de negócio (Class.ts, Classes.ts)
  • 💾 Persistência de dados

Funcionalidades:

  • 🎓 Gerenciamento de Estudantes
  • 📋 Gerenciamento de Turmas
  • 📝 Gerenciamento de Matrículas
  • 📈 Gerenciamento de Avaliações (Definição de critérios)
  • 📄 Importação de dados
  • Provas
  • Flashcards
  • Criação de Metas

Infraestrutura:

  • 🔧 Configurações (cucumber.js, tsconfig.test.json)
  • 📦 Dependências (package.json)
  • 🚀 Scripts de build/deploy
  • 📝 Documentação (README, guias)

🔧 Tipo de mudança

  • 🐛 Correção de bug (fix)
  • ✨ Nova funcionalidade (feature)
  • ♻️ Refatoração de código (Encapsulamento em Class.ts e remoção de any)
  • 📚 Atualização de documentação
  • ✅ Adição/atualização de testes
  • 🎨 Melhorias de UI/UX (Acessibilidade em modais)
  • 🔒 Correção de segurança
  • ⚡ Melhoria de performance

🧪 Testes

Testes automatizados

Por nível de teste:

  • 🔬 Testes Unitários (Jest) - Classes e funções isoladas
    • Validada lógica de construtores e serialização JSON em Class.ts
  • 🔗 Testes de Integração - Interação entre componentes/serviços
  • 🎯 Testes End-to-End (Cucumber) - Fluxos completos da aplicação
    • Cenários de GUI e Server implementados e passando
  • 🌐 Testes de Sistema - Ambiente completo de produção

Por área testada:

  • 🖥️ Testes de GUI (interface do usuário)
  • 📊 Testes de Classes/Models (lógica de negócio)
  • 🔌 Testes de Services/API (comunicação e endpoints)

Cobertura:

  • Cobertura de testes mantida/aumentada
  • Casos de erro e edge cases cobertos (Metas duplicadas, vazias, bloqueio de edição)

Como revisar e testar

Testes Unitários (Server):

cd server
npm install
npm test

Testes E2E (Client):

cd client
npm install
npm start                   # Terminal 1: iniciar app
npm run test:cucumber       # Terminal 2: executar testes

Testar manualmente:

  • Servidor: http://localhost:3000
  • Cliente: http://localhost:3004

📸 Screenshots/GIFs

Screenshot from 2025-12-08 16-27-50 Screenshot from 2025-12-08 16-28-48

✅ Checklist

  • Código segue os padrões do projeto
  • Realizei self-review do código
  • Comentei código em áreas complexas
  • Atualizei a documentação (se necessário)
  • Mudanças não geram warnings
  • Adicionei testes que provam que a correção/feature funciona
  • Testes novos e existentes passam localmente
  • Mudanças dependentes foram merged e publicadas

🔗 Issues relacionadas

  • Closes #
  • Relacionado a #

Copilot AI review requested due to automatic review settings December 9, 2025 15:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a complete feature for creating and managing class-specific assessment goals (metas) within the Teaching Assistant system. The implementation includes:

  • Frontend: Added a modal interface in the Classes component for adding and managing metas, with improved accessibility for modal close buttons
  • Backend: Significant refactoring of the Class and Classes models to encapsulate metas logic, validation, and persistence, removing business logic from the controller
  • Testing: Comprehensive E2E test coverage using Cucumber for both GUI and API interactions

Reviewed changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
server/src/server.ts Added new API endpoints (GET/POST) for managing class metas and updated class creation/loading to support metas
server/src/models/Classes.ts Added methods for retrieving and adding metas to classes
server/src/models/Class.ts Major refactoring: added metas properties, validation logic, locking mechanism, and updated serialization
server/data/app-data.json Updated test data with metas fields and simplified enrollment data
client/src/types/Class.ts Added metas and metasLocked properties to Class interface
client/src/step-definitions/student-steps.ts Refactored to use shared setup scope for browser/page management
client/src/step-definitions/setup.ts New shared setup file for Cucumber test configuration
client/src/step-definitions/server-student-steps.ts Commented out duplicate timeout setting
client/src/step-definitions/server-criacao-metas.steps.ts New E2E tests for server-side metas API
client/src/step-definitions/criacao-metas.steps.ts New E2E tests for GUI-based metas management
client/src/services/ClassService.ts Added setMetas method and updated type usage
client/src/features/server-criacao-metas.feature Feature file defining server-side metas scenarios
client/src/features/criacao-metas.feature Feature file defining GUI metas scenarios
client/src/components/Evaluations.tsx Updated to use class-specific metas instead of hardcoded goals
client/src/components/Classes.tsx Added metas modal UI and management logic
client/src/App.tsx Added success message state and handler
client/src/App.css Added styles for metas UI components and success messages
client/package.json Updated Cucumber version and added type definitions
client/cucumber.js Added TS_NODE_PROJECT environment variable
Files not reviewed (1)
  • client/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +175 to +177
const isLocked = data.metasLocked !== undefined
? data.metasLocked
: (data.metas && data.metas.length > 0);
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The fallback logic (data.metas && data.metas.length > 0) for determining lock status could lead to incorrect behavior. If metasLocked is explicitly set to false but metas exist, this fallback won't be used. Consider using data.metasLocked ?? (data.metas && data.metas.length > 0) to only apply the fallback when the property is actually undefined.

Suggested change
const isLocked = data.metasLocked !== undefined
? data.metasLocked
: (data.metas && data.metas.length > 0);
const isLocked = data.metasLocked ?? (data.metas && data.metas.length > 0);

Copilot uses AI. Check for mistakes.
"Requisitos",
"Testes de software"
],
"metasLocked": false,
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The test data shows metasLocked: false when metas exist (lines 29-32). This contradicts the business logic in Class.ts where setMetas automatically sets metasLocked to true. Test data should reflect the actual system behavior.

Suggested change
"metasLocked": false,
"metasLocked": true,

Copilot uses AI. Check for mistakes.
await scope.page.waitForSelector(SELECTORS.metaInput, { timeout: 1500 });
await scope.page.click(SELECTORS.metaInput, { clickCount: 3 });
await scope.page.focus(SELECTORS.metaInput);
await scope.page.keyboard.down('Control'); await scope.page.keyboard.press('A'); await scope.page.keyboard.up('Control');
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The keyboard combination for text selection is hard-coded for Control+A, which won't work on macOS where Command+A is used. Consider using a cross-platform approach or detecting the operating system.

Suggested change
await scope.page.keyboard.down('Control'); await scope.page.keyboard.press('A'); await scope.page.keyboard.up('Control');
if (process.platform === 'darwin') {
await scope.page.keyboard.down('Meta'); await scope.page.keyboard.press('A'); await scope.page.keyboard.up('Meta');
} else {
await scope.page.keyboard.down('Control'); await scope.page.keyboard.press('A'); await scope.page.keyboard.up('Control');
}

Copilot uses AI. Check for mistakes.
const data = await ClassService.setMetas(classObj.id, localMetas);

// Show server message if provided
const serverMessage = data && (data.message || data.msg) ? (data.message || data.msg) : 'Metas criadas com sucesso!';
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The fallback message is in Portuguese while many other parts of the UI are in English (e.g., 'Close', 'Edit', 'Delete'). Consider using consistent language throughout the application or providing internationalization support.

Suggested change
const serverMessage = data && (data.message || data.msg) ? (data.message || data.msg) : 'Metas criadas com sucesso!';
const serverMessage = data && (data.message || data.msg) ? (data.message || data.msg) : 'Goals created successfully!';

Copilot uses AI. Check for mistakes.
BrunoMog and others added 3 commits December 10, 2025 06:09
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
eu nao fiz as alteracoes na branch necessaria
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant