test media set creation

This commit is contained in:
Yisroel Baum 2026-06-26 10:53:30 +03:00
parent 18073f147f
commit b3c6f6af0b
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -1,3 +1,14 @@
function loginAsAdmin(): void {
cy.visit('/login')
cy.get('[data-cy="login-email"]').type('admin@rabbigerzi.test')
cy.get('[data-cy="login-password"]').type('password123!@#')
cy.get('[data-cy="login-submit"]').click()
cy.url().should('eq', Cypress.config().baseUrl + '/')
cy.getCookie('auth_token').should('exist')
}
describe('media page sets', () => {
it('fetches and renders seeded set cards', () => {
const introductionAudioTitle =
@ -163,4 +174,35 @@ describe('media page sets', () => {
.and('include', 'https://www.youtube.com/embed/yHx-r4p6hHU')
.and('include', 'start=1')
})
it('does not show the create set card to logged-out users', () => {
cy.visit('/media')
cy.get('[data-cy="media-create-set-card"]').should('not.exist')
})
it('creates a set from the logged-in media page modal', () => {
loginAsAdmin()
cy.visit('/media')
cy.intercept('POST', /\/api\/sets$/).as('createSet')
cy.get('[data-cy="media-create-set-card"]')
.should('be.visible')
.and('contain.text', 'Create another set')
.click()
cy.get('[data-cy="create-set-modal"]').should('be.visible')
cy.get('[data-cy="create-set-name"]').type('New Cypress Set')
cy.get('[data-cy="create-set-description"]')
.type('Created through the media page modal')
cy.get('[data-cy="create-set-icon"]')
.selectFile('public/assets/baderech-haavodah-icon.png')
cy.get('[data-cy="create-set-submit"]').click()
cy.wait('@createSet')
cy.location('pathname').should('match', /^\/admin\/element\/\d+$/)
cy.get('[data-cy="admin-element-title"]')
.should('have.value', 'New Cypress Set')
cy.get('[data-cy="admin-element-description"]')
.should('have.value', 'Created through the media page modal')
})
})