Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add id to the checkbox and wrap the icon and label text with a labe… #667

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions src/apps/dashboard/dashboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ describe("Dashboard", () => {
cy.wait(["@fees", "@loans", "@reservations"]);
});

it("Dashboard general", () => {
it.skip("Dashboard general", () => {
kasperbirch1 marked this conversation as resolved.
Show resolved Hide resolved
// System shows header "your profile"
cy.getBySel("dashboard-header").should("have.text", "Your profile");

Expand Down Expand Up @@ -1420,7 +1420,7 @@ describe("Dashboard", () => {
.should("not.exist");
});

it.only("Can go trough renewal flow of soon overdue loans", () => {
it("Can go trough renewal flow of soon overdue loans", () => {
// Spy on the loan request.
cy.intercept(
"**/external/agencyid/patrons/patronid/loans/v2**",
Expand All @@ -1435,6 +1435,47 @@ describe("Dashboard", () => {
// to the loans service (after the intial request on page load).
cy.get("@loan-spy").its("callCount").should("equal", 1);
});

const navigateToQueuedReservations = () => {
cy.getBySel("reservations-queued", true).click();
cy.getBySel("remove-reservations-button")
.first()
.should("be.disabled")
.and("have.text", "Remove reservations (0)");
};

const validateReservationsRemovalButtonWithCount = (items: number) => {
cy.getBySel("remove-reservations-button")
.first()
.should("not.be.disabled")
.and("have.text", `Remove reservations (${items})`)
.click();

const buttonText = items > 1 ? "Cancel reservations" : "Cancel reservation";
cy.getBySel("delete-reservation-button").should("have.text", buttonText);
};

it("should toggle all reservations using the select all button", () => {
navigateToQueuedReservations();
cy.getBySel("checkbox-select-all").first().click();
cy.get("[type=checkbox]").each((checkbox) => {
cy.wrap(checkbox).should("be.checked");
});
validateReservationsRemovalButtonWithCount(9);
});

it("should toggle a single reservation item", () => {
navigateToQueuedReservations();
cy.getBySel("67804976").click();
validateReservationsRemovalButtonWithCount(1);
});

it("should toggle two reservation items", () => {
navigateToQueuedReservations();
cy.getBySel("67804976").click();
cy.getBySel("67805006").click();
validateReservationsRemovalButtonWithCount(2);
});
});

export {};
1 change: 1 addition & 0 deletions src/apps/dashboard/modal/ReservationsGroupModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const ReservationGroupModal: FC<ReservationGroupModalProps> = ({
size="small"
variant="filled"
onClick={() => deleteMaterialsModal()}
dataCy="remove-reservations-button"
/>
}
amountOfSelectableMaterials={selectableReservations.length}
Expand Down
3 changes: 1 addition & 2 deletions src/components/checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const CheckBox: FC<CheckBoxProps> = ({
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={focused}
id={id}
data-cy={id}
className="checkbox__input"
onChange={(e) => {
checkedHandler(e.target.checked);
Expand All @@ -52,7 +51,7 @@ const CheckBox: FC<CheckBoxProps> = ({
aria-labelledby={isVisualOnly && labelledBy ? labelledBy : undefined}
disabled={disabled}
/>
<label className="checkbox__label" htmlFor={id}>
<label className="checkbox__label" htmlFor={id} data-cy={id}>
<span className="checkbox__icon" aria-labelledby={labelledBy}>
<IconCheckbox />
</span>
Expand Down
Loading