JobsUnifiedTopCard.purs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. module Test.JobsUnifiedTopCard where
  2. import Prelude
  3. import Data.Either (Either(..), hush, isRight)
  4. import Data.List (List(..), (:))
  5. import Data.List.NonEmpty (NonEmptyList(..))
  6. import Data.Maybe (Maybe(..), fromJust)
  7. import Data.NonEmpty (NonEmpty(..))
  8. import Data.Traversable (traverse)
  9. import Effect (Effect)
  10. import LinkedIn.DetachedNode (DetachedNode(..), toDetached)
  11. import LinkedIn.Extractible (query)
  12. import LinkedIn.Jobs.JobOffer (JobOffer(..))
  13. import LinkedIn.Jobs.JobOffer as JJO
  14. import LinkedIn.Page.JobOffer (JobOfferPage(..))
  15. import LinkedIn.QueryRunner (runQuery)
  16. import LinkedIn.UI.Basic.Types (JobFlexibility(..))
  17. import LinkedIn.UI.Components.JobsUnifiedTopCard (JobsUnifiedTopCardElement(..), TopCardAction(..), TopCardInsight(..), TopCardInsightContent(..), TopCardPrimaryDescription(..), TopCardSecondaryInsight(..))
  18. import Node.JsDom (jsDomFromFile)
  19. import Partial.Unsafe (unsafePartial)
  20. import Test.Assert (assert, assertEqual)
  21. import Test.Utils (fromDetachedToUI)
  22. main :: Effect Unit
  23. main = do
  24. dom <- jsDomFromFile "test/examples/job_offer.html"
  25. wep <- runQuery $ query dom
  26. assert $ isRight wep
  27. let
  28. JobOfferPage jobCard = unsafePartial $ fromJust $ hush wep
  29. topCard <- traverse toDetached jobCard
  30. assertEqual {
  31. actual: topCard,
  32. expected: JobsUnifiedTopCardElement {
  33. actions: (Just (NonEmptyList
  34. (NonEmpty (TopCardActionButton (DetachedButton {
  35. classes: ("jobs-apply-button" : "artdeco-button" : "artdeco-button--3" : "artdeco-button--primary" : "ember-view" : Nil),
  36. content: "Candidature simplifiée",
  37. role: Nothing
  38. })) ((TopCardActionButton (DetachedButton {
  39. classes: ("jobs-save-button" : "artdeco-button" : "artdeco-button--3" : "artdeco-button--secondary" : Nil),
  40. content: "Enregistrer Enregistrer Data Engineer H/F - Secteur Energie chez LINCOLN",
  41. role: Nothing
  42. })) : Nil)))),
  43. header: (DetachedElement {
  44. classes: ("t-24" : "t-bold" : "job-details-jobs-unified-top-card__job-title" : Nil),
  45. content: "Data Engineer H/F - Secteur Energie",
  46. id: Nothing,
  47. tag: "H1"
  48. }),
  49. insights: (Just (NonEmptyList
  50. (NonEmpty (TopCardInsight {
  51. content: (TopCardInsightContentSecondary {
  52. primary: (DetachedElement {
  53. classes: Nil,
  54. content: "Sur site",
  55. id: Nothing,
  56. tag: "SPAN"
  57. }),
  58. secondary: (NonEmptyList (NonEmpty (TopCardSecondaryInsightNested
  59. (DetachedElement {
  60. classes: Nil,
  61. content: "Temps plein",
  62. id: Nothing,
  63. tag: "SPAN"
  64. })) ((TopCardSecondaryInsightPlain
  65. (DetachedElement {
  66. classes: ("job-details-jobs-unified-top-card__job-insight-view-model-secondary" : Nil),
  67. content: "Confirmé",
  68. id: Nothing,
  69. tag: "SPAN"
  70. })) : Nil))) }),
  71. icon: DetachedLiIcon "job"
  72. }) ((TopCardInsight {
  73. content: (TopCardInsightContentSingle (DetachedElement {
  74. classes: Nil,
  75. content: "201-500 employés · Technologies et services de l’information",
  76. id: Nothing,
  77. tag: "SPAN" })),
  78. icon: DetachedLiIcon "company"
  79. }) : (TopCardInsight {
  80. content: (TopCardInsightContentSingle (DetachedElement {
  81. classes: Nil,
  82. content: "2 anciens élèves travaillent ici",
  83. id: Nothing,
  84. tag: "SPAN" })),
  85. icon: DetachedLiIcon "people"
  86. }) : (TopCardInsight {
  87. content: (TopCardInsightContentSingle (DetachedElement {
  88. classes: Nil,
  89. content: "Découvrez comment vous vous positionnez par rapport à 87 candidats. Essai Premium pour 0 EUR",
  90. id: Nothing,
  91. tag: "SPAN" })),
  92. icon: (DetachedSvgElement { dataTestIcon: (Just "lightbulb-medium"), id: Nothing, tag: "svg" })
  93. }) : (TopCardInsight {
  94. content: (TopCardInsightContentButton (DetachedButton {
  95. classes: ("job-details-jobs-unified-top-card__job-insight-text-button" : Nil),
  96. content: "9 compétences sur 11 correspondent à votre profil, vous pourriez bien convenir pour ce poste",
  97. role: Nothing
  98. })),
  99. icon: (DetachedSvgElement { dataTestIcon: (Just "checklist-medium"), id: Nothing, tag: "svg" })
  100. }) : Nil)))),
  101. primaryDescription: (TopCardPrimaryDescription {
  102. link: (DetachedA { content: "LINCOLN", href: "https://www.linkedin.com/company/lincoln-/life" }),
  103. text: (DetachedText "· Boulogne-Billancourt, Île-de-France, France"),
  104. tvmText: (Just (NonEmptyList
  105. (NonEmpty (DetachedElement {
  106. classes: ("tvm__text" : "tvm__text--neutral" : Nil),
  107. content: "il y a 2 semaines",
  108. id: Nothing,
  109. tag: "SPAN"
  110. }) ((DetachedElement {
  111. classes: ("tvm__text" : "tvm__text--neutral" : Nil),
  112. content: "·",
  113. id: Nothing,
  114. tag: "SPAN"
  115. }) : (DetachedElement {
  116. classes: ("tvm__text" : "tvm__text--neutral" : Nil),
  117. content: "87 candidats",
  118. id: Nothing,
  119. tag: "SPAN"
  120. }) : Nil
  121. ))
  122. ))
  123. })
  124. }
  125. }
  126. assertEqual {
  127. actual: (JJO.fromUI <=< fromDetachedToUI) topCard,
  128. expected:
  129. Right (JobOffer {
  130. companyDomain: (Just "Technologies et services de l’information"),
  131. companyLink: "https://www.linkedin.com/company/lincoln-/life",
  132. companyName: "LINCOLN",
  133. companySize: (Just "201-500 employés"),
  134. hasSimplifiedApplicationProcess: true,
  135. location: (Just "Boulogne-Billancourt, Île-de-France, France"),
  136. flexibility: (Just JobFlexOnSite),
  137. title: "Data Engineer H/F - Secteur Energie"
  138. })
  139. }