JobsUnifiedTopCard.purs 5.9 KB

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