diff --git a/spec/cypress/e2e/annotations_overview_spec.cy.js b/spec/cypress/e2e/annotations_overview_spec.cy.js new file mode 100644 index 000000000..4528610c3 --- /dev/null +++ b/spec/cypress/e2e/annotations_overview_spec.cy.js @@ -0,0 +1,29 @@ +import FactoryBot from "../support/factorybot"; + +describe("Annotations Overview", () => { + describe("Generic user", () => { + beforeEach(function () { + cy.createUser("teacher"); + cy.createUser("admin"); + cy.createUserAndLogin("generic").as("genericUser"); + + cy.then(() => { + FactoryBot.createNoValidate("lesson_medium", "with_video", "released").then((medium) => { + FactoryBot.create("annotation", "with_text", + { medium_id: medium.id, user_id: this.genericUser.id }); + FactoryBot.create("annotation", "with_text", + { medium_id: medium.id, user_id: this.genericUser.id }); + }); + + FactoryBot.createNoValidate("lesson_medium", "with_video", "released").then((medium) => { + FactoryBot.create("annotation", "with_text", + { medium_id: medium.id, user_id: this.genericUser.id }); + }); + }); + }); + + it("can view own annotations", function () { + cy.visit("/annotations/overview"); + }); + }); +}); diff --git a/spec/factories/annotations.rb b/spec/factories/annotations.rb new file mode 100644 index 000000000..6298cda0c --- /dev/null +++ b/spec/factories/annotations.rb @@ -0,0 +1,29 @@ +FactoryBot.define do + factory :annotation do + medium_id { |id| id } + user_id { |id| id } + + transient do + annotation_time do + # Pick a random number such that the annotation is still within the length + # of the sample video (which is around 42s seconds long) + seconds = nil + while seconds.nil? || seconds.to_f > 40.00 + seconds = Faker::Number.decimal(l_digits: 2, r_digits: 2) + end + seconds + end + end + + timestamp do + build(:time_stamp, total_seconds: annotation_time) + end + + color { Annotation.colors.values.sample } + category { Annotation.categories.keys.sample } + + trait :with_text do + comment { Faker::Lorem.sentence } + end + end +end