2021-04-22 02:44:45 -07:00
|
|
|
const withTestId = (testId) => (options) =>
|
|
|
|
cy.get(`[data-test-id="${CSS.escape(testId)}"]`, options);
|
2021-04-19 03:56:51 -07:00
|
|
|
|
2021-05-04 16:31:48 -07:00
|
|
|
export const getNavBackButton = withTestId("wardrobe-nav-back-button");
|
2021-04-22 02:44:45 -07:00
|
|
|
export const getSpeciesSelect = withTestId("wardrobe-species-picker");
|
|
|
|
export const getColorSelect = withTestId("wardrobe-color-picker");
|
|
|
|
export const getPosePickerButton = withTestId("wardrobe-pose-picker");
|
|
|
|
export const getOutfitName = withTestId("outfit-name");
|
|
|
|
export const getSaveOutfitButton = withTestId("wardrobe-save-outfit-button");
|
|
|
|
export const getOutfitIsSavedIndicator = withTestId(
|
|
|
|
"wardrobe-outfit-is-saved-indicator"
|
|
|
|
);
|
2021-05-03 16:05:13 -07:00
|
|
|
export const getOutfitIsSavingIndicator = withTestId(
|
|
|
|
"wardrobe-outfit-is-saving-indicator"
|
|
|
|
);
|
2021-04-19 03:56:51 -07:00
|
|
|
|
|
|
|
export function getPosePickerOption(label, options) {
|
|
|
|
return cy.get(`input[aria-label="${CSS.escape(label)}"]`, options);
|
|
|
|
}
|
|
|
|
|
2021-05-03 16:05:13 -07:00
|
|
|
export function getOutfitPreview(options = { timeout: 15000 }) {
|
2021-05-04 12:28:49 -07:00
|
|
|
// HACK: To return the screenshottable preview *area* (which is what this
|
|
|
|
// function is currently used for), we select the first img tag. That's
|
|
|
|
// because the app relies on CSS `object-fit` to get images to position
|
|
|
|
// correctly, rather than styling the container. This will still
|
|
|
|
// screenshot the full preview, because Cypress can't separate the
|
|
|
|
// layers! It just screenshots the bounded area.
|
|
|
|
//
|
|
|
|
// TODO: The way the layer positioning works is a bit fragile tbh, and the
|
|
|
|
// canvases already do math; it could make sense to just have the
|
|
|
|
// container use the same math, or some clever CSS?
|
|
|
|
//
|
|
|
|
// NOTE: The tests need to run in a 600x600 actual window, or else the
|
|
|
|
// snapshot will come out smaller. This because our snapshot plugin
|
|
|
|
// performs its snapshot within the window's natural area, rather than
|
|
|
|
// the simulated area that most tests run in.
|
|
|
|
return cy
|
2021-05-03 16:05:13 -07:00
|
|
|
.get("[data-test-id=wardrobe-outfit-preview]:not([data-loading])", options)
|
2021-05-04 12:28:49 -07:00
|
|
|
.get("img")
|
|
|
|
.first();
|
2021-04-19 03:56:51 -07:00
|
|
|
}
|
2021-05-04 16:31:48 -07:00
|
|
|
|
|
|
|
export function showOutfitControls(options) {
|
|
|
|
return cy.get("[data-test-id=wardrobe-outfit-controls]", options).click();
|
|
|
|
}
|