Skip to content

Conversation

@BacLuc
Copy link
Contributor

@BacLuc BacLuc commented Aug 2, 2025

frontend: fix creating camp without a prototype

The intermediate value 'none' sneaked into the post-payload.
It's often a good idea to keep the intermediate form state
and the actual payload separate.
Then you can define an explicit mapping between the two representations.


e2e: add test for creating a camp without a prototype

Prefix it with zz because it creates a new camp.
Use data-testid attribute to find the elements.

The test was scaffolded with cypress studio.

The intermediate value 'none' sneaked into the post-payload.
It's often a good idea to keep the intermediate form state
and the actual payload separate.
Then you can define an explicit mapping between the two representations.
@BacLuc BacLuc requested a review from a team August 2, 2025 21:43
@BacLuc
Copy link
Contributor Author

BacLuc commented Aug 2, 2025

@CodeRabbit review this PR

@coderabbitai
Copy link

coderabbitai bot commented Aug 2, 2025

🧩 Analysis chain

I'll review this PR for you. Let me examine the changes to understand the fix for creating camps without a template.


🏁 Script executed:

#!/bin/bash
# Get the PR details and changed files
gh pr view 7902 --json title,body,files

# Get the diff for this PR
gh pr diff 7902

Length of output: 11323


@BacLuc I'll review this PR that fixes camp creation without a template.

Overview

This is a well-structured fix that addresses the core issue where the intermediate form value 'none' was being sent in the API payload. The solution properly separates form state from the API payload, which is excellent architectural practice.

Strengths

Frontend Architecture

The separation of concerns in CampCreateStep2.vue is excellent:

  • selectedPrototypeValue for form state
  • localCamp.campPrototype for API payload
  • watchEffect for clean mapping between the two
watchEffect(() => {
  if (['other', 'none', null].includes(selectedPrototypeValue.value)) {
    localCamp.campPrototype = null
  } else {
    localCamp.campPrototype = selectedPrototypeValue.value
  }
})

Comprehensive E2E Testing

  • Tests the complete user flow
  • Uses proper data-testid attributes for reliable element selection
  • Verifies the final state correctly
  • Good naming convention with zz- prefix for test ordering

Consistent Data-testid Implementation

All interactive elements now have proper test identifiers, improving testability across the application.

🔍 Minor Observations

Code Quality

The implementation is clean and follows Vue 3 composition API best practices. The reactive state management is appropriate.

Test Structure

The e2e test covers the happy path thoroughly. The date handling using tomorrow and in2Days is a good approach for dynamic test data.

Type Safety

The selectedPrototypeValue initialization with null and the array check ['other', 'none', null] handles all edge cases properly.

Conclusion

This is a solid fix that not only resolves the immediate bug but also improves the overall architecture by properly separating form state from API payloads. The comprehensive e2e test ensures the fix works end-to-end and prevents regression.

The changes are focused, well-implemented, and follow good practices. Great work! 🐰✨

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Aug 2, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added an end-to-end test for creating a new camp without selecting a prototype.
  • Refactor
    • Improved internal state management for camp prototype selection during camp creation for clearer UI and data separation.
  • Tests
    • Added and updated data-testid attributes to various form fields and buttons to enhance testability.
    • Enabled an experimental feature in Cypress end-to-end testing configuration.
  • Style
    • No user-facing visual changes, only testability improvements.

Walkthrough

A new Cypress end-to-end test was added to automate camp creation without a prototype. Multiple frontend components were updated to include data-testid attributes for improved testability. The camp prototype selection logic in the camp creation flow was refactored for clearer state management. Cypress configuration was updated to enable an experimental feature.

Changes

Cohort / File(s) Change Summary
Cypress E2E Test Addition
e2e/specs/zz-createCamp.cy.js
Added a new Cypress test to automate the creation of a camp without selecting a prototype, including login, form filling, prototype selection, and verification steps.
Cypress Configuration
e2e/cypress.config.js
Enabled the experimentalStudio feature in the Cypress configuration under the e2e block.
Testability Attributes in Camp Creation Components
frontend/src/components/campCreate/CampCreateStep1.vue, frontend/src/components/campCreate/CampCreateStep2.vue, frontend/src/components/campAdmin/CreateCampPeriods.vue, frontend/src/views/Camps.vue, frontend/src/components/campAdmin/CampSettings.vue
Added data-testid attributes to form fields, buttons, and date pickers to facilitate end-to-end testing.
Camp Prototype Selection Refactor
frontend/src/components/campCreate/CampCreateStep2.vue
Refactored prototype selection logic by introducing a new reactive variable selectedPrototypeValue and synchronizing it with localCamp.campPrototype using a watcher, updating all relevant template bindings and logic.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Cypress
  participant App (Frontend)
  participant Backend

  User->>Cypress: Trigger test run
  Cypress->>App (Frontend): Automate login as test user
  App (Frontend)->>Backend: Authenticate user
  Backend-->>App (Frontend): Return authentication response
  Cypress->>App (Frontend): Navigate to camps page
  Cypress->>App (Frontend): Click "create camp" button
  Cypress->>App (Frontend): Fill camp details (title, organizer, motto, dates)
  Cypress->>App (Frontend): Proceed to next step
  Cypress->>App (Frontend): Select "Keine Vorlage" (no prototype)
  Cypress->>App (Frontend): Submit camp creation
  App (Frontend)->>Backend: Create camp API call
  Backend-->>App (Frontend): Return camp creation result
  Cypress->>App (Frontend): Verify camp info page and title field
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (8)
frontend/src/components/campAdmin/CampSettings.vue (1)

13-14: Lint error: put each attribute on its own line to satisfy ESLint rules

The CI lint warning points to this exact line. Split the attributes to one-per-line (Vuetify style) to unblock the pipeline.

-        <api-text-field path="title" vee-rules="required|max:32" :disabled="disabled" data-testid="title" />
+        <api-text-field
+          path="title"
+          vee-rules="required|max:32"
+          :disabled="disabled"
+          data-testid="title"
+        />
frontend/src/views/Camps.vue (1)

23-25: Same attribute-per-line rule applies to keep ESLint green

-            <button-add data-testid="create-camp-button" icon="mdi-plus" :to="{ name: 'camps/create' }">
+            <button-add
+              data-testid="create-camp-button"
+              icon="mdi-plus"
+              :to="{ name: 'camps/create' }"
+            >
frontend/src/components/campCreate/CampCreateStep1.vue (3)

12-14: Format attributes to pass lint & keep diff noise low

-              data-testid="create-camp-title-input"
-              required
+              data-testid="create-camp-title-input"
+              required

(The essential part is breaking before data-testid; adjust to project’s prettier / ESLint config.)


15-16: Two more lint violations – break attributes

-            <e-text-field v-model="localCamp.organizer" path="organizer" data-testid="create-camp-organizer" />
+            <e-text-field
+              v-model="localCamp.organizer"
+              path="organizer"
+              data-testid="create-camp-organizer"
+            />

Apply the same pattern to the motto field right below.


28-30: Attribute order: put data-testid after other props & on new line

-            <ButtonContinue v-if="valid" @click="$emit('next-step')" data-testid="create-camp-next-step" />
+            <ButtonContinue
+              v-if="valid"
+              @click="$emit('next-step')"
+              data-testid="create-camp-next-step"
+            />
frontend/src/components/campAdmin/CreateCampPeriods.vue (1)

53-56: Nit: keep attribute layout consistent

-              data-testid="start-date-picker"
-              required
+              data-testid="start-date-picker"
+              required

Do the same for the end-date picker at Line 66.

e2e/specs/zz-createCamp.cy.js (1)

29-29: Fix formatting issue with extra space.

There's an extra space before the selector that should be removed for consistent formatting.

-    cy.get( '.v-select__selections > [data-testid="prototype-select"]').click()
+    cy.get('.v-select__selections > [data-testid="prototype-select"]').click()
frontend/src/components/campCreate/CampCreateStep2.vue (1)

181-181: Fix attribute formatting for better readability.

The ESLint formatter suggests breaking the attributes onto separate lines for better readability and consistency.

-              <ButtonAdd v-if="valid" type="submit" :loading="isSaving" data-testid="create-camp-button">
+              <ButtonAdd
+                v-if="valid"
+                type="submit"
+                :loading="isSaving"
+                data-testid="create-camp-button"
+              >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7228172 and 862d368.

📒 Files selected for processing (7)
  • e2e/cypress.config.js (1 hunks)
  • e2e/specs/zz-createCamp.cy.js (1 hunks)
  • frontend/src/components/campAdmin/CampSettings.vue (1 hunks)
  • frontend/src/components/campAdmin/CreateCampPeriods.vue (2 hunks)
  • frontend/src/components/campCreate/CampCreateStep1.vue (2 hunks)
  • frontend/src/components/campCreate/CampCreateStep2.vue (8 hunks)
  • frontend/src/views/Camps.vue (1 hunks)
🧰 Additional context used
🪛 GitHub Check: Lint: Frontend (ESLint)
frontend/src/components/campAdmin/CampSettings.vue

[failure] 13-13:
Replace ·path="title"·vee-rules="required|max:32"·:disabled="disabled"·data-testid="title" with ⏎··········path="title"⏎··········vee-rules="required|max:32"⏎··········:disabled="disabled"⏎··········data-testid="title"⏎·······

frontend/src/views/Camps.vue

[failure] 23-23:
Replace ·data-testid="create-camp-button"·icon="mdi-plus"·:to="{·name:·'camps/create'·}" with ⏎··············data-testid="create-camp-button"⏎··············icon="mdi-plus"⏎··············:to="{·name:·'camps/create'·}"⏎············

frontend/src/components/campCreate/CampCreateStep1.vue

[failure] 16-16:
Replace ·v-model="localCamp.motto"·path="motto"·data-testid="create-camp-motto" with ⏎··············v-model="localCamp.motto"⏎··············path="motto"⏎··············data-testid="create-camp-motto"⏎···········


[failure] 15-15:
Replace ·v-model="localCamp.organizer"·path="organizer"·data-testid="create-camp-organizer" with ⏎··············v-model="localCamp.organizer"⏎··············path="organizer"⏎··············data-testid="create-camp-organizer"⏎···········


[warning] 28-28:
Attribute "data-testid" should go before "@click"


[failure] 28-28:
Replace ·v-if="valid"·@click="$emit('next-step')"·data-testid="create-camp-next-step" with ⏎··············v-if="valid"⏎··············@click="$emit('next-step')"⏎··············data-testid="create-camp-next-step"⏎···········

frontend/src/components/campCreate/CampCreateStep2.vue

[failure] 181-181:
Replace ·v-if="valid"·type="submit"·:loading="isSaving"·data-testid="create-camp-button" with ⏎················v-if="valid"⏎················type="submit"⏎················:loading="isSaving"⏎················data-testid="create-camp-button"⏎··············

🪛 GitHub Check: Lint: e2e (ESLint)
e2e/specs/zz-createCamp.cy.js

[failure] 29-29:
Delete ·

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Tests: End-to-end run / Tests: End-to-end (firefox)
  • GitHub Check: Tests: End-to-end run / Tests: End-to-end (edge)
  • GitHub Check: Tests: End-to-end run / Tests: End-to-end (chrome)
🔇 Additional comments (15)
e2e/cypress.config.js (1)

14-14: experimentalStudio is deprecated – confirm Cypress version and roadmap

experimentalStudio was removed in Cypress v13.0.0. If the project upgrades, this flag will be ignored and the Studio workflow will disappear.

  1. Pin the Cypress major version or migrate away from Studio-generated specs.
  2. Alternatively, gate this option behind a version check or environment variable.
e2e/specs/zz-createCamp.cy.js (4)

3-7: Good dynamic date handling for test robustness.

Using dynamic date calculation ensures the test remains valid regardless of when it's executed, avoiding failures due to hardcoded past dates.


9-12: Well-structured test with clear naming.

The test structure follows Cypress best practices with descriptive naming that clearly indicates the scenario being tested.


13-28: Comprehensive e2e test flow with reliable element selection.

The test properly covers the complete user journey from login to form submission, using data-testid attributes for stable element targeting and appropriate Swiss date formatting.


30-35: Appropriate test assertions for verification.

The test properly verifies both successful navigation to the camp info page and data persistence by checking the title field value.

frontend/src/components/campCreate/CampCreateStep2.vue (10)

217-217: Good addition of Vue 3 composition API import.

Adding watchEffect import supports the new reactive state management pattern for separating form state from API payload.


241-248: Excellent architectural improvement with clean state separation.

The introduction of selectedPrototypeValue and the watchEffect provides a clean separation between the intermediate form state and the actual API payload. The logic correctly handles the edge cases where 'other', 'none', and null should result in a null prototype in the payload.


10-10: Correct v-model update for separated state management.

The v-model correctly binds to selectedPrototypeValue instead of directly to the API payload, supporting the clean state separation.


18-18: Good addition of data-testid for e2e testing.

The data-testid="prototype-select" attribute enables reliable element selection in the e2e test.


21-21: Consistent template update for separated state.

The conditional correctly uses selectedPrototypeValue instead of the API payload property, maintaining consistency with the architectural changes.


260-260: Consistent state update in clipboard entity handler.

The onEntityLoaded handler correctly updates selectedPrototypeValue instead of directly modifying the API payload, maintaining consistency with the new state management.


264-264: Proper error handling with consistent state management.

The error handler correctly updates selectedPrototypeValue while maintaining the existing logic for handling failed clipboard entity loads.


304-304: Consistent computed property updates for new state management.

The computed properties correctly use selectedPrototypeValue instead of the API payload property, maintaining the same functionality while being consistent with the architectural changes.

Also applies to: 312-312, 320-321


348-348: Correct watcher update for new reactive state.

The watcher properly observes selectedPrototypeValue instead of the API payload property, maintaining the existing UI behavior for the "other" prototype selection.


278-278: Proper exposure of reactive state to template.

Adding selectedPrototypeValue to the return statement makes it available to the template, which is necessary for the v-model binding and computed properties.

Prefix it with zz because it creates a new camp.
Use data-testid attribute to find the elements.

The test was scaffolded with cypress studio.
@BacLuc BacLuc force-pushed the fix-create-camp-without-template branch from 862d368 to 3809981 Compare August 2, 2025 21:50
@simfeld simfeld added the deploy! Creates a feature branch deployment for this PR label Aug 3, 2025
@simfeld simfeld temporarily deployed to feature-branch August 3, 2025 15:53 — with GitHub Actions Inactive
@github-actions
Copy link

github-actions bot commented Aug 3, 2025

Feature branch deployment currently inactive.

If the PR is still open, you can add the deploy! label to this PR to trigger a feature branch deployment.

Copy link
Contributor

@simfeld simfeld left a comment

Choose a reason for hiding this comment

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

works 🙏

@BacLuc BacLuc requested a review from a team August 3, 2025 16:08
@pmattmann pmattmann added this pull request to the merge queue Aug 3, 2025
Merged via the queue into ecamp:devel with commit af3ed5f Aug 3, 2025
36 checks passed
@BacLuc BacLuc deleted the fix-create-camp-without-template branch August 3, 2025 19:17
This was referenced Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy! Creates a feature branch deployment for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants