Skip to content
Snippets Groups Projects

Add storybook and tests ICSHWI-9199

Merged John Sparger requested to merge add-storybook-and-tests-ICSHWI-9199 into develop
6 files
+ 253
0
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 49
0
 
import React from "react";
 
import { mount } from "@cypress/react";
 
import { composeStories } from "@storybook/testing-react";
 
import * as stories from "./IOCTable.stories";
 
 
const {AfterAsync} = composeStories(stories)
 
const textColumns = ["IOC Name", "Host", "Network", "Owner", "Git reference"];
 
const columns = ["Status"].concat(textColumns);
 
const firstRowData = ["Active", "VacS-RFQ:SC-IOC-130", "vacs-accv-vm-ioc", "ChannelAccess-FEB", "krisztianloki", "1.0.0"]
 
 
 
describe("HostTable", () => {
 
context("Populated Table", () => {
 
beforeEach(() => {
 
mount(<AfterAsync />)
 
})
 
 
it ("Has the correct columns", () => {
 
cy.get(".p-column-title").each(($el, index) => {
 
console.log(index, columns[index]);
 
cy.wrap($el).contains(columns[index], {matchCase: false});
 
})
 
})
 
 
it ("Truncates all text content", () => {
 
cy.get("tbody > tr").first()
 
.find(".MuiTypography-noWrap")
 
.should("have.length", textColumns.length)
 
})
 
 
it ("Displays correct content in first row", () => {
 
cy.get("tbody > tr").first()
 
.find("td")
 
.each(($el, index) => {
 
if (index === 0) {
 
const iconTitle = firstRowData[index]
 
cy.wrap($el).find(`svg[title=${iconTitle}]`)
 
}
 
else {
 
cy.wrap($el).find("p").should($el => {
 
const text = $el.text().trim().toLowerCase()
 
const expected = firstRowData[index].trim().toLowerCase()
 
cy.expect(text).to.equal(expected);
 
})
 
}
 
})
 
})
 
})
 
})
Loading