JobsUnifiedTopCard.purs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 (NonEmpty (TopCardActionButton
  25. (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. }))
  30. ((TopCardActionButton (DetachedButton {
  31. classes: ("jobs-save-button" : "artdeco-button" : "artdeco-button--3" : "artdeco-button--secondary" : Nil),
  32. content: "Enregistrer Enregistrer Data Engineer H/F - Secteur Energie chez LINCOLN",
  33. role: Nothing
  34. })) : Nil)
  35. ))),
  36. header: (DetachedElement {
  37. classes: ("t-24" : "t-bold" : "job-details-jobs-unified-top-card__job-title" : Nil),
  38. content: "Data Engineer H/F - Secteur Energie",
  39. id: Nothing,
  40. tag: "H1"
  41. }),
  42. insights: (Just (NonEmptyList (NonEmpty (TopCardInsight {
  43. content: (TopCardInsightContentSecondary {
  44. primary: (DetachedElement {classes: Nil, content: "Sur site", id: Nothing, tag: "SPAN"}),
  45. secondary: (NonEmptyList (NonEmpty (TopCardSecondaryInsightNested
  46. (DetachedElement {classes: Nil, content: "Temps plein", id: Nothing, tag: "SPAN"}))
  47. ((TopCardSecondaryInsightPlain
  48. (DetachedElement {classes: ("job-details-jobs-unified-top-card__job-insight-view-model-secondary" : Nil), content: "Confirmé", id: Nothing,tag: "SPAN" })) : Nil))
  49. )
  50. }),
  51. icon: DetachedLiIcon "job"
  52. }) ((TopCardInsight {
  53. content: (TopCardInsightContentSingle (
  54. DetachedElement {classes: Nil, content: "201-500 employés · Technologies et services de l’information", id: Nothing, tag: "SPAN" }
  55. )),
  56. icon: DetachedLiIcon "company"
  57. }) : (TopCardInsight {
  58. content: (TopCardInsightContentSingle (
  59. DetachedElement {classes: Nil, content: "2 anciens élèves travaillent ici", id: Nothing, tag: "SPAN" }
  60. )),
  61. icon: DetachedLiIcon "people"
  62. }) : (TopCardInsight {
  63. content: (TopCardInsightContentSingle (
  64. DetachedElement {classes: Nil, content: "Découvrez comment vous vous positionnez par rapport à 87 candidats. Essai Premium pour 0 EUR", id: Nothing, tag: "SPAN" })),
  65. icon: (DetachedSvgElement { dataTestIcon: (Just "lightbulb-medium"), id: Nothing, tag: "svg" })
  66. }) : (TopCardInsight {
  67. content: (TopCardInsightContentButton (
  68. DetachedButton {classes: ("job-details-jobs-unified-top-card__job-insight-text-button" : Nil), content: "9 compétences sur 11 correspondent à votre profil, vous pourriez bien convenir pour ce poste", role: Nothing}
  69. )),
  70. icon: (DetachedSvgElement { dataTestIcon: (Just "checklist-medium"), id: Nothing, tag: "svg" })
  71. }) : Nil)))),
  72. primaryDescription: (TopCardPrimaryDescription {
  73. link: (DetachedA { content: "LINCOLN", href: "https://www.linkedin.com/company/lincoln-/life" }),
  74. text: (DetachedText "· Boulogne-Billancourt, Île-de-France, France"),
  75. tvmText: (Just (NonEmptyList (NonEmpty (
  76. DetachedElement {classes: ("tvm__text" : "tvm__text--neutral" : Nil), content: "il y a 2 semaines", id: Nothing, tag: "SPAN"})
  77. ((DetachedElement {classes: ("tvm__text" : "tvm__text--neutral" : Nil), content: "·", id: Nothing, tag: "SPAN"})
  78. : (DetachedElement {classes: ("tvm__text" : "tvm__text--neutral" : Nil), content: "87 candidats", id: Nothing, tag: "SPAN"})
  79. : Nil
  80. ))
  81. ))
  82. })
  83. }))
  84. it "reads the JobOffer" do
  85. jobOffer <- getOutputFromFile (Proxy :: Proxy JobOfferPage) "test/examples/job_offer.html"
  86. jobOffer `shouldEqual` Right (OutJobOffer (JobOffer {
  87. companyDomain: (Just "Technologies et services de l’information"),
  88. companyLink: "https://www.linkedin.com/company/lincoln-/life",
  89. companyName: "LINCOLN",
  90. companySize: (Just "201-500 employés"),
  91. hasSimplifiedApplicationProcess: true,
  92. location: (Just "Boulogne-Billancourt, Île-de-France, France"),
  93. flexibility: (Just JobFlexOnSite),
  94. title: "Data Engineer H/F - Secteur Energie"
  95. }))