Skip to content

Commit

Permalink
feat: testing the submission of lesson builds
Browse files Browse the repository at this point in the history
  • Loading branch information
viniblack committed Nov 18, 2024
1 parent a634970 commit e348057
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
70 changes: 70 additions & 0 deletions cypress/e2e/courses/lesson.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const { faker } = require('@faker-js/faker')

describe('Course Workflow', () => {
const email = faker.internet.email()
const password = faker.internet.password()

beforeEach(() => {
cy.clearCookies()
cy.clearLocalStorage()
})

const login = () => {
cy.visit('http://localhost:3000/')
cy.get('#login').click()
cy.get('.mt-3 > .cursor-pointer').click()
cy.get('#email').type(email)
cy.get('#password').type(password)
cy.get('.mt-8 > .w-full').click()
}

const navigateToCourse = () => {
cy.get('[href="/courses"] > .nextui-c-iWjDFM').click()
cy.get('#Rust_State_Machine > .nextui-c-kzikkm > .nextui-c-iWjDFM').click()
}

const accessLesson = () => {
cy.get('#signup-cohort').click()
cy.get(':nth-child(1) > .mt-4 > :nth-child(1) > :nth-child(1) > #access-lesson > .m-0').click()
}

const submitLesson = ({ text, filePath }) => {
cy.get('#submit-lesson > .nextui-button-text').click()

if (filePath) {
cy.get('#load-file').selectFile(filePath)
cy.get('#upload-file').click()
} else if (text) {
cy.get('.mt-2 > .z-10').type(text)
cy.get('#modal-send-lesson').click()
}
}

const validateModalContent = (expectedText) => {
cy.get('.min-h-screen .pt-5').should('contain', expectedText)
}

const nextLesson = () => {
cy.wait(4000)
cy.get('.nextui-c-iWjDFM-wUUIG-color-secondary').click()
}

it('Completes the course workflow', () => {
const submissonText = faker.lorem.sentences(2, '\n')
login()
navigateToCourse()
accessLesson()

// Submeter texto
submitLesson({ text: submissonText })
nextLesson()

// Submeter arquivo
submitLesson({ filePath: 'public/assets/img/screenshot-home-build.png' })
validateModalContent(
'Networking is everything, how about sharing your progress with your friends on Twitter?'
)
cy.get('#modal-cancel-button').click()
nextLesson()
})
})
Binary file added public/assets/img/screenshot-home-build.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions seed-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
{
"twitter": "Acabei de começar a aprender Rust com @web3dev_ - junte-se a mim em https://build.w3d.community/",
"file": "Lesson_2_Requirements.md",
"submission_type": "text",
"submission_type": "upload",
"submission_text": "Você instalou o software necessário?",
"title": "Lição 2: Requisitos",
"submission_title": "Requisitos Instalados!"
Expand Down Expand Up @@ -616,7 +616,7 @@
{
"twitter": "I just started to learn Rust with @web3dev_ - join me at https://build.w3d.community/",
"file": "Lesson_2_Requirements.md",
"submission_type": "text",
"submission_type": "upload",
"submission_text": "Have you installed the required software?",
"title": "Lesson 2: Requirements",
"submission_title": "Requirements Installed!"
Expand Down
1 change: 1 addition & 0 deletions storage.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth == null || request.auth.token.email_verified == false;
allow read, write: if request.auth != null && request.auth.token.email == '[email protected]';
}
}
Expand Down

0 comments on commit e348057

Please sign in to comment.