Skip to content

Commit

Permalink
Merge pull request #438 from VTUL/cy-version-upgrade
Browse files Browse the repository at this point in the history
cypress 13 migration
  • Loading branch information
whunter authored Jan 31, 2024
2 parents 6978a7e + 1683543 commit 928357c
Show file tree
Hide file tree
Showing 38 changed files with 1,829 additions and 1,808 deletions.
10 changes: 10 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'cypress'

export default defineConfig({
chromeWebSecurity: false,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
baseUrl: 'http://localhost:3000/',
},
})
4 changes: 0 additions & 4 deletions cypress.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("browse_collections: Browse collections page", () => {
});

it("renders the first 10 collections by default number of results to be showed", () => {
cy.get(".gallery-item").should("have.length", 4);
cy.get(".gallery-item").should("have.length", 5);
});

it("renders the all the collections if increasing the number of results to be showed", () => {
Expand All @@ -29,6 +29,6 @@ describe("browse_collections: Browse collections page", () => {
.click()
.contains("50")
.click();
cy.get(".gallery-item").should("have.length", 4);
cy.get(".gallery-item").should("have.length", 5);
});
});
47 changes: 47 additions & 0 deletions cypress/e2e/integration/language_config.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
describe("language_config.spec: Selecting English loads English results", () => {
it("Language checkbox exists and updates url", () => {
cy.visit("/search");
cy.wait(2000);
cy.get("div.facet-fields")
.find("div.category > div > h3 > button#category")
.click({ force: true })
.invoke("text")
.should("equal", "Category");
cy.get("input#archive", { timeout: 2000 }).click();
cy.get("div.facet-fields")
.find("div.language > div > h3 > button#language")
.click({ force: true })
.invoke("text")
.should("equal", "Language");
cy.get("input#en", { timeout: 2000 }).click();
cy.wait(2000);
cy.url().should("include", "language=en");
});

it("Items should now be English", () => {
cy.visit("/search");
cy.wait(2000);
cy.get("div.facet-fields")
.find("div.category > div > h3 > button#category")
.click({ force: true })
.invoke("text")
.should("equal", "Category");
cy.get("input#archive", { timeout: 2000 }).click();
cy.get("div.facet-fields")
.find("div.language > div > h3 > button#language")
.click({ force: true })
.invoke("text")
.should("equal", "Language");
cy.get("input#en", { timeout: 2000 }).click();
cy.get("div.gallery-item > div.card > a").first().click({ force: true });
cy.wait(2000);
cy.url().should("include", "/archive/");
cy.get(
'div.details-section-metadata > table[aria-label="Item Metadata"] tbody',
{ timeout: 5000 }
)
.find("tr.language td a", { timeout: 5000 })
.invoke("text")
.should("equal", "English");
});
});
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { buildHeaderSchema } from '../../src/lib/richSchemaTools';
import { buildRichSchema } from "../../src/lib/richSchemaTools";
import { buildHeaderSchema, buildRichSchema } from '../../../src/lib/richSchemaTools';
// import { buildRichSchema } from "../../src/lib/richSchemaTools";

describe("buildHeaderSchema: Create rich schema for about page", () => {
it('About page schema', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('search_facet: Collapsible search filter field', () => {

it('displays the facet field while hiding the list of facet values', () => {
cy.get('div#sidebar div.facet-fields')
.should('not.be.visible');
.should('not.exist');
cy.get('button#category')
.invoke('text')
.should('equal', 'Category');
Expand Down Expand Up @@ -45,7 +45,7 @@ describe('search_facet: Collapsible search filter field', () => {

it('displays the list of facet values after the facet field being expanded', () => {
cy.get('[data-cy=filter-collapsibles] > :nth-child(6) > div > div.facet-listing')
.should('not.be.visible');
.should('not.exist');
cy.get('[data-cy=filter-collapsibles] > :nth-child(6)')
.click();
cy.get('[data-cy=filter-collapsibles] > :nth-child(6) > div > div.facet-listing', { timeout: 5000 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe("searchfacet_checkbox: Search facet checkboxes correspond to the facet
beforeEach(() => {
cy.visit("/search");
cy.get("button#medium").click();
cy.wait(20000);
cy.wait(1000);
});

it("allows to select one of the checkboxes", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('show_all_less_buttons: Search Facet field with more than 5 selectable
beforeEach(() => {
cy.visit('/search');
cy.get('button#medium')
.click().wait(20000);
.click().wait(1000);

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ describe("view_options: Interaction", () => {

it('should display list viewing style if "list" viewing option is selected', () => {
cy.get("button[title='List view']").click();
cy.get(".collection-entry").should("have.length", 4);
cy.get(".collection-entry").should("have.length", 5);
});

it('should display gallery viewing style if "gallery" viewing option is selected', () => {
cy.get("button[title='Gallery view']").click();
cy.get(".gallery-item").should("have.length", 4);
cy.get(".gallery-item").should("have.length", 5);
});
});
90 changes: 90 additions & 0 deletions cypress/e2e/site_admin/archive_edit.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
describe("admin_archive_edit: Update item metadata and change it back", function () {
before(() => {
cy.signIn();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.visit("/siteAdmin").wait(2000);

cy.get("li.updateArchive > a").click();

cy.get("input.identifier-field")
.clear()
.type("Ms1990_025_Per_Ph_B001_F001_003_demo");
cy.contains("Confirm").click().wait(2000);
});

after(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage();
});

afterEach(() => {
cy.saveLocalStorage();
});

it("Unable to empty required metadata", () => {
cy.get("input[value='edit']").parent().click();
cy.get("div[class='required field']")
.first()
.find("textarea")
.clear()
.type(" ");
cy.contains("Update Item Metadata").click();
cy.contains("Please fill in the required field!").should("be.visible");
});

it("Update single-valued metadata", () => {
cy.get("input[value='edit']").parent().click();
cy.get("textarea[name='title']").clear().type("New Title");
cy.contains("Update Item Metadata").click();
cy.contains("Title: New Title", { timeout: 5000 }).should("be.visible");
cy.contains("View Item")
.should("have.attr", "href")
.and("include", "/archive/3h85z50c");
});

it("Change single-valued metadata back", () => {
cy.get("input[value='edit']").parent().click();
cy.get("textarea[name='title']")
.clear()
.type("Unidentified building site, c. 1979. Photographs (Ms1990-025)");
cy.contains("Update Item Metadata").click();
cy.contains(
"Title: Unidentified building site, c. 1979. Photographs (Ms1990-025)"
).should("be.visible");
});

it("Can delete single-valued metadata", () => {
cy.get("input[value='edit']").parent().click();
cy.get("textarea[name='start_date']").clear();
cy.contains("Update Item Metadata").click();
cy.contains("Start date:").should("not.exist");
});

it("Can add single-valued metadata", () => {
cy.get("input[value='edit']").parent().click();
cy.get("textarea[name='start_date']").clear().type("1979/03/23");
cy.contains("Update Item Metadata").click();
cy.contains("Start date: 1979/03/23").should("be.visible");
});

it("Can delete multi-valued metadata", () => {
cy.get("input[value='edit']").parent().click();
cy.get("textarea[name='is_part_of_1']").siblings(".deleteValue").click();
cy.contains("Update Item Metadata").click();
cy.contains("Ms1990-025, Box 1, Folder 1").should("not.exist");
});

it("Can add multi-valued metadata", () => {
cy.get("input[value='edit']").parent().click();
cy.get("#is_part_of_add_value_button").click();
cy.get("textarea[name='is_part_of_1']")
.should("have.value", "new is_part_of")
.clear()
.type("Ms1990-025, Box 1, Folder 1");
cy.contains("Update Item Metadata").click();
cy.contains("Ms1990-025, Box 1, Folder 1").should("be.visible");
});
});
53 changes: 53 additions & 0 deletions cypress/e2e/site_admin/collection_edit.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
describe("admin_collection_edit: Update collection metadata and change it back", function () {
before(() => {
cy.signIn();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.visit("/siteAdmin");

cy.get("#content-wrapper > div > div > ul", { timeout: 2000 })
.find(".collectionFormLink > a")
.contains("New / Update Collection")
.click();
cy.url().should("include", "/siteAdmin");

cy.get("input").clear().type("Ms1988_017_Pfeiffer_demo");
cy.contains("Confirm").click();
cy.get("input[value='view']").parent().find("input").should("be.checked");
cy.contains(
"Alberta Pfeiffer’s architectural career spanned 55 years, where she worked primarily in Hadlyme, Connecticut."
).should("be.visible");
});

after(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage();
});

afterEach(() => {
cy.saveLocalStorage();
});

it("Update single-valued metadata", () => {
cy.get("input[value='edit']").parent().click();
cy.get("textarea[name='title']").invoke("val", "");
cy.get("textarea[name='title']").type("New Title");
cy.contains("Update Collection Metadata").click();
cy.contains("New Title").should("be.visible");
});

it("Change single-valued metadata back", () => {
cy.get("input[value='edit']").parent().click();
cy.get("textarea[name='title']")
.clear()
.type(
"Alberta Pfeiffer Architectural Collection, 1929-1976 (Ms1988-017)"
);
cy.contains("Update Collection Metadata").click();
cy.contains(
"Alberta Pfeiffer Architectural Collection, 1929-1976 (Ms1988-017)"
).should("be.visible");
});
});
113 changes: 113 additions & 0 deletions cypress/e2e/site_admin/collectionpage_filter_sort_config.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
describe("admin_collectionpage_filter_sort_config: Displays and updates browse collections page configurations", () => {
before(() => {
cy.signIn();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.visit("/siteAdmin");

cy.get("#content-wrapper > div > div > ul")
.find(":nth-child(6) > a")
.contains("Browse Collections Page")
.click();
cy.url().should("include", "/siteAdmin");
});

after(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage();
});

afterEach(() => {
cy.saveLocalStorage();
});

describe("admin_collectionpage_filter_sort_config: Displays filter and sort fields", () => {
it("Displays filter field", () => {
cy.get("input[value='view']").parent().click();
cy.contains("Filter Field: subject").should("be.visible");
cy.contains("Values:").should("be.visible");
cy.contains("All").should("be.visible");
});

it("Displays sort fields", () => {
cy.get("input[value='view']").parent().click();
cy.contains("Sort Field: title").should("be.visible");
cy.contains("Sort Direction: asc").should("be.visible");
cy.contains("Sort Field: title").should("be.visible");
cy.contains("Sort Direction: desc").should("be.visible");
cy.contains("Sort Field: start_date").should("be.visible");
cy.contains("Sort Direction: desc").should("be.visible");
});
});

describe("admin_collectionpage_filter_sort_config: Updates filter's value and changes it back", () => {
it("Updates filter's value", () => {
cy.get("input[value='edit']").parent().click();
cy.get("input[name='filter_value_2']")
.first()
.clear()
.type("Infrastructure");
cy.contains("Update Filter and Sort Fields").click();
cy.contains("Infrastructure").should("be.visible");
});

it("Reverses update", () => {
cy.get("input[value='edit']").parent().click();
cy.get("input[name='filter_value_2']")
.first()
.clear()
.type("Architecture");
cy.contains("Update Filter and Sort Fields").click();
cy.contains("Infrastructure").should("not.exist");
cy.contains("Architecture").should("be.visible");
});
});

describe("admin_collectionpage_filter_sort_config: Adds filter's value and removes it", () => {
it("Adds filter's value", () => {
cy.get("input[value='edit']").parent().click();
cy.contains("Add Value").first().click();
cy.get("input[name='filter_value_6']")
.first()
.clear()
.type("Infrastructure");
cy.contains("Update Filter and Sort Fields").click();
cy.contains("Infrastructure").should("be.visible");
});

it("Removes the added filter value", () => {
cy.get("input[value='edit']").parent().click();
cy.get("input[name='filter_value_6']")
.parent()
.parent()
.parent()
.contains("X")
.click();
cy.contains("Update Filter and Sort Fields").click();
cy.contains("Infrastructure").should("not.exist");
});
});

describe("admin_collectionpage_filter_sort_config: Adds a new sort field and removes it", () => {
it("Adds a new sort field", () => {
cy.get("input[value='edit']").parent().click();
cy.get("select").select("identifier (asc)");
cy.contains("Add New Sort Field").click();
cy.contains("Update Filter and Sort Fields").click();
cy.contains("Sort Field: identifier").should("be.visible");
});

it("Removes the newly added sort field", () => {
cy.get("input[value='edit']").parent().click();
cy.get(
"#content-wrapper > div > div > div > form > ul > section#identifier_sort_section > div.deletePageWrapper > a.deletePage"
)
.contains("Delete Sort Field")
.click();
cy.contains("Update Filter and Sort Fields").click();
cy.contains("Sort Field: identifier").should("not.exist");
});
});
});
Loading

0 comments on commit 928357c

Please sign in to comment.