|
| 1 | +describe("Batch Creation", () => { |
| 2 | + it("creates a new batch", () => { |
| 3 | + cy.login(); |
| 4 | + cy.wait(500); |
| 5 | + cy.visit("/lms/batches"); |
| 6 | + cy.closeOnboardingModal(); |
| 7 | + |
| 8 | + // Open Settings |
| 9 | + cy.get("span").contains("Learning").click(); |
| 10 | + cy.get("span").contains("Settings").click(); |
| 11 | + |
| 12 | + // Add a new member |
| 13 | + cy.get('[id^="headlessui-dialog-panel-v-"]') |
| 14 | + .find("span") |
| 15 | + .contains(/^Members$/) |
| 16 | + .click(); |
| 17 | + cy.get('[id^="headlessui-dialog-panel-v-"]') |
| 18 | + .find("button") |
| 19 | + .contains("New") |
| 20 | + .click(); |
| 21 | + |
| 22 | + const dateNow = Date.now(); |
| 23 | + const randomEmail = `testuser_${dateNow}@example.com`; |
| 24 | + const randomName = `Test User ${dateNow}`; |
| 25 | + |
| 26 | + cy.get("input[placeholder='Email']").type(randomEmail); |
| 27 | + cy.get("input[placeholder='First Name']").type(randomName); |
| 28 | + cy.get("button").contains("Add").click(); |
| 29 | + |
| 30 | + // Add evaluator |
| 31 | + cy.get('[id^="headlessui-dialog-panel-v-"]') |
| 32 | + .find("span") |
| 33 | + .contains(/^Evaluators$/) |
| 34 | + .click(); |
| 35 | + |
| 36 | + cy.get('[id^="headlessui-dialog-panel-v-"]') |
| 37 | + .find("button") |
| 38 | + .contains("New") |
| 39 | + .click(); |
| 40 | + const randomEvaluator = `evaluator${dateNow}@example.com`; |
| 41 | + |
| 42 | + cy.get("input[placeholder='Email']").type(randomEvaluator); |
| 43 | + cy.get("button").contains("Add").click(); |
| 44 | + cy.get("div").contains(randomEvaluator).should("be.visible").click(); |
| 45 | + |
| 46 | + cy.visit("/lms/batches"); |
| 47 | + cy.closeOnboardingModal(); |
| 48 | + |
| 49 | + // Create a batch |
| 50 | + cy.get("button").contains("New").click(); |
| 51 | + cy.wait(500); |
| 52 | + cy.url().should("include", "/batches/new/edit"); |
| 53 | + cy.get("label").contains("Title").type("Test Batch"); |
| 54 | + |
| 55 | + cy.get("label").contains("Start Date").type("2030-10-01"); |
| 56 | + cy.get("label").contains("End Date").type("2030-10-31"); |
| 57 | + cy.get("label").contains("Start Time").type("10:00"); |
| 58 | + cy.get("label").contains("End Time").type("11:00"); |
| 59 | + cy.get("label").contains("Timezone").type("IST"); |
| 60 | + cy.get("label").contains("Seat Count").type("10"); |
| 61 | + cy.get("label").contains("Published").click(); |
| 62 | + |
| 63 | + cy.get("label") |
| 64 | + .contains("Short Description") |
| 65 | + .type("Test Batch Short Description to test the UI"); |
| 66 | + cy.get("div[contenteditable=true").invoke( |
| 67 | + "text", |
| 68 | + "Test Batch Description. I need a very big description to test the UI. This is a very big description. It contains more than once sentence. Its meant to be this long as this is a UI test. Its unbearably long and I'm not sure why I'm typing this much. I'm just going to keep typing until I feel like its long enough. I think its long enough now. I'm going to stop typing now." |
| 69 | + ); |
| 70 | + |
| 71 | + /* Instructor */ |
| 72 | + cy.get("label") |
| 73 | + .contains("Instructors") |
| 74 | + .parent() |
| 75 | + .within(() => { |
| 76 | + cy.get("input").click().type("evaluator"); |
| 77 | + cy.get("input") |
| 78 | + .invoke("attr", "aria-controls") |
| 79 | + .as("instructor_list_id"); |
| 80 | + }); |
| 81 | + cy.get("@instructor_list_id").then((instructor_list_id) => { |
| 82 | + cy.get(`[id^=${instructor_list_id}`) |
| 83 | + .should("be.visible") |
| 84 | + .within(() => { |
| 85 | + cy.get("[id^=headlessui-combobox-option-").first().click(); |
| 86 | + }); |
| 87 | + }); |
| 88 | + |
| 89 | + cy.button("Save").click(); |
| 90 | + cy.wait(1000); |
| 91 | + let batchName; |
| 92 | + cy.url().then((url) => { |
| 93 | + console.log(url); |
| 94 | + batchName = url.split("/").pop(); |
| 95 | + cy.wrap(batchName).as("batchName"); |
| 96 | + }); |
| 97 | + cy.wait(500); |
| 98 | + |
| 99 | + // View Batch |
| 100 | + cy.wait(1000); |
| 101 | + cy.visit("/lms/batches"); |
| 102 | + cy.closeOnboardingModal(); |
| 103 | + |
| 104 | + cy.url().should("include", "/lms/batches"); |
| 105 | + |
| 106 | + cy.get('[id^="headlessui-radiogroup-v-"]') |
| 107 | + .find("span") |
| 108 | + .contains("Upcoming") |
| 109 | + .should("be.visible") |
| 110 | + .click(); |
| 111 | + |
| 112 | + cy.get("@batchName").then((batchName) => { |
| 113 | + cy.get(`a[href='/lms/batches/details/${batchName}'`).within(() => { |
| 114 | + cy.get("div").contains("Test Batch").should("be.visible"); |
| 115 | + cy.get("div") |
| 116 | + .contains("Test Batch Short Description to test the UI") |
| 117 | + .should("be.visible"); |
| 118 | + cy.get("span") |
| 119 | + .contains("01 Oct 2030 - 31 Oct 2030") |
| 120 | + .should("be.visible"); |
| 121 | + cy.get("span") |
| 122 | + .contains("10:00 AM - 11:00 AM") |
| 123 | + .should("be.visible"); |
| 124 | + cy.get("span").contains("IST").should("be.visible"); |
| 125 | + cy.get("a").contains("Evaluator").should("be.visible"); |
| 126 | + cy.get("div") |
| 127 | + .contains("10") |
| 128 | + .should("be.visible") |
| 129 | + .get("span") |
| 130 | + .contains("Seats Left") |
| 131 | + .should("be.visible"); |
| 132 | + }); |
| 133 | + cy.get(`a[href='/lms/batches/details/${batchName}'`).click(); |
| 134 | + }); |
| 135 | + |
| 136 | + cy.get("div").contains("Test Batch").should("be.visible"); |
| 137 | + cy.get("div") |
| 138 | + .contains("Test Batch Short Description to test the UI") |
| 139 | + .should("be.visible"); |
| 140 | + cy.get("a").contains("Evaluator").should("be.visible"); |
| 141 | + cy.get("span") |
| 142 | + .contains("01 Oct 2030 - 31 Oct 2030") |
| 143 | + .should("be.visible"); |
| 144 | + cy.get("span").contains("10:00 AM - 11:00 AM").should("be.visible"); |
| 145 | + cy.get("span").contains("IST").should("be.visible"); |
| 146 | + cy.get("div") |
| 147 | + .contains("10") |
| 148 | + .should("be.visible") |
| 149 | + .get("span") |
| 150 | + .contains("Seats Left") |
| 151 | + .should("be.visible"); |
| 152 | + |
| 153 | + cy.get("p") |
| 154 | + .contains( |
| 155 | + "Test Batch Description. I need a very big description to test the UI. This is a very big description. It contains more than once sentence. Its meant to be this long as this is a UI test. Its unbearably long and I'm not sure why I'm typing this much. I'm just going to keep typing until I feel like its long enough. I think its long enough now. I'm going to stop typing now." |
| 156 | + ) |
| 157 | + .should("be.visible"); |
| 158 | + cy.get("button").contains("Manage Batch").click(); |
| 159 | + |
| 160 | + /* Add student to batch */ |
| 161 | + cy.get("button").contains("Add").click(); |
| 162 | + cy.get('div[id^="headlessui-dialog-panel-v-"]') |
| 163 | + .first() |
| 164 | + .find("button") |
| 165 | + .eq(1) |
| 166 | + .click(); |
| 167 | + cy.get("input[id^='headlessui-combobox-input-v-']").type(randomEmail); |
| 168 | + cy.get("div").contains(randomEmail).click(); |
| 169 | + cy.get("button").contains("Submit").click(); |
| 170 | + |
| 171 | + // Verify Seat Count |
| 172 | + cy.get("span").contains("Details").click(); |
| 173 | + cy.get("div") |
| 174 | + .contains("9") |
| 175 | + .should("be.visible") |
| 176 | + .get("span") |
| 177 | + .contains("Seats Left") |
| 178 | + .should("be.visible"); |
| 179 | + }); |
| 180 | +}); |
0 commit comments