Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

81 rader
2.6 KiB

  1. context("Control Color", () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit("/app/website");
  5. });
  6. function get_dialog_with_color() {
  7. return cy.dialog({
  8. title: "Color",
  9. fields: [
  10. {
  11. label: "Color",
  12. fieldname: "color",
  13. fieldtype: "Color",
  14. },
  15. ],
  16. });
  17. }
  18. it("Verifying if the color control is selecting correct", () => {
  19. get_dialog_with_color().as("dialog");
  20. cy.findByPlaceholderText("Choose a color").click();
  21. ///Selecting a color from the color palette
  22. cy.get('[style="background-color: rgb(79, 157, 217);"]').click();
  23. //Checking if the css attribute is correct
  24. cy.get(".color-map").should("have.css", "color", "rgb(79, 157, 217)");
  25. cy.get(".hue-map").should("have.css", "color", "rgb(0, 145, 255)");
  26. //Checking if the correct color is being selected
  27. cy.get("@dialog").then((dialog) => {
  28. let value = dialog.get_value("color");
  29. expect(value).to.equal("#4F9DD9");
  30. });
  31. //Selecting a color
  32. cy.get('[style="background-color: rgb(203, 41, 41);"]').click();
  33. //Checking if the correct css is being selected
  34. cy.get(".color-map").should("have.css", "color", "rgb(203, 41, 41)");
  35. cy.get(".hue-map").should("have.css", "color", "rgb(255, 0, 0)");
  36. //Checking if the correct color is being selected
  37. cy.get("@dialog").then((dialog) => {
  38. let value = dialog.get_value("color");
  39. expect(value).to.equal("#CB2929");
  40. });
  41. //Selecting color from the palette
  42. cy.get(".color-map > .color-selector").click(65, 87, { force: true });
  43. cy.get(".color-map").should("have.css", "color", "rgb(56, 0, 0)");
  44. //Checking if the expected color is selected and getting displayed
  45. cy.get("@dialog").then((dialog) => {
  46. let value = dialog.get_value("color");
  47. expect(value).to.equal("#380000");
  48. });
  49. //Selecting the color from the hue map
  50. cy.get(".hue-map > .hue-selector").click(35, -1, { force: true });
  51. cy.get(".color-map").should("have.css", "color", "rgb(56, 45, 0)");
  52. cy.get(".hue-map").should("have.css", "color", "rgb(255, 204, 0)");
  53. cy.get(".color-map > .color-selector").click(55, 12, { force: true });
  54. cy.get(".color-map").should("have.css", "color", "rgb(46, 37, 0)");
  55. //Checking if the correct color is being displayed
  56. cy.get("@dialog").then((dialog) => {
  57. let value = dialog.get_value("color");
  58. expect(value).to.equal("#2e2500");
  59. });
  60. //Clearing the field and checking if the field contains the placeholder "Choose a color"
  61. cy.get(".input-with-feedback").click({ force: true });
  62. cy.get_field("color", "Color").type("{selectall}").clear();
  63. cy.get_field("color", "Color")
  64. .invoke("attr", "placeholder")
  65. .should("contain", "Choose a color");
  66. });
  67. });