JobsUnifiedTopCard.purs 5.2 KB

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