test explicit scheduling levels

This commit is contained in:
Yisroel Baum 2026-08-11 23:00:11 +03:00
parent 3cf1aff6a9
commit dfca13936a
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
2 changed files with 38 additions and 12 deletions

View file

@ -5,29 +5,37 @@ const authenticatedUser = {
const bibleLayout = { const bibleLayout = {
set: { id: 41, name: 'Bible' }, set: { id: 41, name: 'Bible' },
levels: [
{ id: 1, kind: 'book', depth: 0, elementCount: 2 },
{ id: 2, kind: 'portion', depth: 1, elementCount: 2 },
{ id: 3, kind: 'chapter', depth: 2, elementCount: 1 },
],
elements: [ elements: [
{ {
id: 1, id: 1,
name: 'Genesis', name: 'Genesis',
kind: 'book', kind: 'book',
levelId: 1,
children: [ children: [
{ {
id: 3, id: 3,
name: 'Creation', name: 'Creation',
kind: 'portion', kind: 'portion',
levelId: 2,
children: [ children: [
{ {
id: 4, id: 4,
name: 'Chapter 1', name: 'Chapter 1',
kind: 'chapter', kind: 'chapter',
levelId: 3,
children: [], children: [],
}, },
], ],
}, },
{ id: 5, name: 'Noah', kind: 'portion', children: [] }, { id: 5, name: 'Noah', kind: 'portion', levelId: 2, children: [] },
], ],
}, },
{ id: 2, name: 'Exodus', kind: 'book', children: [] }, { id: 2, name: 'Exodus', kind: 'book', levelId: 1, children: [] },
], ],
} }
@ -89,7 +97,7 @@ describe('set element layout', () => {
cy.intercept('GET', '**/api/sets/41', { cy.intercept('GET', '**/api/sets/41', {
delay: 500, delay: 500,
statusCode: 200, statusCode: 200,
body: { set: { id: 41, name: 'Empty set' }, elements: [] }, body: { set: { id: 41, name: 'Empty set' }, levels: [], elements: [] },
}).as('layout') }).as('layout')
cy.visit('/sets/41') cy.visit('/sets/41')

View file

@ -5,21 +5,29 @@ const authenticatedUser = {
const bibleLayout = { const bibleLayout = {
set: { id: 41, name: 'Bible' }, set: { id: 41, name: 'Bible' },
levels: [
{ id: 1, kind: 'book', depth: 0, elementCount: 2 },
{ id: 2, kind: 'portion', depth: 1, elementCount: 2 },
{ id: 3, kind: 'chapter', depth: 2, elementCount: 2 },
],
elements: [ elements: [
{ {
id: 1, id: 1,
name: 'Genesis', name: 'Genesis',
kind: 'book', kind: 'book',
levelId: 1,
children: [ children: [
{ {
id: 3, id: 3,
name: 'Creation', name: 'Creation',
kind: 'portion', kind: 'portion',
levelId: 2,
children: [ children: [
{ {
id: 4, id: 4,
name: 'Chapter 1', name: 'Chapter 1',
kind: 'chapter', kind: 'chapter',
levelId: 3,
children: [], children: [],
}, },
], ],
@ -30,12 +38,22 @@ const bibleLayout = {
id: 2, id: 2,
name: 'Exodus', name: 'Exodus',
kind: 'book', kind: 'book',
levelId: 1,
children: [ children: [
{ {
id: 5, id: 5,
name: 'Chapter 1', name: 'Shemot',
kind: 'chapter', kind: 'portion',
children: [], levelId: 2,
children: [
{
id: 6,
name: 'Chapter 1',
kind: 'chapter',
levelId: 3,
children: [],
},
],
}, },
], ],
}, },
@ -73,7 +91,7 @@ const scheduleDetail = {
element: { element: {
name: 'Chapter 1', name: 'Chapter 1',
kind: 'chapter', kind: 'chapter',
path: ['Exodus', 'Chapter 1'], path: ['Exodus', 'Shemot', 'Chapter 1'],
}, },
}, },
], ],
@ -103,7 +121,7 @@ describe('set scheduling', () => {
expect(request.headers.accept).to.equal('application/json') expect(request.headers.accept).to.equal('application/json')
expect(request.body).to.deep.equal({ expect(request.body).to.deep.equal({
setId: 41, setId: 41,
elementKind: 'chapter', levelId: 3,
startDate: '2026-08-10', startDate: '2026-08-10',
targetDate: '2026-08-12', targetDate: '2026-08-12',
}) })
@ -121,10 +139,10 @@ describe('set scheduling', () => {
cy.get('h1').should('have.text', 'Schedule Bible') cy.get('h1').should('have.text', 'Schedule Bible')
cy.get('#schedule-level option').then(($options) => { cy.get('#schedule-level option').then(($options) => {
expect([...$options].map((option) => option.textContent?.trim())).to.deep.equal( expect([...$options].map((option) => option.textContent?.trim())).to.deep.equal(
['Choose a level', 'Book (2)', 'Portion (1)', 'Chapter (2)'], ['Choose a level', 'Book (2)', 'Portion (2)', 'Chapter (2)'],
) )
}) })
cy.get('#schedule-level').select('chapter') cy.get('#schedule-level').select('3')
cy.get('#schedule-start-date').type('2026-08-10') cy.get('#schedule-start-date').type('2026-08-10')
cy.get('#schedule-target-date').type('2026-08-12') cy.get('#schedule-target-date').type('2026-08-12')
cy.get('form').submit() cy.get('form').submit()
@ -141,7 +159,7 @@ describe('set scheduling', () => {
.and('not.contain.text', 'Chapter 1') .and('not.contain.text', 'Chapter 1')
cy.get('[data-schedule-date="2026-08-12"]').should( cy.get('[data-schedule-date="2026-08-12"]').should(
'contain.text', 'contain.text',
'Exodus / Chapter 1', 'Exodus / Shemot / Chapter 1',
) )
}) })
@ -168,7 +186,7 @@ describe('set scheduling', () => {
.and('be.visible') .and('be.visible')
cy.get('@createSchedule.all').should('have.length', 0) cy.get('@createSchedule.all').should('have.length', 0)
cy.get('#schedule-level').select('chapter') cy.get('#schedule-level').select('3')
cy.get('#schedule-start-date').type('2026-08-12') cy.get('#schedule-start-date').type('2026-08-12')
cy.get('#schedule-target-date').type('2026-08-10') cy.get('#schedule-target-date').type('2026-08-10')
cy.get('form').submit() cy.get('form').submit()