fix: use file name in cypress tests

This commit is contained in:
Livio Bieri 2023-09-28 09:43:03 +02:00
parent dbe74f754b
commit d646454ae9
2 changed files with 102 additions and 102 deletions

View File

@ -1,84 +1,84 @@
import {checkNavigationLink, EXPERT_LOGIN, login, PARTICIPANT_LOGIN, visitCoursePage} from "./helpers"; import {checkNavigationLink, EXPERT_LOGIN, login, PARTICIPANT_LOGIN, visitCoursePage} from "./helpers";
const openMobileNavigation = () => { const openMobileNavigation = () => {
cy.get('[data-cy="navigation-mobile-menu-button"]').click(); cy.get('[data-cy="navigation-mobile-menu-button"]').click();
} }
describe("Navigation tests", () => { describe("navigation.cy.js", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset");
});
describe("Desktop view", () => {
beforeEach(() => { beforeEach(() => {
cy.manageCommand("cypress_reset"); cy.viewport(1280, 720);
}); });
describe("Desktop view", () => { describe("Expert / Trainer", () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1280, 720); login(...EXPERT_LOGIN);
}); visitCoursePage("cockpit");
});
describe("Expert / Trainer", () => { it("should have correct expert navigation", () => {
beforeEach(() => { checkNavigationLink("navigation-cockpit-link", "cockpit");
login(...EXPERT_LOGIN); checkNavigationLink("navigation-preview-link", "learn");
visitCoursePage("cockpit");
});
it("should have correct expert navigation", () => { cy.get('[data-cy="navigation-competence-profile-link"]').should("not.exist");
checkNavigationLink("navigation-cockpit-link", "cockpit"); cy.get('[data-cy="navigation-learning-path-link"]').should("not.exist");
checkNavigationLink("navigation-preview-link", "learn"); });
cy.get('[data-cy="navigation-competence-profile-link"]').should("not.exist");
cy.get('[data-cy="navigation-learning-path-link"]').should("not.exist");
});
});
describe("Participant", () => {
beforeEach(() => {
login(...PARTICIPANT_LOGIN);
visitCoursePage("learn");
});
it("should have correct navigation", () => {
checkNavigationLink("navigation-competence-profile-link", "competence");
checkNavigationLink("navigation-learning-path-link", "learn");
cy.get('[data-cy="navigation-cockpit-link"]').should("not.exist");
cy.get('[data-cy="navigation-preview-link"]').should("not.exist");
});
});
}); });
describe("Mobile view", () => { describe("Participant", () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(375, 667); login(...PARTICIPANT_LOGIN);
}); visitCoursePage("learn");
});
describe("Expert / Trainer", () => { it("should have correct navigation", () => {
beforeEach(() => { checkNavigationLink("navigation-competence-profile-link", "competence");
login(...EXPERT_LOGIN); checkNavigationLink("navigation-learning-path-link", "learn");
visitCoursePage("cockpit");
openMobileNavigation();
});
it("should have correct expert navigation", () => { cy.get('[data-cy="navigation-cockpit-link"]').should("not.exist");
cy.get('[data-cy="navigation-mobile-cockpit-link"]').should("exist"); cy.get('[data-cy="navigation-preview-link"]').should("not.exist");
cy.get('[data-cy="navigation-mobile-preview-link"]').should("exist"); });
cy.get('[data-cy="navigation-mobile-competence-profile-link"]').should("not.exist"); });
cy.get('[data-cy="navigation-mobile-learning-path-link"]').should("not.exist"); });
})
})
describe("Participant", () => { describe("Mobile view", () => {
beforeEach(() => { beforeEach(() => {
login(...PARTICIPANT_LOGIN); cy.viewport(375, 667);
visitCoursePage("learn"); });
openMobileNavigation();
});
it("should have correct navigation", () => { describe("Expert / Trainer", () => {
cy.get('[data-cy="navigation-mobile-cockpit-link"]').should("not.exist"); beforeEach(() => {
cy.get('[data-cy="navigation-mobile-preview-link"]').should("not.exist"); login(...EXPERT_LOGIN);
cy.get('[data-cy="navigation-mobile-competence-profile-link"]').should("exist"); visitCoursePage("cockpit");
cy.get('[data-cy="navigation-mobile-learning-path-link"]').should("exist"); openMobileNavigation();
}); });
});
it("should have correct expert navigation", () => {
cy.get('[data-cy="navigation-mobile-cockpit-link"]').should("exist");
cy.get('[data-cy="navigation-mobile-preview-link"]').should("exist");
cy.get('[data-cy="navigation-mobile-competence-profile-link"]').should("not.exist");
cy.get('[data-cy="navigation-mobile-learning-path-link"]').should("not.exist");
})
}) })
describe("Participant", () => {
beforeEach(() => {
login(...PARTICIPANT_LOGIN);
visitCoursePage("learn");
openMobileNavigation();
});
it("should have correct navigation", () => {
cy.get('[data-cy="navigation-mobile-cockpit-link"]').should("not.exist");
cy.get('[data-cy="navigation-mobile-preview-link"]').should("not.exist");
cy.get('[data-cy="navigation-mobile-competence-profile-link"]').should("exist");
cy.get('[data-cy="navigation-mobile-learning-path-link"]').should("exist");
});
});
})
}); });

View File

@ -1,45 +1,45 @@
import {checkNavigationLink, login, PARTICIPANT_LOGIN, visitCoursePage} from "./helpers"; import {checkNavigationLink, login, PARTICIPANT_LOGIN, visitCoursePage} from "./helpers";
describe("Preview Bar", () => { describe("preview.cy.js", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset");
})
describe("Expert / Trainer", () => {
beforeEach(() => { beforeEach(() => {
cy.manageCommand("cypress_reset"); login("test-trainer1@example.com", "test");
})
describe("Expert / Trainer", () => {
beforeEach(() => {
login("test-trainer1@example.com", "test");
});
it("should show course preview on learn", () => {
visitCoursePage("learn");
cy.get('[data-cy="course-preview-bar"]').should("exist");
});
it("should show course preview on competence", () => {
visitCoursePage("competence");
cy.get('[data-cy="course-preview-bar"]').should("exist");
});
it("should have correct course preview navigation", () => {
visitCoursePage("learn");
checkNavigationLink("preview-learn-path-link", "learn");
checkNavigationLink("preview-competence-profile-link", "competence");
});
}); });
describe("Participant", () => { it("should show course preview on learn", () => {
before(() => { visitCoursePage("learn");
login(...PARTICIPANT_LOGIN); cy.get('[data-cy="course-preview-bar"]').should("exist");
}); });
it("should not show course preview on learn path", () => { it("should show course preview on competence", () => {
visitCoursePage("learn"); visitCoursePage("competence");
cy.get('[data-cy="course-preview-bar"]').should("not.exist"); cy.get('[data-cy="course-preview-bar"]').should("exist");
}); });
it("should not show course preview on competence", () => { it("should have correct course preview navigation", () => {
visitCoursePage("competence"); visitCoursePage("learn");
cy.get('[data-cy="course-preview-bar"]').should("not.exist"); checkNavigationLink("preview-learn-path-link", "learn");
}); checkNavigationLink("preview-competence-profile-link", "competence");
}) });
});
describe("Participant", () => {
before(() => {
login(...PARTICIPANT_LOGIN);
});
it("should not show course preview on learn path", () => {
visitCoursePage("learn");
cy.get('[data-cy="course-preview-bar"]').should("not.exist");
});
it("should not show course preview on competence", () => {
visitCoursePage("competence");
cy.get('[data-cy="course-preview-bar"]').should("not.exist");
});
})
}); });