JobsUnifiedTopCard.purs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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.Class (liftEffect)
  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.Spec (Spec, describe, it)
  21. import Test.Spec.Assertions (shouldEqual)
  22. import Test.Utils (fromDetachedToUI)
  23. jobsUnifiedTopCardSpec :: Spec Unit
  24. jobsUnifiedTopCardSpec = do
  25. describe "Jobs top card parsing" do
  26. it "works" do
  27. dom <- liftEffect $ jsDomFromFile "test/examples/job_offer.html"
  28. wep <- liftEffect $ runQuery $ query @JobOfferPage dom
  29. isRight wep `shouldEqual` true
  30. let
  31. JobOfferPage jobCard = unsafePartial $ fromJust $ hush wep
  32. topCard <- liftEffect $ traverse toDetached jobCard
  33. topCard `shouldEqual` 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. let
  127. jobOffer = (JJO.fromUI <=< fromDetachedToUI) topCard
  128. jobOffer `shouldEqual` Right (JobOffer {
  129. companyDomain: (Just "Technologies et services de l’information"),
  130. companyLink: "https://www.linkedin.com/company/lincoln-/life",
  131. companyName: "LINCOLN",
  132. companySize: (Just "201-500 employés"),
  133. hasSimplifiedApplicationProcess: true,
  134. location: (Just "Boulogne-Billancourt, Île-de-France, France"),
  135. flexibility: (Just JobFlexOnSite),
  136. title: "Data Engineer H/F - Secteur Energie"
  137. })