JobsUnifiedTopCard.purs 6.2 KB

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