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,21 +5,29 @@ const authenticatedUser = {
const bibleLayout = {
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: [
{
id: 1,
name: 'Genesis',
kind: 'book',
levelId: 1,
children: [
{
id: 3,
name: 'Creation',
kind: 'portion',
levelId: 2,
children: [
{
id: 4,
name: 'Chapter 1',
kind: 'chapter',
levelId: 3,
children: [],
},
],
@ -30,12 +38,22 @@ const bibleLayout = {
id: 2,
name: 'Exodus',
kind: 'book',
levelId: 1,
children: [
{
id: 5,
name: 'Chapter 1',
kind: 'chapter',
children: [],
name: 'Shemot',
kind: 'portion',
levelId: 2,
children: [
{
id: 6,
name: 'Chapter 1',
kind: 'chapter',
levelId: 3,
children: [],
},
],
},
],
},
@ -73,7 +91,7 @@ const scheduleDetail = {
element: {
name: 'Chapter 1',
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.body).to.deep.equal({
setId: 41,
elementKind: 'chapter',
levelId: 3,
startDate: '2026-08-10',
targetDate: '2026-08-12',
})
@ -121,10 +139,10 @@ describe('set scheduling', () => {
cy.get('h1').should('have.text', 'Schedule Bible')
cy.get('#schedule-level option').then(($options) => {
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-target-date').type('2026-08-12')
cy.get('form').submit()
@ -141,7 +159,7 @@ describe('set scheduling', () => {
.and('not.contain.text', 'Chapter 1')
cy.get('[data-schedule-date="2026-08-12"]').should(
'contain.text',
'Exodus / Chapter 1',
'Exodus / Shemot / Chapter 1',
)
})
@ -168,7 +186,7 @@ describe('set scheduling', () => {
.and('be.visible')
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-target-date').type('2026-08-10')
cy.get('form').submit()