JobsUnifiedTopCard.purs 6.0 KB

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