JobsUnifiedTopCard.purs 6.0 KB

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