Skip to content

Commit 5941a17

Browse files
committed
[wip] work toward contennt-authoring e2e tests
1 parent 8bbf438 commit 5941a17

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// platform-ui/cypress/e2e/add-content.cy.js
2+
describe('Content Authoring', () => {
3+
let username;
4+
const courseName = `Content Test Course ${Math.floor(Math.random() * 10000)}`;
5+
const courseDescription = 'This course is for testing content creation functionality';
6+
7+
Cypress.on('uncaught:exception', (err, runnable) => {
8+
// returning false here prevents Cypress from
9+
// failing the test
10+
return false;
11+
});
12+
13+
it('should allow a user to create and navigate to a course for adding content', () => {
14+
// Register a new user
15+
cy.registerUser().then((user) => {
16+
username = user;
17+
// Wait for registration to complete and redirect
18+
cy.url().should('include', `/u/${username}/new`);
19+
20+
// Navigate to the quilts (courses) page
21+
cy.visit('/quilts');
22+
23+
// Create a new course
24+
cy.get('[data-cy="create-course-fab"]').click();
25+
cy.get('[data-cy="course-name-input"]').type(courseName);
26+
cy.get('[data-cy="course-description-input"]').type(courseDescription);
27+
cy.get('[data-cy="private-radio"]').click(); // Create as private course initially
28+
cy.get('[data-cy="save-course-button"]').click();
29+
30+
// Wait for creation to complete and dialog to close
31+
cy.wait(1000);
32+
33+
cy.visit(`/quilts/${courseName.replaceAll(' ', '_')}`);
34+
35+
// Register via `register` button, then wait
36+
cy.get('[data-cy="register-btn"]').click();
37+
cy.wait(1000);
38+
39+
// click `add content` button
40+
cy.get('[data-cy="add-content-btn"]').click();
41+
cy.wait(1000);
42+
43+
cy.get('[data-cy="markdown-input"] textarea')
44+
.should('be.visible')
45+
.type('This {{ is || is not }} a question.', {
46+
parseSpecialCharSequences: false,
47+
});
48+
cy.get('[data-cy="add-card-btn"').click();
49+
});
50+
});
51+
});

packages/platform-ui/src/components/Courses/CourseInformation.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<v-btn color="success">Start a study session</v-btn>
1313
</router-link>
1414
<router-link :to="`/edit/${courseId}`" class="me-2">
15-
<v-btn color="indigo-lighten-1">
15+
<v-btn data-cy="add-content-btn" color="indigo-lighten-1">
1616
<v-icon start>mdi-plus</v-icon>
1717
Add content
1818
</v-btn>
@@ -26,7 +26,7 @@
2626
<v-btn color="error" size="small" variant="outlined" @click="drop"> Drop this course </v-btn>
2727
</div>
2828
<div v-else>
29-
<v-btn color="primary" class="me-2" @click="register">Register</v-btn>
29+
<v-btn data-cy="register-btn" color="primary" class="me-2" @click="register">Register</v-btn>
3030
<router-link :to="`/q/${courseId}/preview`">
3131
<v-btn variant="outlined" color="primary" class="me-2">Start a trial study session</v-btn>
3232
</router-link>

packages/platform-ui/src/components/Edit/ViewableDataInputForm/DataInputForm.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
:ref="(el: FieldInputInstance) => setFieldInputRef(el, i)"
4040
:field="field"
4141
:autofocus="i == 0"
42+
data-cy="markdown-input"
4243
/>
4344
<midi-input
4445
v-else-if="field.type === midi"
@@ -57,6 +58,7 @@
5758
<tags-input ref="tagsInput" :hide-submit="true" :course-i-d="courseCfg.courseID" card-i-d="" />
5859
<v-btn
5960
v-if="!previewComponent"
61+
data-cy="add-card-btn"
6062
class="float-right"
6163
type="submit"
6264
color="primary"

0 commit comments

Comments
 (0)