From cbf46619be99c8dc4c5d3bdd3bf6492d5370e9d1 Mon Sep 17 00:00:00 2001 From: fosterfarrell9 <28628554+fosterfarrell9@users.noreply.github.com> Date: Tue, 20 Aug 2024 20:53:13 +0200 Subject: [PATCH] Add cypress test for lecture edit page --- app/views/lectures/edit/_form.html.erb | 1 + spec/cypress/e2e/lecture_spec.cy.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 spec/cypress/e2e/lecture_spec.cy.js diff --git a/app/views/lectures/edit/_form.html.erb b/app/views/lectures/edit/_form.html.erb index 5060e5b82..00e2608c3 100644 --- a/app/views/lectures/edit/_form.html.erb +++ b/app/views/lectures/edit/_form.html.erb @@ -15,6 +15,7 @@ id="lecture-nav-content" type="button" role="tab" href="#content" data-bs-toggle="pill" data-bs-target="#lecture-pane-content" + data-cy="content-tab-btn" aria-controls="lecture-pane-content" aria-selected="true"> <%= t('content') %> diff --git a/spec/cypress/e2e/lecture_spec.cy.js b/spec/cypress/e2e/lecture_spec.cy.js new file mode 100644 index 000000000..635db144a --- /dev/null +++ b/spec/cypress/e2e/lecture_spec.cy.js @@ -0,0 +1,17 @@ +import FactoryBot from "../support/factorybot"; + +describe("Lecture edit page", () => { + it("shows content tab button", function () { + cy.createUserAndLogin("teacher").as("teacher"); + + cy.then(() => { + FactoryBot.create("lecture", "with_teacher_by_id", + { teacher_id: this.teacher.id }).as("lecture"); + }); + + cy.then(() => { + cy.visit(`/lectures/${this.lecture.id}/edit`); + cy.getBySelector("content-tab-btn").should("be.visible"); + }); + }); +});