Skip to content

Commit

Permalink
test display of all groups and classes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap committed Oct 20, 2023
1 parent b5b3677 commit 51dc4e6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 41 deletions.
7 changes: 4 additions & 3 deletions cypress/e2e/group/showGroupsAndClassesInTable.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ Feature: Group - To show groups and classes in one table with respective functio
Scenario: As a teacher i can see all classes and groups of my school on the new class administration page.
Given I see the new class administration page
Then I can see the page title
And I can see at least 1 class and 1 group in the table
And the group does not have any action icons
And the class has 4 enabled action icons
And I can see the group 'TestSchulklasse' with source 'moin.schule'
And I can see the class '1' without source
And the group 'TestSchulklasse' does not have any action items
And the class '1' has 4 enabled action items

@stable_test
Scenario: As a teacher i can manage my classes
Expand Down
39 changes: 15 additions & 24 deletions cypress/support/pages/group/pageGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,30 @@ class Groups {
cy.get(Groups.#classTitleNew).should('exist')
}

newClassTableContainsClassesAndGroups() {
cy.get(Groups.#classTableNew)
.find('tbody td:nth-child(2)')
.each(($td) => {
const text = $td.text().trim();
if (text === '' || text === 'moin.schule') {
cy.wrap($td).should('be.visible');
}
newClassTableContainsClass(className, sourceName) {
const classNameData = cy.get(Groups.#classTableNew).find('td').contains(className);

classNameData.should('be.visible');
classNameData.siblings('td').eq(0).should(($td) => {
expect($td.text().trim()).to.equal(sourceName);
});
}

groupsHaveNoActionItems(groupName) {
const classNameData = cy.get(Groups.#classTableNew).find('td').contains(groupName);

groupsHaveNoActionIcons() {
const entries = document.querySelector('[data-testid="admin-class-table"]').firstChild.firstChild.querySelector('tbody').children
const group = entries.filter((entry) => entry.children[1].innerText === "moin.schule")

expect(group.children[3].children.length).to.equal(0)
classNameData.siblings('td').eq(2).should('be.empty');
}

classesHave4ActiveActionIcons() {
const entries = document.querySelector('[data-testid="admin-class-table"]').firstChild.firstChild.querySelector('tbody').children
const clazz = entries.filter((entry) => entry.children[1].innerText === "")
const actionIcons = clazz.children[3].children
classesHave4ActiveActionItems(className) {
const classNameData = cy.get(Groups.#classTableNew).find('td').contains(className);

expect(actionIcons.length).to.equal(4)
const buttons = classNameData.siblings('td').eq(2).find('a, button');

let activeIcons = 0
actionIcons.forEach((icon) => {
if (icon.attributes.disabled === false) {
activeIcons = activeIcons + 1
}
buttons.should('have.length', 4);
buttons.each(($btn) => {
cy.wrap($btn).should('not.be.disabled');
})
expect(activeIcons).to.equal(4)
}
}

Expand Down
32 changes: 18 additions & 14 deletions cypress/support/step_definition/group/commonGroupSteps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,45 @@ import Groups from '../../pages/group/pageGroups'
import Management from '../../pages/admin/pageAdministration';


const groups = new Groups()
const management = new Management()
const groups = new Groups();
const management = new Management();

When('I go to class administration', () => {
management.navigateToClassAdministration()
management.navigateToClassAdministration();
})

When('I click on add class', () => {
groups.clickCreateClass()
groups.clickCreateClass();
})

When('I click on the confirm button', () => {
groups.clickConfirmCreateClass()
groups.clickConfirmCreateClass();
})

When('I confirm managing the class', () => {
groups.clickConfirmManageClass()
groups.clickConfirmManageClass();
})

Then('I see the new class administration page', () => {
groups.isNewClassAdministrationPage()
groups.isNewClassAdministrationPage();
})

Then('I can see the page title', () => {
groups.seeNewClassPageTitle()
groups.seeNewClassPageTitle();
})

Then('I can see at least 1 class and 1 group in the table', () => {
groups.newClassTableContainsClassesAndGroups()
Then('I can see the group {string} with source {string}', (groupName, systemName) => {
groups.newClassTableContainsClass(groupName, systemName);
})

Then('the group does not have any action icons', () => {
groups.groupsHaveNoActionIcons()
Then('I can see the class {string} without source', (className) => {
groups.newClassTableContainsClass(className, "");
})

Then('the class has 4 enabled action icons', () => {
groups.classesHave4ActiveActionIcons()
Then('the group {string} does not have any action items', (groupName) => {
groups.groupsHaveNoActionItems(groupName);
})

Then('the class {string} has 4 enabled action items', (className) => {
groups.classesHave4ActiveActionItems(className);
})

0 comments on commit 51dc4e6

Please sign in to comment.